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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +15 -0
  3. data/README.adoc +1 -1
  4. data/lib/kramdown-asciidoc.rb +1 -0
  5. data/lib/kramdown-asciidoc/converter.rb +297 -266
  6. data/lib/kramdown-asciidoc/version.rb +1 -1
  7. data/lib/kramdown-asciidoc/writer.rb +114 -0
  8. data/spec/scenarios/blockquote/deep-nested.adoc +3 -0
  9. data/spec/scenarios/codespan/constrained-triple.adoc +1 -0
  10. data/spec/scenarios/codespan/constrained-triple.md +1 -0
  11. data/spec/scenarios/dl/compound.adoc +11 -0
  12. data/spec/scenarios/{dlist → dl}/compound.md +0 -0
  13. data/spec/scenarios/dl/nested-mixed.adoc +11 -0
  14. data/spec/scenarios/{dlist → dl}/nested-mixed.md +0 -0
  15. data/spec/scenarios/dl/nested.adoc +15 -0
  16. data/spec/scenarios/{dlist → dl}/nested.md +0 -0
  17. data/spec/scenarios/dl/simple.adoc +9 -0
  18. data/spec/scenarios/dl/simple.md +10 -0
  19. data/spec/scenarios/entity/reverse.adoc +2 -0
  20. data/spec/scenarios/entity/reverse.md +2 -0
  21. data/spec/scenarios/p/admonition/in-blockquote.adoc +1 -0
  22. data/spec/scenarios/p/admonition/in-blockquote.md +1 -0
  23. data/spec/scenarios/p/admonition/in-compound-blockquote.adoc +5 -0
  24. data/spec/scenarios/p/admonition/in-compound-blockquote.md +3 -0
  25. data/spec/scenarios/p/admonition/plain.adoc +2 -0
  26. data/spec/scenarios/p/admonition/plain.md +2 -0
  27. data/spec/scenarios/strong/menu.adoc +1 -1
  28. data/spec/scenarios/table/alignment.adoc +7 -0
  29. data/spec/scenarios/table/alignment.md +4 -0
  30. data/spec/scenarios/text/nbsp.adoc +1 -0
  31. data/spec/scenarios/text/nbsp.md +1 -0
  32. data/spec/scenarios/xml_comment/line-adjacent-to-text.adoc +2 -0
  33. data/spec/scenarios/xml_comment/line-adjacent-to-text.md +1 -0
  34. metadata +39 -18
  35. data/spec/scenarios/dlist/compound.adoc +0 -13
  36. data/spec/scenarios/dlist/nested-mixed.adoc +0 -11
  37. data/spec/scenarios/dlist/nested.adoc +0 -23
  38. data/spec/scenarios/dlist/simple.adoc +0 -5
  39. data/spec/scenarios/dlist/simple.md +0 -5
@@ -1,3 +1,3 @@
1
1
  module Kramdown; module AsciiDoc
2
- VERSION = '1.0.0.alpha.4'
2
+ VERSION = '1.0.0.alpha.5'
3
3
  end; end
