Module: GitlabKramdown::Parser::FencedCodeblock
- Included in:
- Kramdown::Parser::GitlabKramdown
- Defined in:
- lib/gitlab_kramdown/parser/fenced_codeblock.rb
Overview
Fenced Codeblock
This parser implements codeblocks fenced by “‘ or ~~~
With a codeblock you can pass the language after the initial fenced separator and use one of Kramdowns syntax highlighters
For maximum compatibility with GitLab, use ‘:rouge` as your highlighter.
Based on Kramdown GFM implementation
Constant Summary collapse
- FENCED_CODEBLOCK_START =
/^ {0,3}[~`]{3,}/
- FENCED_CODEBLOCK_MATCH =
/^ {0,3}(([~`]){3,})\s*?((\S+?)(?:\?\S*)?)?\s*?\n(.*?)^ {0,3}\1\2*\s*?\n/m
Class Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
21 22 23 24 25 |
# File 'lib/gitlab_kramdown/parser/fenced_codeblock.rb', line 21 def self.included(klass) return if klass.has_parser?(:codeblock_fenced_gitlab) klass.define_parser(:codeblock_fenced_gitlab, FENCED_CODEBLOCK_START, nil, 'parse_codeblock_fenced') end |