How to use the markdown.etree function in Markdown

To help you get started, we’ve selected a few Markdown examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github robinhouston / write-to-mp / pylib / markdown / inlinepatterns.py View on Github external
def handleMatch(self, m):
        tag1, tag2 = self.tag.split(",")
        el1 = markdown.etree.Element(tag1)
        el2 = markdown.etree.SubElement(el1, tag2)
        el2.text = m.group(3)
        return el1
github mozilla / chromeless / python-lib / markdown / extensions / api.py View on Github external
def _parseHeader( self, parent, line ):
      div = etree.SubElement(parent, 'div')
      # Remove the spaces and equal signs
      className = line.strip('= ')
      div.set( 'class', className )
      return div
github andymckay / arecibo / listener / lib / markdown / extensions / footnotes.py View on Github external
def handleMatch(self, m):
        sup = etree.Element("sup")
        a = etree.SubElement(sup, "a")
        id = m.group(2)
        sup.set('id', self.footnotes.makeFootnoteRefId(id))
        a.set('href', '#' + self.footnotes.makeFootnoteId(id))
        a.set('rel', 'footnote')
        a.text = str(self.footnotes.footnotes.index(id) + 1)
        return sup
github andymckay / arecibo / listener / lib / markdown / blockparser.py View on Github external
def parseDocument(self, lines):
        """ Parse a markdown document into an ElementTree. 
        
        Given a list of lines, an ElementTree object (not just a parent Element)
        is created and the root element is passed to the parser as the parent.
        The ElementTree object is returned.
        
        This should only be called on an entire document, not pieces.

        """
        # Create a ElementTree from the lines
        self.root = markdown.etree.Element(markdown.DOC_TAG)
        self.parseChunk(self.root, '\n'.join(lines))
        return markdown.etree.ElementTree(self.root)
github andymckay / arecibo / listener / lib / markdown / blockprocessors.py View on Github external
def run(self, parent, blocks):
        block = blocks.pop(0)
        if block.strip():
            # Not a blank block. Add to parent, otherwise throw it away.
            if self.parser.state.isstate('list'):
                # The parent is a tight-list. Append to parent.text
                if parent.text:
                    parent.text = '%s\n%s' % (parent.text, block)
                else:
                    parent.text = block.lstrip()
            else:
                # Create a regular paragraph
                p = markdown.etree.SubElement(parent, 'p')
                p.text = block.lstrip()
github robinhouston / write-to-mp / pylib / markdown / extensions / footnotes.py View on Github external
def handleMatch(self, m):
        sup = etree.Element("sup")
        a = etree.SubElement(sup, "a")
        id = m.group(2)
        sup.set('id', self.footnotes.makeFootnoteRefId(id))
        a.set('href', '#' + self.footnotes.makeFootnoteId(id))
        a.set('rel', 'footnote')
        a.text = str(self.footnotes.footnotes.index(id) + 1)
        return sup
github robinhouston / write-to-mp / pylib / markdown / extensions / footnotes.py View on Github external
def makeFootnotesDiv(self, root):
        """ Return div of footnotes as et Element. """

        if not self.footnotes.keys():
            return None

        div = etree.Element("div")
        div.set('class', 'footnote')
        hr = etree.SubElement(div, "hr")
        ol = etree.SubElement(div, "ol")

        for id in self.footnotes.keys():
            li = etree.SubElement(ol, "li")
            li.set("id", self.makeFootnoteId(id))
            self.parser.parseChunk(li, self.footnotes[id])
            backlink = etree.Element("a")
            backlink.set("href", "#" + self.makeFootnoteRefId(id))
            backlink.set("rev", "footnote")
            backlink.set("title", "Jump back to footnote %d in the text" % \
                            (self.footnotes.index(id)+1))
            backlink.text = FN_BACKLINK_TEXT

            if li.getchildren():
github gwind / ylinux_old / lib / markdown / blockparser.py View on Github external
def parseDocument(self, lines):
        """ Parse a markdown document into an ElementTree. 
        
        Given a list of lines, an ElementTree object (not just a parent Element)
        is created and the root element is passed to the parser as the parent.
        The ElementTree object is returned.
        
        This should only be called on an entire document, not pieces.

        """
        # Create a ElementTree from the lines
        self.root = markdown.etree.Element(markdown.DOC_TAG)
        self.parseChunk(self.root, '\n'.join(lines))
        return markdown.etree.ElementTree(self.root)
github jpfleury / gedit-markdown / plugins / markdown-preview / markdown / extensions / abbr.py View on Github external
def handleMatch(self, m):
        abbr = etree.Element('abbr')
        abbr.text = m.group('abbr')
        abbr.set('title', self.title)
        return abbr
github dellsystem / wikinotes / mdx / mdx_wiki_def_list.py View on Github external
def create_item(self, parent, block):
        """ Create a new dd and parse the block with it as the parent. """
        dd = markdown.etree.SubElement(parent, 'dd')
        self.parser.parseBlocks(dd, [block])