kramdown-asciidoc 2.0.0 → 2.0.1
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/Gemfile +2 -2
- data/LICENSE.adoc +1 -1
- data/README.adoc +2 -2
- data/bin/kramdoc +1 -3
- data/kramdown-asciidoc.gemspec +1 -1
- data/lib/kramdown-asciidoc/api.rb +8 -2
- data/lib/kramdown-asciidoc/cli.rb +5 -7
- data/lib/kramdown-asciidoc/converter.rb +13 -4
- data/lib/kramdown-asciidoc/core_ext/yaml.rb +14 -0
- data/lib/kramdown-asciidoc/preprocessors.rb +1 -1
- data/lib/kramdown-asciidoc/version.rb +1 -1
- data/lib/kramdown-asciidoc.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2f299ca0d156093eca0b0bf206f13bbedb23604e4f6a237b2b5aa16faa76eb0
|
4
|
+
data.tar.gz: 7bc8f03b29ecc1986f25c53858a3f4920b3ff3ba8a1d4b3313cee73c4be0dcaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d67ddef393d8155a0362ca7c8f0a997cf16f232f1293c13c8cb49ffa08009353224fa9703a25a4f1ab3b3b3dc4b048b56721b15d344695ec025ab3c8223efbe
|
7
|
+
data.tar.gz: 3ad990caafd8c8dd4eb0854e1af5095be820b735feff16d28aeac09b98967aabbefc43d6ecae35bda318d8cfdf65a691ea1e34e6b8a060337b17086b4a58e61e
|
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
|
+
== 2.0.1 (2022-06-29) - @mojavelinux
|
9
|
+
|
10
|
+
=== Fixed
|
11
|
+
|
12
|
+
* Fix crash when fenced code block is empty and does not specify a language (#93)
|
13
|
+
* Fix crash when input contains `<script>` tag (#98)
|
14
|
+
* Fix crash if blockquote ends with nested block (#96)
|
15
|
+
* Handle text that maps to an abbreviation (#97)
|
16
|
+
* Handle front matter value that is parsed as a date or datetime (#95)
|
17
|
+
|
18
|
+
=== Changed
|
19
|
+
|
20
|
+
* Add JRuby 9.3 to CI matrix
|
21
|
+
|
22
|
+
=== Details
|
23
|
+
|
24
|
+
{url-repo}/releases/tag/v2.0.1[git tag] | {url-repo}/compare/v2.0.0\...v2.0.1[full diff]
|
25
|
+
|
8
26
|
== 2.0.0 (2021-07-11) - @mojavelinux
|
9
27
|
|
10
28
|
=== Added
|
data/Gemfile
CHANGED
@@ -12,9 +12,9 @@ group :docs do
|
|
12
12
|
end unless without.include? 'docs'
|
13
13
|
|
14
14
|
group :lint do
|
15
|
-
gem 'rubocop', '~> 1.
|
15
|
+
gem 'rubocop', '~> 1.28.0', require: false
|
16
16
|
gem 'rubocop-rake', '~> 0.6.0', require: false
|
17
|
-
gem 'rubocop-rspec', '~> 2.
|
17
|
+
gem 'rubocop-rspec', '~> 2.10.0', require: false
|
18
18
|
end unless without.include? 'lint'
|
19
19
|
|
20
20
|
group :coverage do
|
data/LICENSE.adoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
.The MIT License
|
2
2
|
....
|
3
|
-
Copyright (C) 2016-
|
3
|
+
Copyright (C) 2016-2021 OpenDevise Inc. and the individual contributors to {project-name}.
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.adoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= {project-name} (Markdown to AsciiDoc)
|
2
2
|
Dan Allen <https://github.com/mojavelinux>
|
3
|
-
v2.0.
|
3
|
+
v2.0.1, 2022-06-29
|
4
4
|
// Aliases:
|
5
5
|
:project-name: Kramdown AsciiDoc
|
6
6
|
:project-handle: kramdown-asciidoc
|
@@ -367,7 +367,7 @@ To avoid having to do this, or make the `kramdoc` command available from anywher
|
|
367
367
|
|
368
368
|
== Copyright
|
369
369
|
|
370
|
-
Copyright (C) 2016-
|
370
|
+
Copyright (C) 2016-2021 OpenDevise Inc. and the individual contributors to {project-name}.
|
371
371
|
Free use of this software is granted under the terms of the MIT License.
|
372
372
|
|
373
373
|
See the link:LICENSE.adoc[LICENSE] file for details.
|
data/bin/kramdoc
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
kramdown_asciidoc = File.
|
5
|
-
if File.exist? kramdown_asciidoc
|
4
|
+
if File.file? (kramdown_asciidoc = File.join (File.dirname __dir__), 'lib/kramdown-asciidoc.rb')
|
6
5
|
require kramdown_asciidoc
|
7
6
|
else
|
8
7
|
require 'kramdown-asciidoc'
|
9
8
|
end
|
10
|
-
|
11
9
|
require 'kramdown-asciidoc/cli'
|
12
10
|
|
13
11
|
exit Kramdown::AsciiDoc::Cli.run
|
data/kramdown-asciidoc.gemspec
CHANGED
@@ -27,7 +27,10 @@ module AsciiDoc
|
|
27
27
|
# @option opts [Symbol] :wrap (:preserve) the line wrapping behavior to apply (:preserve, :ventilate, or :none).
|
28
28
|
# @option opts [Integer] :heading_offset (0) the heading offset to apply to heading levels.
|
29
29
|
# @option opts [Boolean] :auto_links (true) whether to allow raw URLs to be recognized as links.
|
30
|
-
# @option opts [Hash] :attributes ({}) AsciiDoc attributes to add to
|
30
|
+
# @option opts [Hash] :attributes ({}) additional AsciiDoc attributes to add to header of output document; reserved
|
31
|
+
# attributes, like stem, may be overridden; some attributes may impact conversion, such as idprefix and idseparator
|
32
|
+
# @option opts [String] :imagesdir (nil) the prefix to remove from image references found in the Markdown document;
|
33
|
+
# if not specified, the value of the imagesdir attribute is used
|
31
34
|
# @option opts [Symbol] :encode (true) whether to reencode the source to UTF-8.
|
32
35
|
# @option opts [Array<Proc>] :preprocessors ([]) a list of preprocessors functions to execute on the cleaned Markdown source.
|
33
36
|
# @option opts [Array<Proc>] :postprocessors ([]) a list of functions through which to run the output document.
|
@@ -82,7 +85,10 @@ module AsciiDoc
|
|
82
85
|
# @option opts [Symbol] :wrap (:preserve) the line wrapping behavior to apply (:preserve, :ventilate, or :none).
|
83
86
|
# @option opts [Integer] :heading_offset (0) the heading offset to apply to heading levels.
|
84
87
|
# @option opts [Boolean] :auto_links (true) whether to allow raw URLs to be recognized as links.
|
85
|
-
# @option opts [Hash] :attributes ({}) AsciiDoc attributes to add to
|
88
|
+
# @option opts [Hash] :attributes ({}) additional AsciiDoc attributes to add to header of output document; reserved
|
89
|
+
# attributes, like stem, may be overridden; some attributes may impact conversion, such as idprefix and idseparator
|
90
|
+
# @option opts [String] :imagesdir (nil) the prefix to remove from image references found in the Markdown document;
|
91
|
+
# if not specified, the value of the imagesdir attribute is used
|
86
92
|
# @option opts [Array<Proc>] :preprocessors ([]) a list of preprocessors functions to execute on the cleaned Markdown source.
|
87
93
|
# @option opts [Array<Proc>] :postprocessors ([]) a list of functions through which to run the output document.
|
88
94
|
# @option opts [Proc] :postprocess (nil) a function through which to run the output document (if :postprocessors is falsy).
|
@@ -15,7 +15,7 @@ module AsciiDoc
|
|
15
15
|
opt_parser = ::OptionParser.new do |opts|
|
16
16
|
opts.program_name = 'kramdoc'
|
17
17
|
opts.banner = <<~EOS
|
18
|
-
Usage: #{opts.program_name} [OPTION]... FILE
|
18
|
+
Usage: #{opts.program_name} [OPTION]... FILE
|
19
19
|
|
20
20
|
Converts Markdown to AsciiDoc.
|
21
21
|
|
@@ -87,10 +87,8 @@ module AsciiDoc
|
|
87
87
|
if args.empty?
|
88
88
|
opt_parser.warn 'Please specify a Markdown file to convert.'
|
89
89
|
$stdout.write opt_parser.help
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
if args.size == 1
|
90
|
+
1
|
91
|
+
elsif args.size == 1
|
94
92
|
options[:input_file] = args[0]
|
95
93
|
[0, options]
|
96
94
|
else
|
@@ -120,8 +118,8 @@ module AsciiDoc
|
|
120
118
|
::Kramdoc.convert_file input_file, options
|
121
119
|
end
|
122
120
|
0
|
123
|
-
rescue ::IOError
|
124
|
-
$stderr.write %(kramdoc: #{
|
121
|
+
rescue ::IOError
|
122
|
+
$stderr.write %(kramdoc: #{$!.message}\n)
|
125
123
|
1
|
126
124
|
end
|
127
125
|
end
|
@@ -206,7 +206,7 @@ module AsciiDoc
|
|
206
206
|
if contents[0].start_with?(*ADMON_MARKERS_ASCIIDOC) && !(contents.include? '')
|
207
207
|
writer.add_lines contents
|
208
208
|
else
|
209
|
-
if contents.size > 1 && (contents[-1].start_with? '-- ')
|
209
|
+
if contents.size > 1 && ::String === (last_line = contents[-1]) && (last_line.start_with? '-- ')
|
210
210
|
attribution = (attribution_line = contents.pop).slice 3, attribution_line.length
|
211
211
|
writer.add_line %([,#{attribution}])
|
212
212
|
# NOTE there will be at least one non-blank line, but coerce .to_s just to be safe
|
@@ -228,18 +228,19 @@ module AsciiDoc
|
|
228
228
|
writer.start_block
|
229
229
|
end
|
230
230
|
lines = el.value.rstrip.split LF
|
231
|
+
first_line = lines[0]
|
231
232
|
if (lang = el.attr['class'])
|
232
233
|
# NOTE Kramdown always prefixes class with language-
|
233
234
|
# TODO remap lang if requested
|
234
235
|
writer.add_line %([,#{lang = lang.slice 9, lang.length}])
|
235
|
-
elsif (prompt =
|
236
|
+
elsif (prompt = first_line && (first_line.start_with? '$ '))
|
236
237
|
writer.add_line %([,#{lang = 'console'}]) if lines.include? ''
|
237
238
|
end
|
238
239
|
if lang || (el.options[:fenced] && !prompt)
|
239
240
|
writer.add_line '----'
|
240
241
|
writer.add_lines lines
|
241
242
|
writer.add_line '----'
|
242
|
-
elsif !prompt && ((lines.include? '') || (ListMarkerRx.match?
|
243
|
+
elsif !prompt && ((lines.include? '') || (first_line && (ListMarkerRx.match? first_line)))
|
243
244
|
writer.add_line '....'
|
244
245
|
writer.add_lines lines
|
245
246
|
writer.add_line '....'
|
@@ -487,6 +488,10 @@ module AsciiDoc
|
|
487
488
|
next_el && next_el.type == :text && (WordRx.match? next_el.value.chr)
|
488
489
|
end
|
489
490
|
|
491
|
+
def convert_abbreviation el, opts
|
492
|
+
opts[:writer].append el.value
|
493
|
+
end
|
494
|
+
|
490
495
|
def convert_text el, opts
|
491
496
|
text = escape_replacements el.value
|
492
497
|
if text.include? '++'
|
@@ -546,7 +551,11 @@ module AsciiDoc
|
|
546
551
|
end
|
547
552
|
|
548
553
|
def convert_html_element el, opts
|
549
|
-
if (tag = el.value) == '
|
554
|
+
if (tag = el.value) == 'script'
|
555
|
+
opts[:writer].start_block
|
556
|
+
opts[:writer].add_lines ['++++', '<script>', el.children[0].value.strip, '</script>', '++++']
|
557
|
+
return
|
558
|
+
elsif tag == 'div' && (child_i = el.children[0]) && child_i.options[:transparent] && (child_i_i = child_i.children[0])
|
550
559
|
if child_i_i.value == 'span' && ((role = el.attr['class'].to_s).start_with? 'note') && child_i_i.attr['class'] == 'notetitle'
|
551
560
|
marker = ADMON_FORMATTED_MARKERS[(to_element child_i_i.children[0]).value] || 'Note'
|
552
561
|
lines = compose_text (child_i.children.drop 1), parent: child_i, strip: true, split: true, wrap: @wrap
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
autoload :Date, 'time'
|
6
|
+
autoload :Time, 'time'
|
7
|
+
|
8
|
+
unless (YAML.method :safe_load).parameters.include? [:key, :aliases]
|
9
|
+
YAML.singleton_class.prepend (Module.new do
|
10
|
+
def safe_load yaml, permitted_classes: [], permitted_symbols: [], aliases: false, filename: nil
|
11
|
+
super yaml, permitted_classes, permitted_symbols, aliases, filename
|
12
|
+
end
|
13
|
+
end)
|
14
|
+
end
|
@@ -18,7 +18,7 @@ module AsciiDoc
|
|
18
18
|
end
|
19
19
|
return source unless line && line.chomp == '---' && !(front_matter.include? ?\n)
|
20
20
|
lines.shift while (line = lines[0]) && line == ?\n
|
21
|
-
(::YAML.safe_load front_matter.join).each do |key, val|
|
21
|
+
(::YAML.safe_load front_matter.join, permitted_classes: [::Date, ::Time]).each do |key, val|
|
22
22
|
if key == 'layout'
|
23
23
|
attributes['page-layout'] = val unless val == 'default'
|
24
24
|
else
|
data/lib/kramdown-asciidoc.rb
CHANGED
@@ -4,6 +4,7 @@ require 'kramdown'
|
|
4
4
|
require_relative 'kramdown-asciidoc/kramdown_ext/parser/base'
|
5
5
|
require_relative 'kramdown-asciidoc/kramdown_ext/parser/html'
|
6
6
|
require_relative 'kramdown-asciidoc/core_ext/regexp/is_match'
|
7
|
+
require_relative 'kramdown-asciidoc/core_ext/yaml'
|
7
8
|
require_relative 'kramdown-asciidoc/preprocessors'
|
8
9
|
require_relative 'kramdown-asciidoc/writer'
|
9
10
|
require_relative 'kramdown-asciidoc/converter'
|
@@ -13,4 +14,3 @@ Kramdown::Converter::Asciidoc = Kramdown::AsciiDoc::Converter
|
|
13
14
|
# add Kramdoc alias
|
14
15
|
Kramdoc = Kramdown::AsciiDoc
|
15
16
|
autoload :Pathname, 'pathname'
|
16
|
-
autoload :YAML, 'yaml'
|
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: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Allen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 3.
|
75
|
+
version: 3.11.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 3.
|
82
|
+
version: 3.11.0
|
83
83
|
description: A kramdown extension for converting Markdown documents to AsciiDoc.
|
84
84
|
email:
|
85
85
|
- dan.j.allen@gmail.com
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- lib/kramdown-asciidoc/cli.rb
|
101
101
|
- lib/kramdown-asciidoc/converter.rb
|
102
102
|
- lib/kramdown-asciidoc/core_ext/regexp/is_match.rb
|
103
|
+
- lib/kramdown-asciidoc/core_ext/yaml.rb
|
103
104
|
- lib/kramdown-asciidoc/kramdown_ext/parser/base.rb
|
104
105
|
- lib/kramdown-asciidoc/kramdown_ext/parser/html.rb
|
105
106
|
- lib/kramdown-asciidoc/preprocessors.rb
|
@@ -128,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
129
|
- !ruby/object:Gem::Version
|
129
130
|
version: '0'
|
130
131
|
requirements: []
|
131
|
-
rubygems_version: 3.
|
132
|
+
rubygems_version: 3.3.7
|
132
133
|
signing_key:
|
133
134
|
specification_version: 4
|
134
135
|
summary: A Markdown to AsciiDoc converter based on kramdown
|