Sha256: 9b178fdd2cff27e17504f9d3aa7e1b879615315300613d06177cea2b049c31da

Contents?: true

Size: 823 Bytes

Versions: 8

Compression:

Stored size: 823 Bytes

Contents

# -*- encoding : utf-8 -*-

class Card
  class Content
    module Chunk
      # These are basic chunks that have a pattern and can be protected.
      # This chunk is used for markdown processing to ensure that
      # the escaping survives the markdown rendering.
      class KeepEscapedLiteral < Abstract
        FULL_RE = { "[" => /\A\\\[\[[^\]]*\]\]/,
                    "{" => /\A\\\{\{[^\}]*\}\}/ }.freeze
        Card::Content::Chunk.register_class self,
                                            prefix_re: '\\\\(?:\\[\\[|\\{\\{)',
                                            idx_char:  '\\'

        def self.full_re prefix
          FULL_RE[prefix[1, 1]]
        end

        def interpret match, _content
          @process_chunk = match[0].sub(/^\\(.)/, '\\\\\\\\\1')
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
card-mod-content-0.11.4 lib/card/content/chunk/keep_escaped_literal.rb
card-mod-content-0.11.3 lib/card/content/chunk/keep_escaped_literal.rb
card-mod-content-0.11.2 lib/card/content/chunk/keep_escaped_literal.rb
card-mod-content-0.11.1 lib/card/content/chunk/keep_escaped_literal.rb
card-mod-content-0.11.0 lib/card/content/chunk/keep_escaped_literal.rb
card-1.100.0 mod/core/chunk/keep_escaped_literal.rb
card-1.99.6 mod/core/chunk/keep_escaped_literal.rb
card-1.99.5 mod/core/chunk/keep_escaped_literal.rb