kramdown-rfc2629 1.3.13 → 1.3.18
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/kdrfc +4 -0
- data/bin/kramdown-rfc2629 +29 -4
- data/data/math.json +1 -0
- data/kramdown-rfc2629.gemspec +3 -2
- data/lib/kramdown-rfc2629.rb +93 -16
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28fbdd54743e2c20350291a2d61dae4fe326e23e55931316547fbdbd9648f8b7
|
4
|
+
data.tar.gz: c6d612a256598e8bfcf65e17cdf1da082c673e3d090d9a735bcfc7059580d4e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6383c69fff2b3f1b8aa67c14ce114053a53cbce20ff0af9bbfcc114ed196073609f2c90cfd94f79807f9f45ebb17d0c68e4785b912b6cd6de23bfccac8fb7dac
|
7
|
+
data.tar.gz: a2d196a6e43d53e363689161bb5a57b694754fc23792352db4d9c5c085d7d6cda15aa96491b8775a459d20e31d61c6b52ffb5f276d238e6e51e4a2d2976e7bdd
|
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/kdrfc
CHANGED
@@ -121,6 +121,9 @@ BANNER
|
|
121
121
|
opts.on("-p", "--[no-]prep", "Convert xml to prepped xml") do |v|
|
122
122
|
$options.prep = v
|
123
123
|
end
|
124
|
+
opts.on("-c", "--[no-]convert", "Convert xml to v3 xml") do |v|
|
125
|
+
$options.v2v3 = v
|
126
|
+
end
|
124
127
|
opts.on("-h", "--[no-]html", "Convert to html as well") do |v|
|
125
128
|
$options.html = v
|
126
129
|
end
|
@@ -135,6 +138,7 @@ op.parse!
|
|
135
138
|
|
136
139
|
def process_the_xml(fn, base)
|
137
140
|
process_xml(fn, "#{base}.prepped.xml", "--preptool") if $options.prep
|
141
|
+
process_xml(fn, "#{base}.v2v3.xml", "--v2v3") if $options.v2v3
|
138
142
|
process_xml(fn, "#{base}.txt") if $options.txt
|
139
143
|
process_xml(fn, "#{base}.html", "--html") if $options.html
|
140
144
|
end
|
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/data/math.json
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"replacements":[["\\textfractionsolidus","⁄"],["\\leftrightsquigarrow","↭"],["\\textpertenthousand","‱"],["\\blacktriangleright","▸"],["\\blacktriangledown","▾"],["\\blacktriangleleft","◂"],["\\twoheadrightarrow","↠"],["\\leftrightharpoons","⇋"],["\\rightleftharpoons","⇌"],["\\textreferencemark","※"],["\\circlearrowright","↻"],["\\rightrightarrows","⇉"],["\\vartriangleright","⊳"],["\\textordmasculine","º"],["\\textvisiblespace","␣"],["\\twoheadleftarrow","↞"],["\\downharpoonright","⇂"],["\\ntrianglerighteq","⋭"],["\\rightharpoondown","⇁"],["\\textperthousand","‰"],["\\leftrightarrows","⇆"],["\\textmusicalnote","♪"],["\\nleftrightarrow","↮"],["\\rightleftarrows","⇄"],["\\bigtriangledown","▽"],["\\textordfeminine","ª"],["\\ntrianglelefteq","⋬"],["\\rightthreetimes","⋌"],["\\trianglerighteq","⊵"],["\\vartriangleleft","⊲"],["\\rightsquigarrow","⇝"],["\\downharpoonleft","⇃"],["\\curvearrowright","↷"],["\\circlearrowleft","↺"],["\\leftharpoondown","↽"],["\\nLeftrightarrow","⇎"],["\\curvearrowleft","↶"],["\\guilsinglright","›"],["\\leftthreetimes","⋋"],["\\leftrightarrow","↔"],["\\rightharpoonup","⇀"],["\\guillemotright","»"],["\\downdownarrows","⇊"],["\\hookrightarrow","↪"],["\\hspace{0.25em}"," "],["\\dashrightarrow","⇢"],["\\leftleftarrows","⇇"],["\\trianglelefteq","⊴"],["\\ntriangleright","⋫"],["\\doublebarwedge","⌆"],["\\upharpoonright","↾"],["\\rightarrowtail","↣"],["\\looparrowright","↬"],["\\Leftrightarrow","⇔"],["\\sphericalangle","∢"],["\\divideontimes","⋇"],["\\measuredangle","∡"],["\\blacktriangle","▴"],["\\ntriangleleft","⋪"],["\\mathchar\"1356","⁁"],["\\texttrademark","™"],["\\mathchar\"2208","⌖"],["\\triangleright","▹"],["\\leftarrowtail","↢"],["\\guilsinglleft","‹"],["\\upharpoonleft","↿"],["\\mathbb{gamma}","ℽ"],["\\fallingdotseq","≒"],["\\looparrowleft","↫"],["\\textbrokenbar","¦"],["\\hookleftarrow","↩"],["\\smallsetminus","﹨"],["\\dashleftarrow","⇠"],["\\guillemotleft","«"],["\\leftharpoonup","↼"],["\\mathbb{Gamma}","ℾ"],["\\bigtriangleup","△"],["\\textcircledP","℗"],["\\risingdotseq","≓"],["\\triangleleft","◃"],["\\mathsterling","£"],["\\textcurrency","¤"],["\\triangledown","▿"],["\\blacklozenge",""],["\\sfrac{5}{6}","⅚"],["\\preccurlyeq","≼"],["\\Rrightarrow","⇛"],["\\circledcirc","⊚"],["\\nRightarrow","⇏"],["\\sfrac{3}{8}","⅜"],["\\sfrac{1}{3}","⅓"],["\\sfrac{2}{5}","⅖"],["\\vartriangle","▵"],["\\Updownarrow","⇕"],["\\nrightarrow","↛"],["\\sfrac{1}{2}","½"],["\\sfrac{3}{5}","⅗"],["\\succcurlyeq","≽"],["\\sfrac{4}{5}","⅘"],["\\diamondsuit","♦"],["\\hphantom{0}"," "],["\\sfrac{1}{6}","⅙"],["\\curlyeqsucc","⋟"],["\\blacksquare","▪"],["\\hphantom{,}"," "],["\\curlyeqprec","⋞"],["\\sfrac{1}{8}","⅛"],["\\sfrac{7}{8}","⅞"],["\\sfrac{1}{5}","⅕"],["\\sfrac{2}{3}","⅔"],["\\updownarrow","↕"],["\\backepsilon","∍"],["\\circleddash","⊝"],["\\eqslantless","⋜"],["\\sfrac{3}{4}","¾"],["\\sfrac{5}{8}","⅝"],["\\hspace{1pt}"," "],["\\sfrac{1}{4}","¼"],["\\mathbb{Pi}","ℿ"],["\\mathcal{M}","ℳ"],["\\mathcal{o}","ȓ4"],["\\mathcal{O}","ᵊA"],["\\nsupseteqq","⊉"],["\\mathcal{B}","ℬ"],["\\textrecipe","℞"],["\\nsubseteqq","⊈"],["\\subsetneqq","⊊"],["\\mathcal{I}","ℑ"],["\\upuparrows","⇈"],["\\mathcal{e}","ℯ"],["\\mathcal{L}","ℒ"],["\\nleftarrow","↚"],["\\mathcal{H}","ℋ"],["\\mathcal{E}","ℰ"],["\\eqslantgtr","⋝"],["\\curlywedge","⋏"],["\\varepsilon","ε"],["\\supsetneqq","⊋"],["\\rightarrow","→"],["\\mathcal{R}","ℛ"],["\\sqsubseteq","⊑"],["\\mathcal{g}","ℊ"],["\\sqsupseteq","⊒"],["\\complement","∁"],["\\Rightarrow","⇒"],["\\gtreqqless","⋛"],["\\lesseqqgtr","⋚"],["\\circledast","⊛"],["\\nLeftarrow","⇍"],["\\Lleftarrow","⇚"],["\\varnothing","∅"],["\\mathcal{N}","𝒩"],["\\Leftarrow","⇐"],["\\gvertneqq","≩"],["\\mathbb{C}","ℂ"],["\\supsetneq","⊋"],["\\leftarrow","←"],["\\nleqslant","≰"],["\\mathbb{Q}","ℚ"],["\\mathbb{Z}","ℤ"],["\\llbracket","〚"],["\\mathbb{H}","ℍ"],["\\spadesuit","♠"],["\\mathit{o}","ℴ"],["\\mathbb{P}","ℙ"],["\\rrbracket","〛"],["\\supseteqq","⊇"],["\\copyright","©"],["\\textsc{k}","ĸ"],["\\gtreqless","⋛"],["\\mathbb{j}","ⅉ"],["\\pitchfork","⋔"],["\\estimated","℮"],["\\ngeqslant","≱"],["\\mathbb{e}","ⅇ"],["\\therefore","∴"],["\\triangleq","≜"],["\\varpropto","∝"],["\\subsetneq","⊊"],["\\heartsuit","♥"],["\\mathbb{d}","ⅆ"],["\\lvertneqq","≨"],["\\checkmark","✓"],["\\nparallel","∦"],["\\mathbb{R}","ℝ"],["\\lesseqgtr","⋚"],["\\downarrow","↓"],["\\mathbb{D}","ⅅ"],["\\mathbb{i}","ⅈ"],["\\backsimeq","⋍"],["\\mathbb{N}","ℕ"],["\\Downarrow","⇓"],["\\subseteqq","⊆"],["\\setminus","∖"],["\\succnsim","⋩"],["\\doteqdot","≑"],["\\clubsuit","♣"],["\\emptyset","∅"],["\\sqsupset","⊐"],["\\fbox{~~}","▭"],["\\curlyvee","⋎"],["\\varkappa","ϰ"],["\\llcorner","⌞"],["\\varsigma","ς"],["\\approxeq","≊"],["\\backcong","≌"],["\\supseteq","⊇"],["\\circledS","Ⓢ"],["\\circledR","®"],["\\textcent","¢"],["\\urcorner","⌝"],["\\lrcorner","⌟"],["\\boxminus","⊟"],["\\texteuro","€"],["\\vartheta","ϑ"],["\\barwedge","⊼"],["\\ding{86}","✶"],["\\sqsubset","⊏"],["\\subseteq","⊆"],["\\intercal","⊺"],["\\ding{73}","☆"],["\\ulcorner","⌜"],["\\recorder","⌕"],["\\precnsim","⋨"],["\\parallel","∥"],["\\boxtimes","⊠"],["\\ding{55}","✗"],["\\multimap","⊸"],["\\maltese","✠"],["\\nearrow","↗"],["\\swarrow","↙"],["\\lozenge","◊"],["\\sqrt[3]","∛"],["\\succsim","≿"],["\\dotplus","∔"],["\\tilde{}","~"],["\\check{}","ˇ"],["\\lessgtr","≶"],["\\Upsilon","ϒ"],["\\Cdprime","Ъ"],["\\gtrless","≷"],["\\backsim","∽"],["\\nexists","∄"],["\\dotplus","∔"],["\\searrow","↘"],["\\lessdot","⋖"],["\\boxplus","⊞"],["\\upsilon","υ"],["\\epsilon","ε"],["\\diamond","⋄"],["\\bigstar","★"],["\\ddagger","‡"],["\\cdprime","ъ"],["\\Uparrow","⇑"],["\\sqrt[4]","∜"],["\\between","≬"],["\\sqangle","∟"],["\\digamma","Ϝ"],["\\uparrow","↑"],["\\nwarrow","↖"],["\\precsim","≾"],["\\breve{}","˘"],["\\because","∵"],["\\bigcirc","◯"],["\\acute{}","´"],["\\grave{}","`"],["\\check{}","ˇ"],["\\lesssim","≲"],["\\partial","∂"],["\\natural","♮"],["\\supset","⊃"],["\\hstrok","ħ"],["\\Tstrok","Ŧ"],["\\coprod","∐"],["\\models","⊧"],["\\otimes","⊗"],["\\degree","°"],["\\gtrdot","⋗"],["\\preceq","≼"],["\\Lambda","Λ"],["\\lambda","λ"],["\\cprime","ь"],["\\varrho","ϱ"],["\\Bumpeq","≎"],["\\hybull","⁃"],["\\lmidot","ŀ"],["\\nvdash","⊬"],["\\lbrace","{"],["\\bullet","•"],["\\varphi","φ"],["\\bumpeq","≏"],["\\ddot{}","¨"],["\\Lmidot","Ŀ"],["\\Cprime","Ь"],["\\female","♀"],["\\rtimes","⋊"],["\\gtrsim","≳"],["\\mapsto","↦"],["\\daleth","ℸ"],["\\square","■"],["\\nVDash","⊯"],["\\rangle","〉"],["\\tstrok","ŧ"],["\\oslash","⊘"],["\\ltimes","⋉"],["\\lfloor","⌊"],["\\marker","▮"],["\\Subset","⋐"],["\\Vvdash","⊪"],["\\propto","∝"],["\\Hstrok","Ħ"],["\\dlcrop","⌍"],["\\forall","∀"],["\\nVdash","⊮"],["\\Supset","⋑"],["\\langle","〈"],["\\ominus","⊖"],["\\rfloor","⌋"],["\\circeq","≗"],["\\eqcirc","≖"],["\\drcrop","⌌"],["\\veebar","⊻"],["\\ulcrop","⌏"],["\\nvDash","⊭"],["\\urcrop","⌎"],["\\exists","∃"],["\\approx","≈"],["\\dagger","†"],["\\boxdot","⊡"],["\\succeq","≽"],["\\bowtie","⋈"],["\\subset","⊂"],["\\Sigma","Σ"],["\\Omega","Ω"],["\\nabla","∇"],["\\colon",":"],["\\boxHu","╧"],["\\boxHd","╤"],["\\aleph","ℵ"],["\\gnsim","⋧"],["\\boxHU","╩"],["\\boxHD","╦"],["\\equiv","≡"],["\\lneqq","≨"],["\\alpha","α"],["\\amalg","∐"],["\\boxhU","╨"],["\\boxhD","╥"],["\\uplus","⊎"],["\\boxhu","┴"],["\\kappa","κ"],["\\sigma","σ"],["\\boxDL","╗"],["\\Theta","Θ"],["\\Vdash","⊩"],["\\boxDR","╔"],["\\boxDl","╖"],["\\sqcap","⊓"],["\\boxDr","╓"],["\\bar{}","¯"],["\\dashv","⊣"],["\\vDash","⊨"],["\\boxdl","┐"],["\\boxVl","╢"],["\\boxVh","╫"],["\\boxVr","╟"],["\\boxdr","┌"],["\\boxdL","╕"],["\\boxVL","╣"],["\\boxVH","╬"],["\\boxVR","╠"],["\\boxdR","╒"],["\\theta","θ"],["\\lhblk","▄"],["\\uhblk","▀"],["\\ldotp","."],["\\ldots","…"],["\\boxvL","╡"],["\\boxvH","╪"],["\\boxvR","╞"],["\\boxvl","┤"],["\\boxvh","┼"],["\\boxvr","├"],["\\Delta","Δ"],["\\boxUR","╚"],["\\boxUL","╝"],["\\oplus","⊕"],["\\boxUr","╙"],["\\boxUl","╜"],["\\doteq","≐"],["\\happy","㋡"],["\\varpi","ϖ"],["\\smile","☺"],["\\boxul","┘"],["\\simeq","≃"],["\\boxuR","╘"],["\\boxuL","╛"],["\\boxhd","┬"],["\\gimel","ℷ"],["\\Gamma","Γ"],["\\lnsim","⋦"],["\\sqcup","⊔"],["\\omega","ω"],["\\sharp","♯"],["\\times","×"],["\\block","█"],["\\hat{}","^"],["\\wedge","∧"],["\\vdash","⊢"],["\\angle","∠"],["\\infty","∞"],["\\gamma","γ"],["\\asymp","≍"],["\\rceil","⌉"],["\\dot{}","˙"],["\\lceil","⌈"],["\\delta","δ"],["\\gneqq","≩"],["\\frown","⌢"],["\\phone","☎"],["\\vdots","⋮"],["\\boxr","└"],["\\k{i}","į"],["\\`{I}","Ì"],["\\perp","⊥"],["\\\"{o}","ö"],["\\={I}","Ī"],["\\`{a}","à"],["\\v{T}","Ť"],["\\surd","√"],["\\H{O}","Ő"],["\\vert","|"],["\\k{I}","Į"],["\\\"{y}","ÿ"],["\\\"{O}","Ö"],["\\'{Y}","Ý"],["\\u{u}","ў"],["\\u{G}","Ğ"],["\\.{E}","Ė"],["\\.{z}","ż"],["\\v{t}","ť"],["\\prec","≺"],["\\H{o}","ő"],["\\mldr","…"],["\\'{y}","ý"],["\\cong","≅"],["\\.{e}","ė"],["\\'{L}","Ĺ"],["\\star","*"],["\\.{Z}","Ż"],["\\'{e}","é"],["\\geqq","≧"],["\\cdot","⋅"],["\\`{U}","Ù"],["\\'{l}","ĺ"],["\\v{L}","Ľ"],["\\c{s}","ş"],["\\'{s}","ś"],["\\~{A}","Ã"],["\\Vert","‖"],["\\k{e}","ę"],["\\lnot","¬"],["\\'{z}","ź"],["\\leqq","≦"],["\\beta","β"],["\\beth","ℶ"],["\\'{E}","É"],["\\~{n}","ñ"],["\\u{i}","й"],["\\c{S}","Ş"],["\\c{N}","Ņ"],["\\H{u}","ű"],["\\v{n}","ň"],["\\'{S}","Ś"],["\\={U}","Ū"],["\\~{O}","Õ"],["\\'{Z}","Ź"],["\\v{E}","Ě"],["\\'{R}","Ŕ"],["\\H{U}","Ű"],["\\v{N}","Ň"],["\\prod","∏"],["\\v{s}","š"],["\\\"{U}","Ü"],["\\c{n}","ņ"],["\\k{U}","Ų"],["\\c{R}","Ŗ"],["\\'{A}","Á"],["\\~{o}","õ"],["\\v{e}","ě"],["\\v{S}","Š"],["\\u{A}","Ă"],["\\circ","∘"],["\\\"{u}","ü"],["\\flat","♭"],["\\v{z}","ž"],["\\r{U}","Ů"],["\\`{O}","Ò"],["\\={u}","ū"],["\\oint","∮"],["\\c{K}","Ķ"],["\\k{u}","ų"],["\\not<","≮"],["\\not>","≯"],["\\`{o}","ò"],["\\\"{I}","Ï"],["\\v{D}","Ď"],["\\.{G}","Ġ"],["\\r{u}","ů"],["\\not=","≠"],["\\`{u}","ù"],["\\v{c}","č"],["\\c{k}","ķ"],["\\.{g}","ġ"],["\\'{N}","Ń"],["\\odot","⊙"],["\\`{e}","э"],["\\c{T}","Ţ"],["\\v{d}","ď"],["\\\"{e}","ё"],["\\'{I}","Í"],["\\v{R}","Ř"],["\\k{a}","ą"],["\\nldr","‥"],["\\`{A}","À"],["\\'{n}","ń"],["\\~{N}","Ñ"],["\\nmid","∤"],["\\.{C}","Ċ"],["\\zeta","ζ"],["\\~{u}","ũ"],["\\`{E}","Э"],["\\~{a}","ã"],["\\c{t}","ţ"],["\\={o}","ō"],["\\v{r}","ř"],["\\={A}","Ā"],["\\.{c}","ċ"],["\\~{U}","Ũ"],["\\k{A}","Ą"],["\\\"{a}","ä"],["\\u{U}","Ў"],["\\iota","ι"],["\\={O}","Ō"],["\\c{C}","Ç"],["\\gneq","≩"],["\\'{c}","ć"],["\\boxH","═"],["\\hbar","ℏ"],["\\\"{A}","Ä"],["\\boxv","│"],["\\boxh","─"],["\\male","♂"],["\\'{u}","ú"],["\\sqrt","√"],["\\succ","≻"],["\\c{c}","ç"],["\\'{C}","Ć"],["\\v{l}","ľ"],["\\u{a}","ă"],["\\v{Z}","Ž"],["\\'{o}","ó"],["\\c{G}","Ģ"],["\\v{C}","Č"],["\\lneq","≨"],["\\\"{E}","Ё"],["\\={a}","ā"],["\\c{l}","ļ"],["\\'{a}","á"],["\\={E}","Ē"],["\\boxV","║"],["\\u{g}","ğ"],["\\'{O}","Ó"],["\\'{g}","ǵ"],["\\u{I}","Й"],["\\c{L}","Ļ"],["\\k{E}","Ę"],["\\.{I}","İ"],["\\~{I}","Ĩ"],["\\quad"," "],["\\c{r}","ŗ"],["\\'{r}","ŕ"],["\\\"{Y}","Ÿ"],["\\={e}","ē"],["\\'{U}","Ú"],["\\leq","≤"],["\\Cup","⋓"],["\\Psi","Ψ"],["\\neq","≠"],["\\k{}","˛"],["\\={}","‾"],["\\H{}","˝"],["\\cup","∪"],["\\geq","≥"],["\\mho","℧"],["\\Dzh","Џ"],["\\cap","∩"],["\\bot","⊥"],["\\psi","ψ"],["\\chi","χ"],["\\c{}","¸"],["\\Phi","Φ"],["\\ast","*"],["\\ell","ℓ"],["\\top","⊤"],["\\lll","⋘"],["\\tau","τ"],["\\Cap","⋒"],["\\sad","☹"],["\\iff","⇔"],["\\eta","η"],["\\eth","ð"],["\\d{}","̣"],["\\rho","ρ"],["\\dzh","џ"],["\\div","÷"],["\\phi","ϕ"],["\\Rsh","↱"],["\\vee","∨"],["\\b{}","ˍ"],["\\t{}","͡"],["\\int","∫"],["\\sim","∼"],["\\r{}","˚"],["\\Lsh","↰"],["\\yen","¥"],["\\ggg","⋙"],["\\mid","∣"],["\\sum","∑"],["\\Dz","Ѕ"],["\\Re","ℜ"],["\\oe","œ"],["\\DH","Ð"],["\\ll","≪"],["\\ng","ŋ"],["\\'G","Ѓ"],["\\wr","≀"],["\\wp","℘"],["\\=I","І"],["\\:)","☺"],["\\:(","☹"],["\\AE","Æ"],["\\AA","Å"],["\\ss","ß"],["\\dz","ѕ"],["\\ae","æ"],["\\aa","å"],["\\th","þ"],["\\to","→"],["\\Pi","Π"],["\\mp","∓"],["\\Im","ℑ"],["\\pm","±"],["\\pi","π"],["\\\"I","Ї"],["\\'C","Ћ"],["\\in","∈"],["\\'K","Ќ"],["\\'k","ќ"],["\\'c","ћ"],["\\'g","ѓ"],["\\ni","∋"],["\\ne","≠"],["\\TH","Þ"],["\\Xi","Ξ"],["\\nu","ν"],["\\NG","Ŋ"],["\\:G","㋡"],["\\xi","ξ"],["\\OE","Œ"],["\\gg","≫"],["\\DJ","Đ"],["\\=e","є"],["\\=E","Є"],["\\mu","μ"],["\\dj","đ"],["\\:"," "],["\\;"," "],["\\&","&"],["\\$","$"],["\\%","%"],["\\#","#"],["\\,"," "],["\\-",""],["\\S","§"],["\\P","¶"],["\\O","Ø"],["\\L","Ł"],["\\}","}"],["\\o","ø"],["\\l","ł"],["\\h","ℎ"],["\\i","ℹ"],["-","−"]],"combiningmarks":[["\\doubleunderline","̳"],["\\strikethrough","̵"],["\\underline","̲"],["\\overline","̅"],["\\tilde","̃"],["\\grave","̀"],["\\acute","́"],["\\slash","̸"],["\\breve","̆"],["\\ddot","̈"],["\\dot","̇"],["\\bar","̅"],["\\vec","⃗"],["\\hat","̂"]],"subsuperscripts":[["_x","ₓ"],["_v","ᵥ"],["_u","ᵤ"],["_t","ₜ"],["_s","ₛ"],["_r","ᵣ"],["_p","ₚ"],["_o","ₒ"],["_n","ₙ"],["_m","ₘ"],["_l","ₗ"],["_k","ₖ"],["_j","ⱼ"],["_i","ᵢ"],["_h","ₕ"],["_e","ₑ"],["_a","ₐ"],["^∫","ᶴ"],["_>","˲"],["_=","₌"],["_<","˱"],["_9","₉"],["_8","₈"],["_7","₇"],["_6","₆"],["_5","₅"],["_4","₄"],["_3","₃"],["_2","₂"],["_1","₁"],["_0","₀"],["_-","₋"],["_−","₋"],["_+","₊"],["_)","₎"],["_(","₍"],["_ρ","ᵨ"],["_χ","ᵪ"],["_φ","ᵩ"],["_β","ᵦ"],["_γ","ᵧ"],["^φ","ᵠ"],["^χ","ᵡ"],["^δ","ᵟ"],["^γ","ᵞ"],["^β","ᵝ"],["^8","⁸"],["^9","⁹"],["^<","˂"],["^=","⁼"],["^>","˃"],["^0","⁰"],["^1","¹"],["^2","²"],["^3","³"],["^4","⁴"],["^5","⁵"],["^6","⁶"],["^7","⁷"],["^(","⁽"],["^)","⁾"],["^*","*"],["^+","⁺"],["^-","⁻"],["^−","⁻"],["^P","ᴾ"],["^R","ᴿ"],["^T","ᵀ"],["^U","ᵁ"],["^V","ᄑ"],["^W","ᵂ"],["^H","ᴴ"],["^I","ᴵ"],["^J","ᴶ"],["^K","ᴷ"],["^L","ᴸ"],["^M","ᴹ"],["^N","ᴺ"],["^O","ᴼ"],["^A","ᴬ"],["^B","ᴮ"],["^D","ᴰ"],["^E","ᴱ"],["^G","ᴳ"],["^x","ˣ"],["^y","ʸ"],["^z","ᶻ"],["^p","ᵖ"],["^r","ʳ"],["^s","ˢ"],["^t","ᵗ"],["^u","ᵘ"],["^v","ᵛ"],["^w","ʷ"],["^h","ʰ"],["^i","ⁱ"],["^j","ʲ"],["^k","ᵏ"],["^l","ˡ"],["^m","ᵐ"],["^n","ⁿ"],["^o","ᵒ"],["^a","ᵃ"],["^b","ᵇ"],["^c","ᶜ"],["^d","ᵈ"],["^e","ᵉ"],["^f","ᶠ"],["^g","ᵍ"]]}
|
data/kramdown-rfc2629.gemspec
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
spec = Gem::Specification.new do |s|
|
2
2
|
s.name = 'kramdown-rfc2629'
|
3
|
-
s.version = '1.3.
|
3
|
+
s.version = '1.3.18'
|
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
7
|
s.add_dependency('kramdown', '~> 1.17.0')
|
8
8
|
s.add_dependency('certified', '~> 1.0')
|
9
|
-
s.
|
9
|
+
s.add_dependency('json', '~> 2.0')
|
10
|
+
s.files = Dir['lib/**/*.rb'] + %w(README.md LICENSE kramdown-rfc2629.gemspec bin/kdrfc bin/kramdown-rfc2629 bin/doilit bin/kramdown-rfc-extract-markdown data/kramdown-rfc2629.erb data/encoding-fallbacks.txt data/math.json)
|
10
11
|
s.require_path = 'lib'
|
11
12
|
s.executables = ['kramdown-rfc2629', 'doilit', 'kramdown-rfc-extract-markdown', 'kdrfc']
|
12
13
|
s.required_ruby_version = '>= 2.3.0'
|
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
|
|
@@ -18,6 +19,7 @@ Kramdown::Parser::Html::Constants::HTML_SPAN_ELEMENTS.concat my_span_elements
|
|
18
19
|
|
19
20
|
require 'rexml/parsers/baseparser'
|
20
21
|
require 'open3' # for math
|
22
|
+
require 'json' # for math
|
21
23
|
|
22
24
|
class Object
|
23
25
|
def deep_clone
|
@@ -235,6 +237,14 @@ COLORS
|
|
235
237
|
out
|
236
238
|
end
|
237
239
|
|
240
|
+
def capture_croak(t, err)
|
241
|
+
if err != ''
|
242
|
+
err.lines do |l|
|
243
|
+
warn "*** [#{t}:] #{l.chomp}"
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
238
248
|
def svg_tool_process(t, result)
|
239
249
|
require 'tempfile'
|
240
250
|
file = Tempfile.new("kramdown-rfc")
|
@@ -242,27 +252,34 @@ COLORS
|
|
242
252
|
file.close
|
243
253
|
case t
|
244
254
|
when "goat"
|
245
|
-
result1, _s = Open3.
|
255
|
+
result1, err, _s = Open3.capture3("goat #{file.path}", stdin_data: result);
|
246
256
|
when "ditaa" # XXX: This needs some form of option-setting
|
247
|
-
result1, _s = Open3.
|
257
|
+
result1, err, _s = Open3.capture3("ditaa #{file.path} --svg -o -", stdin_data: result);
|
248
258
|
when "mscgen"
|
249
|
-
result1, _s = Open3.
|
259
|
+
result1, err, _s = Open3.capture3("mscgen -T svg -i #{file.path} -o -", stdin_data: result);
|
250
260
|
when "mermaid"
|
251
|
-
result1, _s = Open3.
|
261
|
+
result1, err, _s = Open3.capture3("mmdc -i #{file.path}", stdin_data: result); # -b transparent
|
252
262
|
outpath = file.path + ".svg"
|
253
263
|
result1 = File.read(outpath)
|
254
264
|
File.unlink(outpath)
|
255
265
|
when "plantuml", "plantuml-utxt"
|
256
266
|
plantuml = "@startuml\n#{result}\n@enduml"
|
257
|
-
result1, _s = Open3.
|
258
|
-
result, _s = Open3.
|
267
|
+
result1, err, _s = Open3.capture3("plantuml -pipe -tsvg", stdin_data: plantuml);
|
268
|
+
result, err1, _s = Open3.capture3("plantuml -pipe -tutxt", stdin_data: plantuml) if t == "plantuml-utxt"
|
269
|
+
err << err1
|
270
|
+
when "math"
|
271
|
+
result1, err, _s = Open3.capture3("tex2svg --font STIX --speech=false #{Shellwords.escape(' ' << result)}");
|
272
|
+
result, err1, _s = Open3.capture3("asciitex -f #{file.path}")
|
273
|
+
err << err1
|
259
274
|
end
|
275
|
+
capture_croak(t, err)
|
260
276
|
# warn ["goat:", result1.inspect]
|
261
277
|
file.unlink
|
262
278
|
result1 = svg_clean(result1) unless t == "goat"
|
263
|
-
result1, _s = Open3.
|
279
|
+
result1, err, _s = Open3.capture3("svgcheck -qa", stdin_data: result1);
|
280
|
+
capture_croak("svgcheck", err)
|
264
281
|
# warn ["svgcheck:", result1.inspect]
|
265
|
-
[result, result1]
|
282
|
+
[result, result1] # text, svg
|
266
283
|
end
|
267
284
|
|
268
285
|
def convert_codeblock(el, indent, opts)
|
@@ -309,7 +326,7 @@ COLORS
|
|
309
326
|
end
|
310
327
|
end
|
311
328
|
case t
|
312
|
-
when "goat", "ditaa", "mscgen", "plantuml", "plantuml-utxt", "mermaid"
|
329
|
+
when "goat", "ditaa", "mscgen", "plantuml", "plantuml-utxt", "mermaid", "math"
|
313
330
|
result, result1 = memoize(:svg_tool_process, t, result)
|
314
331
|
"#{' '*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"
|
315
332
|
else
|
@@ -377,7 +394,18 @@ COLORS
|
|
377
394
|
end
|
378
395
|
end
|
379
396
|
alias :convert_ol :convert_ul
|
380
|
-
|
397
|
+
|
398
|
+
def convert_dl(el, indent, opts)
|
399
|
+
if $options.v3
|
400
|
+
vspace = el.attr.delete('vspace')
|
401
|
+
if vspace && !el.attr['newline']
|
402
|
+
el.attr['newline'] = 'true'
|
403
|
+
end
|
404
|
+
"#{' '*indent}<dl#{el_html_attributes(el)}>\n#{inner(el, indent, opts.dup)}#{' '*indent}</dl>\n"
|
405
|
+
else
|
406
|
+
convert_ul(el, indent, opts)
|
407
|
+
end
|
408
|
+
end
|
381
409
|
|
382
410
|
def convert_li(el, indent, opts)
|
383
411
|
res_a = inner_a(el, indent, opts)
|
@@ -392,7 +420,16 @@ COLORS
|
|
392
420
|
end
|
393
421
|
"#{' '*indent}<t#{el_html_attributes(el)}>#{res}#{(res =~ /\n\Z/ ? ' '*indent : '')}</t>\n"
|
394
422
|
end
|
423
|
+
|
395
424
|
def convert_dd(el, indent, opts)
|
425
|
+
if $options.v3
|
426
|
+
out = ''
|
427
|
+
if !opts[:haddt]
|
428
|
+
out ="#{' '*indent}<dt/>\n" # you can't make this one up
|
429
|
+
end
|
430
|
+
opts[:haddt] = false
|
431
|
+
out << "#{' '*indent}<dd#{el_html_attributes(el)}>\n#{inner(el, indent, opts)}#{' '*indent}</dd>\n"
|
432
|
+
else
|
396
433
|
output = ' '*indent
|
397
434
|
if @in_dt == 1
|
398
435
|
@in_dt = 0
|
@@ -406,15 +443,25 @@ COLORS
|
|
406
443
|
# output << "\n" << res << ' '*indent
|
407
444
|
# end
|
408
445
|
output << "</t>\n"
|
446
|
+
end
|
409
447
|
end
|
410
448
|
|
411
449
|
def convert_dt(el, indent, opts) # SERIOUSLY BAD HACK:
|
450
|
+
if $options.v3
|
451
|
+
out = ''
|
452
|
+
if opts[:haddt]
|
453
|
+
out ="#{' '*indent}<dd><t/></dd>\n" # you can't make this one up
|
454
|
+
end
|
455
|
+
opts[:haddt] = true
|
456
|
+
out << "#{' '*indent}<dt#{el_html_attributes(el)}>\n#{inner(el, indent, opts)}#{' '*indent}</dt>\n"
|
457
|
+
else
|
412
458
|
close = "#{' '*indent}</t>\n" * @in_dt
|
413
459
|
@in_dt = 1
|
414
460
|
vspace = opts[:vspace]
|
415
461
|
vspaceel = "<vspace blankLines='#{vspace}'/>" if vspace
|
416
462
|
ht = escape_html(inner(el, indent, opts), :attribute) # XXX this may leave gunk
|
417
|
-
"#{close}#{' '*indent}<t#{el_html_attributes(el)} hangText
|
463
|
+
"#{close}#{' '*indent}<t#{el_html_attributes(el)} hangText=\"#{ht}\">#{vspaceel}\n"
|
464
|
+
end
|
418
465
|
end
|
419
466
|
|
420
467
|
HTML_TAGS_WITH_BODY=['div', 'script']
|
@@ -725,13 +772,34 @@ COLORS
|
|
725
772
|
:raquo => [::Kramdown::Utils::Entities.entity('raquo')]
|
726
773
|
}
|
727
774
|
def convert_typographic_sym(el, indent, opts)
|
728
|
-
|
775
|
+
if (result = @options[:typographic_symbols][el.value])
|
776
|
+
escape_html(result, :text)
|
777
|
+
else
|
778
|
+
TYPOGRAPHIC_SYMS[el.value].map {|e| entity_to_str(e) }.join('')
|
779
|
+
end
|
729
780
|
end
|
730
781
|
|
731
782
|
def convert_smart_quote(el, indent, opts)
|
732
783
|
entity_to_str(smart_quote_entity(el))
|
733
784
|
end
|
734
785
|
|
786
|
+
MATH_LATEX_FILENAME = File.expand_path '../../data/math.json', __FILE__
|
787
|
+
MATH_LATEX = JSON.parse(File.read(MATH_LATEX_FILENAME, encoding: Encoding::UTF_8))
|
788
|
+
MATH_REPLACEMENTS = MATH_LATEX["replacements"]
|
789
|
+
MATH_COMBININGMARKS = MATH_LATEX["combiningmarks"]
|
790
|
+
|
791
|
+
def munge_latex(s)
|
792
|
+
MATH_REPLACEMENTS.each do |o, n|
|
793
|
+
s.gsub!(o, n)
|
794
|
+
end
|
795
|
+
MATH_COMBININGMARKS.each do |m, n|
|
796
|
+
re = /\\#{m[1..-1]}\{(\X)\}/
|
797
|
+
s.gsub!(re) { "#$1#{n}" }
|
798
|
+
end
|
799
|
+
s
|
800
|
+
end
|
801
|
+
# XXX: This is missing sup/sub support, which needs to be added
|
802
|
+
|
735
803
|
def convert_math(el, indent, opts) # XXX: This is wrong
|
736
804
|
el = el.deep_clone
|
737
805
|
if el.options[:category] == :block
|
@@ -744,15 +812,24 @@ COLORS
|
|
744
812
|
artwork_attr[md[1]] = v
|
745
813
|
end
|
746
814
|
end
|
747
|
-
result, _s = Open3.
|
815
|
+
result, err, _s = Open3.capture3("tex2mail -noindent -ragged -by_par -linelength=69", stdin_data: el.value);
|
748
816
|
# warn "*** tex2mail not in path?" unless s.success? -- doesn't have useful status
|
817
|
+
capture_croak("tex2mail", err)
|
749
818
|
"#{' '*indent}<figure#{el_html_attributes(el)}><artwork#{html_attributes(artwork_attr)}><![CDATA[#{result}#{result =~ /\n\Z/ ? '' : "\n"}]]></artwork></figure>\n"
|
750
819
|
|
751
820
|
else
|
752
|
-
warn "*** no support for inline math in XML2RFCv2"
|
753
821
|
type = 'spanx'
|
754
|
-
|
755
|
-
|
822
|
+
if $options.v3
|
823
|
+
type = 'contact'
|
824
|
+
result = munge_latex(el.value)
|
825
|
+
attrstring = el_html_attributes_with(el, {"fullname" => result.chomp, "asciiFullname" => ''})
|
826
|
+
else
|
827
|
+
warn "*** no support for inline math in XML2RFCv2"
|
828
|
+
type = 'spanx'
|
829
|
+
attrstring = el_html_attributes_with(el, {"style" => 'verb'})
|
830
|
+
content = escape_html(el.value, :text)
|
831
|
+
end
|
832
|
+
"<#{type}#{attrstring}>#{content}</#{type}>"
|
756
833
|
end
|
757
834
|
end
|
758
835
|
|
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.18
|
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-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: json
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
41
55
|
description: |-
|
42
56
|
An RFC7749 (XML2RFC) generating backend for Thomas Leitner's
|
43
57
|
"kramdown" markdown parser. Mostly useful for RFC writers.
|
@@ -58,6 +72,7 @@ files:
|
|
58
72
|
- bin/kramdown-rfc2629
|
59
73
|
- data/encoding-fallbacks.txt
|
60
74
|
- data/kramdown-rfc2629.erb
|
75
|
+
- data/math.json
|
61
76
|
- kramdown-rfc2629.gemspec
|
62
77
|
- lib/kramdown-rfc/gzip-clone.rb
|
63
78
|
- lib/kramdown-rfc/parameterset.rb
|