diff --git a/enex2notion/note_parser/note.py b/enex2notion/note_parser/note.py index 09554e9..6eac9df 100644 --- a/enex2notion/note_parser/note.py +++ b/enex2notion/note_parser/note.py @@ -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 diff --git a/tests/test_note_parser.py b/tests/test_note_parser.py index 25841cf..ef7021d 100644 --- a/tests/test_note_parser.py +++ b/tests/test_note_parser.py @@ -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=("
test1
\n
"), + 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",