fnp
/
redakcja.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
reference previews
[redakcja.git]
/
src
/
documents
/
xml_tools.py
diff --git
a/src/documents/xml_tools.py
b/src/documents/xml_tools.py
index
f2c885d
..
d7e3fcf
100644
(file)
--- a/
src/documents/xml_tools.py
+++ b/
src/documents/xml_tools.py
@@
-21,7
+21,11
@@
def _trim(text, trim_begin=True, trim_end=True):
that eg. one big XML file can be compiled from many small XML files.
"""
if trim_begin:
that eg. one big XML file can be compiled from many small XML files.
"""
if trim_begin:
- text = RE_TRIM_BEGIN.split(text, maxsplit=1)[-1]
+ parts = RE_TRIM_BEGIN.split(text, maxsplit=1)
+ text = parts[-1]
+ if len(parts) > 1:
+ lines = parts[0].count('\n')
+ text = f'<!--TRIM:{lines}-->' + text
if trim_end:
text = RE_TRIM_END.split(text, maxsplit=1)[0]
return text
if trim_end:
text = RE_TRIM_END.split(text, maxsplit=1)[0]
return text
@@
-103,7
+107,7
@@
def split_xml(text):
# find the chapter's title
name_elem = deepcopy(element)
# find the chapter's title
name_elem = deepcopy(element)
- for tag in 'extra', 'motyw', 'pa', 'pe', 'pr', 'pt', 'uwaga':
+ for tag in 'extra', 'motyw', 'pa', 'pe', 'pr', 'pt', '
ptrad', '
uwaga':
for a in name_elem.findall('.//' + tag):
a.text=''
del a[:]
for a in name_elem.findall('.//' + tag):
a.text=''
del a[:]