bashblog icon indicating copy to clipboard operation
bashblog copied to clipboard

Markdown: Code block is not properly generated

Open carlosen0153 opened this issue 2 years ago • 4 comments

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.

carlosen0153 avatar Mar 08 '22 10:03 carlosen0153

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

obsd-guru avatar Mar 08 '22 12:03 obsd-guru

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

Lex-2008 avatar Aug 11 '22 18:08 Lex-2008

@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.

panki27 avatar Oct 13 '22 17:10 panki27

@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

Lex-2008 avatar Oct 13 '22 19:10 Lex-2008