incubator-ooo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Fisher <dave2w...@comcast.net>
Subject Re: svn commit: r1142819 - /incubator/ooo/site/trunk/content/openofficeorg/people.mdtext
Date Wed, 06 Jul 2011 18:38:21 GMT
Joe,

> Submit a patch to infrastructure@ plaese.

I would, but I am uncomfortable submitting untested code. I need some help setting up a version
of the CMS for testing.

I think that others here may have a similar need.

Thanks.

Anyway if you want to debug what I did here is a diff compared to mdx_elementid.py:

--- mdx_elementid.py	2011-07-06 10:43:22.000000000 -0700
+++ mdx_classtag.py	2011-07-05 18:34:32.000000000 -0700
@@ -1,39 +1,39 @@
 #! 
 
 '''
-id Extension for Python-Markdown
+classtag Extension for Python-Markdown
 ==========================================
 
-This extension adds ids to block elements in Python-Markdown.
+This extension adds class tags to block elements in Python-Markdown.
 
 Simple Usage:
 
     >>> import markdown
     >>> text = """
-    ... list: {#list.1} 
+    ... list: {.list.1} 
     ...
-    ... 1. This is a test {#node1}
-    ... 2. Other {#node2}
+    ... 1. This is a test {.node1}
+    ... 2. Other {#.node2}
     ... 
     ... More
     ... """
-    >>> markdown.markdown(text, ['toc','elementid'])
-    u'<p id="list.1">list:</p>\\n<ol>\\n<li id="node1">This is a
test</li>\\n<li id="node2">Other</li>\\n</ol>\\n<p>More</p>'
-    >>> text2 = u"""Spain {#el1}
+    >>> markdown.markdown(text, ['toc','classtag'])
+    u'<p class="list.1">list:</p>\\n<ol>\\n<li class="node1">This
is a test</li>\\n<li class="node2">Other</li>\\n</ol>\\n<p>More</p>'
+    >>> text2 = u"""Spain {.el1}
     ... :    Name of a country
     ...      in the South West of Europe
     ... 
-    ... Espa\xf1a {#el2}
+    ... Espa\xf1a {.el2}
     ... :    Name of Spain
     ...      in Spanish (contains non-ascii)
     ... 
     ... End of definition list...
     ... """
-    >>> markdown.markdown(text2, ['toc','elementid', 'def_list'])
-    u'<dl>\\n<dt id="el1">Spain</dt>\\n<dd>Name of a country\\n in
the South West of Europe</dd>\\n<dt id="el2">Espa\\xf1a</dt>\\n<dd>Name
of Spain\\n in Spanish (contains non-ascii)</dd>\\n</dl>\\n<p>End of definition
list...</p>'
-
+    >>> markdown.markdown(text2, ['toc','classtag', 'def_list'])
+    u'<dl>\\n<dt class="el1">Spain</dt>\\n<dd>Name of a country\\n
in the South West of Europe</dd>\\n<dt class="el2">Espa\\xf1a</dt>\\n<dd>Name
of Spain\\n in Spanish (contains non-ascii)</dd>\\n</dl>\\n<p>End of definition
list...</p>'
 
 
+Based on mdx_elementid.py
 Copyright 2010
 * [Santiago Gala](http://memojo.com/~sgala/blog/)
 
@@ -46,52 +46,52 @@
 ID_RE = re.compile(r"""[ \t]*                    # optional whitespace
                        [#]{0,6}                  # end of heading
                        [ \t]*                    # optional whitespace
-                       (?:[ \t]*\{[ \t]*\#(?P<id>[-._:a-zA-Z0-9]+)[ \t]*\})
+                       (?:[ \t]*\{[ \t]*\.(?P<classtag>[-._:a-zA-Z0-9]+)[ \t]*\})
                        [ \t]*                    # optional whitespace
                        (\n|$)              #  ^^ group('id') = id attribute
                     """,
                     re.VERBOSE)
 
 
-class IdTreeProcessor(markdown.treeprocessors.Treeprocessor):
-    """ Id Treeprocessor - parse text for id specs. """
+class ClasstagTreeProcessor(markdown.treeprocessors.Treeprocessor):
+    """ Classtag Treeprocessor - parse text for classtag specs. """
 
-    def _parseID(self, element):
-        ''' recursively parse all {#idname}s at eol into ids '''
+    def _parseClasstag(self, element):
+        ''' recursively parse all {.classtag}s at eol into ids '''
         if markdown.isBlockLevel(element.tag) and element.tag not in ['code', 'pre']:
             #print element
             if (element.text and element.text.strip()):
                 m = ID_RE.search(element.text)
                 if m:
-                    element.set('id',m.group('id'))
+                    element.set('classtag',m.group('classtag'))
                     element.text = element.text[:m.start()]
             for e in element:
-                self._parseID(e)
+                self._parseClasstag(e)
         return element
         
 
     def run(self, root):
         '''
-        Find and remove all id specs references from the text,
-        and add them as the id attribute of the element.
+        Find and remove all classtag specs references from the text,
+        and add them as the class attribute of the element.
         
         '''
         if markdown.isBlockLevel(root.tag) and root.tag not in ['code', 'pre']:
-            self._parseID(root)
+            self._parseClasstag(root)
         return root
 
-class IdExtension(markdown.Extension):
-    """ Id Extension for Python-Markdown. """
+class ClasstagExtension(markdown.Extension):
+    """ Classtag Extension for Python-Markdown. """
 
     def extendMarkdown(self, md, md_globals):
-        """ Insert IdTreeProcessor in tree processors. It should be before toc. """
-        idext = IdTreeProcessor(md)
-        idext.config = self.config
-        md.treeprocessors.add("elid", idext, "_begin")
+        """ Insert ClasstagTreeProcessor in tree processors. It should be before toc. """
+        classtagext = ClasstagTreeProcessor(md)
+        classtagext.config = self.config
+        md.treeprocessors.add("elid", classtagext, "_begin")
 
 
 def makeExtension(configs=None):
-    return IdExtension(configs=configs)
+    return ClasstagExtension(configs=configs)
 
 if __name__ == "__main__":
     import doctest

Regards,
Dave


> 
> Sent from my iPhone
> 
> On Jul 5, 2011, at 11:46 PM, Dave Fisher <dave2wave@comcast.net> wrote:
> 
> Hi Joe,
> 
> I've made what I think is an appropriate edit to create an mdx_classtag.py.
> 
> (1) Basically id was converted to classtag all over. (class is a reserved word.)
> 
> (2) The appropriate # was changed to . in the regex (I hope)
> 
> What would be my easiest strategy for testing it on my people.a.o account?
> 
> Is it as simple as downloading the proper part of the repos?
> 
> Regards,
> Dave
> 
> On Jul 5, 2011, at 2:11 PM, Joe Schaefer wrote:
> 
> 
> 
> ----- Original Message ----
> From: Dave Fisher <dave2wave@comcast.net>
> To: ooo-dev@incubator.apache.org
> Cc: ooo-commits@incubator.apache.org
> Sent: Tue, July 5, 2011 4:57:36 PM
> Subject: Re: svn commit: r1142819 - 
> /incubator/ooo/site/trunk/content/openofficeorg/people.mdtext
> 
> Hi Joe,
> 
> Thanks for all the CMS tips.
> 
> I see from this commit that #  {#foo} is inserted into the table header html as 
> <th  id="foo">.
> 
> Would # {.bar} add class="bar"?
> 
> Not as it's currently implemented, no.  What you want to look at is the source 
> for
> mdx_elementid.py as it's a custom extension of our markdown impl.  If you hack 
> it
> to do what you want, and your code doesn't suck, I'll apply the patch.  The 
> source
> is here https://svn.apache.org/repos/infra/websites/cms/build/mdx_elementid.py .
> 
> 


Mime
View raw message