Changeset 1774

Show
Ignore:
Timestamp:
09/24/08 16:18:02 (2 months ago)
Author:
JensDiemer
Message:
  • Creole lineending bugfix: convert all lineendings to \n
  • Add a test for this.
Location:
trunk/pylucid_project
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/pylucid_project/PyLucid/system/markups/creole.py

    r1771 r1774  
    521521    def parse(self): 
    522522        """Parse the text given as self.raw and return DOM tree.""" 
    523         self.parse_block(self.raw) 
     523        # convert all lineendings to \n 
     524        text = self.raw.replace("\r\n", "\n").replace("\r", "\n") 
     525        self.parse_block(text) 
    524526        return self.root 
    525527 
  • trunk/pylucid_project/tests/markup_creole.py

    r1771 r1774  
    8787        out_string = self._parse("a text line.") 
    8888        self.assertEqual(out_string, "<p>a text line.</p>\n") 
     89 
     90    def test_lineendings(self): 
     91        """ Test all existing lineending version """ 
     92        out_string = self._parse(u"first\nsecond") 
     93        self.assertEqual(out_string, u"<p>first<br />\nsecond</p>\n") 
     94         
     95        out_string = self._parse(u"first\rsecond") 
     96        self.assertEqual(out_string, u"<p>first<br />\nsecond</p>\n") 
     97         
     98        out_string = self._parse(u"first\r\nsecond") 
     99        self.assertEqual(out_string, u"<p>first<br />\nsecond</p>\n") 
    89100 
    90101    def test_creole_linebreak(self):