kramdown-rfc2629 1.4.8 → 1.4.13
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/bin/kramdown-rfc2629 +42 -11
 - data/kramdown-rfc2629.gemspec +1 -1
 - data/lib/kramdown-rfc2629.rb +32 -6
 - 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: 509111a53b346a7af409423bc1aea0e64c3fbded3e42868a875de6b867392429
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 3c882b8d76cbbfcc9e070157c453a25105fe23de1d061a2c0bc56591857e7f08
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: a42a8122990612bb885799121492673d37f47285d1481a0b2db4e0a2e12b2ebee9b630131596f228a99daed62190fcf411317b37434dc46cf84e429ede139bdb
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: e5197f5394cfa12dd11042bb5c90d73dd02e6582f05175e7b2516c1d731fbd13d7699106666f43b1bd1ec1c98473229ba618f3cfde48a40759ec137d1e10087f
         
     | 
    
        data/bin/kramdown-rfc2629
    CHANGED
    
    | 
         @@ -14,21 +14,29 @@ Encoding.default_external = "UTF-8" # wake up, smell the coffee 
     | 
|
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
            def boilerplate(key)
         
     | 
| 
       16 
16 
     | 
    
         
             
              case key.downcase
         
     | 
| 
       17 
     | 
    
         
            -
              when /\Abcp14(\+)?(-tagged)?\z/i
         
     | 
| 
       18 
     | 
    
         
            -
                ret =  
     | 
| 
      
 17 
     | 
    
         
            +
              when /\Abcp14(info)?(\+)?(-tagged)?\z/i
         
     | 
| 
      
 18 
     | 
    
         
            +
                ret = ''
         
     | 
| 
      
 19 
     | 
    
         
            +
                if $1
         
     | 
| 
      
 20 
     | 
    
         
            +
                  ret << <<RFC8174ise
         
     | 
| 
      
 21 
     | 
    
         
            +
            Although this document is not an IETF Standards Track publication, it
         
     | 
| 
      
 22 
     | 
    
         
            +
            adopts the conventions for normative language to provide clarity of
         
     | 
| 
      
 23 
     | 
    
         
            +
            instructions to the implementer.
         
     | 
| 
      
 24 
     | 
    
         
            +
            RFC8174ise
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
                ret << <<RFC8174
         
     | 
| 
       19 
27 
     | 
    
         
             
            The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL
         
     | 
| 
       20 
28 
     | 
    
         
             
            NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED",
         
     | 
| 
       21 
29 
     | 
    
         
             
            "MAY", and "OPTIONAL" in this document are to be interpreted as
         
     | 
| 
       22 
30 
     | 
    
         
             
            described in BCP 14 {{!RFC2119}} {{!RFC8174}} when, and only when, they
         
     | 
| 
       23 
31 
     | 
    
         
             
            appear in all capitals, as shown here.
         
     | 
| 
       24 
32 
     | 
    
         
             
            RFC8174
         
     | 
| 
       25 
     | 
    
         
            -
                if $ 
     | 
| 
      
 33 
     | 
    
         
            +
                if $2
         
     | 
| 
       26 
34 
     | 
    
         
             
                  ret << <<PLUS
         
     | 
| 
       27 
35 
     | 
    
         
             
            These words may also appear in this document in
         
     | 
| 
       28 
36 
     | 
    
         
             
            lower case as plain English words, absent their normative meanings.
         
     | 
| 
       29 
37 
     | 
    
         
             
            PLUS
         
     | 
| 
       30 
38 
     | 
    
         
             
                end
         
     | 
| 
       31 
     | 
    
         
            -
                if $ 
     | 
| 
      
 39 
     | 
    
         
            +
                if $3
         
     | 
| 
       32 
40 
     | 
    
         
             
                  if $options.v3
         
     | 
| 
       33 
41 
     | 
    
         
             
                    ret << <<TAGGED
         
     | 
| 
       34 
42 
     | 
    
         | 
| 
         @@ -83,12 +91,26 @@ NORMINFORM = { "!" => :normative, "?" => :informative } 
     | 
|
| 
       83 
91 
     | 
    
         | 
| 
       84 
92 
     | 
    
         
             
            def yaml_load(input, *args)
         
     | 
| 
       85 
93 
     | 
    
         
             
              if YAML.respond_to?(:safe_load)
         
     | 
| 
       86 
     | 
    
         
            -
                 
     | 
| 
      
 94 
     | 
    
         
            +
                begin
         
     | 
| 
      
 95 
     | 
    
         
            +
                  YAML.safe_load(input, *args)
         
     | 
