Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix Asciidoc syntax highlight #1276
This pull request improves the way in which code listing blocks in extra file objects are matched.
Fixes #1239 (went with option 2).
The regular expression used for code blocks detection has been significantly relaxed. The updated one makes no assumptions on what HTML attributes can be set on
The programming language detection still considers the values of
Finally, this pull request properly ensures that code blocks produced from Ruby source files are not highlighted twice. It wasn't a problem before only because of a very lucky situation that code blocks produced by
This commit replaces the regular expression, which detects code blocks in the HTML document produced by a markup renderer, with a more general one. The new regular expression makes no assumptions on what HTML attributes can be set on <pre> or <code> element. As a consequence, code block's programming language detection is now slightly more complicated, because it must deal with parsing HTML attribute lists. A new private method has been defined to handle that.
Recognize "data-lang" HTML attribute, which is set on code blocks in HTML documents produced by AsciiDoctor.
The #html_markup_ruby method, which is responsible for creating HTML from Ruby snippets, produces output with syntax highlighting already applied. Doing it for the second time messes things up. It wasn't a big deal before the regular expression in #parse_codeblocks has been relaxed. Only a slightly different set of HTML attributes was preventing the rendered Ruby listings from being matched. But now, a proper fix is needed, and it is introduced in this very commit.