small manuel bugfix

Chris McDonough <[email protected]>
Newsgroups gmane.comp.web.zope.devel
Message-ID <[email protected]>
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@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  -  [email protected]
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 )
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.