summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xojgrep.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/xojgrep.py b/xojgrep.py
index 4938b51..a162a4d 100644
--- a/xojgrep.py
+++ b/xojgrep.py
@@ -86,12 +86,10 @@ class XOJFile:
# TODO check if that works with a xournal file without texts
pagecount = len(self.tree.xpath('/xournal/page'))
for pn in range(1, pagecount + 1):
- pagecontent = []
texts = self.tree.xpath('/xournal/page[{}]//text'.format(pn))
for text in texts:
- pagecontent.append(text.text)
- if pagecontent:
- content.append((pn, pagecontent))
+ for line in text.split('\n'):
+ content.append((pn, line))
return content
@@ -109,8 +107,8 @@ class PDFFile:
for pn in range(0, pagecount):
page = self.doc.getPage(pn)
text = page.extractText()
- if text:
- content.append((pn + 1, [text]))
+ for line in text.split('\n'):
+ content.append((pn + 1, text))
return content
@@ -124,7 +122,7 @@ class TXTFile:
def getcontent(self):
content = []
for (ln, line) in enumerate(self.txtfile, 1):
- content.append((ln, [line.rstrip('\n')]))
+ content.append((ln, line.rstrip('\n')))
return content