kramdown-asciidoc 1.0.0.alpha.2 → 1.0.0.alpha.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +14 -1
- data/Gemfile +5 -0
- data/README.adoc +10 -9
- data/lib/kramdown-asciidoc.rb +11 -0
- data/lib/kramdown-asciidoc/converter.rb +36 -13
- data/lib/kramdown-asciidoc/version.rb +1 -1
- data/spec/fixtures/br/tag-in-table-cell.adoc +4 -0
- data/spec/fixtures/br/tag-in-table-cell.md +1 -0
- data/spec/fixtures/html_element/empty-p.adoc +5 -0
- data/spec/fixtures/html_element/empty-p.md +5 -0
- data/spec/fixtures/html_element/img-with-css-width.adoc +1 -0
- data/spec/fixtures/html_element/img-with-css-width.md +1 -0
- data/spec/fixtures/p/{multiple.adoc → sequential.adoc} +0 -0
- data/spec/fixtures/p/{multiple.md → sequential.md} +0 -0
- data/spec/fixtures/table/alignment.adoc +12 -0
- data/spec/fixtures/table/alignment.md +4 -0
- data/spec/fixtures/text/typographic_sym/ndash.adoc +1 -1
- data/spec/spec_helper.rb +6 -5
- metadata +22 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e95a5d12ba8c16a4dffb8257066dda516b072943947fa156ef5e94914451b36d
|
4
|
+
data.tar.gz: 1381d930ab4aaa34f9ec2bf1ccf274357c76f061a0f4715336bacd6fee7e3124
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3acf70f81410433141239ed11bfc9fb3d498eddeecffad94144a98386aac5146b80ab4609dd3b673609961fefedad7ef5f4a21e05ef34859f3d4915e5e48062
|
7
|
+
data.tar.gz: cdc0863d2926c1488a263ec73f067ca201038192f35b25c79872507d5da6b81ef70cf53134d40e770c9edbd6170f98079cdd0d05ddc2d33b1b1c80c0ff74b3ea
|
data/CHANGELOG.adoc
CHANGED
@@ -5,6 +5,19 @@
|
|
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.3 (2018-05-31) - @mojavelinux
|
9
|
+
|
10
|
+
=== Added
|
11
|
+
|
12
|
+
* patch conversion from HTML br element to native until the fix for gettalong/kramdown#514 is released
|
13
|
+
* preserve non-default table column alignment
|
14
|
+
* honor image width specified in style attribute of HTML img element
|
15
|
+
* replace empty HTML p element with paragraph containing \{blank}
|
16
|
+
|
17
|
+
=== Changed
|
18
|
+
|
19
|
+
* replace ndash symbol with \-- instead of \–
|
20
|
+
|
8
21
|
== 1.0.0.alpha.2 (2018-05-24) - @mojavelinux
|
9
22
|
|
10
23
|
=== Added
|
@@ -13,7 +26,7 @@ For a detailed view of what has changed, refer to the {uri-repo}/commits/master[
|
|
13
26
|
* convert HTML-based admonition blocks
|
14
27
|
* drop HTML div element if enclosing an image
|
15
28
|
* transfer id and class/role attributes to block image
|
16
|
-
*
|
29
|
+
* honor image width specified on width attribute of HTML img element
|
17
30
|
|
18
31
|
=== Changed
|
19
32
|
|
data/Gemfile
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.3, 2018-05-31
|
4
4
|
// Aliases:
|
5
5
|
:project-name: Kramdown AsciiDoc
|
6
6
|
:project-handle: kramdown-asciidoc
|
@@ -23,14 +23,15 @@ endif::[]
|
|
23
23
|
:uri-asciidoc: https://asciidoctor.org/docs/what-is-asciidoc/#what-is-asciidoc
|
24
24
|
:uri-asciidoctor: https://asciidoctor.org
|
25
25
|
:uri-rvm: https://rvm.io
|
26
|
-
:uri-install
|
27
|
-
//:img-gem: https://img.shields.io/gem/v/kramdown-asciidoc.svg?label=gem
|
26
|
+
:uri-rvm-install: https://rvm.io/rvm/install
|
28
27
|
:uri-ci-travis: https://travis-ci.org/asciidoctor/kramdown-asciidoc
|
29
|
-
:
|
28
|
+
:uri-ci-travis-img: https://img.shields.io/travis/asciidoctor/kramdown-asciidoc/master.svg
|
29
|
+
:uri-gem: https://rubygems.org/gems/kramdown-asciidoc
|
30
|
+
:uri-gem-img: https://img.shields.io/gem/v/kramdown-asciidoc.svg?label=gem
|
30
31
|
|
31
32
|
ifdef::status[]
|
32
|
-
|
33
|
-
image:{
|
33
|
+
image:{uri-gem-img}[Gem Version,link={uri-gem}]
|
34
|
+
image:{uri-ci-travis-img}[Build Status (Travis CI),link={uri-ci-travis}]
|
34
35
|
endif::[]
|
35
36
|
|
36
37
|
{uri-repo}[{project-name}] (gem: *{project-handle}*) is a Kramdown extension for converting Markdown documents to {uri-asciidoc}[AsciiDoc].
|
@@ -41,7 +42,7 @@ Notably, the converter generates modern AsciiDoc syntax suitable for use with {u
|
|
41
42
|
To install and run {project-name}, you need Ruby 2.4 or better installed and a few RubyGems (aka gems).
|
42
43
|
We'll explain how to install the gems in the next section.
|
43
44
|
|
44
|
-
To check whether you have Ruby installed, and which version
|
45
|
+
To check whether you have Ruby installed, and which version, run the following command:
|
45
46
|
|
46
47
|
$ ruby -v
|
47
48
|
|
@@ -50,7 +51,7 @@ We generally recommend using RVM because it allows you to install gems without r
|
|
50
51
|
|
51
52
|
== Installation
|
52
53
|
|
53
|
-
{project-name} is published as a pre-release gem named {project-handle}
|
54
|
+
{project-name} is published to RubyGems.org as a pre-release gem named *{project-handle}*.
|
54
55
|
|
55
56
|
You can install the pre-release version using the following command:
|
56
57
|
|
@@ -95,7 +96,7 @@ Next, switch to the project directory:
|
|
95
96
|
|
96
97
|
We recommend using {uri-rvm}[RVM] when developing applications with Ruby.
|
97
98
|
We like RVM because it keeps the dependencies required by the project isolated from the rest of your system.
|
98
|
-
Follow the {uri-install
|
99
|
+
Follow the {uri-rvm-install}[installation instructions] on the RVM site to setup RVM and install Ruby.
|
99
100
|
|
100
101
|
Once you have RVM setup, switch to the RVM-managed version of Ruby recommended by the project using this command:
|
101
102
|
|
data/lib/kramdown-asciidoc.rb
CHANGED
@@ -1,2 +1,13 @@
|
|
1
1
|
require 'kramdown'
|
2
2
|
require_relative 'kramdown-asciidoc/converter'
|
3
|
+
autoload :YAML, 'yaml'
|
4
|
+
|
5
|
+
# REMOVE once Kramdown > 1.16.2 is released
|
6
|
+
class Kramdown::Parser::Html::ElementConverter
|
7
|
+
def convert_br el
|
8
|
+
el.options.clear
|
9
|
+
el.type = el.value.to_sym
|
10
|
+
el.value = ''
|
11
|
+
nil
|
12
|
+
end
|
13
|
+
end
|
@@ -21,7 +21,6 @@ module Kramdown; module AsciiDoc
|
|
21
21
|
|
22
22
|
def self.extract_front_matter source, attributes
|
23
23
|
if (line_i = (lines = source.each_line).next) && line_i.chomp == '---'
|
24
|
-
require 'yaml' unless defined? ::YAML
|
25
24
|
lines = lines.drop 1
|
26
25
|
front_matter = []
|
27
26
|
while (line = lines.shift) && line.chomp != '---'
|
@@ -59,7 +58,7 @@ module Kramdown; module AsciiDoc
|
|
59
58
|
'’' => '`\'',
|
60
59
|
# FIXME in the future, mdash will be three dashes in AsciiDoc; for now, down-convert
|
61
60
|
'—' => '--',
|
62
|
-
'–' => '
|
61
|
+
'–' => '--',
|
63
62
|
'…' => '...',
|
64
63
|
}
|
65
64
|
TYPOGRAPHIC_ENTITY_TO_MARKUP = {
|
@@ -72,9 +71,15 @@ module Kramdown; module AsciiDoc
|
|
72
71
|
laquo_scape: '<< ',
|
73
72
|
raquo_space: ' >>',
|
74
73
|
}
|
74
|
+
TABLE_ALIGNMENTS = {
|
75
|
+
left: '<',
|
76
|
+
center: '^',
|
77
|
+
right: '>',
|
78
|
+
}
|
75
79
|
|
76
80
|
ApostropheRx = /\b’\b/
|
77
81
|
CommentPrefixRx = /^ *! ?/m
|
82
|
+
CssPropDelimRx = /\s*;\s*/
|
78
83
|
ReplaceableTextRx = /[-=]>|<[-=]|\.\.\./
|
79
84
|
StartOfLinesRx = /^/m
|
80
85
|
TypographicSymbolRx = /[“”‘’—–…]/
|
@@ -154,19 +159,22 @@ module Kramdown; module AsciiDoc
|
|
154
159
|
else
|
155
160
|
prefix, suffix = '', LFx2
|
156
161
|
end
|
162
|
+
if (children = el.children).empty?
|
163
|
+
contents = '{blank}'
|
157
164
|
# NOTE detect plain admonition marker (e.g, Note: ...)
|
158
|
-
|
165
|
+
elsif (child_i = children[0]).type == :text && (child_i_text = child_i.value).start_with?(*ADMON_MARKERS)
|
159
166
|
marker, child_i_text = child_i_text.split ': ', 2
|
160
167
|
child_i = clone child_i, value: %(#{ADMON_TYPE_MAP[marker]}: #{child_i_text})
|
161
|
-
el = clone el, children: [child_i] + (
|
168
|
+
el = clone el, children: [child_i] + (children.drop 1)
|
162
169
|
contents = inner el, opts
|
163
170
|
# NOTE detect formatted admonition marker (e.g., *Note:* ...)
|
164
171
|
elsif (child_i.type == :strong || child_i.type == :em) &&
|
165
172
|
(marker_el = child_i.children[0]) && ((marker = ADMON_FORMATTED_MARKERS[marker_el.value]) ||
|
166
|
-
((marker = ADMON_LABELS[marker_el.value]) && (child_ii =
|
173
|
+
((marker = ADMON_LABELS[marker_el.value]) && (child_ii = children[1] || VoidElement).type == :text &&
|
167
174
|
((child_ii_text = child_ii.value).start_with? ': ')))
|
168
|
-
|
169
|
-
|
175
|
+
children = children.drop 1
|
176
|
+
children[0] = clone child_ii, value: (child_ii_text.slice 1, child_ii_text.length) if child_ii
|
177
|
+
el = clone el, children: children
|
170
178
|
contents = %(#{ADMON_TYPE_MAP[marker]}:#{inner el, opts})
|
171
179
|
else
|
172
180
|
contents = inner el, opts
|
@@ -251,11 +259,16 @@ module Kramdown; module AsciiDoc
|
|
251
259
|
prefix = (prev = opts[:prev]) && prev.options[:compound] ? LF : ''
|
252
260
|
marker = opts[:parent].type == :ol ? '.' : '*'
|
253
261
|
indent = (level = opts[:level]) - 1
|
254
|
-
%(#{prefix}#{indent > 0 ?
|
262
|
+
%(#{prefix}#{indent > 0 ? ' ' * indent : ''}#{marker * level} #{(inner el, (opts.merge rstrip: true))}#{LF})
|
255
263
|
end
|
256
264
|
|
257
265
|
def convert_table el, opts
|
258
|
-
head =
|
266
|
+
head = nil
|
267
|
+
cols = (alignments = el.options[:alignment]).size
|
268
|
+
if alignments.any? {|align| align == :center || align == :right }
|
269
|
+
colspecs = alignments.map {|align| TABLE_ALIGNMENTS[align] }.join ','
|
270
|
+
colspecs = %("#{colspecs}") if cols > 1
|
271
|
+
end
|
259
272
|
table_buf = ['|===']
|
260
273
|
el.children.each do |container|
|
261
274
|
container.children.each do |row|
|
@@ -265,18 +278,20 @@ module Kramdown; module AsciiDoc
|
|
265
278
|
cell_contents = cell_contents.gsub '|', '\|' if cell_contents.include? '|'
|
266
279
|
row_buf << %(| #{cell_contents})
|
267
280
|
end
|
268
|
-
cols ||= row_buf.size
|
269
281
|
if container.type == :thead
|
270
282
|
head = true
|
271
|
-
row_buf = [row_buf * ' ']
|
272
|
-
row_buf << ''
|
283
|
+
row_buf = [row_buf * ' ', '']
|
273
284
|
elsif cols > 1
|
274
285
|
row_buf << ''
|
275
286
|
end
|
276
287
|
table_buf.concat row_buf
|
277
288
|
end
|
278
289
|
end
|
279
|
-
|
290
|
+
if colspecs
|
291
|
+
table_buf.unshift %([cols=#{colspecs}])
|
292
|
+
elsif !head && cols > 1
|
293
|
+
table_buf.unshift %([cols=#{cols}*])
|
294
|
+
end
|
280
295
|
table_buf.pop if table_buf[-1] == ''
|
281
296
|
table_buf << '|==='
|
282
297
|
%(#{table_buf * LF}#{LFx2})
|
@@ -371,6 +386,14 @@ module Kramdown; module AsciiDoc
|
|
371
386
|
if (width = el.attr['width'])
|
372
387
|
macro_attrs << '' if macro_attrs.empty?
|
373
388
|
macro_attrs << width
|
389
|
+
elsif (css = el.attr['style']) && (width_css = (css.split CssPropDelimRx).find {|p| p.start_with? 'width:' })
|
390
|
+
macro_attrs << '' if macro_attrs.empty?
|
391
|
+
width = (width_css.slice (width_css.index ':') + 1, width_css.length).strip
|
392
|
+
unless width.end_with? '%'
|
393
|
+
width = width.to_f
|
394
|
+
width = width.to_i if width == width.to_i
|
395
|
+
end
|
396
|
+
macro_attrs << width
|
374
397
|
end
|
375
398
|
if (url = opts[:url])
|
376
399
|
macro_attrs << %(link=#{url})
|
@@ -0,0 +1 @@
|
|
1
|
+
| This is a test.<br/>This is only a test. |
|
@@ -0,0 +1 @@
|
|
1
|
+
image::logo.png[,480]
|
@@ -0,0 +1 @@
|
|
1
|
+
<img src="logo.png" style="float: right; width: 480px">
|
File without changes
|
File without changes
|
@@ -1 +1 @@
|
|
1
|
-
9
|
1
|
+
9--5 is the gig.
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
|
1
|
+
case ENV['COVERAGE']
|
2
|
+
when 'deep'
|
3
|
+
ENV['DEEP_COVER'] = 'true'
|
4
|
+
require 'deep_cover'
|
5
|
+
when 'true'
|
6
|
+
require 'deep_cover/builtin_takeover'
|
2
7
|
require 'simplecov'
|
3
|
-
SimpleCov.start do
|
4
|
-
add_filter %w(/.bundle/ /spec/)
|
5
|
-
coverage_dir 'build/coverage-report'
|
6
|
-
end
|
7
8
|
end
|
8
9
|
|
9
10
|
require 'kramdown-asciidoc'
|
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.3
|
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-05-
|
11
|
+
date: 2018-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|
@@ -113,6 +113,8 @@ files:
|
|
113
113
|
- spec/fixtures/blockquote/with-attribution.md
|
114
114
|
- spec/fixtures/br/tag-followed-by-newline.adoc
|
115
115
|
- spec/fixtures/br/tag-followed-by-newline.md
|
116
|
+
- spec/fixtures/br/tag-in-table-cell.adoc
|
117
|
+
- spec/fixtures/br/tag-in-table-cell.md
|
116
118
|
- spec/fixtures/br/tag-preceded-by-space.adoc
|
117
119
|
- spec/fixtures/br/tag-preceded-by-space.md
|
118
120
|
- spec/fixtures/br/tag.adoc
|
@@ -167,12 +169,16 @@ files:
|
|
167
169
|
- spec/fixtures/html_element/abbr.md
|
168
170
|
- spec/fixtures/html_element/admonition.adoc
|
169
171
|
- spec/fixtures/html_element/admonition.md
|
172
|
+
- spec/fixtures/html_element/empty-p.adoc
|
173
|
+
- spec/fixtures/html_element/empty-p.md
|
170
174
|
- spec/fixtures/html_element/heading-with-class.adoc
|
171
175
|
- spec/fixtures/html_element/heading-with-class.md
|
172
176
|
- spec/fixtures/html_element/heading-with-id.adoc
|
173
177
|
- spec/fixtures/html_element/heading-with-id.md
|
174
178
|
- spec/fixtures/html_element/img-with-alt-and-width.adoc
|
175
179
|
- spec/fixtures/html_element/img-with-alt-and-width.md
|
180
|
+
- spec/fixtures/html_element/img-with-css-width.adoc
|
181
|
+
- spec/fixtures/html_element/img-with-css-width.md
|
176
182
|
- spec/fixtures/html_element/img-with-width.adoc
|
177
183
|
- spec/fixtures/html_element/img-with-width.md
|
178
184
|
- spec/fixtures/html_element/img.adoc
|
@@ -231,8 +237,8 @@ files:
|
|
231
237
|
- spec/fixtures/p/admonition/strong-emphasis.md
|
232
238
|
- spec/fixtures/p/multiple-lines.adoc
|
233
239
|
- spec/fixtures/p/multiple-lines.md
|
234
|
-
- spec/fixtures/p/
|
235
|
-
- spec/fixtures/p/
|
240
|
+
- spec/fixtures/p/sequential.adoc
|
241
|
+
- spec/fixtures/p/sequential.md
|
236
242
|
- spec/fixtures/p/single-line.adoc
|
237
243
|
- spec/fixtures/p/single-line.md
|
238
244
|
- spec/fixtures/root/body-only.adoc
|
@@ -253,6 +259,8 @@ files:
|
|
253
259
|
- spec/fixtures/strong/constrained.md
|
254
260
|
- spec/fixtures/strong/nested-emphasis.adoc
|
255
261
|
- spec/fixtures/strong/nested-emphasis.md
|
262
|
+
- spec/fixtures/table/alignment.adoc
|
263
|
+
- spec/fixtures/table/alignment.md
|
256
264
|
- spec/fixtures/table/cell-with-pipe.adoc
|
257
265
|
- spec/fixtures/table/cell-with-pipe.md
|
258
266
|
- spec/fixtures/table/single-column-with-header.adoc
|
@@ -375,6 +383,8 @@ test_files:
|
|
375
383
|
- spec/fixtures/blockquote/with-attribution.md
|
376
384
|
- spec/fixtures/br/tag-followed-by-newline.adoc
|
377
385
|
- spec/fixtures/br/tag-followed-by-newline.md
|
386
|
+
- spec/fixtures/br/tag-in-table-cell.adoc
|
387
|
+
- spec/fixtures/br/tag-in-table-cell.md
|
378
388
|
- spec/fixtures/br/tag-preceded-by-space.adoc
|
379
389
|
- spec/fixtures/br/tag-preceded-by-space.md
|
380
390
|
- spec/fixtures/br/tag.adoc
|
@@ -429,12 +439,16 @@ test_files:
|
|
429
439
|
- spec/fixtures/html_element/abbr.md
|
430
440
|
- spec/fixtures/html_element/admonition.adoc
|
431
441
|
- spec/fixtures/html_element/admonition.md
|
442
|
+
- spec/fixtures/html_element/empty-p.adoc
|
443
|
+
- spec/fixtures/html_element/empty-p.md
|
432
444
|
- spec/fixtures/html_element/heading-with-class.adoc
|
433
445
|
- spec/fixtures/html_element/heading-with-class.md
|
434
446
|
- spec/fixtures/html_element/heading-with-id.adoc
|
435
447
|
- spec/fixtures/html_element/heading-with-id.md
|
436
448
|
- spec/fixtures/html_element/img-with-alt-and-width.adoc
|
437
449
|
- spec/fixtures/html_element/img-with-alt-and-width.md
|
450
|
+
- spec/fixtures/html_element/img-with-css-width.adoc
|
451
|
+
- spec/fixtures/html_element/img-with-css-width.md
|
438
452
|
- spec/fixtures/html_element/img-with-width.adoc
|
439
453
|
- spec/fixtures/html_element/img-with-width.md
|
440
454
|
- spec/fixtures/html_element/img.adoc
|
@@ -493,8 +507,8 @@ test_files:
|
|
493
507
|
- spec/fixtures/p/admonition/strong-emphasis.md
|
494
508
|
- spec/fixtures/p/multiple-lines.adoc
|
495
509
|
- spec/fixtures/p/multiple-lines.md
|
496
|
-
- spec/fixtures/p/
|
497
|
-
- spec/fixtures/p/
|
510
|
+
- spec/fixtures/p/sequential.adoc
|
511
|
+
- spec/fixtures/p/sequential.md
|
498
512
|
- spec/fixtures/p/single-line.adoc
|
499
513
|
- spec/fixtures/p/single-line.md
|
500
514
|
- spec/fixtures/root/body-only.adoc
|
@@ -515,6 +529,8 @@ test_files:
|
|
515
529
|
- spec/fixtures/strong/constrained.md
|
516
530
|
- spec/fixtures/strong/nested-emphasis.adoc
|
517
531
|
- spec/fixtures/strong/nested-emphasis.md
|
532
|
+
- spec/fixtures/table/alignment.adoc
|
533
|
+
- spec/fixtures/table/alignment.md
|
518
534
|
- spec/fixtures/table/cell-with-pipe.adoc
|
519
535
|
- spec/fixtures/table/cell-with-pipe.md
|
520
536
|
- spec/fixtures/table/single-column-with-header.adoc
|