@@ -14,34 +14,37 @@ from collections import Counter
14
14
15
15
from vimsnippets import complete
16
16
17
- # http://docutils.sourceforge.net/docs/ref/rst/roles.html
18
- TEXT_ROLES = [' emphasis' ,' literal' ,' code' ,' math' ,
19
- ' pep-reference' ,' rfc-reference' ,
20
- ' strong' ,' subscript' ,' superscript' ,
21
- ' title-reference' ,' raw' ]
17
+ # http://docutils.sourceforge.net/docs/ref/rst/roles.html
18
+ TEXT_ROLES = [' emphasis' , ' literal' , ' code' , ' math' ,
19
+ ' pep-reference' , ' rfc-reference' ,
20
+ ' strong' , ' subscript' , ' superscript' ,
21
+ ' title-reference' , ' raw' ]
22
22
TEXT_ROLES_REGEX = r ' \.\. \s role::? \s ( w+ ) '
23
23
24
- # http://docutils.sourceforge.net/docs/ref/rst/directives.html#specific-admonitions
24
+ # http://docutils.sourceforge.net/docs/ref/rst/directives.html#specific-admonitions
25
25
SPECIFIC_ADMONITIONS = [" attention" , " caution" , " danger" ,
26
26
" error" , " hint" , " important" , " note" ,
27
27
" tip" , " warning" ]
28
- # http://docutils.sourceforge.net/docs/ref/rst/directives.html
29
- DIRECTIVES = [' topic' ,' sidebar' ,' math' ,' epigraph' ,
30
- ' parsed-literal' ,' code' ,' highlights' ,
31
- ' pull-quote' ,' compound' ,' container' ,' table' ,' csv-table' ,
32
- ' list-table' ,' class' ,' sectnum' ,
33
- ' role' ,' default-role' ,' unicode' ,
34
- ' raw' ]
28
+ # http://docutils.sourceforge.net/docs/ref/rst/directives.html
29
+ DIRECTIVES = [' code' , ' contents' , ' admonition' , ' table' , ' csv-table' , ' list-table' ,
30
+ ' class' , ' container' , ' sidebar' , ' topic' , ' title' ,
31
+ ' role' , ' default-role' , ' raw' ]
35
32
36
- NONE_CONTENT_DIRECTIVES = [' rubric' , ' contents' , ' header' ,
37
- ' footer' , ' date' , ' include' , ' title' ]
33
+ # DIRECTIVES_WITHOUT_TITLE means directive arguments equal None
34
+ DIRECTIVES_WITHOUT_TITLE = [' math' , ' meta' , ' parsed-literal' , ' line-block' ,
35
+ ' header' , ' compound' , ' highlights' , ' pull-quote' ,
36
+ ' footer' , ' epigraph' , ' rubric' , ' sectnum' ]
38
37
39
38
INCLUDABLE_DIRECTIVES = [' image' , ' figure' , ' include' ]
39
+
40
+ # Directives for Subsubsection Definition
41
+ DIRECTIVES_FOR_SUBSTITUTION = [' replace' , ' unicode' , ' date' ]
42
+
40
43
# CJK chars
41
44
# http://stackoverflow.com/questions/2718196/find-all-chinese-text-in-a-string-using-python-and-regex
42
45
CJK_RE = re.compile(u ' [⺀-⺙⺛-⻳⼀-⿕々〇〡-〩〸-〺〻㐀-䶵一-鿃豈-鶴侮-頻並-龎]' , re.UNICODE )
43
46
44
- # http://www.pygal.org/en/stable/documentation/types/index.html
47
+ # http://www.pygal.org/en/stable/documentation/types/index.html
45
48
CHART_TYPES = [" Line" , " StackedLine" , " HorizontalLine" , " Bar" , " StackedBar" , " HorizontalBar" , " Histogram" , " XY" , " DateLine" , " TimeLine" , " TimeDeltaLine" , " DateTimeLine" , " Pie" , " Radar" , " Box" , " Dot" , " Funnel" , " Gauge" , " SolidGauge" , " Pyramid" , " Treemap" ]
46
49
47
50
def has_cjk (s ):
@@ -264,23 +267,30 @@ snippet di "Directives" b
264
267
$0
265
268
endsnippet
266
269
267
- snippet nd " None Content Directives" b
268
- .. $1 `!p snip.rv= complete(t[1 ], NONE_CONTENT_DIRECTIVES ) ` :: $2
270
+ snippet dt " Directives without title" b
271
+ .. $1 `!p snip.rv= complete(t[1 ], DIRECTIVES_WITHOUT_TITLE ) ` ::
272
+
273
+ ${2: ${VISUAL:Content } }
274
+ $0
275
+ endsnippet
276
+
277
+ snippet ds " Directives for subscription" b
278
+ .. |$1 | $2 `!p snip.rv= complete(t[2 ], DIRECTIVES_FOR_SUBSTITUTION ) ` :: ${3: Content }
269
279
$0
270
280
endsnippet
271
281
272
282
snippet sa " Specific Admonitions" b
273
- .. $1 `!p snip.rv = complete(t[1 ], SPECIFIC_ADMONITIONS ) ` ::
283
+ .. $1 `!p snip.rv = complete(t[1 ], SPECIFIC_ADMONITIONS ) ` :: $2
274
284
275
- ${2 : ${VISUAL:Content } }
285
+ ${3 : ${VISUAL:Content } }
276
286
277
287
$0
278
288
endsnippet
279
289
280
- # it will be trigger at start of line or after a word
290
+ # it will be trigger at start of line or after a word
281
291
snippet ro " Text Roles" w
282
292
\ :$1 `!p snip.rv= complete(t[1 ],
283
- TEXT_ROLES + look_up_directives(TEXT_ROLES_REGEX ,
293
+ TEXT_ROLES + look_up_directives(TEXT_ROLES_REGEX ,
284
294
path)) ` :\` $2 \` \
285
295
endsnippet
286
296
@@ -306,7 +316,7 @@ snippet chart "Pygal chart for Nikola" b
306
316
.. chart:: $1 `!p snip.rv= complete(t[1 ], CHART_TYPES ) `
307
317
:title: '${2: Browser usage evolution (in %) } '
308
318
:x_labels: [${3: "2002", "2003", "2004", "2005", "2006", "2007" } ]
309
-
319
+
310
320
'Firefox', [None, None, 0, 16.6, 25, 31]
311
321
'Chrome', [None, None, None, None, None, None]
312
322
'IE', [85.8, 84.6, 84.7, 74.5, 66, 58.6]
@@ -323,4 +333,5 @@ snippet sid "SideBar" b
323
333
324
334
${2: ${VISUAL:SideBar Content } }
325
335
endsnippet
326
- # vim:ft=snippets:
336
+
337
+ # vim:set list noet sts=0 sw=4 ts=4:
0 commit comments