Beispiel #1
0
    def parseWrappedText(
            self, block, reWrap, reWrapHere, tagname,
            break_on_whitespace=False,
    ):
        """ Parsing subscript for support message like H~2~0."""
        subs = self.match(reWrapHere)
        if subs is None:
            return False
        after_open_subs = self.pos
        matched = self.match(reWrap)
        while matched is not None:
            if (matched == subs):
                node = Node(tagname, None)
                c = self.subject[after_open_subs:self.pos - len(subs)]
                if not break_on_whitespace:
                    c = c.strip()
                    c = re.sub(reWhitespace, ' ', c)
                elif ' ' in c:
                    break

                node.literal = c
                block.append_child(node)
                return True
            matched = self.match(reWrap)

        # If we got here, we didn't math a closing sequence, or skip here
        self.pos = after_open_subs
        block.append_child(text(subs))
        return True
Beispiel #2
0
 def parseHtmlTag(self, block):
     """Attempt to parse a raw HTML tag."""
     m = self.match(common.reHtmlTag)
     if m is None:
         return False
     else:
         node = Node('HtmlInline', None)
         node.literal = m
         block.append_child(node)
         return True
Beispiel #3
0
 def parseHtmlTag(self, block):
     """Attempt to parse a raw HTML tag."""
     m = self.match(common.reHtmlTag)
     if m is None:
         return False
     else:
         node = Node('HtmlInline', None)
         node.literal = m
         block.append_child(node)
         return True
 def parseLiqidTag(self, block):
     """Attempt to parse a raw Liqid tag."""
     m = self.match(reLiqidBlock)
     if m is None:
         return False
     else:
         node = Node('liqid_inline', None)
         node.literal = m
         block.append_child(node)
         return True
Beispiel #5
0
 def parseBackticks(self, block):
     """ Attempt to parse backticks, adding either a backtick code span or a
     literal sequence of backticks to the 'inlines' list."""
     ticks = self.match(reTicksHere)
     if ticks is None:
         return False
     after_open_ticks = self.pos
     matched = self.match(reTicks)
     while matched is not None:
         if (matched == ticks):
             node = Node('Code', None)
             c = self.subject[after_open_ticks:self.pos - len(ticks)]
             c = c.strip()
             c = re.sub(reWhitespace, ' ', c)
             node.literal = c
             block.append_child(node)
             return True
         matched = self.match(reTicks)
     # If we got here, we didn't match a closing backtick sequence.
     self.pos = after_open_ticks
     block.append_child(text(ticks))
     return True
Beispiel #6
0
 def parseBackticks(self, block):
     """ Attempt to parse backticks, adding either a backtick code span or a
     literal sequence of backticks to the 'inlines' list."""
     ticks = self.match(reTicksHere)
     if ticks is None:
         return False
     after_open_ticks = self.pos
     matched = self.match(reTicks)
     while matched is not None:
         if (matched == ticks):
             node = Node('Code', None)
             c = self.subject[after_open_ticks:self.pos - len(ticks)]
             c = c.strip()
             c = re.sub(reWhitespace, ' ', c)
             node.literal = c
             block.append_child(node)
             return True
         matched = self.match(reTicks)
     # If we got here, we didn't match a closing backtick sequence.
     self.pos = after_open_ticks
     block.append_child(text(ticks))
     return True
Beispiel #7
0
def text(s):
    node = Node('Text', None)
    node.literal = s
    return node
Beispiel #8
0
def text(s):
    node = Node('Text', None)
    node.literal = s
    return node
Beispiel #9
0
def text(s):
    node = Node("Text", None)
    node.literal = s
    return node