Skip to content

Commit

Permalink
Improve parsing of some multiline code blocks
Browse files Browse the repository at this point in the history
Issue #12
  • Loading branch information
xuhcc committed May 12, 2020
1 parent 6ec0581 commit e7881af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion export.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def prepare_docx(file_name: str, drawing_dir: str = None) -> bytes:
# consider it a code block and mark it with SourceCode style
# https://groups.google.com/d/msg/pandoc-discuss/SIwE9dhGF4U/Wjy8zmQ1CQAJ
para.style = doc.styles['SourceCode']
continue
break
if run.font.name in ['Consolas', 'Courier New']:
# Mark with striketrough style to convert to inline code later
run.font.strike = True
Expand Down
8 changes: 6 additions & 2 deletions filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
run_filter,
stringify,
BlockQuote,
Cite,
Code,
CodeBlock,
Header,
Expand Down Expand Up @@ -104,8 +105,11 @@ def action(elem, doc):
# in 'A Comparison of Beancount and Ledger' document
pass
else:
text = stringify(elem)
return Code(text)
if any(isinstance(item, LineBreak) for item in elem.content):
return [*elem.content]
else:
text = stringify(elem)
return Code(text)

elif isinstance(elem, Header):
# There must be only one level 1 header
Expand Down

0 comments on commit e7881af

Please sign in to comment.