Jrnl: Markdown export adds only one \n before second ###

Created on 17 Mar 2020  路  5Comments  路  Source: jrnl-org/jrnl

~
$ jrnl -v
jrnl version v2.2
~

Installed via brew install jrnl on 2020-03-16 (Mon).

Software:

~~~
System Software Overview:

  System Version: macOS 10.14.6 (18G3020)
  Kernel Version: Darwin 18.7.0
  Boot Volume: Macintosh HD
  Boot Mode: Normal
  Computer Name: MKO
  User Name: Marek Kowalczyk (marekkowalczyk)
  Secure Virtual Memory: Enabled
  System Integrity Protection: Enabled
  Time since boot: 4 days 2:25

~~~

jrnl --export markdown -o jrnl.md produces

~~~

March

2020-03-16 10:25 Lorem ipsum.

Donec diam nisl, pellentesque at mi vel, sodales dapibus lectus.

2020-03-16 23:54 Ut vitae luctus risus, sed dictum nunc.

Aenean suscipit euismod vulputate.
~~~

Expected behavior

~~~

March

2020-03-16 10:25 Lorem ipsum.

Donec diam nisl, pellentesque at mi vel, sodales dapibus lectus.

2020-03-16 23:54 Ut vitae luctus risus, sed dictum nunc.

Aenean suscipit euismod vulputate.
~~~

bug

All 5 comments

Yeah, that's fair. Technically, the markdown spec doesn't require a newline, but many parsers do, so we should probably just add a line there to be more widely compatible.

A workaround is to disable the requirement for Pandoc to have a blank line before a heading. The extension to be blocked is blank_before_header with a - (dash) before its invocation.

The entire command is:

pandoc --from=markdown-blank_before_header jrnl.txt -o jrnl.pdf.

In case you need a pandoc-compatible MD file with \n\n before headers:

pandoc --from=markdown-blank_before_header jrnl.txt -o jrnl.md

This is happening because the entries don't end with a newline. To fix it, it's a oneline addition to add a blank line after each entry.

But does the "fix" need to turn itself "off" for entries that do end with a newline? If we don't do that, then you're bound to get a mix of single and double empty lines above the level 3 headers...

@MinchinWeb You might want to use sed after adding a newline to remove superfluous newlines. A bit crude but guarenteed to work.

Was this page helpful?
0 / 5 - 0 ratings