Module: Asciidoctor::RFC::V3::Front

Included in:
Converter
Defined in:
lib/asciidoctor/rfc/v3/front.rb

Instance Method Summary collapse

Instance Method Details

#address(node, suffix, xml) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/asciidoctor/rfc/v3/front.rb', line 81

def address(node, suffix, xml)
  email = node.attr("email#{suffix}")
  facsimile = node.attr("fax#{suffix}")
  phone = node.attr("phone#{suffix}")
  postalline = node.attr("postal-line#{suffix}")
  street = node.attr("street#{suffix}")
  uri = node.attr("uri#{suffix}")
  if [email, facsimile, phone, postalline, street, uri].any?
    xml.address do |xml_address|
      address1 node, suffix, xml_address if [postalline, street].any?
      xml_address.phone { |p| p << phone } unless phone.nil?
      xml_address.facsimile { |f| f << facsimile } unless facsimile.nil?
      xml_address.email { |e| e << email } unless email.nil?
      xml_address.uri { |u| u << uri } unless uri.nil?
    end
  end
end

#front(node, xml) ⇒ Object

Syntax:

= Title
Author
:METADATA


8
9
10
11
12
13
14
15
16
17
18
# File 'lib/asciidoctor/rfc/v3/front.rb', line 8

def front(node, xml)
  xml.front do |xml_front|
    title node, xml_front
    series_info node, xml_front
    author node, xml_front
    date node, xml_front
    area node, xml_front
    workgroup node, xml_front
    keyword node, xml_front
  end
end

#organization(node, suffix, xml) ⇒ Object



76
77
78
79
# File 'lib/asciidoctor/rfc/v3/front.rb', line 76

def organization(node, suffix, xml)
  organization = node.attr("organization#{suffix}")
  xml.organization { |org| org << organization } unless organization.nil?
end

#series_info(node, xml) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/asciidoctor/rfc/v3/front.rb', line 20

def series_info(node, xml)
  docname = node.attr("name")
  return if docname.nil? || docname&.empty?
  is_rfc = docname =~ /^rfc-?/i || node.attr("doctype") == "rfc"

  if is_rfc
    name = docname.gsub(/^rfc-?/i, "") 
    nameattr = "RFC" 
  else
    name = docname
    nameattr = "Internet-Draft"
  end
  value = name.gsub(/\.[^\/]+$/, "")

  seriesInfo_attributes = {
    name: nameattr,
    status: node.attr("status"),
    stream: node.attr("submission-type") || "IETF",
    value: value,
  }
  xml.seriesInfo **attr_code(seriesInfo_attributes)

  intendedstatus = node.attr("intended-series")
  if !is_rfc && !intendedstatus.nil?
    unless intendedstatus =~ /^(standard|full-standard|bcp|fyi|informational|experimental|historic)$/
      warn %(asciidoctor: WARNING (#{current_location(node)}): disallowed value for intended-series in document header: #{intendedstatus})
    end
    seriesInfo_attributes = {
      name: "",
      status: intendedstatus,
      value: value,
    }
    xml.seriesInfo **attr_code(seriesInfo_attributes)
  end

  rfcstatus = intendedstatus
  if is_rfc && !rfcstatus.nil?
    m = /^(\S+) (\d+)$/.match rfcstatus
    if m.nil?
      rfcstatus = "exp" if rfcstatus == "experimental"
      rfcstatus = "info" if rfcstatus == "informational"
      warn %(asciidoctor: WARNING (#{current_location(node)}): disallowed value for intended-series in document header with no series number: #{rfcstatus}) unless rfcstatus =~ /^(info|exp|historic)$/
    else
      rfcstatus = m[1]
      value = m[2]
      warn %(asciidoctor: WARNING (#{current_location(node)}): disallowed value for intended-series in document header with series number: #{rfcstatus}) unless rfcstatus =~ /^(standard|full-standard|bcp)$/
    end
    seriesInfo_attributes = {
      name: "",
      status: rfcstatus,
      value: value,
    }
    xml.seriesInfo **attr_code(seriesInfo_attributes)
  end
end