Sha256: 6276ed8f765bc304004200a1eb32c632492576f8295543be6795d55e9d3621fe

Contents?: true

Size: 821 Bytes

Versions: 7

Compression:

Stored size: 821 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

7 entries across 7 versions & 1 rubygems

Version Path
card-mod-content-0.13.2 lib/card/content/chunk/keep_escaped_literal.rb
card-mod-content-0.13.1 lib/card/content/chunk/keep_escaped_literal.rb
card-mod-content-0.13.0 lib/card/content/chunk/keep_escaped_literal.rb
card-mod-content-0.11.7 lib/card/content/chunk/keep_escaped_literal.rb
card-mod-content-0.12.0 lib/card/content/chunk/keep_escaped_literal.rb
card-mod-content-0.11.6 lib/card/content/chunk/keep_escaped_literal.rb
card-mod-content-0.11.5 lib/card/content/chunk/keep_escaped_literal.rb