kramdown-rfc2629 1.5.15 → 1.5.19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a7de9b6c78edf74415c185732e4b41a2d5685b07968bd187ce0948ea6dfd607
4
- data.tar.gz: 52abd5a775d5c9922531b199fc957fbfe645621b4db3b59a624b0940ec328bf9
3
+ metadata.gz: 4a589f2a63da88b17cc5b56af63afe5a0faa9e7aae446f99b0a14aed7876e22d
4
+ data.tar.gz: 693ce583c48dbe4768727d684f3aa303436ad46bf824f291a9f0b3d63063d62c
5
5
  SHA512:
6
- metadata.gz: 6a10a5fa3678b60ac5e1fa56ca42ef38529ff577e1a206c87784d9afb53d73af853ba16fbf0ec233152c55614b0ee9a22b40e332c0fd2b14bf7371333359baf7
7
- data.tar.gz: 4dd3ef2b8698068f39b3e2c032f3bd76d281ac8fadb46820867b266339bee9aa86787eb0a60b72d853f03b33f0190256c4125fdf8950d8a877106dbdb855e6e3
6
+ metadata.gz: 965e4be16c1a7b5f372a911d861d5bfca8fdca3ebc999b1e61feb1aaabb003b3504f882f28224185ec497777eba1c4e6aa1be98890cf9f05ae0493b9b5d146a5
7
+ data.tar.gz: 4b9a3ec95bc29455192af45e0dac1701b2e76f934816746edea7b57ffca1001f23ed11df91b710398a60356297e955807d9e5d912298eb320ebb62daab17302c
data/README.md CHANGED
@@ -28,7 +28,8 @@ structure provided by kramdown. `bin/kramdown-rfc2629` started out as
28
28
  a simple command-line program showing how to use this, but can now do
29
29
  much more (see below).
30
30
 
31
- To use kramdown-rfc2629, you'll need a Ruby 2.x, and maybe
31
+ To use kramdown-rfc2629, you'll need Ruby (at least version 2.3, but
32
+ preferably a current version), and maybe
32
33
  [XML2RFC][] if you want to see the fruits of your work.
33
34
 
34
35
  kramdown-rfc2629 mydraft.mkd >mydraft.xml
@@ -12,14 +12,36 @@
12
12
  <% end -%>
13
13
  ]>
14
14
 
15
- <% ps.arr("pi", false) do |pi, val| -%>
16
- <?rfc <%=pi%>="<%= {true => "yes", false => "no", nil => "yes"}[val] || val %>"?>
15
+ <%
16
+ ps.rest.fetch("consensus") do
17
+ # consensus not given -- default intelligently
18
+ cat = ps.has("category") || ps.has("cat")
19
+ MUST_CONSENSUS = {"std" => true, "bcp" => true}
20
+ ps["consensus"] = true if MUST_CONSENSUS[cat]
21
+ end
22
+ rfcattrs = ps.attrs("ipr", "docName=docname", "category=cat",
23
+ "consensus", "submissionType=submissiontype", "xml:lang=lang",
24
+ "number", "obsoletes", "updates", "seriesNo=seriesno")
25
+ TRUE_FALSE = {nil => "true", false => "false", true => "true"}
26
+ YES_NO = {"true" => "yes", "false" => "no"}
27
+ pis = KramdownRFC::ParameterSet.new({})
28
+ ps.arr("pi", false) do |pi, val|
29
+ pis[pi] = TRUE_FALSE[val] || val
30
+ end
31
+ if $options.v3
32
+ piattrs = pis.attrs("tocDepth=tocdepth", "tocInclude=toc",
33
+ "sortRefs=sortrefs", "symRefs=symrefs", "indexInclude=index")
34
+ if piattrs != ""
35
+ rfcattrs << " " << piattrs
36
+ end
37
+ end
38
+ pis.rest.each do |pi, val|
39
+ v = YES_NO[val] || escape_html(val.to_s, :attribute)
40
+ -%>
41
+ <?rfc <%=pi%>="<%=v%>"?>
17
42
  <% end -%>
18
43
 
