Sha256: a4f61486e67f30312c3c66ef947f43a2127b07dd56a8fa93ffc2d144041a3363

Contents?: true

Size: 1.43 KB

Versions: 3

Compression:

Stored size: 1.43 KB

Contents

module Coradoc
  module Parser
    module Asciidoc
      module Content

        def highlight
          text_id >> newline >>
            underline >> highlight_text >> newline
        end

        def underline
          str("[underline]") | str("[.underline]")
        end

        def highlight_text
          str("#") >> words.as(:text) >> str("#")
        end

        def literal_space
          (match[" "] | match[' \t']).repeat(1)
        end

        # Override
        def literal_space?
          literal_space.maybe
        end

        # Text
        def text_line(many_breaks = false)
            tl = (asciidoc_char_with_id.absent? | text_id) >> literal_space? >>
            text.as(:text)
            if many_breaks
              tl >> line_ending.repeat(1).as(:line_break)
            else
              tl >> line_ending.as(:line_break)
            end
        end

        def asciidoc_char
          match('^[*_:=\-+]')
        end

        def asciidoc_char_with_id
          asciidoc_char | str('[#') | str('[[')
        end

        def text_id
          str("[[") >> str('[').absent? >> keyword.as(:id) >> str("]]") |
            str("[#") >> keyword.as(:id) >> str("]")
        end

        def glossary
          keyword.as(:key) >> str("::") >> (str(" ") | newline) >>
            text.as(:value) >> line_ending.as(:line_break)
        end

        def glossaries
          glossary.repeat(1)
        end

      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
coradoc-1.1.3 lib/coradoc/parser/asciidoc/content.rb
coradoc-1.1.2 lib/coradoc/parser/asciidoc/content.rb
coradoc-1.1.1 lib/coradoc/parser/asciidoc/content.rb