@@ -0,0 +1,114 @@
1
+ module Kramdown; module AsciiDoc
2
+ class Writer
3
+ LF = ?\n
4
+
5
+ attr_reader :header
6
+ attr_reader :body
7
+
8
+ def initialize
9
+ @header = []
10
+ @body = []
11
+ @nesting_stack = []
12
+ @block_delimiter = nil
13
+ @block_separator = ''
14
+ end
15
+
16
+ def doctitle
17
+ if (doctitle_line = @header.find {|l| l.start_with? '= ' })
18
+ doctitle_line.slice 2, doctitle_line.length
19
+ end
20
+ end
21
+
22
+ def doctitle= new_doctitle
23
+ if (doctitle_idx = @header.index {|l| l.start_with? '= ' })
24
+ @header[doctitle_idx] = %(= #{new_doctitle})
25
+ else
26
+ @header.unshift %(= #{new_doctitle})
27
+ end
28
+ nil
29
+ end
30
+
31
+ def add_attributes attributes
32
+ attributes.each {|k, v| add_attribute k, v }
33
+ nil
34
+ end
35
+
36
+ def add_attribute name, value
37
+ @header << %(:#{name}:#{value.empty? ? '' : ' ' + value.to_s})
38
+ nil
39
+ end
40
+
41
+ def start_block
42
+ @body << @block_separator unless empty?
43
+ nil
44
+ end
45
+
46
+ # Q: perhaps in_list that takes a block?
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 = '+'
51
+ nil
52
+ end
53
+
54
+ def end_list nested = false
55
+ @block_separator = '' unless nested
56
+ nil
57
+ end
58
+
59
+ def start_delimited_block delimiter
60
+ @body << (@block_delimiter = delimiter.length == 1 ? delimiter * 4 : delimiter)
61
+ @nesting_stack << [(@body.pop @body.length), @block_delimiter, @block_separator]
62
+ @block_separator = ''
63
+ nil
64
+ end
65
+
66
+ def end_delimited_block
67
+ parent_body, @block_delimiter, @block_separator = @nesting_stack.pop
68
+ @body = (parent_body + @body) << @block_delimiter
69
+ @block_delimiter = nil
70
+ nil
71
+ end
72
+
73
+ def clear_line
74
+ @body[-1] = '' unless empty?
75
+ nil
76
+ end
77
+
78
+ def add_blank_line
79
+ @body << ''
80
+ nil
81
+ end
82
+
83
+ def add_line line
84
+ @body << line
85
+ nil
86
+ end
87
+
88
+ def add_lines lines
89
+ @body += lines
90
+ nil
91
+ end
92
+
93
+ def append str
94
+ if empty?
95
+ @body << str
96
+ else
97
+ @body[-1] += str
98
+ end
99
+ nil
100
+ end
101
+
102
+ def current_line
103
+ @body[-1]
104
+ end
105
+
106
+ def empty?
107
+ @body.empty?
108
+ end
109
+
110
+ def to_s
111
+ ((@header.empty? ? @body : (@header + (@body.empty? ? [] : ['']) + @body)).join LF) + LF
112
+ end
113
+ end
114
+ end; end
@@ -2,10 +2,13 @@ Here's about how that conversation went:
2
2
 
3
3
  ____
4
4
  he said
5
+
5
6
  ______
6
7
  she said
8
+
7
9
  ________
8
10
  he said
11
+
9
12
  __________
10
13
  she said
11
14
  __________
@@ -0,0 +1 @@
1
+ A standard login form contains a `username` and a `password` field.
@@ -0,0 +1 @@
1
+ A standard login form contains a ```username``` and a ```password``` field.
@@ -0,0 +1,11 @@
1
+ kramdown:: A Markdown-superset converter
2
+ +
3
+ ____
4
+ Aren't they all?
5
+ ____
6
+
7
+ kramdown-asciidoc:: A Markdown to AsciiDoc converter based on kramdown
8
+ +
9
+ ____
10
+ AsciiDoc is where it's at!
11
+ ____
File without changes
@@ -0,0 +1,11 @@
1
+ kramdown:: A Markdown-superset converter (aren't they all?)
2
+
3
+ * Fast
4
+ * Free
5
+ * Extensible
6
+
7
+ kramdown-asciidoc:: A Markdown to AsciiDoc converter
8
+
9
+ * Based on kramdown
10
+ * Outputs concise, modern AsciiDoc
11
+ * Well tested
File without changes
@@ -0,0 +1,15 @@
1
+ kramdown:: A Markdown-superset converter
2
+
3
+ Language;; Ruby
4
+
5
+ License;; MIT
6
+
7
+ Author;; Thomas Leitner
8
+
9
+ kramdown-asciidoc:: A Markdown to AsciiDoc converter based on kramdown
10
+
11
+ Language;; Ruby
12
+
13
+ License;; MIT
14
+
15
+ Author;; Dan Allen
File without changes
@@ -0,0 +1,9 @@
1
+ kramdown:: A Markdown-superset converter (aren't they all?)
2
+
3
+ kramdown-asciidoc::
4
+ A Markdown to AsciiDoc converter;
5
+ based on kramdown
6
+
7
+ asciidoctor::
8
+ The modern AsciiDoc converter.
9
+ This tool will come in handy once you've made the switch to AsciiDoc.
@@ -0,0 +1,10 @@
1
+ kramdown
2
+ : A Markdown-superset converter (aren't they all?)
3
+
4
+ kramdown-asciidoc
5
+ : A Markdown to AsciiDoc converter;
6
+ based on kramdown
7
+
8
+ asciidoctor
9
+ : The modern AsciiDoc converter.
10
+ This tool will come in handy once you've made the switch to AsciiDoc.
@@ -1,3 +1,5 @@
1
1
  <undefined>
2
2
 
3
3
  a | b
4
+
5
+ a & b
@@ -1,3 +1,5 @@
1
1
  &lt;undefined&gt;
2
2
 
3
3
  a &#124; b
4
+
5
+ a &amp; b
@@ -0,0 +1 @@
1
+ NOTE: The `npm install <package>` command uses the `latest` tag by default.
@@ -0,0 +1 @@
1
+ > Note: The `npm install <package>` command uses the `latest` tag by default.
@@ -0,0 +1,5 @@
1
+ ____
2
+ TIP: Always test your code.
3
+
4
+ You'll thank yourself later.
5
+ ____
@@ -0,0 +1,3 @@
1
+ > Tip: Always test your code.
2
+ >
3
+ > You'll thank yourself later.
@@ -9,3 +9,5 @@ CAUTION: Slippery when wet.
9
9
  WARNING: The software you're about to use has not been tested.
10
10
 
11
11
  IMPORTANT: Sign off before stepping away from the computer.
12
+
13
+ TIP: Stop signs with white borders are optional.
@@ -9,3 +9,5 @@ Caution: Slippery when wet.
9
9
  Warning: The software you're about to use has not been tested.
10
10
 
11
11
  Important: Sign off before stepping away from the computer.
12
+
13
+ Hint: Stop signs with white borders are optional.
@@ -1,3 +1,3 @@
1
- :experimental:
1
+ :experimental:
2
2
 
3
3
  menu:Settings[Account > Change username]
@@ -10,3 +10,10 @@
10
10
  | 2
11
11
  | bop
12
12
  |===
13
+
14
+ [cols=^]
15
+ |===
16
+ | Grade
17
+
18
+ | A+
19
+ |===
@@ -2,3 +2,7 @@
2
2
  |-----:|:-----:|:-----|
3
3
  | foo | 1 | bar |
4
4
  | bim | 2 | bop |
5
+
6
+ | Grade |
7
+ |:-----:|
8
+ | A+ |
@@ -0,0 +1 @@
1
+ deceptive{nbsp}spaces{nbsp}live{nbsp}here
@@ -0,0 +1 @@
1
+ deceptive spaces live here
@@ -0,0 +1,2 @@
1
+ $5,000 off
2
+ // price after rebate
@@ -0,0 +1 @@
1
+ $5,000 off<!-- price after rebate -->
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
4
+ version: 1.0.0.alpha.5
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-13 00:00:00.000000000 Z
11
+ date: 2018-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown
@@ -84,6 +84,7 @@ files:
84
84
  - lib/kramdown-asciidoc.rb
85
85
  - lib/kramdown-asciidoc/converter.rb
86
86
  - lib/kramdown-asciidoc/version.rb
87
+ - lib/kramdown-asciidoc/writer.rb
87
88
  - spec/converter_spec.rb
88
89
  - spec/integration_spec.rb
89
90
  - spec/scenarios/a/bare-url.adoc
@@ -144,18 +145,20 @@ files:
144
145
  - spec/scenarios/codeblock/with-command-prompt.md
145
146
  - spec/scenarios/codeblock/with-non-contiguous-command-prompts.adoc
146
147
  - spec/scenarios/codeblock/with-non-contiguous-command-prompts.md
148
+ - spec/scenarios/codespan/constrained-triple.adoc
149
+ - spec/scenarios/codespan/constrained-triple.md
147
150
  - spec/scenarios/codespan/constrained.adoc
148
151
  - spec/scenarios/codespan/constrained.md
149
152
  - spec/scenarios/codespan/literal.adoc
150
153
  - spec/scenarios/codespan/literal.md
151
- - spec/scenarios/dlist/compound.adoc
152
- - spec/scenarios/dlist/compound.md
153
- - spec/scenarios/dlist/nested-mixed.adoc
154
- - spec/scenarios/dlist/nested-mixed.md
155
- - spec/scenarios/dlist/nested.adoc
156
- - spec/scenarios/dlist/nested.md
157
- - spec/scenarios/dlist/simple.adoc
158
- - spec/scenarios/dlist/simple.md
154
+ - spec/scenarios/dl/compound.adoc
155
+ - spec/scenarios/dl/compound.md
156
+ - spec/scenarios/dl/nested-mixed.adoc
157
+ - spec/scenarios/dl/nested-mixed.md
158
+ - spec/scenarios/dl/nested.adoc
159
+ - spec/scenarios/dl/nested.md
160
+ - spec/scenarios/dl/simple.adoc
161
+ - spec/scenarios/dl/simple.md
159
162
  - spec/scenarios/em/asterisks.adoc
160
163
  - spec/scenarios/em/asterisks.md
161
164
  - spec/scenarios/em/constrained.adoc
@@ -262,6 +265,10 @@ files:
262
265
  - spec/scenarios/ol/simple.md
263
266
  - spec/scenarios/p/admonition/emphasis.adoc
264
267
  - spec/scenarios/p/admonition/emphasis.md
268
+ - spec/scenarios/p/admonition/in-blockquote.adoc
269
+ - spec/scenarios/p/admonition/in-blockquote.md
270
+ - spec/scenarios/p/admonition/in-compound-blockquote.adoc
271
+ - spec/scenarios/p/admonition/in-compound-blockquote.md
265
272
  - spec/scenarios/p/admonition/in-list-item.adoc
266
273
  - spec/scenarios/p/admonition/in-list-item.md
267
274
  - spec/scenarios/p/admonition/plain.adoc
@@ -312,6 +319,8 @@ files:
312
319
  - spec/scenarios/text/caret.md
313
320
  - spec/scenarios/text/lte.adoc
314
321
  - spec/scenarios/text/lte.md
322
+ - spec/scenarios/text/nbsp.adoc
323
+ - spec/scenarios/text/nbsp.md
315
324
  - spec/scenarios/text/plus-plus.adoc
316
325
  - spec/scenarios/text/plus-plus.md
317
326
  - spec/scenarios/text/typographic_sym/apostrophe.adoc
@@ -358,6 +367,8 @@ files:
358
367
  - spec/scenarios/xml_comment/at-start-of-line.md
359
368
  - spec/scenarios/xml_comment/block.adoc
360
369
  - spec/scenarios/xml_comment/block.md
370
+ - spec/scenarios/xml_comment/line-adjacent-to-text.adoc
371
+ - spec/scenarios/xml_comment/line-adjacent-to-text.md
361
372
  - spec/scenarios/xml_comment/line-offset-by-space.adoc
362
373
  - spec/scenarios/xml_comment/line-offset-by-space.md
363
374
  - spec/scenarios/xml_comment/line.adoc
@@ -460,18 +471,20 @@ test_files:
460
471
  - spec/scenarios/codeblock/with-command-prompt.md
461
472
  - spec/scenarios/codeblock/with-non-contiguous-command-prompts.adoc
462
473
  - spec/scenarios/codeblock/with-non-contiguous-command-prompts.md
474
+ - spec/scenarios/codespan/constrained-triple.adoc
475
+ - spec/scenarios/codespan/constrained-triple.md
463
476
  - spec/scenarios/codespan/constrained.adoc
464
477
  - spec/scenarios/codespan/constrained.md
465
478
  - spec/scenarios/codespan/literal.adoc
466
479
  - spec/scenarios/codespan/literal.md
467
- - spec/scenarios/dlist/compound.adoc
468
- - spec/scenarios/dlist/compound.md
469
- - spec/scenarios/dlist/nested-mixed.adoc
470
- - spec/scenarios/dlist/nested-mixed.md
471
- - spec/scenarios/dlist/nested.adoc
472
- - spec/scenarios/dlist/nested.md
473
- - spec/scenarios/dlist/simple.adoc
474
- - spec/scenarios/dlist/simple.md
480
+ - spec/scenarios/dl/compound.adoc
481
+ - spec/scenarios/dl/compound.md
482
+ - spec/scenarios/dl/nested-mixed.adoc
483
+ - spec/scenarios/dl/nested-mixed.md
484
+ - spec/scenarios/dl/nested.adoc
485
+ - spec/scenarios/dl/nested.md
486
+ - spec/scenarios/dl/simple.adoc
487
+ - spec/scenarios/dl/simple.md
475
488
  - spec/scenarios/em/asterisks.adoc
476
489
  - spec/scenarios/em/asterisks.md
477
490
  - spec/scenarios/em/constrained.adoc
@@ -578,6 +591,10 @@ test_files:
578
591
  - spec/scenarios/ol/simple.md
579
592
  - spec/scenarios/p/admonition/emphasis.adoc
580
593
  - spec/scenarios/p/admonition/emphasis.md
594
+ - spec/scenarios/p/admonition/in-blockquote.adoc
595
+ - spec/scenarios/p/admonition/in-blockquote.md
596
+ - spec/scenarios/p/admonition/in-compound-blockquote.adoc
597
+ - spec/scenarios/p/admonition/in-compound-blockquote.md
581
598
  - spec/scenarios/p/admonition/in-list-item.adoc
582
599
  - spec/scenarios/p/admonition/in-list-item.md
583
600
  - spec/scenarios/p/admonition/plain.adoc
@@ -628,6 +645,8 @@ test_files:
628
645
  - spec/scenarios/text/caret.md
629
646
  - spec/scenarios/text/lte.adoc
630
647
  - spec/scenarios/text/lte.md
648
+ - spec/scenarios/text/nbsp.adoc
649
+ - spec/scenarios/text/nbsp.md
631
650
  - spec/scenarios/text/plus-plus.adoc
632
651
  - spec/scenarios/text/plus-plus.md
633
652
  - spec/scenarios/text/typographic_sym/apostrophe.adoc
@@ -674,6 +693,8 @@ test_files:
674
693
  - spec/scenarios/xml_comment/at-start-of-line.md
675
694
  - spec/scenarios/xml_comment/block.adoc
676
695
  - spec/scenarios/xml_comment/block.md
696
+ - spec/scenarios/xml_comment/line-adjacent-to-text.adoc
697
+ - spec/scenarios/xml_comment/line-adjacent-to-text.md
677
698
  - spec/scenarios/xml_comment/line-offset-by-space.adoc
678
699
  - spec/scenarios/xml_comment/line-offset-by-space.md
679
700
  - spec/scenarios/xml_comment/line.adoc
@@ -1,13 +0,0 @@
1
- kramdown::
2
- A Markdown-superset converter
3
- +
4
- ____
5
- Aren't they all?
6
- ____
7
-
8
- kramdown-asciidoc::
9
- A Markdown to AsciiDoc converter based on kramdown
10
- +
11
- ____
12
- AsciiDoc is where it's at!
13
- ____