19
- <rfc <%= ps.attrs("ipr", "docName=docname", "category=cat",
20
- "consensus", "submissionType=submissiontype", "xml:lang=lang",
21
- "number", "obsoletes", "updates", "seriesNo=seriesno") %>>
22
-
44
+ <rfc <%=rfcattrs%>>
23
45
  <front>
24
46
  <%= ps.ele("title", ps.attr("abbrev=titleabbrev")) %>
25
47
 
@@ -46,22 +68,44 @@
46
68
  <% venue = ps[:venue] -%>
47
69
  <% if venue -%>
48
70
  <% venue = KramdownRFC::ParameterSet.new(venue) -%>
49
- <note title="Discussion Venues" removeInRFC="true">
50
- <% if mail = venue[:mail] -%>
51
- <% mail_local, mail_host = mail.split("@", 2) -%>
71
+ <note title="About This Document" removeInRFC="true">
72
+ <% if (dn = ps.av[:docName]) &&
73
+ (dt = dn.rpartition('-')[0]) != ""
74
+ -%>
75
+ <t>
76
+ <% if latest = venue[:latest] -%>
77
+ The latest revision of this draft can be found at <eref target="<%=latest%>"/>.
78
+ <% end -%>
79
+ Status information for this document may be found at <eref target="https://datatracker.ietf.org/doc/<%=dt%>/"/>.
80
+ </t>
81
+ <% end -%>
82
+ <% mail = venue[:mail] -%>
83
+ <% homepage = venue[:home] -%>
84
+ <% gtype = venue[:type] -%>
85
+ <% if mail || homepage -%>
86
+ <t>
87
+ <% end -%>
88
+ <% if mail && (mail_local, mail_host = mail.split("@", 2)) && mail_host -%>
52
89
  <% mail_subdomain, mail_domain = mail_host.split(".", 2) -%>
53
90
  <% group = venue[:group] || mail_local # XXX -%>
54
91
  <% arch = venue[:arch] || "https://mailarchive.ietf.org/arch/browse/#{mail_local}/" -%>
55
92
  <% GROUPS = {"ietf" => "Working ", "irtf" => "Research "} -%>
56
- <% type = venue[:type] || "#{GROUPS[mail_subdomain]}Group" -%>
57
- <t>Discussion of this document takes place on the
58
- <%=group%> <%=type%> mailing list (<%=mail%>),
59
- which is archived at <eref target="<%=arch%>"/>.</t>
93
+ <% gtype ||= "#{GROUPS[mail_subdomain]}Group" -%>
94
+ Discussion of this document takes place on the
95
+ <%=group%> <%=gtype%> mailing list (<eref target="mailto:<%=mail%>"/>),
96
+ which is archived at <eref target="<%=arch%>"/>.
97
+ <% end -%>
98
+ <% if homepage -%>
99
+ <%=gtype%> information can be found at <eref target="<%=homepage%>"/>.
100
+ <% end -%>
101
+ <% if mail || homepage -%>
102
+ </t>
60
103
  <% end -%>
61
- <% if gh = venue[:github] -%>
104
+ <% if repo = venue[:repo] || ((gh = venue[:github]) && "https://github.com/#{gh}") -%>
62
105
  <t>Source for this draft and an issue tracker can be found at
63
- <eref target="https://github.com/<%=gh%>"/>.</t>
106
+ <eref target="<%=repo%>"/>.</t>
64
107
  <% end -%>
108
+ <%= venue.ele("t=text", nil, nil, true) -%>
65
109
  </note>
66
110
  <% venue.warn_if_leftovers -%>
67
111
  <% end -%>
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'kramdown-rfc2629'
3
- s.version = '1.5.15'
3
+ s.version = '1.5.19'
4
4
  s.summary = "Kramdown extension for generating RFC 7749 XML."
5
5
  s.description = %{An RFC7749 (XML2RFC) generating backend for Thomas Leitner's
6
6
  "kramdown" markdown parser. Mostly useful for RFC writers.}
@@ -7,10 +7,15 @@ module KramdownRFC
7
7
  def initialize(y)
8
8
  raise "*** invalid parameter set #{y.inspect}" unless Hash === y
9
9
  @f = y
