Skip to content

Commit

Permalink
Keep text formatting in convertToText
Browse files Browse the repository at this point in the history
  • Loading branch information
muggot committed Feb 17, 2013
1 parent a2e7869 commit 7420632
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion goose/outputformatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def convertToText(self):
txt = HTMLParser().unescape(txt)
txts.append(innerTrim(txt))
for node in list(self.getTopNode()):
txt = Parser.getText(node)
txt = Parser.getFormattedText(node)
if txt:
txt = HTMLParser().unescape(txt)
txts.append(innerTrim(txt))
Expand Down
7 changes: 7 additions & 0 deletions goose/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,13 @@ def getText(self, node):
txts = [i for i in node.itertext()]
return innerTrim(u' '.join(txts).strip())

@classmethod
def getFormattedText(self, node):
pars = node.cssselect('p')
for p in pars:
if p.text is not None: p.text = u'\ufffc ' + p.text
return Parser.getText(node)

@classmethod
def previousSiblings(self, node):
nodes = []
Expand Down

0 comments on commit 7420632

Please sign in to comment.