Commits

Anonymous committed 4b5bad1

Enable normal line breaks within paragraphs (the docbook4 expander's complaining)

Comments (0)

Files changed (6)

czechtile/__init__.py

       macros.Hyperlink, macros.TriTecky, macros.Pomlcka,
       macros.Uvozovky, macros.FootNote, macros.Preskrtnute,
       macros.HorniIndex, macros.DolniIndex,
-      macros.Trademark, macros.Copyright, macros.RightsReserved
+      macros.Trademark, macros.Copyright, macros.RightsReserved,
+      macros.NovyRadek
 ]
 
 hyperlink_macros = [macro for macro in common_inline_macros if macro is not macros.Hyperlink]

czechtile/expanders/xhtml11.py

     def expand(self, node, format, node_map):
         return self.expand_with_content(node, format, node_map, u'<sub>', u'</sub>')
 
+class NovyRadek(CzechtileExpander):
+    def expand(self, node, format, node_map):
+        return u'<br />'
+
 class List(ListExpander):
     tag_map = {
         '-': {'tag': u'ul', 'attrs': u''},
     nodes.Uvozovky: entities.Uvozovky,
     nodes.PevnaMedzera: entities.PevnaMedzera,
     nodes.Preskrtnute: Preskrtnute,
-    nodes.Obrazek: Obrazek
-})
+    nodes.Obrazek: Obrazek,
+    nodes.NovyRadek: NovyRadek
+})

czechtile/macros.py

     name = 'dolni-index'
     help = '((dolni-index text posazeny do dolniho indexu))'
     node = nodes.DolniIndex
+
+class NovyRadek(CzechtileMacro):
+    name = 'novy_radek'
+    help = '((novy_radek))'
+
+    def expand_to_nodes(self, *args):
+        self.builder.append(nodes.NovyRadek(), move_actual=False)

czechtile/nodes.py

 class Trademark(Node): pass
 class Copyright(Node): pass
 class RightsReserved(Node): pass
+class NovyRadek(Node): pass
 
 class List(Node): pass
 class ListItem(Node): pass

czechtile/parsers.py

     start = ['(\.){3}']
     end = None
     macro = macros.TriTecky
-
 parsers += [TriTecky]
 
 class Pomlcka(Parser):
         self.stream = self.stream[endMatch.end():]
 
 	if self.stream[:2] == '""':
-	    raise ParserRollback
+            raise ParserRollback
 parsers += [Uvozovky]
 
+class NovyRadek(TypographicParser):
+    start = ['(\n){1}']
+    end = None
+    macro = macros.NovyRadek
+parsers += [NovyRadek]
+
 ### End of typographic parsers ###
 
 ### End of inline elements ###

czechtile/test/test_typo.py

 
 """ Test nahrazovani na peknou ceskou typografii
 """
+
 ###
 #Czechtile: WikiHezkyCesky
 #Copyright (C) 2006 Lukas "Almad" Linhart http://www.almad.net/
         result = expand(tree, 'xhtml11', expander_map)
         self.assertXhtml('''<p>&#8222;Uvodzovkujem&#8220;</p>''', result)
 
+    def testNovyRadek(self):
+        tree = parse('''A
+B
+C''', register_map)
+
+        result = expand(tree, 'docbook4', expander_map)
+        result = expand(tree, 'xhtml11', expander_map)
+        self.assertXhtml('''<p>A<br />B<br />C</p>''', result)
+
 if __name__ == "__main__":
     main()