kramdown-asciidoc 1.0.0.alpha.9 → 1.0.0.alpha.10
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/CHANGELOG.adoc +18 -0
 - data/README.adoc +7 -1
 - data/lib/kramdown-asciidoc/cli.rb +9 -1
 - data/lib/kramdown-asciidoc/converter.rb +19 -16
 - data/lib/kramdown-asciidoc/version.rb +1 -1
 - data/lib/kramdown-asciidoc/writer.rb +29 -17
 - data/spec/cli_spec.rb +33 -0
 - data/spec/scenarios/a/no-auto-links.adoc +3 -0
 - data/spec/scenarios/a/no-auto-links.md +3 -0
 - data/spec/scenarios/a/no-auto-links.opts +1 -0
 - data/spec/scenarios/codespan/literal.adoc +2 -0
 - data/spec/scenarios/codespan/literal.md +2 -0
 - data/spec/scenarios/dl/nested-bookended.adoc +8 -0
 - data/spec/scenarios/dl/nested-bookended.md +6 -0
 - data/spec/scenarios/strong/unconstrained.adoc +1 -0
 - data/spec/scenarios/strong/unconstrained.md +1 -0
 - data/spec/scenarios/ul/compound-nested.adoc +2 -0
 - data/spec/scenarios/ul/compound-nested.md +2 -0
 - data/spec/scenarios/ul/compound-separated.adoc +12 -0
 - data/spec/scenarios/ul/compound-separated.md +7 -0
 - data/spec/scenarios/ul/compound.adoc +12 -0
 - data/spec/scenarios/ul/compound.md +6 -0
 - data/spec/scenarios/ul/inside-delimited-block.adoc +9 -0
 - data/spec/scenarios/ul/inside-delimited-block.md +7 -0
 - data/spec/scenarios/ul/nested-bookended.adoc +7 -0
 - data/spec/scenarios/ul/nested-bookended.md +7 -0
 - metadata +20 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 8c9eaf28d5d26d6a4fe664121fa5d19507c9144644711cca82e348330428a1b2
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: d4a0b308bb683012ccc1ed75a54aeeb8f6ceefcf6fbabd54ce4728b34f728895
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: c2b4579e6829ae8b230ac72d9fb5f8e9880c4c40ad037784f695e916cfbd4b83353e44a8b507bd4c92baa1b3805d389420dc12944be0f283c3a30969e5444b50
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 8a73cc65511611f3f5aa541818314bd938e5b0be9aa0f8585e3f2883065fafee1c1d96018c5a552ca6936f73ffa6ec36d67b68e7a9316a305d1ac7f6bba62ab5
         
     | 
    
        data/CHANGELOG.adoc
    CHANGED
    
    | 
         @@ -5,6 +5,24 @@ 
     | 
|
| 
       5 
5 
     | 
    
         
             
            This document provides a high-level view of the changes to {project-name} by release.
         
     | 
| 
       6 
