[Checkins] SVN: manuel/branches/chrism-codeblocks/src/manuel/codeblock.py Ignore RST roles which follow .. code-block:: python, e.g.
Chris McDonough
chrism at plope.com
Fri Dec 25 01:29:58 EST 2009
Log message for revision 107065:
Ignore RST roles which follow .. code-block:: python, e.g.
.. code-block:: python
:linenos:
Changed:
U manuel/branches/chrism-codeblocks/src/manuel/codeblock.py
-=-
Modified: manuel/branches/chrism-codeblocks/src/manuel/codeblock.py
===================================================================
--- manuel/branches/chrism-codeblocks/src/manuel/codeblock.py 2009-12-25 06:25:35 UTC (rev 107064)
+++ manuel/branches/chrism-codeblocks/src/manuel/codeblock.py 2009-12-25 06:29:58 UTC (rev 107065)
@@ -2,7 +2,9 @@
import manuel
import textwrap
-CODEBLOCK_START = re.compile(r'^\.\.\s*(invisible-)?code-block::?\s*python\b', re.MULTILINE)
+CODEBLOCK_START = re.compile(
+ r'(^\.\.\s*(invisible-)?code-block::?\s*python\b(?:\s*\:\w+\:)*)',
+ re.MULTILINE)
CODEBLOCK_END = re.compile(r'(\n\Z|\n(?=\S))')
@@ -13,7 +15,8 @@
def find_code_blocks(document):
for region in document.find_regions(CODEBLOCK_START, CODEBLOCK_END):
- source = textwrap.dedent('\n'.join(region.source.splitlines()[1:]))
+ start_end = CODEBLOCK_START.search(region.source).end()
+ source = textwrap.dedent(region.source[start_end:])
source_location = '%s:%d' % (document.location, region.lineno)
code = compile(source, source_location, 'exec', 0, True)
document.claim_region(region)
More information about the checkins
mailing list