Closed balintkissdev closed 1 year ago
Thanks a lot @balintkissdev for this contribution! Multiline text is something I have not considered or tested, yet.
Some thoughts:
The body of indent_multiline_text()
could be simplified to:
return ('\n' + indent*(level)).join(text.splitlines())
given we accepted indented empty lines as before your second commit. (I do not know, if any Markdown style guide discourages this.) Removing indentation in empty lines would otherwise require something like:
re.sub(r'^\s+$', '', result, flags=re.MULTILINE)
.
(It might become even simpler using textwrap.indent(), but would add one more dependency.)
What do you think?
I use LogSeq mainly, so I tried out and created a page with the same multiline content in LogSeq. The result is that LogSeq does not care about removing whitespaces on empty lines from the created Markdown file.
<!-- Whitespace test in LogSeq.md -->
- Subnote 1
text
- Subnote 2
text
- Subnote 3
text
In the end Markdown just collapses into HTML anyway when displayed where needless whitespaces are removed. So I'm fine too with return ('\n' + indent*(level)).join(text.splitlines())
.
EDIT: LogSeq goes even further by inserting hard tabs, but I would avoid that.
Similar when using Obsidian.
<!-- Whitespace test in Obsidian.md -->
- Subnote 1
text
- Subnote 2
text
- Subnote 3
text
There is a way for nodes that contain multiple lines to follow the indentation of the first line. The change also takes header level options into account too.
Without the fix it would look like this:
Using the fix, the lines will follow the indentation:
Providing the fix for HTML richcontent nodes is still a TODO though.