Module: GitlabKramdown::Parser::Strikethrough
- Included in:
- Kramdown::Parser::GitlabKramdown
- Defined in:
- lib/gitlab_kramdown/parser/strikethrough.rb
Overview
Strikethrough
This parser implements strikethrough markup based on GFM used as-is in GitLab Flavored Markdown
Based on Kramdown GFM implementation
Constant Summary collapse
- STRIKETHROUGH_DELIM =
/~~/
- STRIKETHROUGH_MATCH =
%r{ (?<re> #{STRIKETHROUGH_DELIM} # start with ~~ (?!\s|~) # not followed by ~ or space (negative lookahead) (?:\g<re>|.*?)* # recursive <re> or lazy match anything (?<!\s|~) # something different than space and ~ (negative lookbehind) #{STRIKETHROUGH_DELIM} # end with ~~ ) }x
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
25 26 27 |
# File 'lib/gitlab_kramdown/parser/strikethrough.rb', line 25 def self.included(klass) klass.define_parser(:strikethrough_gitlab, STRIKETHROUGH_MATCH, '~~') end |
Instance Method Details
#parse_strikethrough_gitlab ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/gitlab_kramdown/parser/strikethrough.rb', line 29 def parse_strikethrough_gitlab line_number = @src.current_line_number @src.pos += @src.matched_size el = Kramdown::Element.new(:html_element, 'del', {}, category: :span, line: line_number) @tree.children << el env = save_env reset_env(src: Kramdown::Utils::StringScanner.new(@src.matched[2..-3], line_number), text_type: :text) parse_spans(el) restore_env(env) el end |