cfenollosa / bashblog

A single Bash script to create blogs. Download, run, write, done!
1.66k stars 228 forks source link

Markdown: Code block is not properly generated #170

Open carlosen0153 opened 2 years ago

carlosen0153 commented 2 years ago

My computer is running Debian 10 and I installed markdown (apt install markdown). I am using bashblog (commit 1715ee1) and in genreal works well using markdown. However, if I insert the following code block

```
int compute_sum(const vector<int> &vec)
for (int i=0; i<vec.size(); ++i)
sum += vec[i];
return sum;
```

when posting the code block is displayed a single line.

obsd-guru commented 2 years ago

i also wrote a similar issue just a few days ago. https://github.com/cfenollosa/bashblog/issues/169 . but sadly no answer to it.

Lex-2008 commented 2 years ago

It's an issue with markdown, and there's not much bashblog can do (apart from creating its own markdown). apt install markdown installs this package: https://packages.debian.org/buster/markdown - which uses this implementation: https://daringfireball.net/projects/markdown/ (rightside bar, "External Resources" - "Homepage). If you switch to "syntax" tab, then under "code blocks" it says that:

To produce a code block in Markdown, simply indent every line of the block by at least 4 spaces or 1 tab.

It would be cool if bashblog supported Pandoc or CommonMark, but that's up to @cfenollosa to decide.

Alternatively, a possible workaround might be to uninstall markdown, install CommonMark, and symlink CommonMark executable to Markdown.pl

panki27 commented 2 years ago

@Lex-2008 thank you for this! I finally got around to it. Compiling cmark and replacing Markdown.pl with it works.

As I expected, no code highlighting though. Doesn't seem like cmark supports generating CSS to go along.

Lex-2008 commented 2 years ago

@panki27 you can consider adding some javascript-based code highlighter. For example, I'm using microlight.js: project page, my blog post. As you can see, it even survived my migration from bashblog! :D