[Zope-dev] small manuel bugfix

Chris McDonough chrism at plope.com
Fri Dec 25 21:40:34 EST 2009


Ugh, that patch is rendered backwards... but you get the idea.

Chris McDonough wrote:
> I added a branch of manuel to the Zope SVN that fixes the codeblock plugin when 
> you use codeblock "roles" such as:
> 
> .. code-block:: python
>     :linenos:
> 
> Currently it only works without roles, e.g.:
> 
> .. code-block:: python
> 
> The branch is at 
> svn+ssh://svn.zope.org/repos/main/manuel/branches/chrism-codeblocks
> 
> The diff against the current head is as follows:
> 
> [chrism at snowpro manuel]$ svn diff 
> ===================================================================
> --- src/manuel/codeblock.py	(.../branches/chrism-codeblocks)	(revision 107071)
> +++ src/manuel/codeblock.py	(.../trunk)	(revision 107071)
> @@ -2,9 +2,7 @@
>   import manuel
>   import textwrap
> 
> -CODEBLOCK_START = re.compile(
> -    r'(^\.\.\s*(invisible-)?code-block::?\s*python\b(?:\s*\:\w+\:)*)',
> -    re.MULTILINE)
> +CODEBLOCK_START = re.compile(r'^\.\.\s*(invisible-)?code-block::?\s*python\b', 
> re.MULTILINE)
>   CODEBLOCK_END = re.compile(r'(\n\Z|\n(?=\S))')
> 
> 
> @@ -15,8 +13,7 @@
> 
>   def find_code_blocks(document):
>       for region in document.find_regions(CODEBLOCK_START, CODEBLOCK_END):
> -        start_end = CODEBLOCK_START.search(region.source).end()
> -        source = textwrap.dedent(region.source[start_end:])
> +        source = textwrap.dedent('\n'.join(region.source.splitlines()[1:]))
>           source_location = '%s:%d' % (document.location, region.lineno)
>           code = compile(source, source_location, 'exec', 0, True)
>           document.claim_region(region)
> 
> I submit it for Benji's consideration.
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev at zope.org
> https://mail.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists - 
>  https://mail.zope.org/mailman/listinfo/zope-announce
>  https://mail.zope.org/mailman/listinfo/zope )
> 



More information about the Zope-Dev mailing list