Skip to content

Instantly share code, notes, and snippets.

View tk0miya's full-sized avatar

Takeshi KOMIYA tk0miya

View GitHub Profile
# extension testbed
from datetime import datetime, timedelta
from itertools import islice
from operator import itemgetter
from typing import Dict, List
from sphinx.domains import Domain
from sphinx.util import logging

paragraph continuation in deep indented list and paragraph

   - a
    continuation line
   - b
    - shallow indented by baseline of list item
   - d
 - indented as same as list item
@tk0miya
tk0miya / README.md
Last active November 26, 2021 05:41

simple table

| hello | world |
| ----- | ----- |
| hello | world |
| hello | world |

| hello | world |

from docutils import languages, nodes
from docutils.parsers.rst.states import Struct
from sphinx.writers.latex import LaTeXTranslator
def quote_role(typ, rawtext, text, lineno, inliner, options={}, content=[]):
language = languages.get_language(inliner.document.settings.language_code,
inliner.document.reporter)
memo = Struct(document=inliner.document,
reporter=inliner.document.reporter,
diff --git a/docutils/docutils/parsers/rst/languages/af.py b/docutils/docutils/parsers/rst/languages/af.py
index 792bfca21..e3335d160 100644
--- a/docutils/docutils/parsers/rst/languages/af.py
+++ b/docutils/docutils/parsers/rst/languages/af.py
@@ -104,3 +104,6 @@ roles = {
'rou': 'raw',}
"""Mapping of Afrikaans role names to canonical role names for interpreted text.
"""
+
+east_asian_widths = 'WF'
@tk0miya
tk0miya / README
Created November 28, 2018 15:19
reST の gridtable で ambiguous multibytes character を使う
reStructuredText のグリッドテーブルに一部の全角文字(◯などの記号やキリル文字など)を使うと Malformed table 扱いされてビルドできない。
そこで、このコードでは docutils が処理する前の原稿をハックし、Ambiguous な文字にパディングを入れ込むようにした。
かなりの dirty hack ではあるが、単純なテーブルが動くことは確認できた。
詳しくはこちらのスライド参照。
https://speakerdeck.com/anzawatta/sphinxfalseteburudequan-jiao-ji-hao-woshi-itai-sphinxcon-jp-2018-53c329a6-e71a-4200-9374-2568f0c172b5
@tk0miya
tk0miya / README.rst
Last active September 10, 2021 03:26

Sphinx のアンカーを hash ベースにする実験

無保証です。なんとなく動くことは確認しました。

Well known issue:

  • セクション名などを使って hash 値を生成しているので、同名のセクション名がファイル内に複数回登場すると破綻します。

元ネタはこのあたり参照:

@tk0miya
tk0miya / gist:f65f9f9fa3eacdbb4267d89951e113e1
Created August 7, 2018 15:12
OSS 開発者への支援について
エイチワークス
宮沢さくら様
こんにちは、小宮と申します。
Twitter で御社のコミュニティ支援に関する情報を拝見しました。
私もいくつかのコミュニティに参加していますが、
手弁当で運営されているものもまだまだ多い状況ですので、
御社のように積極的なコミュニティへのサポートが表明されていると
一参加者としては非常にありがたいと感じています。
all: aodag.pdf
%.dvi: %.tex
platex $<
%.pdf: %.dvi
dvipdfmx $<
clean:
rm -f *.aux *.log *.dvi *.pdf
@tk0miya
tk0miya / gist:121081d9eed7bb9a03351669a7945d10
Created May 24, 2018 07:36
now async becomes keyword!
[1] tkomiya@deneb> python3.6
Python 3.6.5 (default, Mar 31 2018, 01:44:52)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> def foo(**kwargs):
... return kwargs
...
>>> foo(async=True)
{'async': True}
>>>