Skip to content

Commit

Permalink
fix: improve yinxiang markdown block filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
vzhd1701 committed Oct 18, 2022
1 parent 785992c commit 497940b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
5 changes: 4 additions & 1 deletion enex2notion/note_parser/note.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ def _parse_note_dom(note: EvernoteNote) -> Optional[Tag]:
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", ""):
if not isinstance(last_block, Tag):
return note_dom

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

return note_dom
Expand Down
18 changes: 18 additions & 0 deletions tests/test_note_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,24 @@ def test_yinxiang_markdown(parse_rules):
]


def test_yinxiang_markdown_bad_end(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>\n</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 497940b

Please sign in to comment.