I am having tons of problems with pandoc’s conversion of html to md. It “works” but external links are cosmetically “messed up” when imported into Obsidian.
The html files look perfect when viewed in my browser, but the md files are screwed up when viewed in Obsidian. The links to the assets folder is fine and pics show perfectly in the note. However, there are random line breaks in the middle of sentences, and often in the middle of a link. They can be fixed by going to the end of the line, hitting delete to remove the return, and then reinserting a space. So I guess I cd say that randomly, spaces are being replaced by returns. Very strange.
The original script I used with pandoc to convert to html was as follows:
#!/bin/bash
# Use the current working directory as the root directory
root_dir=“.”
# Recursively traverse the directory structure
find “$root_dir” -name ‘*.html’ -type f -exec sh -c ‘pandoc “$1” -o “${1%.html}.md”’ _ {} ;
THAT created all kinds of gibberish that I have been told (above) has to do with pandoc’s fenced divs, which obsidian apparently doesn’t support.
I revised the script, which got rid of the gibberish:
find "$root_dir" -name '*.html' -type f -exec sh -c 'pandoc "$1" -t gfm-raw_html -o "${1%.html}.md"' _ {} \;
It appears as though the gibberish is gone in my notes now, which is great, but the problems above with the random returns persist.
In a related post on Stack Overflow, John MacFarlane said:
Those are a pandoc markdown extension, fenced divs. Apparently obsidian’s markdown dialect doesn’t support them. That’s fine, you can disable them by running pandoc with
-t markdown-fenced_divs
. In that case you may get some raw HTML div tags; to disable all of this you can use-t markdown-fenced_divs-native_divs-raw_html
. Or you could try something like-t commonmark
or-t gfm
or-t markdown_strict
. Pandoc supports many different markdown dialects.
Could the random-returns problem be related to an improper format in my revised pandoc script? If I could get that random-return thing fixed I’d be home free.
I am absolutely at a loss. Any help would be tremendously appreciated.