Exemplo n.º 1
0
 def __init__(self, subject=None, pos=0):
     self.doc = Node.makeNode("Document", 1, 1)
     self.subject = subject
     self.pos = pos
     self.tip = self.doc
     self.refmap = {}
     self.inlineParser = InlineParser()
Exemplo n.º 2
0
 def __init__(self, subject=None, pos=0):
     self.doc = Node.makeNode("Document", 1, 1)
     self.subject = subject
     self.pos = pos
     self.tip = self.doc
     self.refmap = {}
     self.inlineParser = InlineParser()
Exemplo n.º 3
0
 def parse(self, my_input):
     """ The main parsing function.  Returns a parsed document AST."""
     self.doc = Node.makeNode("Document", 1, 1)
     self.tip = self.doc
     self.refmap = {}
     lines = re.split(reLineEnding, re.sub(r'\n$', '', my_input))
     length = len(lines)
     for i in range(length):
         self.incorporateLine(lines[i], i + 1)
     while (self.tip):
         self.finalize(self.tip, length)
     self.processInlines(self.doc)
     return self.doc
Exemplo n.º 4
0
 def parse(self, my_input):
     """ The main parsing function.  Returns a parsed document AST."""
     self.doc = Node.makeNode("Document", 1, 1)
     self.tip = self.doc
     self.refmap = {}
     lines = re.split(reLineEnding, re.sub(r'\n$', '', my_input))
     length = len(lines)
     for i in range(length):
         self.incorporateLine(lines[i], i + 1)
     while (self.tip):
         self.finalize(self.tip, length)
     self.processInlines(self.doc)
     return self.doc
Exemplo n.º 5
0
 def addChild(self, tag, line_number, offset):
     """ Add block of type tag as a child of the tip.  If the tip can't
     accept children, close and finalize it and try its parent,
     and so on til we find a block that can accept children."""
     while not (self.tip.t == "Document" or self.tip.t == "BlockQuote"
                or self.tip.t == "Item" or
                (self.tip.t == "List" and tag == "Item")):
         self.finalize(self.tip, line_number - 1)
     column_number = offset + 1
     newNode = Node.makeNode(tag, line_number, column_number)
     self.tip.children.append(newNode)
     newNode.parent = self.tip
     self.tip = newNode
     return newNode
Exemplo n.º 6
0
 def addChild(self, tag, line_number, offset):
     """ Add block of type tag as a child of the tip.  If the tip can't
     accept children, close and finalize it and try its parent,
     and so on til we find a block that can accept children."""
     while not (self.tip.t == "Document" or
                self.tip.t == "BlockQuote" or
                self.tip.t == "Item" or
                (self.tip.t == "List" and tag == "Item")):
         self.finalize(self.tip, line_number - 1)
     column_number = offset + 1
     newNode = Node.makeNode(tag, line_number, column_number)
     self.tip.children.append(newNode)
     newNode.parent = self.tip
     self.tip = newNode
     return newNode