kramdown-rfc2629 1.3.12 → 1.3.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/bin/kramdown-rfc2629 +29 -4
- data/kramdown-rfc2629.gemspec +1 -1
- data/lib/kramdown-rfc2629.rb +31 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eaff5274766d9c9fe2de618bc8ed0f2d86cb1a7a9413e0de92568e1cdca2df30
|
4
|
+
data.tar.gz: e519ff100dbfbbae7881100d023ee2f370805d84c7ee9e49beadfa99b02a72d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b178e930deec32e6951277d9162453643be47fd6b87719f517ed05dd87c3e63414e7b3db1ed2258edf52b6b82fd11f07d371276c9624f17a43a3b721fef21ad6
|
7
|
+
data.tar.gz: 22d55e1830b09db10b297700021b98d110204414b79225509b59818a2feefb48a4fed9a8be2b4cfe23547f788a63f3fc7fa7535c9a027fa059ada59dd77b6d72
|
data/README.md
CHANGED
@@ -351,7 +351,7 @@ generate XML2RFCv2 XML instead of kramdown-rfc YAML.
|
|
351
351
|
(1.0.31:)
|
352
352
|
The kramdown `smart_quotes` feature can be controlled better.
|
353
353
|
By default, it is on (with default kramdown settings), unless `coding:
|
354
|
-
us-ascii` is in effect,
|
354
|
+
us-ascii` is in effect (1.3.14: or --v3 is given), in which case it is off by default.
|
355
355
|
It also can be explicitly set on (`true`) or off (`false`) in the YAML
|
356
356
|
header, or to a specific value (an array of four kramdown entity names
|
357
357
|
or character numbers). E.g., for a German text (that is not intended
|
data/bin/kramdown-rfc2629
CHANGED
@@ -87,6 +87,7 @@ def xml_from_sections(input)
|
|
87
87
|
ps = KramdownRFC::ParameterSet.new(yaml_load(yaml_in, [Date], [], true))
|
88
88
|
coding_override = ps.has(:coding)
|
89
89
|
smart_quotes = ps[:smart_quotes]
|
90
|
+
typographic_symbols = ps[:typographic_symbols]
|
90
91
|
kramdown_options = ps[:kramdown_options]
|
91
92
|
|
92
93
|
# all the other sections are put in a Hash, possibly concatenated from parts there
|
@@ -237,7 +238,7 @@ def xml_from_sections(input)
|
|
237
238
|
warn "*** sections left #{sechash.keys.inspect}!"
|
238
239
|
end
|
239
240
|
|
240
|
-
[input, coding_override, link_defs, smart_quotes, kramdown_options]
|
241
|
+
[input, coding_override, link_defs, smart_quotes, typographic_symbols, kramdown_options]
|
241
242
|
end
|
242
243
|
|
243
244
|
XML_RESOURCE_ORG_PREFIX = Kramdown::Converter::Rfc2629::XML_RESOURCE_ORG_PREFIX
|
@@ -339,14 +340,16 @@ end
|
|
339
340
|
link_defs = {}
|
340
341
|
if input =~ /\A---/ # this is a sectionized file
|
341
342
|
do_the_tls_dance unless ENV["KRAMDOWN_DONT_VERIFY_HTTPS"]
|
342
|
-
input, target_coding, link_defs, smart_quotes, kramdown_options = xml_from_sections(input)
|
343
|
+
input, target_coding, link_defs, smart_quotes, typographic_symbols, kramdown_options = xml_from_sections(input)
|
343
344
|
end
|
344
345
|
if input =~ /\A<\?xml/ # if this is a whole XML file, protect it
|
345
346
|
input = "{::nomarkdown}\n#{input}\n{:/nomarkdown}\n"
|
346
347
|
end
|
347
348
|
options = {input: 'RFC2629Kramdown', entity_output: coding_override, link_defs: link_defs}
|
348
|
-
if
|
349
|
-
|
349
|
+
if smart_quotes.nil?
|
350
|
+
if (target_coding && target_coding =~ /ascii/) || $options.v3
|
351
|
+
smart_quotes = false
|
352
|
+
end
|
350
353
|
end
|
351
354
|
if smart_quotes == false
|
352
355
|
smart_quotes = ["'".ord, "'".ord, '"'.ord, '"'.ord]
|
@@ -359,6 +362,28 @@ when nil, true
|
|
359
362
|
else
|
360
363
|
warn "*** Can't deal with smart_quotes value #{smart_quotes.inspect}"
|
361
364
|
end
|
365
|
+
if typographic_symbols.nil?
|
366
|
+
if (target_coding && target_coding =~ /ascii/) || $options.v3
|
367
|
+
typographic_symbols = false
|
368
|
+
end
|
369
|
+
end
|
370
|
+
if typographic_symbols == false
|
371
|
+
typographic_symbols = Hash[::Kramdown::Parser::Kramdown::TYPOGRAPHIC_SYMS.map { |k, v|
|
372
|
+
if Symbol === v
|
373
|
+
[v.intern, k]
|
374
|
+
end
|
375
|
+
}.compact]
|
376
|
+
end
|
377
|
+
# warn [:TYPOGRAPHIC_SYMBOLS, typographic_symbols].to_yaml
|
378
|
+
case typographic_symbols
|
379
|
+
when Hash
|
380
|
+
options[:typographic_symbols] = typographic_symbols
|
381
|
+
when nil, true
|
382
|
+
# nothin
|
383
|
+
else
|
384
|
+
warn "*** Can't deal with typographic_symbols value #{typographic_symbols.inspect}"
|
385
|
+
end
|
386
|
+
|
362
387
|
if kramdown_options
|
363
388
|
options.merge! kramdown_options
|
364
389
|
end
|
data/kramdown-rfc2629.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
spec = Gem::Specification.new do |s|
|
2
2
|
s.name = 'kramdown-rfc2629'
|
3
|
-
s.version = '1.3.
|
3
|
+
s.version = '1.3.17'
|
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.}
|
data/lib/kramdown-rfc2629.rb
CHANGED
@@ -8,6 +8,7 @@
|
|
8
8
|
# This derived work is also licensed under the MIT license, see LICENSE.
|
9
9
|
#++
|
10
10
|
#
|
11
|
+
require 'shellwords'
|
11
12
|
|
12
13
|
raise "sorry, 1.8 was last decade" unless RUBY_VERSION >= '1.9'
|
13
14
|
|
@@ -37,16 +38,27 @@ module Kramdown
|
|
37
38
|
@span_parsers.unshift(:iref)
|
38
39
|
end
|
39
40
|
|
40
|
-
XREF_START = /\{\{(.*?)\}\}/u
|
41
|
+
XREF_START = /\{\{(?:(?:\{(.*?)\}(?:\{(.*?)\})?)|(.*?))((?:\}\})|\})/u
|
41
42
|
|
42
43
|
# Introduce new {{target}} syntax for empty xrefs, which would
|
43
44
|
# otherwise be an ugly  or 
|
44
45
|
# (I'd rather use [[target]], but that somehow clashes with links.)
|
45
46
|
def parse_xref
|
46
47
|
@src.pos += @src.matched_size
|
47
|
-
|
48
|
-
|
49
|
-
|
48
|
+
unless @src[4] == "}}"
|
49
|
+
warn "*** #{@src[0]}: unmatched braces #{@src[4].inspect}"
|
50
|
+
end
|
51
|
+
if contact_name = @src[1]
|
52
|
+
attr = {'fullname' => contact_name}
|
53
|
+
if ascii_name = @src[2]
|
54
|
+
attr["asciiFullname"] = ascii_name
|
55
|
+
end
|
56
|
+
el = Element.new(:contact, nil, attr)
|
57
|
+
else
|
58
|
+
href = @src[3]
|
59
|
+
href = href.gsub(/\A[0-9]/) { "_#{$&}" } # can't start an IDREF with a number
|
60
|
+
el = Element.new(:xref, nil, {'target' => href})
|
61
|
+
end
|
50
62
|
@tree.children << el
|
51
63
|
end
|
52
64
|
define_parser(:xref, XREF_START, '{{')
|
@@ -245,13 +257,16 @@ COLORS
|
|
245
257
|
plantuml = "@startuml\n#{result}\n@enduml"
|
246
258
|
result1, _s = Open3.capture2("plantuml -pipe -tsvg", stdin_data: plantuml);
|
247
259
|
result, _s = Open3.capture2("plantuml -pipe -tutxt", stdin_data: plantuml) if t == "plantuml-utxt"
|
260
|
+
when "math"
|
261
|
+
result1, _s = Open3.capture2("tex2svg --font STIX #{Shellwords.escape(' ' << result)}");
|
262
|
+
result, _s = Open3.capture2("asciitex -f #{file.path}")
|
248
263
|
end
|
249
264
|
# warn ["goat:", result1.inspect]
|
250
265
|
file.unlink
|
251
266
|
result1 = svg_clean(result1) unless t == "goat"
|
252
267
|
result1, _s = Open3.capture2("svgcheck -qa", stdin_data: result1);
|
253
268
|
# warn ["svgcheck:", result1.inspect]
|
254
|
-
[result, result1]
|
269
|
+
[result, result1] # text, svg
|
255
270
|
end
|
256
271
|
|
257
272
|
def convert_codeblock(el, indent, opts)
|
@@ -298,7 +313,7 @@ COLORS
|
|
298
313
|
end
|
299
314
|
end
|
300
315
|
case t
|
301
|
-
when "goat", "ditaa", "mscgen", "plantuml", "plantuml-utxt", "mermaid"
|
316
|
+
when "goat", "ditaa", "mscgen", "plantuml", "plantuml-utxt", "mermaid", "math"
|
302
317
|
result, result1 = memoize(:svg_tool_process, t, result)
|
303
318
|
"#{' '*indent}<figure#{el_html_attributes(el)}><artset><artwork #{html_attributes(artwork_attr.merge("type"=> "svg"))}>#{result1.sub(/.*?<svg/m, "<svg")}</artwork><artwork #{html_attributes(artwork_attr.merge("type"=> "ascii-art"))}><![CDATA[#{result}#{result =~ /\n\Z/ ? '' : "\n"}]]></artwork></artset></figure>\n"
|
304
319
|
else
|
@@ -403,7 +418,7 @@ COLORS
|
|
403
418
|
vspace = opts[:vspace]
|
404
419
|
vspaceel = "<vspace blankLines='#{vspace}'/>" if vspace
|
405
420
|
ht = escape_html(inner(el, indent, opts), :attribute) # XXX this may leave gunk
|
406
|
-
"#{close}#{' '*indent}<t#{el_html_attributes(el)} hangText
|
421
|
+
"#{close}#{' '*indent}<t#{el_html_attributes(el)} hangText=\"#{ht}\">#{vspaceel}\n"
|
407
422
|
end
|
408
423
|
|
409
424
|
HTML_TAGS_WITH_BODY=['div', 'script']
|
@@ -524,6 +539,10 @@ COLORS
|
|
524
539
|
end
|
525
540
|
end
|
526
541
|
|
542
|
+
def convert_contact(el, indent, opts)
|
543
|
+
"<contact#{el_html_attributes(el)}/>"
|
544
|
+
end
|
545
|
+
|
527
546
|
REFCACHEDIR = ENV["KRAMDOWN_REFCACHEDIR"] || ".refcache"
|
528
547
|
|
529
548
|
# warn "*** REFCACHEDIR #{REFCACHEDIR}"
|
@@ -710,7 +729,11 @@ COLORS
|
|
710
729
|
:raquo => [::Kramdown::Utils::Entities.entity('raquo')]
|
711
730
|
}
|
712
731
|
def convert_typographic_sym(el, indent, opts)
|
713
|
-
|
732
|
+
if (result = @options[:typographic_symbols][el.value])
|
733
|
+
escape_html(result, :text)
|
734
|
+
else
|
735
|
+
TYPOGRAPHIC_SYMS[el.value].map {|e| entity_to_str(e) }.join('')
|
736
|
+
end
|
714
737
|
end
|
715
738
|
|
716
739
|
def convert_smart_quote(el, indent, opts)
|
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.3.
|
4
|
+
version: 1.3.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|