Sha256: ee08529f0c808f486c3d26915b8498b3cdf2898ef3b9e3f10f3fdb2f7b6089f4

Contents?: true

Size: 1.17 KB

Versions: 6

Compression:

Stored size: 1.17 KB

Contents

module Coradoc
  module Parser
    module Asciidoc
      module Citation
        def xref_anchor
          match('[^,>]').repeat(1).as(:href_arg).repeat(1,1)
        end

        def xref_str
          match('[^,>]').repeat(1).as(:text)
        end

        def xref_arg
          (str('section') | str('paragraph') | str('clause') | str('annex') | str('table')).as(:key) >>
          match('[ =]').as(:delimiter) >>
          match('[^,>=]').repeat(1).as(:value)
        end

        def cross_reference
          str('<<') >> xref_anchor >>
          ( (str(',') >> xref_arg).repeat(1) |
            (str(',') >> xref_str).repeat(1)
            ).maybe >>
            str('>>')
        end

        def citation_xref
          cross_reference.as(:cross_reference) >> newline |
          cross_reference.as(:cross_reference) >>
            (text_line.repeat(1)
            ).as(:comment).maybe
        end

        def citation_noxref
          (text_line.repeat(1)
          ).as(:comment)
        end

        def citation
          match('^[\[]') >> str(".source]\n") >>
          ( citation_xref |
            citation_noxref
          ).as(:citation)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
coradoc-1.1.6 lib/coradoc/parser/asciidoc/citation.rb
coradoc-1.1.5 lib/coradoc/parser/asciidoc/citation.rb
coradoc-1.1.4 lib/coradoc/parser/asciidoc/citation.rb
coradoc-1.1.3 lib/coradoc/parser/asciidoc/citation.rb
coradoc-1.1.2 lib/coradoc/parser/asciidoc/citation.rb
coradoc-1.1.1 lib/coradoc/parser/asciidoc/citation.rb