用Git+Sphinx记笔记?

接前面 TeX、LaTeX、TeXLive 小结,练习使用Sphinx写点东西:

效果

图1:

用Git+Sphinx记笔记?_第1张图片

图2:

用Git+Sphinx记笔记?_第2张图片

git

Google code 提供Git

  • http://code.google.com/p/debao-qt-blogs/

只是不清楚什么原因,无论 push 还是 pull 总是失败。(伟大的墙在发挥作用?)

* About to connect() to code.google.com port 443 (#0)
*   Trying 72.14.203.102... * Connection timed out
* Failed connect to code.google.com:443; Connection timed out
* Closing connection #0
* About to connect() to code.google.com port 443 (#0)
*   Trying 72.14.203.102... * Connection reset by peer
* Failed connect to code.google.com:443; Connection reset by peer
* Closing connection #0
error: Failed connect to code.google.com:443; Connection reset by peer while accessing https://code.google.com/p/debao-qt-blogs/info/refs

那就使用 gitorious 了。

  • https://gitorious.org/hexamples/blogs

sphinx

在TeX、LaTeX、TeXLive 小结一文中,是直接修改Sphinx的latex生成器来支持中文的,不过稍后发现,设置项目的配置文件就可以实现了:

  • conf.py

latex_elements = {
        'babel':'',
        'fontpkg':'',
        'inputenc':'',
        'fontenc':'',
        'utf8extra':''
}

latex_docclass = {
        'howto':'ctexart',
        'manual':'ctexrep'
}

只需要添加这两项即可。

尽管如此,Sphinx的latex生成器还是很不成熟,在当前稳定版Sphinx 1.0.8 尚不支持表格的rowspan和colspan。源码仓库中的Sphinx 1.1 开始支持表格的这两个属性,不过rowspan有bug(无法正常工作)。

简单改动一下,凑活一下:

birkenfeld-sphinx-0dc8c4da3ef5

--- a/latex.py
+++ b/latex.py
@@ -730,19 +730,29 @@ class LaTeXTranslator(nodes.NodeVisitor):
     def visit_row(self, node):
         self.table.col = 0
     def depart_row(self, node):
+        for col in range(self.table.col, self.table.colcount):
+            self.body.append(' & ')
         if self.previous_spanning_row == 1:
-            self.previous_spanning_row = 0
+            #self.previous_spanning_row = 0
             self.body.append('\\\\\n')
         else:
             self.body.append('\\\\\\hline\n')
         self.table.rowcount += 1
 
     def visit_entry(self, node):
-        if self.remember_multirow.get(0, 0) > 1:
-            self.body.append(' & ')
+        print "visit_entry:", self.table.rowcount, self.table.col, self.table.c
+        for col in range(self.table.col, self.table.colcount):
+            if self.remember_multirow.get(col, 0) > 1:
+                self.remember_multirow[col] -= 1
+                if self.remember_multirow[col] == 1:
+                    self.previous_spanning_row = 0
+                if self.table.col > 0:
+                    self.body.append(' & ')
+            else:
+                self.table.col = col
+                break
         if self.table.col > 0:
             self.body.append(' & ')
-        self.table.col += 1
         self.context.append('')
         if 'morerows' in node:
             self.body.append(' \multirow{')
@@ -751,10 +761,11 @@ class LaTeXTranslator(nodes.NodeVisitor):
             self.body.append('}{*}{')
             self.context.append('}')
             self.remember_multirow[self.table.col] = node.get('morerows') + 1
+            self.previous_spanning_row = 1
         if 'morecols' in node:
             self.body.append(' \multicolumn{')
             self.body.append(str(node.get('morecols') + 1))
-            if self.table.col == 1:
+            if self.table.col == 0:
                 self.body.append('}{|l|}{')
             else:
                 self.body.append('}{l|}{')
@@ -762,9 +773,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
         if isinstance(node.parent.parent, nodes.thead):
             self.body.append('\\textbf{')
             self.context.append('}')
-        if self.remember_multirow.get(self.table.col + 1, 0) > 1:
-            self.remember_multirow[self.table.col + 1] -= 1
-            self.context.append(' & ')
+        self.table.col += 1
     def depart_entry(self, node):
         self.body.append(self.context.pop()) # header

你可能感兴趣的:(c,工作,header,git,Class)