10
+ @av = {}
10
11
  end
12
+ attr :av
11
13
  def [](pn)
12
14
  @f.delete(pn.to_s)
13
15
  end
16
+ def []=(pn, val)
17
+ @f[pn] = val
18
+ end
14
19
  def has(pn)
15
20
  @f[pn.to_s]
16
21
  end
@@ -24,6 +29,7 @@ module KramdownRFC
24
29
  end
25
30
  def attr(pn)
26
31
  val, an = van(pn)
32
+ @av[an.intern] = val
27
33
  %{#{an}="#{escattr(val)}"} if val
28
34
  end
29
35
  def attrs(*pns)
@@ -34,6 +34,18 @@ module Kramdown
34
34
 
35
35
  class RFC2629Kramdown < Kramdown
36
36
 
37
+ def replace_abbreviations(el, regexps = nil)
38
+ unless regexps # DUPLICATED AND MODIFIED CODE FROM UPSTREAM, CHECK ON UPSTREAM UPGRADE
39
+ sorted_abbrevs = @root.options[:abbrev_defs].keys.sort {|a, b| b.length <=> a.length }
40
+ regexps = [Regexp.union(*sorted_abbrevs.map {|k|
41
+ /#{Regexp.escape(k).gsub(/\\\s/, "[\\s\\p{Z}]+").force_encoding(Encoding::UTF_8)}/})]
42
+ # warn regexps.inspect
43
+ regexps << /(?=(?:\W|^)#{regexps.first}(?!\w))/ # regexp should only match on word boundaries
44
+ end
45
+ super(el, regexps)
46
+ end
47
+
48
+
37
49
  def initialize(*doc)
38
50
  super
39
51
  @span_parsers.unshift(:xref)
@@ -612,6 +624,35 @@ COLORS
612
624
  "sourcecode"
613
625
  end
614
626
  )
627
+ loc_str =
628
+ if anchor = el.attr['anchor']
629
+ "##{anchor}"
630
+ elsif lineno = el.options[:location]
631
+ "approx. line #{lineno}" # XXX
632
+ else
633
+ "UNKNOWN"
634
+ end
635
+ case t
636
+ when "json"
637
+ begin
638
+ JSON.load(result)
639
+ rescue => e
640
+ err1 = "*** #{loc_str}: JSON isn't: #{e.message[0..40]}\n"
641
+ begin
642
+ JSON.load("{" << result << "}")
643
+ rescue => e
644
+ warn err1 << "*** not even with braces added around: #{e.message[0..40]}"
645
+ end
646
+ end
647
+ when "json-from-yaml"
648
+ begin
649
+ y = YAML.safe_load(result, aliases: true, filename: loc_str)
650
+ result = JSON.pretty_generate(y)
651
+ t = "json" # XXX, this could be another format!
652
+ rescue => e
653
+ warn "*** YAML isn't: #{e.message}\n"
654
+ end
655
+ end
615
656
  "#{' '*indent}<figure#{el_html_attributes(el)}><#{gi}#{html_attributes(artwork_attr)}><![CDATA[#{result}#{result =~ /\n\Z/ ? '' : "\n"}]]></#{gi}></figure>\n"
616
657
  end
617
658
  end
@@ -1264,9 +1305,14 @@ COLORS
1264
1305
  return el.value
1265
1306
  end
1266
1307
 
1267
- title = @root.options[:abbrev_defs][el.value]
1268
- title = nil if title.empty?
1269
1308
  value = el.value
1309
+ ix = value.gsub(/[\s\p{Z}]+/, " ")
1310
+ title = @root.options[:abbrev_defs][ix]
1311
+ if title.nil?
1312
+ warn "*** abbrev mismatch: value = #{value.inspect} ix = #{ix.inspect}"
1313
+ else
1314
+ title = nil if title.empty?
1315
+ end
1270
1316
 
1271
1317
  if title == "<bcp14>" && $options.v3
1272
1318
  return "<bcp14>#{value}</bcp14>"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kramdown-rfc2629
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.15
4
+ version: 1.5.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-29 00:00:00.000000000 Z
11
+ date: 2021-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown