• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

generic text markup tools


Commit MetaInfo

Revisión525f9b8a7032ccc3862f4b411e8f9cef69a405e3 (tree)
Tiempo2014-02-05 19:42:36
Autorhylom <hylom@hylo...>
Commiterhylom

Log Message

editing ctable...

Cambiar Resumen

Diferencia incremental

--- a/plugins/ctable.py
+++ b/plugins/ctable.py
@@ -5,6 +5,7 @@
55 import re
66
77 table_rows = []
8+table_attrs = {}
89
910 def tableRow(context, args):
1011 line = args[0]
@@ -13,15 +14,49 @@ def tableRow(context, args):
1314 return []
1415
1516 def tableHeaderRow(context, args):
16- return tableRow(context, args)
17+ tableRow(context, args)
18+ row_count = len(table_rows)
19+ for i in range(0, len(table_rows[-1])):
20+ table_attrs[(row_count-1, i)] = {"header": True}
21+ return []
22+
23+def start_tag(tag, attrs={}):
24+ if len(attrs) > 0:
25+ attr = " " + " ".join([x + "=" + '"' + attrs[x] + '"' for x in attrs.keys()])
26+ else:
27+ attr = ""
28+ return "<" + tag + attr + ">"
29+
30+def end_tag(tag):
31+ return "</" + tag + ">"
1732
1833 def renderTable(context, args):
1934 buf = ""
20- for row in table_rows:
35+ height = len(table_rows)
36+ for i in range(0, height):
2137 buf += "<tr>\n "
22- for cell in row:
23- buf += "<td>" + cell + "</td>"
38+ width = len(table_rows[i])
39+ for j in range(0, width):
40+ print ":" + str(i) + "," + str(j)
41+ attrs = {}
42+ # check: cell is header?
43+ if table_attrs.get((i, j), False):
44+ tag = "th"
45+ else:
46+ tag = "td"
47+ # check:
48+ if i == 0:
49+ rowspan = 0
50+ for x in range(i+1, height):
51+ if table_rows[x][j] != "":
52+ break;
53+ rowspan += 1;
54+ if rowspan > 0:
55+ attrs["rowspan"] = rowspan
56+
57+ buf += start_tag(tag, attrs) + table_rows[i][j] + end_tag(tag)
2458 buf += "\n</tr>"
59+
2560 return [('ctable', buf)]
2661
2762 def flushTable(context, args):