6 
     | 
    
         
             
            For a detailed view of what has changed, refer to the {uri-repo}/commits/master[commit history] on GitHub.
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
      
 8 
     | 
    
         
            +
            == 1.0.0.alpha.10 (2018-07-16) - @mojavelinux
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            === Added
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            * add --auto-id-prefix CLI option to set the prefix added to all auto-generated section title IDs (#26)
         
     | 
| 
      
 13 
     | 
    
         
            +
            * add :auto_links API option and --no-auto-links CLI option to control whether bare URLs are converted into links
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            === Changed
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            * escape codespan text using passthrough if it contains a URL
         
     | 
| 
      
 18 
     | 
    
         
            +
            * add blank line after list item that contains a table
         
     | 
| 
      
 19 
     | 
    
         
            +
            * reset list level inside delimited block (e.g., quote block)
         
     | 
| 
      
 20 
     | 
    
         
            +
            * move list level handling into writer
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            === Fixed
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            * insert blank line above list continuation to attach to parent list item (#27)
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
       8 
26 
     | 
    
         
             
            == 1.0.0.alpha.9 (2018-07-10) - @mojavelinux
         
     | 
| 
       9 
27 
     | 
    
         | 
| 
       10 
28 
     | 
    
         
             
            === Changed
         
     | 
    
        data/README.adoc
    CHANGED
    
    | 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            = {project-name} (Markdown to AsciiDoc)
         
     | 
| 
       2 
2 
     | 
    
         
             
            Dan Allen <https://github.com/mojavelinux>
         
     | 
| 
       3 
     | 
    
         
            -
            v1.0.0.alpha. 
     | 
| 
      
 3 
     | 
    
         
            +
            v1.0.0.alpha.10, 2018-07-16
         
     | 
| 
       4 
4 
     | 
    
         
             
            // Aliases:
         
     | 
| 
       5 
5 
     | 
    
         
             
            :project-name: Kramdown AsciiDoc
         
     | 
| 
       6 
6 
     | 
    
         
             
            :project-handle: kramdown-asciidoc
         
     | 
| 
         @@ -85,6 +85,12 @@ To see all the options the `kramdoc` command accepts, pass the `-h` option to th 
     | 
|
| 
       85 
85 
     | 
    
         | 
| 
       86 
86 
     | 
    
         
             
             $ kramdoc -h
         
     | 
| 
       87 
87 
     | 
    
         | 
| 
      
 88 
     | 
    
         
            +
            For example, you can inject attributes (key/value pairs) into the header of the AsciiDoc output document using the `-a` option.
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
             $ kramdoc -a product-name="ACME Cloud" -a hide-uri-scheme sample.md
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
            Another use for attributes is setting the shared images directory, which is coverd in the next section.
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
       88 
94 
     | 
    
         
             
            == Configure shared images directory
         
     | 
| 
       89 
95 
     | 
    
         | 
| 
       90 
96 
     | 
    
         
             
            If the images in the source document share a common directory prefix, such as [.path]_images/_, you can configure the converter to extract that prefix, optionally promoting it to the document header.
         
     | 
| 
         @@ -49,10 +49,18 @@ module Kramdown; module AsciiDoc 
     | 
|
| 
       49 
49 
     | 
    
         
             
                      options[:html_to_native] = html_to_native
         
     | 
| 
       50 
50 
     | 
    
         
             
                    end
         
     | 
| 
       51 
51 
     | 
    
         | 
| 
       52 
     | 
    
         
            -
                    opts.on '--auto-ids', 'Set whether to auto-generate IDs for section titles' do |auto_ids|
         
     | 
| 
      
 52 
     | 
    
         
            +
                    opts.on '--auto-ids', 'Set whether to auto-generate IDs for all section titles' do |auto_ids|
         
     | 
| 
       53 
53 
     | 
    
         
             
                      options[:auto_ids] = auto_ids
         
     | 
| 
       54 
54 
     | 
    
         
             
                    end
         
     | 
| 
       55 
55 
     | 
    
         | 
| 
      
 56 
     | 
    
         
            +
                    opts.on '--auto-id-prefix=STRING', 'Set the prefix to add to auto-generated section title IDs' do |string|
         
     | 
| 
      
 57 
     | 
    
         
            +
                      options[:auto_id_prefix] = string
         
     | 
| 
      
 58 
     | 
    
         
            +
                    end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                    opts.on '--[no-]auto-links', 'Set whether to automatically convert bare URLs into links (default: true)' do |auto_links|
         
     | 
| 
      
 61 
     | 
    
         
            +
                      options[:auto_links] = auto_links
         
     | 
| 
      
 62 
     | 
    
         
            +
                    end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
       56 
64 
     | 
    
         
             
                    opts.on '-h', '--help', 'Display this help text and exit' do
         
     | 
| 
       57 
65 
     | 
    
         
             
                      $stdout.puts opts.help
         
     | 
| 
       58 
66 
     | 
    
         
             
                      return 0
         
     | 
| 
         @@ -49,7 +49,7 @@ module Kramdown; module AsciiDoc 
     | 
|
| 
       49 
49 
     | 
    
         
             
                ADMON_MARKERS_ASCIIDOC = %w(NOTE TIP CAUTION WARNING IMPORTANT).map {|l| %(#{l}: ) }
         
     | 
| 
       50 
50 
     | 
    
         
             
                ADMON_FORMATTED_MARKERS = ADMON_LABELS.map {|l, _| [%(#{l}:), l] }.to_h
         
     | 
| 
       51 
51 
     | 
    
         
             
                ADMON_TYPE_MAP = ADMON_LABELS.map {|l, _| [l, l.upcase] }.to_h.merge 'Attention' => 'IMPORTANT', 'Hint' => 'TIP'
         
     | 
| 
       52 
     | 
    
         
            -
                BLOCK_TYPES = [:p, :blockquote, :codeblock]
         
     | 
| 
      
 52 
     | 
    
         
            +
                BLOCK_TYPES = [:p, :blockquote, :codeblock, :table]
         
     | 
| 
       53 
53 
     | 
    
         
             
                DLIST_MARKERS = %w(:: ;; ::: ::::)
         
     | 
| 
       54 
54 
     | 
    
         
             
                # FIXME here we reverse the smart quotes; add option to allow them (needs to be handled carefully)
         
     | 
| 
       55 
55 
     | 
    
         
             
                SMART_QUOTE_ENTITY_TO_MARKUP = { ldquo: ?", rdquo: ?", lsquo: ?', rsquo: ?' }
         
     | 
| 
         @@ -86,10 +86,11 @@ module Kramdown; module AsciiDoc 
     | 
|
| 
       86 
86 
     | 
    
         
             
                FullStopRx = /(?<=.\.)\p{Blank}+(?!\Z)/
         
     | 
| 
       87 
87 
     | 
    
         
             
                InadvertentReplacementsRx = /[-=]>|<[-=]|\.\.\.|\{\p{Word}[\p{Word}-]*\}/
         
     | 
| 
       88 
88 
     | 
    
         
             
                MenuRefRx = /^([\p{Word}&].*?)\s>\s([\p{Word}&].*(?:\s>\s|$))+/
         
     | 
| 
       89 
     | 
    
         
            -
                ReplaceableTextRx = /[-=]>|<[-=]| -- |\p{Word}--\p{Word}|\*\*|\.\.\.|&\S+;|\{\p{Word}[\p{Word}-]*\}|\((?:C|R|TM)\)/
         
     | 
| 
      
 89 
     | 
    
         
            +
                ReplaceableTextRx = /[-=]>|<[-=]| -- |\p{Word}--\p{Word}|\*\*|\.\.\.|&\S+;|\{\p{Word}[\p{Word}-]*\}|(?:https?|ftp):\/\/\p{Word}|\((?:C|R|TM)\)/
         
     | 
| 
       90 
90 
     | 
    
         
             
                SmartApostropheRx = /\b’\b/
         
     | 
| 
       91 
91 
     | 
    
         
             
                TrailingSpaceRx = / +$/
         
     | 
| 
       92 
92 
     | 
    
         
             
                TypographicSymbolRx = /[“”‘’—–…]/
         
     | 
| 
      
 93 
     | 
    
         
            +
                UriSchemeRx = /(?:https?|ftp):\/\/\p{Word}/
         
     | 
| 
       93 
94 
     | 
    
         
             
                WordishRx = /[\p{Word};:<>&]/
         
     | 
| 
       94 
95 
     | 
    
         
             
                WordRx = /\p{Word}/
         
     | 
| 
       95 
96 
     | 
    
         
             
                XmlCommentRx = /\A<!--(.*)-->\Z/m
         
     | 
| 
         @@ -102,10 +103,11 @@ module Kramdown; module AsciiDoc 
     | 
|
| 
       102 
103 
     | 
    
         
             
                def initialize root, opts
         
     | 
| 
       103 
104 
     | 
    
         
             
                  super
         
     | 
| 
       104 
105 
     | 
    
         
             
                  @attributes = opts[:attributes] || {}
         
     | 
| 
       105 
     | 
    
         
            -
                  @ 
     | 
| 
      
 106 
     | 
    
         
            +
                  @auto_links = opts.fetch :auto_links, true
         
     | 
| 
       106 
107 
     | 
    
         
             
                  @heading_offset = opts[:heading_offset] || 0
         
     | 
| 
       107 
     | 
    
         
            -
                  @ 
     | 
| 
      
 108 
     | 
    
         
            +
                  @imagesdir = opts[:imagesdir] || @attributes['imagesdir']
         
     | 
| 
       108 
109 
     | 
    
         
             
                  @wrap = opts[:wrap] || :preserve
         
     | 
| 
      
 110 
     | 
    
         
            +
                  @current_heading_level = nil
         
     | 
| 
       109 
111 
     | 
    
         
             
                end
         
     | 
| 
       110 
112 
     | 
    
         | 
| 
       111 
113 
     | 
    
         
             
                def convert el, opts = {}
         
     | 
| 
         @@ -291,12 +293,11 @@ module Kramdown; module AsciiDoc 
     | 
|
| 
       291 
293 
     | 
    
         
             
                end
         
     | 
| 
       292 
294 
     | 
    
         | 
| 
       293 
295 
     | 
    
         
             
                def convert_ul el, opts
         
     | 
| 
       294 
     | 
    
         
            -
                   
     | 
| 
       295 
     | 
    
         
            -
                   
     | 
| 
       296 
     | 
    
         
            -
                  opts[level_opt] = (opts[level_opt] || 0) + 1
         
     | 
| 
      
 296 
     | 
    
         
            +
                  kin = el.type == :dl ? :dlist : :list
         
     | 
| 
      
 297 
     | 
    
         
            +
                  (writer = opts[:writer]).start_list (parent = opts[:parent]).type == :dd || parent.options[:compound], kin
         
     | 
| 
       297 
298 
     | 
    
         
             
                  traverse el, opts
         
     | 
| 
       298 
     | 
    
         
            -
                   
     | 
| 
       299 
     | 
    
         
            -
                  writer. 
     | 
| 
      
 299 
     | 
    
         
            +
                  writer.end_list kin
         
     | 
| 
      
 300 
     | 
    
         
            +
                  writer.add_blank_line if writer.in_list? && opts[:next]
         
     | 
| 
       300 
301 
     | 
    
         
             
                end
         
     | 
| 
       301 
302 
     | 
    
         | 
| 
       302 
303 
     | 
    
         
             
                alias convert_ol convert_ul
         
     | 
| 
         @@ -306,7 +307,7 @@ module Kramdown; module AsciiDoc 
     | 
|
| 
       306 
307 
     | 
    
         
             
                  writer = opts[:writer]
         
     | 
| 
       307 
308 
     | 
    
         
             
                  writer.add_blank_line if (prev = opts[:prev]) && prev.options[:compound]
         
     | 
| 
       308 
309 
     | 
    
         
             
                  marker = opts[:parent].type == :ol ? '.' : '*'
         
     | 
| 
       309 
     | 
    
         
            -
                  indent = (level =  
     | 
| 
      
 310 
     | 
    
         
            +
                  indent = (level = writer.list_level) - 1
         
     | 
| 
       310 
311 
     | 
    
         
             
                  if (children = el.children)[0].type == :p
         
     | 
| 
       311 
312 
     | 
    
         
             
                    primary, remaining = [(children = children.dup).shift, children]
         
     | 
| 
       312 
313 
     | 
    
         
             
                    primary_lines = compose_text [primary], parent: el, strip: true, split: true, wrap: @wrap
         
     | 
| 
         @@ -324,12 +325,13 @@ module Kramdown; module AsciiDoc 
     | 
|
| 
       324 
325 
     | 
    
         
             
                end
         
     | 
| 
       325 
326 
     | 
    
         | 
| 
       326 
327 
     | 
    
         
             
                def convert_dt el, opts
         
     | 
| 
      
 328 
     | 
    
         
            +
                  writer = opts[:writer]
         
     | 
| 
       327 
329 
     | 
    
         
             
                  # NOTE kramdown removes newlines from term
         
     | 
| 
       328 
330 
     | 
    
         
             
                  term = compose_text el, strip: true
         
     | 
| 
       329 
     | 
    
         
            -
                  marker = DLIST_MARKERS[ 
     | 
| 
       330 
     | 
    
         
            -
                  # 
     | 
| 
       331 
     | 
    
         
            -
                   
     | 
| 
       332 
     | 
    
         
            -
                   
     | 
| 
      
 331 
     | 
    
         
            +
                  marker = DLIST_MARKERS[(writer.list_level :dlist) - 1]
         
     | 
| 
      
 332 
     | 
    
         
            +
                  #writer.add_blank_line if (prev = opts[:prev]) && prev.options[:compound]
         
     | 
| 
      
 333 
     | 
    
         
            +
                  writer.add_blank_line if opts[:prev]
         
     | 
| 
      
 334 
     | 
    
         
            +
                  writer.add_line %(#{term}#{marker})
         
     | 
| 
       333 
335 
     | 
    
         
             
                end
         
     | 
| 
       334 
336 
     | 
    
         | 
| 
       335 
337 
     | 
    
         
             
                def convert_dd el, opts
         
     | 
| 
         @@ -457,12 +459,12 @@ module Kramdown; module AsciiDoc 
     | 
|
| 
       457 
459 
     | 
    
         
             
                end
         
     | 
| 
       458 
460 
     | 
    
         | 
| 
       459 
461 
     | 
    
         
             
                def prev_char_wordish? prev_el
         
     | 
| 
       460 
     | 
    
         
            -
                  prev_el && (prev_el.type == :entity || ( 
     | 
| 
      
 462 
     | 
    
         
            +
                  prev_el && (prev_el.type == :entity || (prev_el.type == :text && (WordishRx.match? prev_el.value[-1])))
         
     | 
| 
       461 
463 
     | 
    
         
             
                end
         
     | 
| 
       462 
464 
     | 
    
         | 
| 
       463 
465 
     | 
    
         
             
                def next_char_word? next_el, enclosure
         
     | 
| 
       464 
466 
     | 
    
         
             
                  if next_el.type == :text
         
     | 
| 
       465 
     | 
    
         
            -
                    (next_ch = next_el.value.chr) 
     | 
| 
      
 467 
     | 
    
         
            +
                    (WordRx.match? (next_ch = next_el.value.chr)) || (enclosure == :codespan && next_ch == ?')
         
     | 
| 
       466 
468 
     | 
    
         
             
                  elsif enclosure == :codespan && next_el.type == :smart_quote
         
     | 
| 
       467 
469 
     | 
    
         
             
                    true
         
     | 
| 
       468 
470 
     | 
    
         
             
                  end if next_el
         
     | 
| 
         @@ -484,6 +486,7 @@ module Kramdown; module AsciiDoc 
     | 
|
| 
       484 
486 
     | 
    
         
             
                def escape_replacements text
         
     | 
| 
       485 
487 
     | 
    
         
             
                  # NOTE the replacement \\\\\& inserts a single backslash in front of the matched text
         
     | 
| 
       486 
488 
     | 
    
         
             
                  text = text.gsub InadvertentReplacementsRx, '\\\\\&' if InadvertentReplacementsRx.match? text
         
     | 
| 
      
 489 
     | 
    
         
            +
                  text = text.gsub UriSchemeRx, '\\\\\&' if !@auto_links && (text.include? '://')
         
     | 
| 
       487 
490 
     | 
    
         
             
                  text = text.gsub '^', '{caret}' if (text.include? '^') && text != '^'
         
     | 
| 
       488 
491 
     | 
    
         
             
                  unless text.ascii_only?
         
     | 
| 
       489 
492 
     | 
    
         
             
                    text = (text.gsub SmartApostropheRx, ?').gsub TypographicSymbolRx, TYPOGRAPHIC_SYMBOL_TO_MARKUP
         
     | 
| 
         @@ -10,7 +10,8 @@ module Kramdown; module AsciiDoc 
     | 
|
| 
       10 
10 
     | 
    
         
             
                  @body = []
         
     | 
| 
       11 
11 
     | 
    
         
             
                  @nesting_stack = []
         
     | 
| 
       12 
12 
     | 
    
         
             
                  @block_delimiter = nil
         
     | 
| 
       13 
     | 
    
         
            -
                  @block_separator = []
         
     | 
| 
      
 13 
     | 
    
         
            +
                  @block_separator = ['']
         
     | 
| 
      
 14 
     | 
    
         
            +
                  @list_level = { list: 0, dlist: 0 }
         
     | 
| 
       14 
15 
     | 
    
         
             
                end
         
     | 
| 
       15 
16 
     | 
    
         | 
| 
       16 
17 
     | 
    
         
             
                def doctitle
         
     | 
| 
         @@ -39,37 +40,48 @@ module Kramdown; module AsciiDoc 
     | 
|
| 
       39 
40 
     | 
    
         
             
                end
         
     | 
| 
       40 
41 
     | 
    
         | 
| 
       41 
42 
     | 
    
         
             
                def start_block
         
     | 
| 
       42 
     | 
    
         
            -
                  @body <<  
     | 
| 
      
 43 
     | 
    
         
            +
                  @body << @block_separator[-1] unless empty?
         
     | 
| 
       43 
44 
     | 
    
         
             
                  nil
         
     | 
| 
       44 
45 
     | 
    
         
             
                end
         
     | 
| 
       45 
46 
     | 
    
         | 
| 
       46 
     | 
    
         
            -
                 
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
                  @ 
     | 
| 
       50 
     | 
    
         
            -
                  @ 
     | 
| 
      
 47 
     | 
    
         
            +
                def start_delimited_block delimiter
         
     | 
| 
      
 48 
     | 
    
         
            +
                  @body << (@block_delimiter = delimiter.length == 1 ? delimiter * 4 : delimiter)
         
     | 
| 
      
 49 
     | 
    
         
            +
                  @nesting_stack << [(@body.pop @body.length), @block_delimiter, @block_separator, @list_level]
         
     | 
| 
      
 50 
     | 
    
         
            +
                  @block_separator = ['']
         
     | 
| 
      
 51 
     | 
    
         
            +
                  @list_level = { list: 0, dlist: 0 }
         
     | 
| 
       51 
52 
     | 
    
         
             
                  nil
         
     | 
| 
       52 
53 
     | 
    
         
             
                end
         
     | 
| 
       53 
54 
     | 
    
         | 
| 
       54 
     | 
    
         
            -
                def  
     | 
| 
       55 
     | 
    
         
            -
                  @block_separator.pop
         
     | 
| 
      
 55 
     | 
    
         
            +
                def end_delimited_block
         
     | 
| 
      
 56 
     | 
    
         
            +
                  parent_body, @block_delimiter, @block_separator, @list_level = @nesting_stack.pop
         
     | 
| 
      
 57 
     | 
    
         
            +
                  @body = (parent_body + @body) << @block_delimiter
         
     | 
| 
      
 58 
     | 
    
         
            +
                  @block_delimiter = nil
         
     | 
| 
       56 
59 
     | 
    
         
             
                  nil
         
     | 
| 
       57 
60 
     | 
    
         
             
                end
         
     | 
| 
       58 
61 
     | 
    
         | 
| 
       59 
     | 
    
         
            -
                 
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
                   
     | 
| 
       62 
     | 
    
         
            -
                  @ 
     | 
| 
      
 62 
     | 
    
         
            +
                # Q: perhaps do_in_list that takes a block?
         
     | 
| 
      
 63 
     | 
    
         
            +
                def start_list compound, kin = :list
         
     | 
| 
      
 64 
     | 
    
         
            +
                  # Q: can this be further optimized?
         
     | 
| 
      
 65 
     | 
    
         
            +
                  @body << '' if in_list? ? compound : !empty?
         
     | 
| 
      
 66 
     | 
    
         
            +
                  @block_separator << '+'
         
     | 
| 
      
 67 
     | 
    
         
            +
                  @list_level[kin] += 1
         
     | 
| 
       63 
68 
     | 
    
         
             
                  nil
         
     | 
| 
       64 
69 
     | 
    
         
             
                end
         
     | 
| 
       65 
70 
     | 
    
         | 
| 
       66 
     | 
    
         
            -
                def  
     | 
| 
       67 
     | 
    
         
            -
                   
     | 
| 
       68 
     | 
    
         
            -
                  @ 
     | 
| 
       69 
     | 
    
         
            -
                  @block_delimiter = nil
         
     | 
| 
      
 71 
     | 
    
         
            +
                def end_list kin = :list
         
     | 
| 
      
 72 
     | 
    
         
            +
                  @block_separator.pop
         
     | 
| 
      
 73 
     | 
    
         
            +
                  @list_level[kin] -= 1
         
     | 
| 
       70 
74 
     | 
    
         
             
                  nil
         
     | 
| 
       71 
75 
     | 
    
         
             
                end
         
     | 
| 
       72 
76 
     | 
    
         | 
| 
      
 77 
     | 
    
         
            +
                def list_level kin = :list
         
     | 
| 
      
 78 
     | 
    
         
            +
                  @list_level[kin]
         
     | 
| 
      
 79 
     | 
    
         
            +
                end
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
                def in_list?
         
     | 
| 
      
 82 
     | 
    
         
            +
                  @block_separator[-1] == '+'
         
     | 
| 
      
 83 
     | 
    
         
            +
                end
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
       73 
85 
     | 
    
         
             
                def add_blank_line
         
     | 
| 
       74 
86 
     | 
    
         
             
                  @body << ''
         
     | 
| 
       75 
87 
     | 
    
         
             
                  nil
         
     | 
    
        data/spec/cli_spec.rb
    CHANGED
    
    | 
         @@ -174,6 +174,20 @@ describe Kramdown::AsciiDoc::Cli do 
     | 
|
| 
       174 
174 
     | 
    
         
             
                  (expect $stdout.string).to eql expected
         
     | 
| 
       175 
175 
     | 
    
         
             
                end
         
     | 
| 
       176 
176 
     | 
    
         | 
| 
      
 177 
     | 
    
         
            +
                it 'does not escape bare URLs when --auto-links is used' do
         
     | 
| 
      
 178 
     | 
    
         
            +
                  the_source_file = scenario_file 'a/bare-url.md'
         
     | 
| 
      
 179 
     | 
    
         
            +
                  expected = IO.read scenario_file 'a/bare-url.adoc'
         
     | 
| 
      
 180 
     | 
    
         
            +
                  (expect subject.run %W(-o - --auto-links #{the_source_file})).to eql 0
         
     | 
| 
      
 181 
     | 
    
         
            +
                  (expect $stdout.string).to eql expected
         
     | 
| 
      
 182 
     | 
    
         
            +
                end
         
     | 
| 
      
 183 
     | 
    
         
            +
             
     | 
| 
      
 184 
     | 
    
         
            +
                it 'escapes bare URLs when --no-auto-links is used' do
         
     | 
| 
      
 185 
     | 
    
         
            +
                  the_source_file = scenario_file 'a/no-auto-links.md'
         
     | 
| 
      
 186 
     | 
    
         
            +
                  expected = IO.read scenario_file 'a/no-auto-links.adoc'
         
     | 
| 
      
 187 
     | 
    
         
            +
                  (expect subject.run %W(-o - --no-auto-links #{the_source_file})).to eql 0
         
     | 
| 
      
 188 
     | 
    
         
            +
                  (expect $stdout.string).to eql expected
         
     | 
| 
      
 189 
     | 
    
         
            +
                end
         
     | 
| 
      
 190 
     | 
    
         
            +
             
     | 
| 
       177 
191 
     | 
    
         
             
                it 'shifts headings by offset when --heading-offset is used' do
         
     | 
| 
       178 
192 
     | 
    
         
             
                  the_source_file = scenario_file 'heading/offset.md'
         
     | 
| 
       179 
193 
     | 
    
         
             
                  expected = IO.read scenario_file 'heading/offset.adoc'
         
     | 
| 
         @@ -188,6 +202,25 @@ describe Kramdown::AsciiDoc::Cli do 
     | 
|
| 
       188 
202 
     | 
    
         
             
                  (expect $stdout.string).to eql expected
         
     | 
| 
       189 
203 
     | 
    
         
             
                end
         
     | 
| 
       190 
204 
     | 
    
         | 
| 
      
 205 
     | 
    
         
            +
                it 'adds prefix specified by --auto-id-prefix to any automatically generated section title ID' do
         
     | 
| 
      
 206 
     | 
    
         
            +
                  the_source_file = scenario_file 'heading/auto-ids.md'
         
     | 
| 
      
 207 
     | 
    
         
            +
                  expected = <<~EOS
         
     | 
| 
      
 208 
     | 
    
         
            +
                  [#_heading-1]
         
     | 
| 
      
 209 
     | 
    
         
            +
                  = Heading 1
         
     | 
| 
      
 210 
     | 
    
         
            +
             
     | 
| 
      
 211 
     | 
    
         
            +
                  [#_heading-2]
         
     | 
| 
      
 212 
     | 
    
         
            +
                  == Heading 2
         
     | 
| 
      
 213 
     | 
    
         
            +
             
     | 
| 
      
 214 
     | 
    
         
            +
                  [#_heading-3]
         
     | 
| 
      
 215 
     | 
    
         
            +
                  === Heading 3
         
     | 
| 
      
 216 
     | 
    
         
            +
             
     | 
| 
      
 217 
     | 
    
         
            +
                  [#_back-to-heading-2]
         
     | 
| 
      
 218 
     | 
    
         
            +
                  == Back to Heading 2
         
     | 
| 
      
 219 
     | 
    
         
            +
                  EOS
         
     | 
| 
      
 220 
     | 
    
         
            +
                  (expect subject.run %W(-o - --auto-id-prefix=_ --auto-ids #{the_source_file})).to eql 0
         
     | 
| 
      
 221 
     | 
    
         
            +
                  (expect $stdout.string).to eql expected
         
     | 
| 
      
 222 
     | 
    
         
            +
                end
         
     | 
| 
      
 223 
     | 
    
         
            +
             
     | 
| 
       191 
224 
     | 
    
         
             
                it 'adds specified attributes to document header' do
         
     | 
| 
       192 
225 
     | 
    
         
             
                  the_source_file = scenario_file 'root/header-and-body.md'
         
     | 
| 
       193 
226 
     | 
    
         
             
                  (expect subject.run %W(-o - -a idprefix -a idseparator=- #{the_source_file})).to eql 0
         
     | 
| 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            :auto_links: false
         
     | 
| 
         @@ -11,3 +11,5 @@ In AsciiDoc, `+{name}+` is the syntax for an attribute reference. 
     | 
|
| 
       11 
11 
     | 
    
         
             
            `pass:c[{lang}++]` is simply better than `+{lang}+`.
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
            Type `+©+` or `+(C)+` to enter a copyright symbol.
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            The admin console is available at `+http://localhost:8080+` or `http://[::1]:8080` (IPv6).
         
     | 
| 
         @@ -19,6 +19,18 @@ This is equivalent to the following command: 
     | 
|
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
             $ git init project
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
      
 22 
     | 
    
         
            +
            * Create boilerplate files
         
     | 
| 
      
 23 
     | 
    
         
            +
            +
         
     | 
| 
      
 24 
     | 
    
         
            +
            |===
         
     | 
| 
      
 25 
     | 
    
         
            +
            | Filename | Purpose
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            | README.adoc
         
     | 
| 
      
 28 
     | 
    
         
            +
            | Introduces the project
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            | .gitignore
         
     | 
| 
      
 31 
     | 
    
         
            +
            | Ignores non-versioned files
         
     | 
| 
      
 32 
     | 
    
         
            +
            |===
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
       22 
34 
     | 
    
         
             
            * Create source files
         
     | 
| 
       23 
35 
     | 
    
         
             
            +
         
     | 
| 
       24 
36 
     | 
    
         
             
            We can't help you here.
         
     | 
| 
         @@ -17,6 +17,13 @@ 
     | 
|
| 
       17 
17 
     | 
    
         | 
| 
       18 
18 
     | 
    
         
             
                  $ git init project
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
      
 20 
     | 
    
         
            +
            * Create boilerplate files
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              | Filename    | Purpose                     |
         
     | 
| 
      
 23 
     | 
    
         
            +
              | ----------- | --------------------------- |
         
     | 
| 
      
 24 
     | 
    
         
            +
              | README.adoc | Introduces the project      |
         
     | 
| 
      
 25 
     | 
    
         
            +
              | .gitignore  | Ignores non-versioned files |
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
       20 
27 
     | 
    
         
             
            * Create source files
         
     | 
| 
       21 
28 
     | 
    
         | 
| 
       22 
29 
     | 
    
         
             
              We can't help you here.
         
     | 
| 
         @@ -19,6 +19,18 @@ This is equivalent to the following command: 
     | 
|
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
             $ git init project
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
      
 22 
     | 
    
         
            +
            * Create boilerplate files
         
     | 
| 
      
 23 
     | 
    
         
            +
            +
         
     | 
| 
      
 24 
     | 
    
         
            +
            |===
         
     | 
| 
      
 25 
     | 
    
         
            +
            | Filename | Purpose
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            | README.adoc
         
     | 
| 
      
 28 
     | 
    
         
            +
            | Introduces the project
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            | .gitignore
         
     | 
| 
      
 31 
     | 
    
         
            +
            | Ignores non-versioned files
         
     | 
| 
      
 32 
     | 
    
         
            +
            |===
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
       22 
34 
     | 
    
         
             
            * Create source files
         
     | 
| 
       23 
35 
     | 
    
         
             
            +
         
     | 
| 
       24 
36 
     | 
    
         
             
            We can't help you here.
         
     | 
| 
         @@ -12,6 +12,12 @@ 
     | 
|
| 
       12 
12 
     | 
    
         
             
              This is equivalent to the following command:
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
                  $ git init project
         
     | 
| 
      
 15 
     | 
    
         
            +
            * Create boilerplate files
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              | Filename    | Purpose                     |
         
     | 
| 
      
 18 
     | 
    
         
            +
              | ----------- | --------------------------- |
         
     | 
| 
      
 19 
     | 
    
         
            +
              | README.adoc | Introduces the project      |
         
     | 
| 
      
 20 
     | 
    
         
            +
              | .gitignore  | Ignores non-versioned files |
         
     | 
| 
       15 
21 
     | 
    
         
             
            * Create source files
         
     | 
| 
       16 
22 
     | 
    
         | 
| 
       17 
23 
     | 
    
         
             
              We can't help you here.
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: kramdown-asciidoc
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.0.0.alpha. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.0.0.alpha.10
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Dan Allen
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2018-07- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2018-07-17 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: kramdown
         
     | 
| 
         @@ -104,6 +104,9 @@ files: 
     | 
|
| 
       104 
104 
     | 
    
         
             
            - spec/scenarios/a/internal.md
         
     | 
| 
       105 
105 
     | 
    
         
             
            - spec/scenarios/a/local.adoc
         
     | 
| 
       106 
106 
     | 
    
         
             
            - spec/scenarios/a/local.md
         
     | 
| 
      
 107 
     | 
    
         
            +
            - spec/scenarios/a/no-auto-links.adoc
         
     | 
| 
      
 108 
     | 
    
         
            +
            - spec/scenarios/a/no-auto-links.md
         
     | 
| 
      
 109 
     | 
    
         
            +
            - spec/scenarios/a/no-auto-links.opts
         
     | 
| 
       107 
110 
     | 
    
         
             
            - spec/scenarios/a/url-matches-text.adoc
         
     | 
| 
       108 
111 
     | 
    
         
             
            - spec/scenarios/a/url-matches-text.md
         
     | 
| 
       109 
112 
     | 
    
         
             
            - spec/scenarios/a/url-with-text.adoc
         
     | 
| 
         @@ -168,6 +171,8 @@ files: 
     | 
|
| 
       168 
171 
     | 
    
         
             
            - spec/scenarios/dl/compound.md
         
     | 
| 
       169 
172 
     | 
    
         
             
            - spec/scenarios/dl/empty-dd.adoc
         
     | 
| 
       170 
173 
     | 
    
         
             
            - spec/scenarios/dl/empty-dd.md
         
     | 
| 
      
 174 
     | 
    
         
            +
            - spec/scenarios/dl/nested-bookended.adoc
         
     | 
| 
      
 175 
     | 
    
         
            +
            - spec/scenarios/dl/nested-bookended.md
         
     | 
| 
       171 
176 
     | 
    
         
             
            - spec/scenarios/dl/nested-mixed.adoc
         
     | 
| 
       172 
177 
     | 
    
         
             
            - spec/scenarios/dl/nested-mixed.md
         
     | 
| 
       173 
178 
     | 
    
         
             
            - spec/scenarios/dl/nested.adoc
         
     | 
| 
         @@ -384,6 +389,10 @@ files: 
     | 
|
| 
       384 
389 
     | 
    
         
             
            - spec/scenarios/ul/compound.md
         
     | 
| 
       385 
390 
     | 
    
         
             
            - spec/scenarios/ul/formatted.adoc
         
     | 
| 
       386 
391 
     | 
    
         
             
            - spec/scenarios/ul/formatted.md
         
     | 
| 
      
 392 
     | 
    
         
            +
            - spec/scenarios/ul/inside-delimited-block.adoc
         
     | 
| 
      
 393 
     | 
    
         
            +
            - spec/scenarios/ul/inside-delimited-block.md
         
     | 
| 
      
 394 
     | 
    
         
            +
            - spec/scenarios/ul/nested-bookended.adoc
         
     | 
| 
      
 395 
     | 
    
         
            +
            - spec/scenarios/ul/nested-bookended.md
         
     | 
| 
       387 
396 
     | 
    
         
             
            - spec/scenarios/ul/nested-separated.adoc
         
     | 
| 
       388 
397 
     | 
    
         
             
            - spec/scenarios/ul/nested-separated.md
         
     | 
| 
       389 
398 
     | 
    
         
             
            - spec/scenarios/ul/nested.adoc
         
     | 
| 
         @@ -475,6 +484,9 @@ test_files: 
     | 
|
| 
       475 
484 
     | 
    
         
             
            - spec/scenarios/a/internal.md
         
     | 
| 
       476 
485 
     | 
    
         
             
            - spec/scenarios/a/local.adoc
         
     | 
| 
       477 
486 
     | 
    
         
             
            - spec/scenarios/a/local.md
         
     | 
| 
      
 487 
     | 
    
         
            +
            - spec/scenarios/a/no-auto-links.adoc
         
     | 
| 
      
 488 
     | 
    
         
            +
            - spec/scenarios/a/no-auto-links.md
         
     | 
| 
      
 489 
     | 
    
         
            +
            - spec/scenarios/a/no-auto-links.opts
         
     | 
| 
       478 
490 
     | 
    
         
             
            - spec/scenarios/a/url-matches-text.adoc
         
     | 
| 
       479 
491 
     | 
    
         
             
            - spec/scenarios/a/url-matches-text.md
         
     | 
| 
       480 
492 
     | 
    
         
             
            - spec/scenarios/a/url-with-text.adoc
         
     | 
| 
         @@ -539,6 +551,8 @@ test_files: 
     | 
|
| 
       539 
551 
     | 
    
         
             
            - spec/scenarios/dl/compound.md
         
     | 
| 
       540 
552 
     | 
    
         
             
            - spec/scenarios/dl/empty-dd.adoc
         
     | 
| 
       541 
553 
     | 
    
         
             
            - spec/scenarios/dl/empty-dd.md
         
     | 
| 
      
 554 
     | 
    
         
            +
            - spec/scenarios/dl/nested-bookended.adoc
         
     | 
| 
      
 555 
     | 
    
         
            +
            - spec/scenarios/dl/nested-bookended.md
         
     | 
| 
       542 
556 
     | 
    
         
             
            - spec/scenarios/dl/nested-mixed.adoc
         
     | 
| 
       543 
557 
     | 
    
         
             
            - spec/scenarios/dl/nested-mixed.md
         
     | 
| 
       544 
558 
     | 
    
         
             
            - spec/scenarios/dl/nested.adoc
         
     | 
| 
         @@ -755,6 +769,10 @@ test_files: 
     | 
|
| 
       755 
769 
     | 
    
         
             
            - spec/scenarios/ul/compound.md
         
     | 
| 
       756 
770 
     | 
    
         
             
            - spec/scenarios/ul/formatted.adoc
         
     | 
| 
       757 
771 
     | 
    
         
             
            - spec/scenarios/ul/formatted.md
         
     | 
| 
      
 772 
     | 
    
         
            +
            - spec/scenarios/ul/inside-delimited-block.adoc
         
     | 
| 
      
 773 
     | 
    
         
            +
            - spec/scenarios/ul/inside-delimited-block.md
         
     | 
| 
      
 774 
     | 
    
         
            +
            - spec/scenarios/ul/nested-bookended.adoc
         
     | 
| 
      
 775 
     | 
    
         
            +
            - spec/scenarios/ul/nested-bookended.md
         
     | 
| 
       758 
776 
     | 
    
         
             
            - spec/scenarios/ul/nested-separated.adoc
         
     | 
| 
       759 
777 
     | 
    
         
             
            - spec/scenarios/ul/nested-separated.md
         
     | 
| 
       760 
778 
     | 
    
         
             
            - spec/scenarios/ul/nested.adoc
         
     |