asciidoctor / kramdown-asciidoc

A kramdown extension for converting Markdown documents to AsciiDoc.
Other
207 stars 19 forks source link

fenced code blocks and syntax highlighting #106

Closed ConcurrentState closed 2 years ago

ConcurrentState commented 2 years ago

Hello, I'm new to asciidoctor and love it. Here is a question (or problem):

If in markdown, there is

```C++
int i_func(int i) { return i; }
it will be converted to

[,C++]

int i_func(int i) { return i; }

and not to

[source,C++]

int i_func(int i) { return i; }



While that does highlight the source in VS Code asciidoctor with highlightjs, it does not highlight the code with rouge or coderay, when using the asciidoctor gem from the command line.
The fenced code block is rendered as expected, only the syntax coloring is missing.
If I insert `source` in `[,C++]`, it works.

Am I missing something?

Cheers
ConcurrentState commented 2 years ago

This is with version kramdoc 2.1.0

mojavelinux commented 2 years ago

The source style on the block is optional if the language is specified. (See https://docs.asciidoctor.org/asciidoc/latest/verbatim/source-blocks/). Therefore, the behavior of kramdown-asciidoc is correct. Perhaps you are using an old version of Asciidoctor. Please verify that you are using Asciidoctor 2 or better.

Rouge, Pygments, and CodeRay do not recognize the language tag C++. It must be written as c++ instead (lowercase). I would consider enhancing kramdown-asciidoc to convert the language to lowercase. That would solve the language mapping issue.