[Pythonjp-checkins] [python-doc-ja] push by songo****@gmail***** - 改行の前後の文字が非latin-1の場合は、行を連結する拡張を導入。 on 2011-03-05 09:24 GMT

アーカイブの一覧に戻る

pytho****@googl***** pytho****@googl*****
2011年 3月 5日 (土) 18:25:53 JST


Revision: 0ab9e951df
Author: INADA Naoki  <inada****@klab*****>
Date: Sat Mar  5 01:24:08 2011
Log: 改行の前後の文字が非latin-1の場合は、行を連結する拡張を導入。
http://code.google.com/p/python-doc-ja/source/detail?r=0ab9e951df

Added:
  /tools/sphinxext/jpsupport.py
Modified:
  /conf.py

=======================================
--- /dev/null
+++ /tools/sphinxext/jpsupport.py	Sat Mar  5 01:24:08 2011
@@ -0,0 +1,21 @@
+def trunc_whitespace(app, doctree, docname):
+    from docutils.nodes import Text, paragraph
+    if not app.config.japanesesupport_trunc_whitespace:
+        return
+    for node in doctree.traverse(Text):
+        if isinstance(node.parent, paragraph):
+            lines = node.astext().splitlines()
+            newlines = [lines[0]]
+            for i in xrange(1, len(lines)):
+                line = lines[i]
+                prev = lines[i-1]
+                if prev and ord(prev[-1]) > 255 and line and ord(line[0])  
> 255:
+                    newlines[-1] += line
+                else:
+                    newlines.append(line)
+            newtext = '\n'.join(newlines)
+            node.parent.replace(node, Text(newtext))
+
+def setup(app):
+    app.add_config_value('japanesesupport_trunc_whitespace', True, True)
+    app.connect("doctree-resolved", trunc_whitespace)
=======================================
--- /conf.py	Sat Feb 19 22:10:38 2011
+++ /conf.py	Sat Mar  5 01:24:08 2011
@@ -20,6 +20,7 @@
                'sphinx.ext.doctest',
                'pyspecific',
                'sphinx.ext.todo',
+              'jpsupport',
                ]
  templates_path = ['tools/sphinxext']




Pythonjp-checkins メーリングリストの案内
アーカイブの一覧に戻る