Module: Coradoc::Parser::Asciidoc::Citation

Included in:
Base, Base
Defined in:
lib/coradoc/parser/asciidoc/citation.rb

Instance Method Summary collapse

Instance Method Details

#citationObject



39
40
41
42
43
44
# File 'lib/coradoc/parser/asciidoc/citation.rb', line 39

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

#citation_noxrefObject



34
35
36
37
# File 'lib/coradoc/parser/asciidoc/citation.rb', line 34

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

#citation_xrefObject



27
28
29
30
31
32
# File 'lib/coradoc/parser/asciidoc/citation.rb', line 27

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

#cross_referenceObject



19
20
21
22
23
24
25
# File 'lib/coradoc/parser/asciidoc/citation.rb', line 19

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

#xref_anchorObject



5
6
7
# File 'lib/coradoc/parser/asciidoc/citation.rb', line 5

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

#xref_argObject



13
14
15
16
17
# File 'lib/coradoc/parser/asciidoc/citation.rb', line 13

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

#xref_strObject



9
10
11
# File 'lib/coradoc/parser/asciidoc/citation.rb', line 9

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