Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line breaks from md files are removed #55

Closed
ih8snow opened this issue Dec 30, 2021 · 6 comments · Fixed by #57
Closed

Line breaks from md files are removed #55

ih8snow opened this issue Dec 30, 2021 · 6 comments · Fixed by #57

Comments

@ih8snow
Copy link

ih8snow commented Dec 30, 2021

Hi Nick;
here's my challenge:

I created a vault with Obsidian v.0.13.17.
The vault contains several folder with *.md notes.

When I use obsidian-export in Linux or Windows 11 everything works fine. I checked the files re to the below mentioned error and I don't see a problem. (line breaks are there)

See screenshot:
obs-export_2

Now I use this data to create a static HTML site with mkdocs and the material theme. Using this yml file for a local html.site (following the info on the mkdocs website:

site_name: Report site_url: "" theme: 'material' use_directory_urls: false plugins: []

Again all ok, except that all line breaks are removed. (same with different theme)
See Screenshots:
obsidian-export

I really have no idea what's going on here, is that something you can fix this with the exporter?
/Jörn

Attached the test vault "ExportTest"
ExportTest.zip

Vault after obsidian-export:
Sitemd_files_after_obs-export.zip

HTML_Site after mkdocs export:
HTML-site.zip

@zoni
Copy link
Owner

zoni commented Dec 30, 2021

Hey @ih8snow,

I suspect you have the option Strict line breaks (found under the Editor options setting) turned off in your Obsidian settings, is that right?

Strictly speaking, Markdown/CommonMark, ignores linebreaks. That is, the following text is rendered as a single sentence:

This is a line
which is split across multiple lines
in markdown source text.

If you want insert hard linebreaks here, there's two ways you can do this with Markdown. The first option is to append two blank spaces ( ) at the end of the lines:

This is a line  
which is split across multiple lines  
in markdown source text.

The other option, which I personally prefer and recommend, is to add a backslash at the end of the line:

This is a line \
which is split across multiple lines \
in markdown source text.

Does that help?

@zoni
Copy link
Owner

zoni commented Dec 30, 2021

Some more good news. 😄 I took a look at the information provided by the underlying parser, and it turns out it emits SoftBreak events for these soft linebreaks in your original example.

I'm able to use this information to turn these SoftBreaks into HardBreaks, which should mimic Obsidian's Strict line breaks option. With all of the postprocessor infrastructure I introduced in v0.7.0 (2021-04-11) this is quite trivial to implement now and I already have a working proof of concept implementation.

I just need to organize this new code properly, hook it up to a CLI argument, add some testcases, etc. so expect a new feature and release with this somewhere over the next week or so.

@ih8snow
Copy link
Author

ih8snow commented Dec 31, 2021

I suspect you have the option Strict line breaks (found under the Editor options setting) turned off in your Obsidian settings, is that right?

Hi,
you are correct. I'm using these settings. Thanks for your explanation, that definitely helps. I was not really sure what these settings will cause in the work with obsidian, but now I can see it more clear.

@ih8snow
Copy link
Author

ih8snow commented Dec 31, 2021

I'm able to use this information to turn these SoftBreaks into HardBreaks, which should mimic Obsidian's Strict line breaks option.

That is super cool! Great news at the end of the year.
I'll test with the above-mentioned settings and of course wait for the new version.
Many thanks for your support!

@zoni
Copy link
Owner

zoni commented Jan 2, 2022

Happy new year! v22.1.0 is out now with a new --hard-linebreaks CLI argument. It appears to work as intended on my basic, exploratory testing, but please feel free to let me know if you run into unexpected issues on a real vault.

@ih8snow
Copy link
Author

ih8snow commented Jan 3, 2022

Thanks!!!
Works perfect!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants