Skip to content

Commit

Permalink
fix: skip Yinxiang hidden markdown appendix
Browse files Browse the repository at this point in the history
  • Loading branch information
vzhd1701 committed Oct 15, 2022
1 parent f7382e8 commit aa5989e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
9 changes: 9 additions & 0 deletions enex2notion/note_parser/note.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ def _parse_note_dom(note: EvernoteNote) -> Optional[Tag]:
logger.error(f"Failed to extract DOM from note '{note.title}'")
return None

return _filter_yinxiang_markdown(note_dom)


def _filter_yinxiang_markdown(note_dom: Tag) -> Tag:
last_block = note_dom.contents[-1]

if last_block and "display:none" in last_block.attrs.get("style", ""):
last_block.extract()

return note_dom


Expand Down
23 changes: 23 additions & 0 deletions tests/test_note_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,29 @@ def test_linebreaks_inside_root(parse_html):
]


def test_yinxiang_markdown(parse_rules):
test_note = EvernoteNote(
title="test1",
created=datetime(2021, 11, 18, 0, 0, 0, tzinfo=tzutc()),
updated=datetime(2021, 11, 18, 0, 0, 0, tzinfo=tzutc()),
content=(
"<en-note>"
"<div>test1</div>"
"<center style='display:none'>test2</center>"
"</en-note>"
),
tags=[],
author="",
url="",
is_webclip=False,
resources=[],
)

assert parse_note(test_note, parse_rules) == [
NotionTextBlock(text_prop=TextProp("test1")),
]


def test_resource_recursive(smallest_gif, parse_rules):
test_note = EvernoteNote(
title="test1",
Expand Down

0 comments on commit aa5989e

Please sign in to comment.