kramdown-asciidoc 1.0.0.alpha.5 → 1.0.0.alpha.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 047f74e6cf78d83f0044f72410f8df7e5338800cf1f5796de4c919a0ff79ed36
4
- data.tar.gz: ab08640754fff574b51a5ef5f0c400b493ff17f31d54163a33f4af5e115a64ab
3
+ metadata.gz: d7e7b3ea076bc3a4367cee05e190fd4fb7aa867c941786b122ac5696a0f8869e
4
+ data.tar.gz: 8a964360802076fdd8ccd9aa569c810fd90843b84a3394326e7b6b31d8e76f46
5
5
  SHA512:
6
- metadata.gz: 3170271705bb355ad77d7aa262724f07e789947b4eaf4e0c3ee09fbf48409cce910c445011f825be92c53f90e30b17d9d2562e9c627a4b0b86ca764d05748331
7
- data.tar.gz: 6412723030a019d5c039206c5f4ada159b4c6c75f728648a7161ad989cb9990c938e56be6e48986b5c28e80cbff738b522d8c82248de1a6b7564eca4307e9652
6
+ metadata.gz: 0fd80955421722cfa21688637e06d9d94377ab46679df75958ae8e61b6ba4eb80784beea8a90cf8f1ed415389a95b316a5fc8b349a608edb406704123db92c37
7
+ data.tar.gz: 284fb8dfbd153aca87bdf10687c24e80995aee0e135709a2aca6b4b22fc4a562e36472c83cd54a7c2d17e6f53a0c7e0fff8056872a29a8218c844078c28fb6af
@@ -5,6 +5,22 @@
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.6 (2018-06-26) - @mojavelinux
9
+
10
+ === Added
11
+
12
+ * added options and usage to CLI (#2)
13
+ * ensure directory of output file exists
14
+ * add option to enable automatic generation of IDs for section titles
15
+
16
+ === Changed
17
+
18
+ * handle case when dd is nil
19
+ * handle case when dd has no primary text
20
+ * handle case when li has no primary text
21
+ * use writer to track list nesting level
22
+ * fix warnings
23
+
8
24
  == 1.0.0.alpha.5 (2018-06-19) - @mojavelinux
9
25
 
10
26
  === Added
@@ -1,6 +1,6 @@
1
1
  = {project-name} (Markdown to AsciiDoc)
2
2
  Dan Allen <https://github.com/mojavelinux>
3
- v1.0.0.alpha.5, 2018-06-19
3
+ v1.0.0.alpha.6, 2018-06-26
4
4
  // Aliases:
5
5
  :project-name: Kramdown AsciiDoc
6
6
  :project-handle: kramdown-asciidoc
@@ -64,17 +64,26 @@ TIP: To test a feature that's not yet released, you can <<Development,run the ap
64
64
 
65
65
  == Usage
66
66
 
67
- To convert a Markdown file to AsciiDoc using {project-name}, run the `kramdoc` command as follows:
67
+ To convert a Markdown file to AsciiDoc using {project-name}, pass the name of the file to the `kramdoc` command as follows:
68
68
 
69
69
  $ kramdoc sample.md
70
70
 
71
- The `kramdoc` command automatically creates the output file [.path]_sample.adoc_ in the same folder as the input file.
72
- This path is calculated by removing the Markdown file extension, `.md`, and adding the AsciiDoc file extension, `.adoc`.
71
+ By default, the `kramdoc` command automatically creates the output file [.path]_sample.adoc_ in the same folder as the input file.
72
+ This path is calculated by removing the Markdown file extension, `.md`, and replacing it with the AsciiDoc file extension, `.adoc`.
73
73
 
74
74
  NOTE: The converter assumes the input uses the GitHub-flavor Markdown (GFM) syntax.
75
75
 
76
- The `kramdoc` command does not currently support any options other than the input file.
77
- Support for additional options is planned.
76
+ If you want to direct the output to a different file, pass the name of that file to the `kramdoc` command using the `-o` option as follows:
77
+
78
+ $ kramdoc -o result.adoc sample.md
79
+
80
+ To direct the output to the console (i.e., STDOUT) instead of a file, use the special value `-` as follows:
81
+
82
+ $ kramdoc -o - sample.md
83
+
84
+ To see all the options the `kramdoc` command accepts, pass the `-h` option to the `kramdoc` command as follows:
85
+
86
+ $ kramdoc -h
78
87
 
79
88
  == Development
80
89
 
@@ -6,19 +6,6 @@ else
6
6
  require 'kramdown-asciidoc'
7
7
  end
8
8
 
9
- infile = ARGV.first
10
- unless infile
11
- warn 'Please specify a Markdown file to convert.'
12
- exit 1
13
- end
14
- outfile = %(#{infile.slice 0, infile.length - (File.extname infile).length}.adoc)
15
- input = (IO.read infile, mode: 'r:UTF-8', newline: :universal).rstrip
16
- input = input.slice 1, input.length while input.start_with? ?\n
17
- attributes = {}
18
- input = Kramdown::AsciiDoc.extract_front_matter input, attributes
19
- input = Kramdown::AsciiDoc.replace_toc input, attributes
20
- # FIXME allow input type to be specified (Kramdown, GFM, etc)
21
- doc = Kramdown::Document.new input, (Kramdown::AsciiDoc::DEFAULT_PARSER_OPTS.merge attributes: attributes)
22
- # FIXME provide option to write to different file or stdout
23
- IO.write outfile, doc.to_asciidoc
24
- exit 0
9
+ require 'kramdown-asciidoc/cli'
10
+
11
+ exit Kramdown::AsciiDoc::Cli.run
@@ -0,0 +1,107 @@
1
+ require 'optparse'
2
+ require 'pathname'
3
+
4
+ module Kramdown; module AsciiDoc
5
+ class Cli
6
+ def parse args
7
+ options = {
8
+ attributes: {},
9
+ input: 'GFM',
10
+ html_to_native: true,
11
+ }
12
+
13
+ opt_parser = ::OptionParser.new do |opts|
14
+ opts.program_name = 'kramdoc'
15
+ opts.banner = <<~EOS
16
+ Usage: #{opts.program_name} [OPTION]... FILE...
17
+
18
+ Converts Markdown to AsciiDoc.
19
+
20
+ EOS
21
+
22
+ opts.on '-o FILE', '--output=FILE', 'Set the output filename or stream' do |file|
23
+ options[:output] = file
24
+ end
25
+
26
+ opts.on '--format=GFM|kramdown|markdown', %w(kramdown markdown GFM), 'Set the flavor of Markdown to parse (default: GFM)' do |format|
27
+ options[:input] = format
28
+ end
29
+
30
+ opts.on '-a KEY[=VALUE]', '--attribute=KEY[=VALUE]', 'Set an attribute in the document header (accepts: key, key!, or key=value' do |attr|
31
+ key, val = attr.split '=', 2
32
+ val = '' unless val
33
+ options[:attributes][key] = val
34
+ end
35
+
36
+ opts.on '--heading-offset=NUMBER', 'Shift the heading level by the specified number', ::Integer do |offset|
37
+ options[:heading_offset] = offset
38
+ end
39
+
40
+ opts.on '--[no-]html-to-native', 'Set whether to passthrough HTML or convert it to AsciiDoc syntax where possible (default: true)' do |html_to_native|
41
+ options[:html_to_native] = html_to_native
42
+ end
43
+
44
+ opts.on '--auto-ids', 'Set whether to auto-generate IDs for section titles' do |auto_ids|
45
+ options[:auto_ids] = auto_ids
46
+ end
47
+
48
+ opts.on '-h', '--help', 'Display this help text and exit' do
49
+ $stdout.puts opts.help
50
+ return 0
51
+ end
52
+
53
+ opts.on '-v', '--version', %(Display version information and exit) do
54
+ $stdout.puts %(#{opts.program_name} #{VERSION})
55
+ return 0
56
+ end
57
+ end
58
+
59
+ args = opt_parser.parse args
60
+
61
+ if args.empty?
62
+ opt_parser.warn 'Please specify a Markdown file to convert.'
63
+ $stdout.puts opt_parser.help
64
+ return 1
65
+ end
66
+
67
+ if args.size == 1
68
+ options[:source] = args[0]
69
+ [0, options]
70
+ else
71
+ opt_parser.warn %(extra arguments detected (unparsed arguments: #{(args.drop 1).join ' '}))
72
+ $stdout.puts opt_parser.help
73
+ [1, options]
74
+ end
75
+ rescue ::OptionParser::InvalidOption
76
+ $stderr.puts %(#{opt_parser.program_name}: #{$!.message})
77
+ $stdout.puts opt_parser.help
78
+ return 1
79
+ end
80
+
81
+ def self.run args = ARGV
82
+ code, options = new.parse args
83
+ return code unless code == 0 && options
84
+ if (source_file = options.delete :source) == '-'
85
+ markdown = $stdin.read.rstrip
86
+ else
87
+ markdown = (::IO.read source_file, mode: 'r:UTF-8', newline: :universal).rstrip
88
+ end
89
+ if (output_file = options.delete :output)
90
+ (Pathname output_file).dirname.mkpath
91
+ else
92
+ output_file = ((Pathname source_file).sub_ext '.adoc').to_s
93
+ end
94
+ markdown = markdown.slice 1, markdown.length while markdown.start_with? ?\n
95
+ attributes = options[:attributes]
96
+ markdown = ::Kramdown::AsciiDoc.extract_front_matter markdown, attributes
97
+ markdown = ::Kramdown::AsciiDoc.replace_toc markdown, attributes
98
+ doc = ::Kramdown::Document.new markdown, (::Kramdown::AsciiDoc::DEFAULT_PARSER_OPTS.merge options)
99
+ if output_file == '-'
100
+ $stdout.puts doc.to_asciidoc
101
+ else
102
+ ::IO.write output_file, doc.to_asciidoc
103
+ end
104
+ 0
105
+ end
106
+ end
107
+ end; end
@@ -98,11 +98,12 @@ module Kramdown; module AsciiDoc
98
98
  super
99
99
  @attributes = opts[:attributes] || {}
100
100
  @imagesdir = (@attributes.delete 'implicit-imagesdir') || @attributes['imagesdir']
101
+ @heading_offset = opts[:heading_offset] || 0
101
102
  @current_heading_level = nil
102
103
  end
103
104
 
104
105
  def convert el, opts = {}
105
- send %(convert_#{el.type}), el, opts
106
+ send %(convert_#{el.type}), el, opts if el
106
107
  end
107
108
 
108
109
  def convert_root el, opts
@@ -118,7 +119,7 @@ module Kramdown; module AsciiDoc
118
119
 
119
120
  def convert_heading el, opts
120
121
  (writer = opts[:writer]).start_block
121
- level = el.options[:level]
122
+ level = el.options[:level] + @heading_offset
122
123
  style = []
123
124
  # Q: should writer track last heading level?
124
125
  if (discrete = @current_heading_level && level > @current_heading_level + 1)
@@ -280,13 +281,12 @@ module Kramdown; module AsciiDoc
280
281
  end
281
282
 
282
283
  def convert_ul el, opts
283
- nested = (parent = opts[:parent]) && (parent.type == :li || parent.type == :dd)
284
- (writer = opts[:writer]).start_list nested && parent.type != :dd && !parent.options[:compound]
284
+ (writer = opts[:writer]).start_list (parent = opts[:parent]).type != :dd && !parent.options[:compound]
285
285
  level_opt = el.type == :dl ? :dlist_level : :list_level
286
- level = opts[level_opt] ? (opts[level_opt] += 1) : (opts[level_opt] = 1)
286
+ opts[level_opt] = (opts[level_opt] || 0) + 1
287
287
  traverse el, opts
288
288
  opts.delete level_opt if (opts[level_opt] -= 1) < 1
289
- writer.end_list nested
289
+ writer.end_list
290
290
  end
291
291
 
292
292
  alias convert_ol convert_ul
@@ -297,10 +297,15 @@ module Kramdown; module AsciiDoc
297
297
  writer.add_blank_line if (prev = opts[:prev]) && prev.options[:compound]
298
298
  marker = opts[:parent].type == :ol ? '.' : '*'
299
299
  indent = (level = opts[:list_level]) - 1
300
- primary, remaining = [(children = el.children.dup).shift, children]
301
- lines = compose_text [primary], parent: el, strip: true, split: true
302
- lines.unshift %(#{indent > 0 ? ' ' * indent : ''}#{marker * level} #{lines.shift})
303
- writer.add_lines lines
300
+ if (children = el.children)[0].type == :p
301
+ primary, remaining = [(children = children.dup).shift, children]
302
+ primary_lines = compose_text [primary], parent: el, strip: true, split: true
303
+ else
304
+ remaining = children
305
+ primary_lines = ['{blank}']
306
+ end
307
+ primary_lines.unshift %(#{indent > 0 ? ' ' * indent : ''}#{marker * level} #{primary_lines.shift})
308
+ writer.add_lines primary_lines
304
309
  unless remaining.empty?
305
310
  next_node = remaining.find {|n| n.type != :blank }
306
311
  el.options[:compound] = true if next_node && (BLOCK_TYPES.include? next_node.type)
@@ -317,13 +322,17 @@ module Kramdown; module AsciiDoc
317
322
  end
318
323
 
319
324
  def convert_dd el, opts
320
- primary, remaining = [(children = el.children.dup).shift, children]
321
- primary_lines = compose_text [primary], parent: el, strip: true, split: true
322
- if primary_lines.size == 1
323
- opts[:writer].append %( #{primary_lines[0]})
325
+ if el.options[:first_as_para] == false
326
+ remaining = el.children
324
327
  else
325
- el.options[:compound] = true
326
- opts[:writer].add_lines primary_lines
328
+ remaining = (children = el.children).drop 1
329
+ primary_lines = compose_text [children[0]], parent: el, strip: true, split: true
330
+ if primary_lines.size == 1
331
+ opts[:writer].append %( #{primary_lines[0]})
332
+ else
333
+ el.options[:compound] = true
334
+ opts[:writer].add_lines primary_lines
335
+ end
327
336
  end
328
337
  unless remaining.empty?
329
338
  next_node = remaining.find {|n| n.type != :blank }
@@ -1,3 +1,3 @@
1
1
  module Kramdown; module AsciiDoc
2
- VERSION = '1.0.0.alpha.5'
2
+ VERSION = '1.0.0.alpha.6'
3
3
  end; end
@@ -10,7 +10,7 @@ module Kramdown; module AsciiDoc
10
10
  @body = []
11
11
  @nesting_stack = []
12
12
  @block_delimiter = nil
13
- @block_separator = ''
13
+ @block_separator = []
14
14
  end
15
15
 
16
16
  def doctitle
@@ -39,27 +39,27 @@ module Kramdown; module AsciiDoc
39
39
  end
40
40
 
41
41
  def start_block
42
- @body << @block_separator unless empty?
42
+ @body << (@block_separator.last || '') unless empty?
43
43
  nil
44
44
  end
45
45
 
46
46
  # Q: perhaps in_list that takes a block?
47
47
  # Q: should we keep stack of list depth?
48
- def start_list compound_nested = false
49
- @body << '' unless compound_nested || empty?
50
- @block_separator = '+'
48
+ def start_list compound = false
49
+ @body << '' unless (compound && @block_separator.last == '+') || empty?
50
+ @block_separator << '+'
51
51
  nil
52
52
  end
53
53
 
54
- def end_list nested = false
55
- @block_separator = '' unless nested
54
+ def end_list
55
+ @block_separator.pop
56
56
  nil
57
57
  end
58
58
 
59
59
  def start_delimited_block delimiter
60
60
  @body << (@block_delimiter = delimiter.length == 1 ? delimiter * 4 : delimiter)
61
61
  @nesting_stack << [(@body.pop @body.length), @block_delimiter, @block_separator]
62
- @block_separator = ''
62
+ @block_separator = []
63
63
  nil
64
64
  end
65
65
 
@@ -0,0 +1,149 @@
1
+ require_relative 'spec_helper'
2
+ require 'kramdown-asciidoc/cli'
3
+ require 'stringio'
4
+
5
+ describe Kramdown::AsciiDoc::Cli do
6
+ before :each do
7
+ @old_stdout, $stdout = $stdout, StringIO.new
8
+ @old_stderr, $stderr = $stderr, StringIO.new
9
+ end
10
+
11
+ after :each do
12
+ $stdout, $stderr = @old_stdout, @old_stderr
13
+ end
14
+
15
+ context 'option flags' do
16
+ it 'returns non-zero exit status and displays usage when no arguments are given' do
17
+ expected = 'kramdoc: Please specify a Markdown file to convert.'
18
+ (expect Kramdown::AsciiDoc::Cli.run []).to eql 1
19
+ (expect $stderr.string.chomp).to eql expected
20
+ (expect $stdout.string.chomp).to start_with 'Usage: kramdoc'
21
+ end
22
+
23
+ it 'returns non-zero exit status and displays usage when more than one argument is given' do
24
+ expected = 'kramdoc: extra arguments detected (unparsed arguments: bar.md)'
25
+ (expect Kramdown::AsciiDoc::Cli.run %w(foo.md bar.md)).to eql 1
26
+ (expect $stderr.string.chomp).to eql expected
27
+ (expect $stdout.string.chomp).to start_with 'Usage: kramdoc'
28
+ end
29
+
30
+ it 'returns non-zero exit status when invalid argument is given' do
31
+ (expect Kramdown::AsciiDoc::Cli.run %w(--invalid-option)).to eql 1
32
+ (expect $stderr.string.chomp).to eql 'kramdoc: invalid option: --invalid-option'
33
+ (expect $stdout.string.chomp).to start_with 'Usage: kramdoc'
34
+ end
35
+
36
+ it 'displays version when -v flag is used' do
37
+ (expect Kramdown::AsciiDoc::Cli.run %w(-v)).to eql 0
38
+ (expect $stdout.string.chomp).to eql %(kramdoc #{Kramdown::AsciiDoc::VERSION})
39
+ end
40
+
41
+ it 'displays help when -h flag is used' do
42
+ (expect Kramdown::AsciiDoc::Cli.run %w(-h)).to eql 0
43
+ (expect $stdout.string.chomp).to start_with 'Usage: kramdoc'
44
+ end
45
+
46
+ it 'computes output file from input file' do
47
+ the_source_file = output_file 'implicit-output.md'
48
+ the_output_file = output_file 'implicit-output.adoc'
49
+ IO.write the_source_file, 'This is just a test.'
50
+ (expect Kramdown::AsciiDoc::Cli.run %W(#{the_source_file})).to eql 0
51
+ (expect (IO.read the_output_file).chomp).to eql 'This is just a test.'
52
+ end
53
+
54
+ it 'writes output to file specified by the -o option' do
55
+ the_source_file = output_file 'explicit-output.md'
56
+ the_output_file = output_file 'my-explicit-output.adoc'
57
+ IO.write the_source_file, 'This is only a test.'
58
+ (expect Kramdown::AsciiDoc::Cli.run %W(-o #{the_output_file} #{the_source_file})).to eql 0
59
+ (expect (IO.read the_output_file).chomp).to eql 'This is only a test.'
60
+ end
61
+
62
+ it 'ensures directory of explicit output file exists before writing' do
63
+ the_source_file = output_file 'ensure-output-dir.md'
64
+ the_output_file = output_file 'path/to/output/file.adoc'
65
+ IO.write the_source_file, 'Everything is going to be fine.'
66
+ (expect Kramdown::AsciiDoc::Cli.run %W(-o #{the_output_file} #{the_source_file})).to eql 0
67
+ (expect (IO.read the_output_file).chomp).to eql 'Everything is going to be fine.'
68
+ end
69
+
70
+ it 'writes output to stdout when -o option equals -' do
71
+ the_source_file = scenario_file 'p/single-line.md'
72
+ (expect Kramdown::AsciiDoc::Cli.run %W(-o - #{the_source_file})).to eql 0
73
+ (expect $stdout.string.chomp).to eql 'A paragraph that consists of a single line.'
74
+ end
75
+
76
+ it 'reads input from stdin when argument is -' do
77
+ old_stdin, $stdin = $stdin, StringIO.new
78
+ begin
79
+ $stdin.puts '- list item'
80
+ $stdin.rewind
81
+ (expect Kramdown::AsciiDoc::Cli.run %W(-o - -)).to eql 0
82
+ (expect $stdout.string.chomp).to eql '* list item'
83
+ ensure
84
+ $stdin = old_stdin
85
+ end
86
+ end
87
+
88
+ it 'removes leading blank lines and trailing whitespace from source' do
89
+ the_source_file = output_file 'leading-trailing-space.md'
90
+ IO.write the_source_file, %(\n\n\n\n# Heading\n\ncontent. \n\n)
91
+ (expect Kramdown::AsciiDoc::Cli.run %W(-o - #{the_source_file})).to eql 0
92
+ (expect $stdout.string.chomp).to eql %(= Heading\n\ncontent.)
93
+ end
94
+
95
+ it 'reads Markdown source using specified format' do
96
+ the_source_file = output_file 'format-markdown.md'
97
+ IO.write the_source_file, '#Heading'
98
+ (expect Kramdown::AsciiDoc::Cli.run %W(-o - --format=markdown #{the_source_file})).to eql 0
99
+ (expect $stdout.string.chomp).to eql '= Heading'
100
+ end
101
+
102
+ it 'shifts headings by offset when --heading-offset is used' do
103
+ the_source_file = scenario_file 'heading/offset.md'
104
+ expected = IO.read scenario_file 'heading/offset.adoc'
105
+ (expect Kramdown::AsciiDoc::Cli.run %W(-o - --heading-offset=-1 #{the_source_file})).to eql 0
106
+ (expect $stdout.string).to eql expected
107
+ end
108
+
109
+ it 'automatically generates IDs for section titles when --auto-ids is used' do
110
+ the_source_file = scenario_file 'heading/auto-ids.md'
111
+ expected = IO.read scenario_file 'heading/auto-ids.adoc'
112
+ (expect Kramdown::AsciiDoc::Cli.run %W(-o - --auto-ids #{the_source_file})).to eql 0
113
+ (expect $stdout.string).to eql expected
114
+ end
115
+
116
+ it 'adds specified attributes to document header' do
117
+ the_source_file = scenario_file 'root/header-and-body.md'
118
+ (expect Kramdown::AsciiDoc::Cli.run %W(-o - -a idprefix -a idseparator=- #{the_source_file})).to eql 0
119
+ expected = <<~EOS
120
+ = Document Title
121
+ :idprefix:
122
+ :idseparator: -
123
+
124
+ Body content.
125
+ EOS
126
+ (expect $stdout.string).to eql expected
127
+ end
128
+
129
+ it 'passes through HTML when --no-html-to-native flag is used' do
130
+ the_source_file = scenario_file 'html_element/native.md'
131
+ (expect Kramdown::AsciiDoc::Cli.run %W(-o - --no-html-to-native #{the_source_file})).to eql 0
132
+ expected = <<~EOS
133
+ +++<p>++++++<strong>+++strong emphasis (aka bold)+++</strong>+++ +++<em>+++emphasis (aka italic)+++</em>+++ +++<code>+++monospace+++</code>++++++</p>+++
134
+ EOS
135
+ (expect $stdout.string).to eql expected
136
+ end
137
+
138
+ it 'reads arguments from ARGV by default' do
139
+ old_ARGV = ARGV.dup
140
+ ARGV.replace %w(-v)
141
+ begin
142
+ (expect Kramdown::AsciiDoc::Cli.run).to eql 0
143
+ (expect $stdout.string.chomp).to eql %(kramdoc #{Kramdown::AsciiDoc::VERSION})
144
+ ensure
145
+ ARGV.replace old_ARGV
146
+ end
147
+ end
148
+ end
149
+ end
@@ -4,7 +4,7 @@ require 'yaml'
4
4
  describe 'integration scenario' do
5
5
  let(:doc) { Kramdown::Document.new input, (Kramdown::AsciiDoc::DEFAULT_PARSER_OPTS.merge extra_options) }
6
6
 
7
- Dir.chdir File.absolute_path 'scenarios', __dir__ do
7
+ Dir.chdir scenarios_dir do
8
8
  (Dir.glob '**/*.md').each do |input_filename|
9
9
  input_stem = input_filename.slice 0, input_filename.length - 3
10
10
  scenario_name = input_stem.gsub '/', '::'
@@ -0,0 +1,16 @@
1
+ secrets::
2
+
3
+ . password
4
+ . token
5
+ . private key
6
+
7
+ create a secret::
8
+
9
+ $ echo -n '1234567890' | base64
10
+ MTIzNDU2Nzg5MA==
11
+
12
+ Markdown::
13
+ +
14
+ ____
15
+ Which flavor?
16
+ ____
@@ -0,0 +1,13 @@
1
+ secrets
2
+ : 1. password
3
+ 2. token
4
+ 3. private key
5
+
6
+ create a secret
7
+ : ```
8
+ $ echo -n '1234567890' | base64
9
+ MTIzNDU2Nzg5MA==
10
+ ```
11
+
12
+ Markdown
13
+ : > Which flavor?
@@ -0,0 +1,3 @@
1
+ key::
2
+
3
+ next paragraph
@@ -0,0 +1,4 @@
1
+ key
2
+ :
3
+
4
+ next paragraph
@@ -0,0 +1,11 @@
1
+ [#heading-1]
2
+ = Heading 1
3
+
4
+ [#heading-2]
5
+ == Heading 2
6
+
7
+ [#heading-3]
8
+ === Heading 3
9
+
10
+ [#back-to-heading-2]
11
+ == Back to Heading 2
@@ -0,0 +1,7 @@
1
+ # Heading 1
2
+
3
+ ## Heading 2
4
+
5
+ ### Heading 3
6
+
7
+ ## Back to Heading 2
@@ -0,0 +1 @@
1
+ :auto_ids: true
@@ -0,0 +1,5 @@
1
+ = Document Title
2
+
3
+ == First Section
4
+
5
+ And so it begins...
@@ -0,0 +1,5 @@
1
+ ## Document Title
2
+
3
+ ### First Section
4
+
5
+ And so it begins...
@@ -0,0 +1 @@
1
+ :heading_offset: -1
@@ -0,0 +1,5 @@
1
+ * {blank}
2
+ +
3
+ ----
4
+ puts "Hello, World!"
5
+ ----
@@ -0,0 +1,3 @@
1
+ * ```
2
+ puts "Hello, World!"
3
+ ```
@@ -8,3 +8,28 @@ when 'true'
8
8
  end
9
9
 
10
10
  require 'kramdown-asciidoc'
11
+ require 'fileutils'
12
+
13
+ RSpec.configure do |config|
14
+ config.after :suite do
15
+ FileUtils.rm_r output_dir, force: true, secure: true
16
+ end
17
+
18
+ def output_dir
19
+ dir = File.join __dir__, 'output'
20
+ FileUtils.mkpath dir
21
+ dir
22
+ end
23
+
24
+ def output_file path
25
+ File.join output_dir, path
26
+ end
27
+
28
+ def scenarios_dir
29
+ File.join __dir__, 'scenarios'
30
+ end
31
+
32
+ def scenario_file path
33
+ File.join scenarios_dir, path
34
+ end
35
+ end
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.5
4
+ version: 1.0.0.alpha.6
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-06-19 00:00:00.000000000 Z
11
+ date: 2018-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown
@@ -82,9 +82,11 @@ files:
82
82
  - bin/kramdoc
83
83
  - kramdown-asciidoc.gemspec
84
84
  - lib/kramdown-asciidoc.rb
85
+ - lib/kramdown-asciidoc/cli.rb
85
86
  - lib/kramdown-asciidoc/converter.rb
86
87
  - lib/kramdown-asciidoc/version.rb
87
88
  - lib/kramdown-asciidoc/writer.rb
89
+ - spec/cli_spec.rb
88
90
  - spec/converter_spec.rb
89
91
  - spec/integration_spec.rb
90
92
  - spec/scenarios/a/bare-url.adoc
@@ -151,8 +153,12 @@ files:
151
153
  - spec/scenarios/codespan/constrained.md
152
154
  - spec/scenarios/codespan/literal.adoc
153
155
  - spec/scenarios/codespan/literal.md
156
+ - spec/scenarios/dl/compound-only.adoc
157
+ - spec/scenarios/dl/compound-only.md
154
158
  - spec/scenarios/dl/compound.adoc
155
159
  - spec/scenarios/dl/compound.md
160
+ - spec/scenarios/dl/empty-dd.adoc
161
+ - spec/scenarios/dl/empty-dd.md
156
162
  - spec/scenarios/dl/nested-mixed.adoc
157
163
  - spec/scenarios/dl/nested-mixed.md
158
164
  - spec/scenarios/dl/nested.adoc
@@ -169,10 +175,16 @@ files:
169
175
  - spec/scenarios/entity/numeric.md
170
176
  - spec/scenarios/entity/reverse.adoc
171
177
  - spec/scenarios/entity/reverse.md
178
+ - spec/scenarios/heading/auto-ids.adoc
179
+ - spec/scenarios/heading/auto-ids.md
180
+ - spec/scenarios/heading/auto-ids.opts
172
181
  - spec/scenarios/heading/block-title.adoc
173
182
  - spec/scenarios/heading/block-title.md
174
183
  - spec/scenarios/heading/not-block-title.adoc
175
184
  - spec/scenarios/heading/not-block-title.md
185
+ - spec/scenarios/heading/offset.adoc
186
+ - spec/scenarios/heading/offset.md
187
+ - spec/scenarios/heading/offset.opts
176
188
  - spec/scenarios/heading/out-of-sequence.adoc
177
189
  - spec/scenarios/heading/out-of-sequence.md
178
190
  - spec/scenarios/heading/outline.adoc
@@ -347,6 +359,8 @@ files:
347
359
  - spec/scenarios/ul/blockquote.md
348
360
  - spec/scenarios/ul/compound-nested.adoc
349
361
  - spec/scenarios/ul/compound-nested.md
362
+ - spec/scenarios/ul/compound-only.adoc
363
+ - spec/scenarios/ul/compound-only.md
350
364
  - spec/scenarios/ul/compound-separated.adoc
351
365
  - spec/scenarios/ul/compound-separated.md
352
366
  - spec/scenarios/ul/compound.adoc
@@ -411,6 +425,7 @@ signing_key:
411
425
  specification_version: 4
412
426
  summary: A Markdown to AsciiDoc converter based on kramdown
413
427
  test_files:
428
+ - spec/cli_spec.rb
414
429
  - spec/converter_spec.rb
415
430
  - spec/integration_spec.rb
416
431
  - spec/scenarios/a/bare-url.adoc
@@ -477,8 +492,12 @@ test_files:
477
492
  - spec/scenarios/codespan/constrained.md
478
493
  - spec/scenarios/codespan/literal.adoc
479
494
  - spec/scenarios/codespan/literal.md
495
+ - spec/scenarios/dl/compound-only.adoc
496
+ - spec/scenarios/dl/compound-only.md
480
497
  - spec/scenarios/dl/compound.adoc
481
498
  - spec/scenarios/dl/compound.md
499
+ - spec/scenarios/dl/empty-dd.adoc
500
+ - spec/scenarios/dl/empty-dd.md
482
501
  - spec/scenarios/dl/nested-mixed.adoc
483
502
  - spec/scenarios/dl/nested-mixed.md
484
503
  - spec/scenarios/dl/nested.adoc
@@ -495,10 +514,16 @@ test_files:
495
514
  - spec/scenarios/entity/numeric.md
496
515
  - spec/scenarios/entity/reverse.adoc
497
516
  - spec/scenarios/entity/reverse.md
517
+ - spec/scenarios/heading/auto-ids.adoc
518
+ - spec/scenarios/heading/auto-ids.md
519
+ - spec/scenarios/heading/auto-ids.opts
498
520
  - spec/scenarios/heading/block-title.adoc
499
521
  - spec/scenarios/heading/block-title.md
500
522
  - spec/scenarios/heading/not-block-title.adoc
501
523
  - spec/scenarios/heading/not-block-title.md
524
+ - spec/scenarios/heading/offset.adoc
525
+ - spec/scenarios/heading/offset.md
526
+ - spec/scenarios/heading/offset.opts
502
527
  - spec/scenarios/heading/out-of-sequence.adoc
503
528
  - spec/scenarios/heading/out-of-sequence.md
504
529
  - spec/scenarios/heading/outline.adoc
@@ -673,6 +698,8 @@ test_files:
673
698
  - spec/scenarios/ul/blockquote.md
674
699
  - spec/scenarios/ul/compound-nested.adoc
675
700
  - spec/scenarios/ul/compound-nested.md
701
+ - spec/scenarios/ul/compound-only.adoc
702
+ - spec/scenarios/ul/compound-only.md
676
703
  - spec/scenarios/ul/compound-separated.adoc
677
704
  - spec/scenarios/ul/compound-separated.md
678
705
  - spec/scenarios/ul/compound.adoc