| 
      
 96 
     | 
    
         
            +
                rescue ArgumentError
         
     | 
| 
      
 97 
     | 
    
         
            +
                  YAML.safe_load(input, permitted_classes: args[0], permitted_symbols: args[1], aliases: args[2])
         
     | 
| 
      
 98 
     | 
    
         
            +
                end
         
     | 
| 
       87 
99 
     | 
    
         
             
              else
         
     | 
| 
       88 
100 
     | 
    
         
             
                YAML.load(input)
         
     | 
| 
       89 
101 
     | 
    
         
             
             end
         
     | 
| 
       90 
102 
     | 
    
         
             
            end
         
     | 
| 
       91 
103 
     | 
    
         | 
| 
      
 104 
     | 
    
         
            +
            XREF_SECTIONS_RE = ::Kramdown::Parser::RFC2629Kramdown::SECTIONS_RE
         
     | 
| 
      
 105 
     | 
    
         
            +
            XSR_PREFIX = "#{XREF_SECTIONS_RE} of "
         
     | 
| 
      
 106 
     | 
    
         
            +
            XSR_SUFFIX = ", (#{XREF_SECTIONS_RE})| \\((#{XREF_SECTIONS_RE})\\)"
         
     | 
| 
      
 107 
     | 
    
         
            +
            XREF_TXT = ::Kramdown::Parser::RFC2629Kramdown::XREF_TXT
         
     | 
| 
      
 108 
     | 
    
         
            +
            XREF_TXT_SUFFIX = " \\(#{XREF_TXT}\\)"
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
            def spacify_re(s)
         
     | 
| 
      
 111 
     | 
    
         
            +
              s.gsub(' ', '[\u00A0\s]+')
         
     | 
| 
      
 112 
     | 
    
         
            +
            end
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
       92 
114 
     | 
    
         
             
            def xml_from_sections(input)
         
     | 
| 
       93 
115 
     | 
    
         | 
| 
       94 
116 
     | 
    
         
             
              unless ENV["KRAMDOWN_NO_SOURCE"]
         
     | 
| 
         @@ -158,11 +180,20 @@ def xml_from_sections(input) 
     | 
|
| 
       158 
180 
     | 
    
         
             
              # collect normative/informative tagging {{!RFC2119}} {{?RFC4711}}
         
     | 
| 
       159 
181 
     | 
    
         
             
              sechash.each do |k, v|
         
     | 
| 
       160 
182 
     | 
    
         
             
                next if k == "fluff"
         
     | 
