coradoc 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.docker/Dockerfile +1 -1
- data/.docker/docker-compose.yml +2 -2
- data/.editorconfig +15 -0
- data/CHANGELOG.md +4 -0
- data/Rakefile +10 -0
- data/coradoc.gemspec +11 -2
- data/exe/reverse_adoc +70 -0
- data/exe/w2a +72 -0
- data/lib/coradoc/document.rb +5 -6
- data/lib/coradoc/element/admonition.rb +8 -6
- data/lib/coradoc/element/attribute_list.rb +2 -2
- data/lib/coradoc/element/audio.rb +1 -1
- data/lib/coradoc/element/author.rb +16 -14
- data/lib/coradoc/element/base.rb +0 -2
- data/lib/coradoc/element/block/core.rb +2 -2
- data/lib/coradoc/element/block/literal.rb +1 -1
- data/lib/coradoc/element/block/sourcecode.rb +2 -2
- data/lib/coradoc/element/image/core.rb +1 -0
- data/lib/coradoc/element/image.rb +0 -1
- data/lib/coradoc/element/inline/bold.rb +1 -0
- data/lib/coradoc/element/inline/highlight.rb +1 -0
- data/lib/coradoc/element/inline/image.rb +1 -0
- data/lib/coradoc/element/inline/italic.rb +1 -0
- data/lib/coradoc/element/inline/link.rb +9 -9
- data/lib/coradoc/element/inline/monospace.rb +1 -0
- data/lib/coradoc/element/inline/quotation.rb +1 -0
- data/lib/coradoc/element/inline/subscript.rb +1 -0
- data/lib/coradoc/element/inline/superscript.rb +1 -0
- data/lib/coradoc/element/inline.rb +0 -1
- data/lib/coradoc/element/list/core.rb +3 -4
- data/lib/coradoc/element/list.rb +0 -1
- data/lib/coradoc/element/list_item.rb +1 -1
- data/lib/coradoc/element/paragraph.rb +1 -1
- data/lib/coradoc/element/revision.rb +18 -16
- data/lib/coradoc/element/table.rb +10 -10
- data/lib/coradoc/element/text_element.rb +21 -15
- data/lib/coradoc/element/title.rb +2 -2
- data/lib/coradoc/element/video.rb +1 -1
- data/lib/coradoc/generator.rb +2 -2
- data/lib/coradoc/legacy_parser.rb +41 -41
- data/lib/coradoc/oscal.rb +2 -4
- data/lib/coradoc/parser/asciidoc/content.rb +15 -15
- data/lib/coradoc/parser/asciidoc/document_attributes.rb +1 -1
- data/lib/coradoc/parser/asciidoc/header.rb +6 -6
- data/lib/coradoc/parser/asciidoc/section.rb +1 -1
- data/lib/coradoc/reverse_adoc/LICENSE.txt +25 -0
- data/lib/coradoc/reverse_adoc/README.adoc +302 -0
- data/lib/coradoc/reverse_adoc/cleaner.rb +113 -0
- data/lib/coradoc/reverse_adoc/config.rb +54 -0
- data/lib/coradoc/reverse_adoc/converters/a.rb +42 -0
- data/lib/coradoc/reverse_adoc/converters/aside.rb +16 -0
- data/lib/coradoc/reverse_adoc/converters/audio.rb +29 -0
- data/lib/coradoc/reverse_adoc/converters/base.rb +100 -0
- data/lib/coradoc/reverse_adoc/converters/blockquote.rb +27 -0
- data/lib/coradoc/reverse_adoc/converters/br.rb +15 -0
- data/lib/coradoc/reverse_adoc/converters/bypass.rb +81 -0
- data/lib/coradoc/reverse_adoc/converters/code.rb +56 -0
- data/lib/coradoc/reverse_adoc/converters/div.rb +18 -0
- data/lib/coradoc/reverse_adoc/converters/drop.rb +22 -0
- data/lib/coradoc/reverse_adoc/converters/em.rb +55 -0
- data/lib/coradoc/reverse_adoc/converters/figure.rb +25 -0
- data/lib/coradoc/reverse_adoc/converters/h.rb +42 -0
- data/lib/coradoc/reverse_adoc/converters/head.rb +23 -0
- data/lib/coradoc/reverse_adoc/converters/hr.rb +15 -0
- data/lib/coradoc/reverse_adoc/converters/ignore.rb +16 -0
- data/lib/coradoc/reverse_adoc/converters/img.rb +93 -0
- data/lib/coradoc/reverse_adoc/converters/li.rb +17 -0
- data/lib/coradoc/reverse_adoc/converters/mark.rb +21 -0
- data/lib/coradoc/reverse_adoc/converters/math.rb +31 -0
- data/lib/coradoc/reverse_adoc/converters/ol.rb +64 -0
- data/lib/coradoc/reverse_adoc/converters/p.rb +23 -0
- data/lib/coradoc/reverse_adoc/converters/pass_through.rb +13 -0
- data/lib/coradoc/reverse_adoc/converters/pre.rb +55 -0
- data/lib/coradoc/reverse_adoc/converters/q.rb +16 -0
- data/lib/coradoc/reverse_adoc/converters/strong.rb +52 -0
- data/lib/coradoc/reverse_adoc/converters/sub.rb +16 -0
- data/lib/coradoc/reverse_adoc/converters/sup.rb +16 -0
- data/lib/coradoc/reverse_adoc/converters/table.rb +69 -0
- data/lib/coradoc/reverse_adoc/converters/td.rb +83 -0
- data/lib/coradoc/reverse_adoc/converters/text.rb +65 -0
- data/lib/coradoc/reverse_adoc/converters/th.rb +14 -0
- data/lib/coradoc/reverse_adoc/converters/tr.rb +22 -0
- data/lib/coradoc/reverse_adoc/converters/video.rb +29 -0
- data/lib/coradoc/reverse_adoc/converters.rb +32 -0
- data/lib/coradoc/reverse_adoc/errors.rb +10 -0
- data/lib/coradoc/reverse_adoc/html_converter.rb +61 -0
- data/lib/coradoc/reverse_adoc.rb +27 -0
- data/lib/coradoc/transformer.rb +24 -14
- data/lib/coradoc/version.rb +1 -1
- data/lib/reverse_adoc.rb +20 -0
- metadata +178 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c721a05ddb985a8bde74747c3c39e47818beca7525b13115794673394d46b2ab
|
4
|
+
data.tar.gz: f45600c3b4b85877a97904f38a03d5161b0ff83e7259ad6f54da5e1711ac9e46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0063e9145b1a8e46046c7397b4278a480535ee119624842fad72a8e9280def9de4af7c8335dc5f64b5a118040a8e178af800b27879d8c335a00d37d574b34bbb
|
7
|
+
data.tar.gz: 8f02e79025a941ab47c8f359a7638129ce2e7a7aa80352a38bb9004540efdbadff8cd3c0427641004ab834a346f7d39676b9ace64e47f62dcbb9c0b0a357d2ce
|
data/.docker/Dockerfile
CHANGED
data/.docker/docker-compose.yml
CHANGED
data/.editorconfig
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# EditorConfig is awesome: http://EditorConfig.org
|
2
|
+
|
3
|
+
# top-most EditorConfig file
|
4
|
+
root = true
|
5
|
+
|
6
|
+
# Unix-style newlines with a newline ending every file
|
7
|
+
[*]
|
8
|
+
charset = utf-8
|
9
|
+
end_of_line = lf
|
10
|
+
|
11
|
+
[{*.adoc,*.html,*.js,*.json,*.rake,*.rb,*.rf,*.yaml,*.yml,Rakefile,rakefile}]
|
12
|
+
indent_style = space
|
13
|
+
indent_size = 2
|
14
|
+
insert_final_newline = true
|
15
|
+
trim_trailing_whitespace = true
|
data/CHANGELOG.md
CHANGED
data/Rakefile
CHANGED
@@ -1,7 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "bundler/gem_tasks"
|
4
|
+
|
5
|
+
if File.exist?(".codeclimate")
|
6
|
+
ENV["CODECLIMATE_REPO_TOKEN"] = File.read(".codeclimate").strip
|
7
|
+
end
|
8
|
+
|
4
9
|
require "rspec/core/rake_task"
|
5
10
|
|
6
11
|
RSpec::Core::RakeTask.new(:spec)
|
7
12
|
task default: :spec
|
13
|
+
|
14
|
+
desc "Open an irb session preloaded with this library"
|
15
|
+
task :console do
|
16
|
+
sh "irb -Ilib -rcoradoc -rcoradoc/reverse_adoc"
|
17
|
+
end
|
data/coradoc.gemspec
CHANGED
@@ -28,11 +28,20 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
spec.required_ruby_version = ">= 2.7.0"
|
30
30
|
|
31
|
-
spec.add_dependency "
|
31
|
+
spec.add_dependency "marcel", "~> 1.0.0"
|
32
|
+
spec.add_dependency "mathml2asciimath"
|
33
|
+
spec.add_dependency "nokogiri", "~> 1.13"
|
32
34
|
spec.add_dependency "oscal", "~> 0.1.1"
|
33
|
-
|
35
|
+
spec.add_dependency "parslet"
|
36
|
+
spec.add_dependency "premailer", "~> 1.11.0"
|
37
|
+
spec.add_dependency "word-to-markdown"
|
38
|
+
spec.add_development_dependency "codeclimate-test-reporter"
|
34
39
|
spec.add_development_dependency "pry"
|
35
40
|
spec.add_development_dependency "rake"
|
41
|
+
spec.add_development_dependency "redcarpet"
|
36
42
|
spec.add_development_dependency "rspec"
|
37
43
|
spec.add_development_dependency "rubocop"
|
44
|
+
spec.add_development_dependency "rubocop-performance"
|
45
|
+
spec.add_development_dependency "simplecov"
|
46
|
+
# spec.add_runtime_dependency "thor"
|
38
47
|
end
|
data/exe/reverse_adoc
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Usage: reverse_adoc [FILE]...
|
3
|
+
# Usage: cat FILE | reverse_adoc
|
4
|
+
require "rubygems"
|
5
|
+
require "bundler/setup"
|
6
|
+
|
7
|
+
require "coradoc/reverse_adoc"
|
8
|
+
require "optparse"
|
9
|
+
require "fileutils"
|
10
|
+
|
11
|
+
OptionParser.new do |opts|
|
12
|
+
opts.banner = "Usage: reverse_adoc [options] <file>"
|
13
|
+
opts.on("-m", "--mathml2asciimath", "Convert MathML to AsciiMath") do |_v|
|
14
|
+
Coradoc::ReverseAdoc.config.mathml2asciimath = true
|
15
|
+
end
|
16
|
+
|
17
|
+
opts.on("-oFILENAME", "--output=FILENAME", "Output file to write to") do |v|
|
18
|
+
Coradoc::ReverseAdoc.config.destination = File.expand_path(v)
|
19
|
+
# puts "output goes to #{Coradoc::ReverseAdoc.config.destination}"
|
20
|
+
end
|
21
|
+
|
22
|
+
opts.on("-e", "--external-images", "Export images if data URI") do |_v|
|
23
|
+
Coradoc::ReverseAdoc.config.external_images = true
|
24
|
+
end
|
25
|
+
|
26
|
+
opts.on("-u", "--unknown_tags [pass_through, drop, bypass, raise]",
|
27
|
+
"Unknown tag handling (default: pass_through)") do |v|
|
28
|
+
Coradoc::ReverseAdoc.config.unknown_tags = v
|
29
|
+
end
|
30
|
+
|
31
|
+
opts.on("-v", "--version", "Version information") do |_v|
|
32
|
+
puts "reverse_adoc: v#{Coradoc::ReverseAdoc::VERSION}"
|
33
|
+
exit
|
34
|
+
end
|
35
|
+
|
36
|
+
opts.on("-h", "--help", "Prints this help") do
|
37
|
+
puts opts
|
38
|
+
exit
|
39
|
+
end
|
40
|
+
end.parse!
|
41
|
+
|
42
|
+
if filename = ARGV.pop
|
43
|
+
input_content = IO.read(filename)
|
44
|
+
Coradoc::ReverseAdoc.config.sourcedir = File.dirname(File.expand_path(filename))
|
45
|
+
else
|
46
|
+
if Coradoc::ReverseAdoc.config.external_images
|
47
|
+
raise "The -e | --external-images feature cannot be used with STDIN input. Exiting."
|
48
|
+
end
|
49
|
+
|
50
|
+
input_content = ARGF.read
|
51
|
+
end
|
52
|
+
|
53
|
+
if Coradoc::ReverseAdoc.config.external_images && Coradoc::ReverseAdoc.config.destination.nil?
|
54
|
+
raise "The -e | --external-images feature must be used with -o | --output. Exiting."
|
55
|
+
end
|
56
|
+
|
57
|
+
# Read from STDIN
|
58
|
+
adoc_content = Coradoc::ReverseAdoc.convert(input_content)
|
59
|
+
|
60
|
+
# Print to STDOUT
|
61
|
+
unless Coradoc::ReverseAdoc.config.destination
|
62
|
+
puts adoc_content
|
63
|
+
exit
|
64
|
+
end
|
65
|
+
|
66
|
+
# Write output to Coradoc::ReverseAdoc.config.destination
|
67
|
+
FileUtils.mkdir_p(File.dirname(Coradoc::ReverseAdoc.config.destination))
|
68
|
+
File.open(Coradoc::ReverseAdoc.config.destination, "w") do |file|
|
69
|
+
file.write(adoc_content)
|
70
|
+
end
|
data/exe/w2a
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "rubygems"
|
5
|
+
require "bundler/setup"
|
6
|
+
|
7
|
+
require "word-to-markdown"
|
8
|
+
require "optparse"
|
9
|
+
require "coradoc/reverse_adoc"
|
10
|
+
|
11
|
+
ARGV.push("-h") if ARGV.empty?
|
12
|
+
|
13
|
+
OptionParser.new do |opts|
|
14
|
+
opts.banner = "Usage: w2a [options] <file>"
|
15
|
+
opts.on("-m", "--mathml2asciimath", "Convert MathML to AsciiMath") do |_v|
|
16
|
+
Coradoc::ReverseAdoc.config.mathml2asciimath = true
|
17
|
+
end
|
18
|
+
|
19
|
+
opts.on("-oFILENAME", "--output=FILENAME", "Output file to write to") do |v|
|
20
|
+
Coradoc::ReverseAdoc.config.destination = File.expand_path(v)
|
21
|
+
# puts "output goes to #{Coradoc::ReverseAdoc.config.destination}"
|
22
|
+
end
|
23
|
+
|
24
|
+
opts.on("-e", "--external-images", "Export images if data URI") do |_v|
|
25
|
+
Coradoc::ReverseAdoc.config.external_images = true
|
26
|
+
end
|
27
|
+
|
28
|
+
opts.on("-v", "--version", "Version information") do |_v|
|
29
|
+
puts "reverse_adoc: v#{Coradoc::ReverseAdoc::VERSION}"
|
30
|
+
puts "[dependency] WordToMarkdown: v#{WordToMarkdown::VERSION}"
|
31
|
+
if Gem.win_platform?
|
32
|
+
puts "[dependency] LibreOffice: version not available on Windows"
|
33
|
+
else
|
34
|
+
puts "[dependency] LibreOffice: v#{WordToMarkdown.soffice.version}"
|
35
|
+
end
|
36
|
+
exit
|
37
|
+
end
|
38
|
+
|
39
|
+
opts.on("-h", "--help", "Prints this help") do
|
40
|
+
puts opts
|
41
|
+
exit
|
42
|
+
end
|
43
|
+
end.parse!
|
44
|
+
|
45
|
+
filename = ARGV.pop
|
46
|
+
raise "Please provide an input file to process. Exiting." unless filename
|
47
|
+
|
48
|
+
if Coradoc::ReverseAdoc.config.external_images && Coradoc::ReverseAdoc.config.destination.nil?
|
49
|
+
raise "The -e | --external-images feature must be used with -o | --output. Exiting."
|
50
|
+
end
|
51
|
+
|
52
|
+
Coradoc::ReverseAdoc.config.sourcedir = Dir.mktmpdir
|
53
|
+
|
54
|
+
doc = WordToMarkdown.new(filename, Coradoc::ReverseAdoc.config.sourcedir)
|
55
|
+
# File.open("test.html", "w:UTF-8") { |f| f.write doc.document.html }
|
56
|
+
adoc_content = Coradoc::ReverseAdoc.convert(
|
57
|
+
Coradoc::ReverseAdoc.cleaner.preprocess_word_html(doc.document.html),
|
58
|
+
WordToMarkdown::REVERSE_MARKDOWN_OPTIONS,
|
59
|
+
)
|
60
|
+
# puts scrub_whitespace(doc.document.html)
|
61
|
+
|
62
|
+
# Print to STDOUT
|
63
|
+
unless Coradoc::ReverseAdoc.config.destination
|
64
|
+
puts adoc_content
|
65
|
+
exit
|
66
|
+
end
|
67
|
+
|
68
|
+
# Write output to Coradoc::ReverseAdoc.config.destination
|
69
|
+
FileUtils.mkdir_p(File.dirname(Coradoc::ReverseAdoc.config.destination))
|
70
|
+
File.open(Coradoc::ReverseAdoc.config.destination, "w") do |file|
|
71
|
+
file.write(adoc_content)
|
72
|
+
end
|
data/lib/coradoc/document.rb
CHANGED
@@ -20,7 +20,6 @@ require_relative "element/break"
|
|
20
20
|
|
21
21
|
module Coradoc
|
22
22
|
class Document
|
23
|
-
|
24
23
|
class << self
|
25
24
|
def from_adoc(filename)
|
26
25
|
ast = Coradoc::Parser.parse(filename)
|
@@ -43,22 +42,22 @@ module Coradoc
|
|
43
42
|
end
|
44
43
|
end
|
45
44
|
|
46
|
-
|
45
|
+
new(
|
47
46
|
document_attributes: @document_attributes,
|
48
47
|
header: @header,
|
49
|
-
sections: @sections
|
48
|
+
sections: @sections,
|
50
49
|
)
|
51
50
|
end
|
52
51
|
end
|
53
52
|
|
54
53
|
attr_accessor :header, :document_attributes, :sections
|
55
54
|
|
56
|
-
def initialize(options={})
|
57
|
-
@document_attributes = options.fetch(:document_attributes,
|
55
|
+
def initialize(options = {})
|
56
|
+
@document_attributes = options.fetch(:document_attributes,
|
57
|
+
Coradoc::Element::DocumentAttributes.new)
|
58
58
|
@header = options.fetch(:header, Coradoc::Element::Header.new(""))
|
59
59
|
@sections = options.fetch(:sections, [])
|
60
60
|
self
|
61
61
|
end
|
62
|
-
|
63
62
|
end
|
64
63
|
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
module Coradoc
|
2
|
-
|
3
|
-
|
2
|
+
module Element
|
3
|
+
class Admonition
|
4
|
+
attr_reader :type, :content, :line_break
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
def initialize(content, type, options = {})
|
7
|
+
@content = content
|
8
|
+
@type = type.downcase.to_sym
|
9
|
+
@line_break = options.fetch(:line_break, "")
|
10
|
+
end
|
9
11
|
end
|
10
12
|
end
|
11
13
|
end
|
@@ -29,12 +29,12 @@ module Coradoc
|
|
29
29
|
adoc << @named.map do |k, v|
|
30
30
|
if v.is_a?(String)
|
31
31
|
v2 = v.to_s
|
32
|
-
v2 = v2.include?("\"") ? v2.gsub("\"","\\\"") : v2
|
32
|
+
v2 = v2.include?("\"") ? v2.gsub("\"", "\\\"") : v2
|
33
33
|
if v2.include?(" ") || v2.include?(",") || v2.include?("\"")
|
34
34
|
v2 = "\"#{v2}\""
|
35
35
|
end
|
36
36
|
elsif v.is_a?(Array)
|
37
|
-
v2 = "\"#{v.join(
|
37
|
+
v2 = "\"#{v.join(',')}\""
|
38
38
|
end
|
39
39
|
[k.to_s, "=", v2].join
|
40
40
|
end.join(",")
|
@@ -1,20 +1,22 @@
|
|
1
1
|
module Coradoc
|
2
|
-
|
3
|
-
|
2
|
+
module Element
|
3
|
+
class Author
|
4
|
+
attr_reader :email, :last_name, :first_name
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
def initialize(first_name, last_name, email, middle_name = nil)
|
7
|
+
@first_name = first_name
|
8
|
+
@last_name = last_name
|
9
|
+
@email = email
|
10
|
+
@middle_name = middle_name
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
def to_adoc
|
14
|
+
adoc = "#{@first_name} "
|
15
|
+
adoc << "#{@middle_name} " if @middle_name
|
16
|
+
adoc << @last_name.to_s
|
17
|
+
adoc << " <#{@email}>" if @email
|
18
|
+
adoc
|
19
|
+
end
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
data/lib/coradoc/element/base.rb
CHANGED
@@ -28,6 +28,7 @@ module Coradoc
|
|
28
28
|
def gen_title
|
29
29
|
t = Coradoc::Generator.gen_adoc(@title)
|
30
30
|
return "" if t.empty?
|
31
|
+
|
31
32
|
".#{t}\n"
|
32
33
|
end
|
33
34
|
|
@@ -59,10 +60,9 @@ module Coradoc
|
|
59
60
|
"****" => :side,
|
60
61
|
"----" => :source,
|
61
62
|
"====" => :example,
|
62
|
-
"...." => :literal
|
63
|
+
"...." => :literal,
|
63
64
|
}
|
64
65
|
end
|
65
|
-
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
@@ -2,7 +2,7 @@ module Coradoc
|
|
2
2
|
module Element
|
3
3
|
module Block
|
4
4
|
class Literal < Core
|
5
|
-
def initialize(
|
5
|
+
def initialize(_title, options = {})
|
6
6
|
@id = options.fetch(:id, nil)
|
7
7
|
@anchor = @id.nil? ? nil : Inline::Anchor.new(@id)
|
8
8
|
@lines = options.fetch(:lines, [])
|
@@ -2,10 +2,10 @@ module Coradoc
|
|
2
2
|
module Element
|
3
3
|
module Block
|
4
4
|
class SourceCode < Core
|
5
|
-
def initialize(
|
5
|
+
def initialize(_title, options = {})
|
6
6
|
@id = options.fetch(:id, nil)
|
7
7
|
@anchor = @id.nil? ? nil : Inline::Anchor.new(@id)
|
8
|
-
@lang = options.fetch(:lang,
|
8
|
+
@lang = options.fetch(:lang, "")
|
9
9
|
@lines = options.fetch(:lines, [])
|
10
10
|
@delimiter_char = "-"
|
11
11
|
@delimiter_len = options.fetch(:delimiter_len, 4)
|
@@ -5,19 +5,19 @@ module Coradoc
|
|
5
5
|
attr_reader :path, :title, :name
|
6
6
|
|
7
7
|
def initialize(options = {})
|
8
|
-
@path = options.fetch(:path,nil)
|
8
|
+
@path = options.fetch(:path, nil)
|
9
9
|
@title = options.fetch(:title, nil)
|
10
|
-
@name = options.fetch(:name,nil)
|
10
|
+
@name = options.fetch(:name, nil)
|
11
11
|
end
|
12
12
|
|
13
13
|
def to_adoc
|
14
|
-
link = @path.to_s
|
15
|
-
if @name.to_s.empty?
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
link.prepend(
|
14
|
+
link = @path.to_s&.match?(URI::DEFAULT_PARSER.make_regexp) ? @path : "link:#{@path}"
|
15
|
+
link << if @name.to_s.empty?
|
16
|
+
"[#{@title}]"
|
17
|
+
else
|
18
|
+
"[#{@name}]"
|
19
|
+
end
|
20
|
+
link.prepend(" ")
|
21
21
|
link
|
22
22
|
end
|
23
23
|
end
|
@@ -21,15 +21,14 @@ module Coradoc
|
|
21
21
|
@items.each do |item|
|
22
22
|
c = Coradoc::Generator.gen_adoc(item)
|
23
23
|
if !c.empty?
|
24
|
-
content <<
|
24
|
+
content << prefix.to_s
|
25
25
|
content << c
|
26
26
|
end
|
27
27
|
end
|
28
|
-
anchor = @anchor.nil? ? "" :
|
29
|
-
attrs = @attrs.nil? ? "" :
|
28
|
+
anchor = @anchor.nil? ? "" : @anchor.to_adoc.to_s
|
29
|
+
attrs = @attrs.nil? ? "" : @attrs.to_adoc.to_s
|
30
30
|
"\n#{anchor}#{attrs}" + content
|
31
31
|
end
|
32
|
-
|
33
32
|
end
|
34
33
|
end
|
35
34
|
end
|
data/lib/coradoc/element/list.rb
CHANGED
@@ -22,7 +22,7 @@ module Coradoc
|
|
22
22
|
def to_adoc
|
23
23
|
anchor = @anchor.nil? ? "" : "#{@anchor.to_adoc}\n"
|
24
24
|
if @tdsinglepara
|
25
|
-
|
25
|
+
anchor.to_s << Coradoc::Generator.gen_adoc(@content).strip
|
26
26
|
else
|
27
27
|
"\n\n#{anchor}" << Coradoc::Generator.gen_adoc(@content).strip << "\n\n"
|
28
28
|
end
|
@@ -1,22 +1,24 @@
|
|
1
1
|
module Coradoc
|
2
|
-
|
3
|
-
|
2
|
+
module Element
|
3
|
+
class Revision
|
4
|
+
attr_reader :number, :date, :remark
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
def initialize(number, options = {})
|
7
|
+
@number = number
|
8
|
+
@date = options.fetch(:date, nil)
|
9
|
+
@remark = options.fetch(:remark, nil)
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
12
|
+
def to_adoc
|
13
|
+
if @date.nil? && @remark.nil?
|
14
|
+
"v#{@number}\n"
|
15
|
+
elsif @remark.nil?
|
16
|
+
"#{@number}, #{@date}\n"
|
17
|
+
elsif @date.nil?
|
18
|
+
"#{@number}: #{@remark}\n"
|
19
|
+
else
|
20
|
+
"#{@number}, #{@date}: #{@revision}\n"
|
21
|
+
end
|
20
22
|
end
|
21
23
|
end
|
22
24
|
end
|