13 a .. directive:: somewhere::
17 .. code-block:: python
18 .. code-block:: python
19 .. code-block:: python listings
20 .. code-block:: python listings
29 def get_regexp(marker
):
30 class self
: pass # dummy to make the definitions compatible to pylit
32 self
.marker_regexp
= re
.compile('^( *(?!\.\.).*)(%s)([ \n]*)$'
35 # assume code_block_marker is a directive like '.. code-block::'
36 self
.marker_regexp
= re
.compile('^( *)(%s)(.*\n?)$' % marker
)
37 return self
.marker_regexp
39 for marker
in ('::', '.. code-block::'):
40 print 'regexp test for %r' % marker
41 regexp
= get_regexp(marker
)
42 for sample
in (literal
+ directive
+ misses
).splitlines(True):
43 match
= regexp
.search(sample
)
44 print '%-40r'%(sample),
46 print '-> ', match
.groups()
47 # print '-> ', repr(match.group())
60 no_options
= [' :lineno:2', # no space before option arg
61 ':lineno:', # no leading whitespace
63 ' :lin$no:', # invalid character
65 option_regexp
= re
.compile(r
' +:(\w|[-._+:])+:( |$)')
67 print 'regexp test for option_regexp'
68 for sample
in (options
).splitlines(True) + no_options
:
69 match
= option_regexp
.search(sample
)
70 print '%-40r'%(sample),
72 print '-> ', match
.groups()
73 # print '-> ', repr(match.group())