Beispiel #1
0
 def expand_to_nodes(self, token, content):
     node = nodes.List()
     node.token = token
     self.builder.append(node, move_actual=True)
     parse(content, self.register_map, self.register, builder=self.builder, state=self.state)
     assert self.builder.actual_node == node
     self.builder.move_up()
Beispiel #2
0
 def expand_to_nodes(self, level, content):
     node = nodes.Nadpis()
     node.level = level
     self.builder.append(node, move_actual = True)
     parse(content, self.register_map, self.register, builder=self.builder, state=self.state)
     assert node == self.builder.actual_node
     self.builder.move_up()
Beispiel #3
0
 def expand_to_nodes(self, content):
     node = nodes.Odstavec()
     self.builder.append(node, move_actual=False)
     if isinstance(node.parent, nodes.TextNode):
         self.builder.replace(node)
     self.builder.set_actual_node(node)
     parse(content, self.register_map, self.register, builder=self.builder, state=self.state)
     assert node == self.builder.actual_node
     self.builder.move_up()
Beispiel #4
0
 def expand_to_nodes(self, link, content):
     node = nodes.Hyperlink()
     node.link = link
     self.builder.append(node, move_actual = True)
     if link == content:
         tn = nodes.TextNode()
         tn.content = content
         self.builder.append(tn, move_actual=False)
     else:
         parse(content, self.register_map, self.register, builder=self.builder, state=self.state)
     self.builder.move_up()
Beispiel #5
0
 def testProperResolving(self):
     s = '((odstavec text odstavce))'
     o = parse(s, self.register_map, document_root=True)
     self.assertEquals(len(o.children), 1)
     self.assertEquals(o.children[0].__class__, ParagraphNode)
     self.assertEquals(o.children[0].children[0].__class__, TextNode)
     self.assertEquals(o.children[0].children[0].content, 'text odstavce')
 def testProperMultipleNested(self):
     s = "((container ((container ((container text))))))"
     o = parse(s, self.register_map, document_root=True)
     self.assertEquals(o.children[0].__class__, DummyNode)
     self.assertEquals(o.children[0].children[0].__class__, DummyNode)
     self.assertEquals(o.children[0].children[0].children[0].__class__, DummyNode)
     self.assertEquals(o.children[0].children[0].children[0].children[0].__class__, TextNode)
     self.assertEquals(o.children[0].children[0].children[0].children[0].content, "text")
Beispiel #7
0
 def testProperNestedQuoted(self):
     # we cannot use odstavec as macro, because it is not parsing it's args
     s = '((silne "silne silny)) text odstavce"))'
     o = parse(s, self.register_map, document_root=True)
     self.assertEquals(len(o.children), 1)
     self.assertEquals(o.children[0].__class__, StrongNode)
     self.assertEquals(o.children[0].children[0].__class__, TextNode)
     self.assertEquals(o.children[0].children[0].content, 'silne silny)) text odstavce')
Beispiel #8
0
 def testProperNested(self):
     s = '((odstavec ((silne silny)) text odstavce))'
     o = parse(s, self.register_map, document_root=True)
     self.assertEquals(len(o.children), 1)
     self.assertEquals(o.children[0].__class__, ParagraphNode)
     self.assertEquals(o.children[0].children[0].__class__, StrongNode)
     self.assertEquals(o.children[0].children[0].children[0].__class__, TextNode)
     self.assertEquals(o.children[0].children[0].children[0].content, 'silny')
     self.assertEquals(o.children[0].children[1].__class__, TextNode)
     self.assertEquals(o.children[0].children[1].content, ' text odstavce')
Beispiel #9
0
 def testBadCall(self):
     s = '((odstavec))'
     o = parse(s, self.register_map, document_root=True)
     self.assertEquals(len(o.children), 1)
     self.assertEquals(o.children[0].__class__, TextNode)
     self.assertEquals(o.children[0].content, '((odstavec))')
 def testCallWithoutMacroName(self):
     s = "(())"
     o = parse(s, self.register_map, document_root=True)
     self.assertEquals(len(o.children), 1)
     self.assertEquals(o.children[0].__class__, TextNode)
     self.assertEquals(o.children[0].content, "(())")
Beispiel #11
0
 def expand_to_nodes(self, content):
     node = nodes.Article()
     self.builder.append(node, move_actual = True)
     parse(content, self.register_map, self.register, builder=self.builder, state=self.state)
     self.wrap_text_nodes(node)
     self.builder.move_up()
Beispiel #12
0
 def expand_to_nodes(self, content):
     node = nodes.ListItem()
     self.builder.append(node, move_actual=True)
     parse(content, self.register_map, self.register, builder=self.builder, state=self.state)
     self.builder.move_up()
 def testManyMacroBeginsEven(self):
     s = "(((((((()))"
     o = parse(s, self.register_map, document_root=True)
     self.assertEquals(len(o.children), 1)
     self.assertEquals(o.children[0].__class__, TextNode)
     self.assertEquals(o.children[0].content, "(((((((()))")
Beispiel #14
0
 def testNegateMacroSyntaxWithTwoNegationsChars(self):
     s = 2*NEGATION_CHAR+'((odstavec text !odstavce))'
     o = parse(s, self.register_map, document_root=True)
     self.assertEquals(len(o.children), 1)
     self.assertEquals(o.children[0].__class__, TextNode)
     self.assertEquals(o.children[0].content, NEGATION_CHAR+'((odstavec text !odstavce))')
Beispiel #15
0
 def test_kwargs_resolved(self):
     s = '((picture http://pic.png title="My picture"))'
     o = parse(s, self.register_map, document_root=True)
     self.assertEquals(1, len(o.children))
     self.assertEquals(PictureNode, o.children[0].__class__)
     self.assertEquals(u"My picture", o.children[0].kwargs['title'])
 def testParsingShortArgument(self):
     s = "((onearg test))"
     o = parse(s, RegisterMap({OneArgumentMacro: Register()}), document_root=True)
     self.assertEquals(DummyNode, o.children[0].__class__)
     self.assertEquals(u"test", o.children[0].children[0].content)
Beispiel #17
0
 def testNegateParserSyntax(self):
     s = NEGATION_CHAR+'""strong""'
     o = parse(s, self.register_map, parsers=parsers_list, document_root=True)
     self.assertEquals(len(o.children), 1)
     self.assertEquals(o.children[0].__class__, TextNode)
     self.assertEquals(o.children[0].content, '""strong""')
Beispiel #18
0
 def testParsingLongArgumentWithTrailingSlash(self):
     s = '((onearg "long argument "))'
     o = parse(s, RegisterMap({OneArgumentMacro : Register()}), document_root = True)
     self.assertEquals(u"long argument ", o.children[0].children[0].content)
Beispiel #19
0
 def testParsingLongArgument(self):
     s = '((onearg "long argument"))'
     o = parse(s, RegisterMap({OneArgumentMacro : Register()}), document_root = True)
     self.assertEquals(DummyNode, o.children[0].__class__)
     self.assertEquals(u"long argument", o.children[0].children[0].content)