| 
       161 
     | 
    
         
            -
                v.gsub!(/{{( 
     | 
| 
       162 
     | 
    
         
            -
                   
     | 
| 
       163 
     | 
    
         
            -
             
     | 
| 
       164 
     | 
    
         
            -
                   
     | 
| 
       165 
     | 
    
         
            -
             
     | 
| 
      
 183 
     | 
    
         
            +
                v.gsub!(/{{(#{
         
     | 
| 
      
 184 
     | 
    
         
            +
                  spacify_re(XSR_PREFIX)
         
     | 
| 
      
 185 
     | 
    
         
            +
                })?(?:([?!])(-)?|(-))([\w._\-]+)(?:=([\w.\/_\-]+))?(#{
         
     | 
| 
      
 186 
     | 
    
         
            +
                  XREF_TXT_SUFFIX
         
     | 
| 
      
 187 
     | 
    
         
            +
                })?(#{
         
     | 
| 
      
 188 
     | 
    
         
            +
                  spacify_re(XSR_SUFFIX)
         
     | 
| 
      
 189 
     | 
    
         
            +
                })?}}/) do |match|
         
     | 
| 
      
 190 
     | 
    
         
            +
                  xsr_prefix = $1
         
     | 
| 
      
 191 
     | 
    
         
            +
                  norminform = $2
         
     | 
| 
      
 192 
     | 
    
         
            +
                  replacing = $3 || $4
         
     | 
| 
      
 193 
     | 
    
         
            +
                  word = $5
         
     | 
| 
      
 194 
     | 
    
         
            +
                  bibref = $6
         
     | 
| 
      
 195 
     | 
    
         
            +
                  xrt_suffix = $7
         
     | 
| 
      
 196 
     | 
    
         
            +
                  xsr_suffix = $8
         
     | 
| 
       166 
197 
     | 
    
         
             
                  if replacing
         
     | 
| 
       167 
198 
     | 
    
         
             
                    if new = ref_replacements[word]
         
     | 
| 
       168 
199 
     | 
    
         
             
                      word = new
         
     | 
| 
         @@ -186,7 +217,7 @@ def xml_from_sections(input) 
     | 
|
| 
       186 
217 
     | 
    
         
             
                  if norminform
         
     | 
| 
       187 
218 
     | 
    
         
             
                    norm_ref[word] ||= norminform == '!' # one normative ref is enough
         
     | 
| 
       188 
219 
     | 
    
         
             
                  end
         
     | 
| 
       189 
     | 
    
         
            -
                  "{{#{word}}}"
         
     | 
| 
      
 220 
     | 
    
         
            +
                  "{{#{xsr_prefix}#{word}#{xrt_suffix}#{xsr_suffix}}}"
         
     | 
| 
       190 
221 
     | 
    
         
             
                end
         
     | 
| 
       191 
222 
     | 
    
         
             
              end
         
     | 
| 
       192 
223 
     | 
    
         | 
    
        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.4. 
     | 
| 
      
 3 
     | 
    
         
            +
              s.version = '1.4.13'
         
     | 
| 
       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
    
    | 
         @@ -363,6 +363,19 @@ COLORS 
     | 
|
| 
       363 
363 
     | 
    
         
             
                    end
         
     | 
| 
       364 
364 
     | 
    
         
             
                  end
         
     | 
| 
       365 
365 
     | 
    
         | 
| 
      
 366 
     | 
    
         
            +
                  def svg_clean_kgt(s)
         
     | 
| 
      
 367 
     | 
    
         
            +
                    d = REXML::Document.new(s)
         
     | 
| 
      
 368 
     | 
    
         
            +
                    REXML::XPath.each(d.root, "//rect|//line|//path") do |x|
         
     | 
| 
      
 369 
     | 
    
         
            +
                      x.attributes["fill"] = "none"
         
     | 
| 
      
 370 
     | 
    
         
            +
                      x.attributes["stroke"] = "black"
         
     | 
| 
      
 371 
     | 
    
         
            +
                      x.attributes["stroke-width"] = "1.5"
         
     | 
| 
      
 372 
     | 
    
         
            +
                    end
         
     | 
| 
      
 373 
     | 
    
         
            +
                    d.to_s
         
     | 
| 
      
 374 
     | 
    
         
            +
                  rescue => detail
         
     | 
| 
      
 375 
     | 
    
         
            +
                    warn "*** Can't clean SVG: #{detail}"
         
     | 
| 
      
 376 
     | 
    
         
            +
                    d
         
     | 
| 
      
 377 
     | 
    
         
            +
                  end
         
     | 
| 
      
 378 
     | 
    
         
            +
             
     | 
| 
       366 
379 
     | 
    
         
             
                  def svg_clean(s)          # expensive, risky
         
     | 
| 
       367 
380 
     | 
    
         
             
                    d = REXML::Document.new(s)
         
     | 
| 
       368 
381 
     | 
    
         
             
                    REXML::XPath.each(d.root, "//*[@shape-rendering]") { |x| x.attributes["shape-rendering"] = nil }  #; warn x.inspect }
         
     | 
| 
         @@ -407,9 +420,12 @@ COLORS 
     | 
|
| 
       407 
420 
     | 
    
         
             
                    file = Tempfile.new("kramdown-rfc")
         
     | 
| 
       408 
421 
     | 
    
         
             
                    file.write(result)
         
     | 
| 
       409 
422 
     | 
    
         
             
                    file.close
         
     | 
| 
      
 423 
     | 
    
         
            +
                    dont_clean = false
         
     | 
| 
      
 424 
     | 
    
         
            +
                    dont_check = false
         
     | 
| 
       410 
425 
     | 
    
         
             
                    case t
         
     | 
| 
       411 
426 
     | 
    
         
             
                    when "goat"
         
     | 
| 
       412 
427 
     | 
    
         
             
                      result1, err, _s = Open3.capture3("goat #{file.path}", stdin_data: result);
         
     | 
| 
      
 428 
     | 
    
         
            +
                      dont_clean = true
         
     | 
| 
       413 
429 
     | 
    
         
             
                    when "ditaa"        # XXX: This needs some form of option-setting
         
     | 
| 
       414 
430 
     | 
    
         
             
                      result1, err, _s = Open3.capture3("ditaa #{file.path} --svg -o -", stdin_data: result);
         
     | 
| 
       415 
431 
     | 
    
         
             
                    when "mscgen"
         
     | 
| 
         @@ -424,18 +440,27 @@ COLORS 
     | 
|
| 
       424 
440 
     | 
    
         
             
                      result1, err, _s = Open3.capture3("plantuml -pipe -tsvg", stdin_data: plantuml);
         
     | 
| 
       425 
441 
     | 
    
         
             
                      result, err1, _s = Open3.capture3("plantuml -pipe -tutxt", stdin_data: plantuml) if t == "plantuml-utxt"
         
     | 
| 
       426 
442 
     | 
    
         
             
                      err << err1.to_s
         
     | 
| 
      
 443 
     | 
    
         
            +
                    when "railroad", "railroad-utf8"
         
     | 
| 
      
 444 
     | 
    
         
            +
                      result1, err1, _s = Open3.capture3("kgt -l abnf -e svg", stdin_data: result);
         
     | 
| 
      
 445 
     | 
    
         
            +
                      result1 = svg_clean_kgt(result1); dont_clean = true
         
     | 
| 
      
 446 
     | 
    
         
            +
                      result, err, _s = Open3.capture3("kgt -l abnf -e rr#{t == "railroad" ? "text" : "utf8"}",
         
     | 
| 
      
 447 
     | 
    
         
            +
                                                        stdin_data: result);
         
     | 
| 
      
 448 
     | 
    
         
            +
                      err << err1.to_s
         
     | 
| 
       427 
449 
     | 
    
         
             
                    when "math"
         
     | 
| 
       428 
450 
     | 
    
         
             
                      result1, err, _s = Open3.capture3("tex2svg --font STIX --speech=false #{Shellwords.escape(' ' << result)}");
         
     | 
| 
       429 
451 
     | 
    
         
             
                      result, err1, _s = Open3.capture3("asciitex -f #{file.path}")
         
     | 
| 
       430 
452 
     | 
    
         
             
                      err << err1
         
     | 
| 
       431 
453 
     | 
    
         
             
                    end
         
     | 
| 
       432 
454 
     | 
    
         
             
                    capture_croak(t, err)
         
     | 
| 
       433 
     | 
    
         
            -
                    # warn [" 
     | 
| 
      
 455 
     | 
    
         
            +
                    # warn ["text:", result.inspect]
         
     | 
| 
      
 456 
     | 
    
         
            +
                    # warn ["svg:", result1.inspect]
         
     | 
| 
       434 
457 
     | 
    
         
             
                    file.unlink
         
     | 
| 
       435 
     | 
    
         
            -
                    result1 = svg_clean(result1) unless  
     | 
| 
       436 
     | 
    
         
            -
                     
     | 
| 
       437 
     | 
    
         
            -
             
     | 
| 
       438 
     | 
    
         
            -
             
     | 
| 
      
 458 
     | 
    
         
            +
                    result1 = svg_clean(result1) unless dont_clean
         
     | 
| 
      
 459 
     | 
    
         
            +
                    unless dont_check
         
     | 
| 
      
 460 
     | 
    
         
            +
                      result1, err, _s = Open3.capture3("svgcheck -Xqa", stdin_data: result1);
         
     | 
| 
      
 461 
     | 
    
         
            +
                      # warn ["svgcheck:", result1.inspect]
         
     | 
| 
      
 462 
     | 
    
         
            +
                      capture_croak("svgcheck", err)
         
     | 
| 
      
 463 
     | 
    
         
            +
                    end
         
     | 
| 
       439 
464 
     | 
    
         
             
                    if result1 == ''
         
     | 
| 
       440 
465 
     | 
    
         
             
                      warn "*** could not create svg for #{result.inspect[0...20]}..."
         
     | 
| 
       441 
466 
     | 
    
         
             
                      exit 65 # EX_DATAERR
         
     | 
| 
         @@ -490,7 +515,8 @@ COLORS 
     | 
|
| 
       490 
515 
     | 
    
         
             
                        end
         
     | 
| 
       491 
516 
     | 
    
         
             
                      end
         
     | 
| 
       492 
517 
     | 
    
         
             
                      case t
         
     | 
| 
       493 
     | 
    
         
            -
                      when "goat", "ditaa", "mscgen", "plantuml", "plantuml-utxt",  
     | 
| 
      
 518 
     | 
    
         
            +
                      when "goat", "ditaa", "mscgen", "plantuml", "plantuml-utxt", 
         
     | 
| 
      
 519 
     | 
    
         
            +
                           "railroad", "railroad-utf8", "mermaid", "math"
         
     | 
| 
       494 
520 
     | 
    
         
             
                        if gi
         
     | 
| 
       495 
521 
     | 
    
         
             
                          warn "*** Can't set GI #{gi} for composite SVG artset"
         
     | 
| 
       496 
522 
     | 
    
         
             
                        end
         
     | 
    
        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.4. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.4.13
         
     | 
| 
       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-05- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2021-05-21 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: kramdown
         
     |