I want markdown files to get autoformatted on safe.
For that, I want to use pandoc. Since I have markdown files with pandoc’s YAML markdown header and latex content, I need to consider that.
Since the workaround needed for this creates redundant newlines in the beginning of the file (see github isse), I want to adress this by either deleting theses newlines or by changing the
formatcmd depending on file content.
Why not use
prettier for formatting?
I would like to use
--reference-links with pandoc, which creates references for all the links in the document at the bottom of the file.
Depending on which way I choose, I want to do one of the following:
- (a) delete three newlines in the beginning of the file or after the YAML header
- (b) check the file content for a specific line within the YAML header
The problem is that either way, I’m not sure how to approach this since the YAML header starts with
--- but ends with either
Also, it normally is at the beginning of the file but it doesn’t have to by definition.
So the only way I can come up with for matching this is some sort of complicated PCRE regex, wich wouldn’t be very portable at all.
Maybe soneone else has another idea?