coradoc 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Makefile +35 -0
- data/{.docker/readme.md → README.Docker.adoc} +21 -25
- data/README.adoc +121 -0
- data/coradoc.gemspec +4 -0
- data/docker-compose.yml +14 -0
- data/exe/coradoc +5 -0
- data/exe/reverse_adoc +24 -34
- data/exe/w2a +16 -28
- data/lib/coradoc/cli.rb +105 -0
- data/lib/coradoc/converter.rb +145 -0
- data/lib/coradoc/document.rb +13 -0
- data/lib/coradoc/element/admonition.rb +5 -0
- data/lib/coradoc/element/attribute_list.rb +1 -1
- data/lib/coradoc/element/author.rb +4 -4
- data/lib/coradoc/element/bibliography.rb +24 -0
- data/lib/coradoc/element/bibliography_entry.rb +24 -0
- data/lib/coradoc/element/block/core.rb +6 -4
- data/lib/coradoc/element/block/example.rb +1 -0
- data/lib/coradoc/element/block/pass.rb +21 -0
- data/lib/coradoc/element/block/quote.rb +1 -1
- data/lib/coradoc/element/block/reviewer_comment.rb +19 -0
- data/lib/coradoc/element/block/side.rb +4 -2
- data/lib/coradoc/element/block/sourcecode.rb +1 -0
- data/lib/coradoc/element/block.rb +2 -0
- data/lib/coradoc/element/comment_block.rb +22 -0
- data/lib/coradoc/element/comment_line.rb +18 -0
- data/lib/coradoc/element/document_attributes.rb +8 -1
- data/lib/coradoc/element/header.rb +1 -1
- data/lib/coradoc/element/image/block_image.rb +8 -0
- data/lib/coradoc/element/image/core.rb +6 -5
- data/lib/coradoc/element/include.rb +18 -0
- data/lib/coradoc/element/inline/citation.rb +24 -0
- data/lib/coradoc/element/inline/cross_reference.rb +29 -8
- data/lib/coradoc/element/inline.rb +1 -0
- data/lib/coradoc/element/list/core.rb +10 -2
- data/lib/coradoc/element/list_item.rb +7 -5
- data/lib/coradoc/element/paragraph.rb +8 -5
- data/lib/coradoc/element/revision.rb +1 -1
- data/lib/coradoc/element/section.rb +6 -4
- data/lib/coradoc/element/table.rb +2 -2
- data/lib/coradoc/element/tag.rb +19 -0
- data/lib/coradoc/element/term.rb +21 -0
- data/lib/coradoc/element/text_element.rb +9 -1
- data/lib/coradoc/element/title.rb +1 -1
- data/lib/coradoc/generator.rb +2 -0
- data/lib/coradoc/input/adoc.rb +28 -0
- data/lib/coradoc/input/docx.rb +35 -0
- data/lib/coradoc/{reverse_adoc → input/html}/README.adoc +9 -9
- data/lib/coradoc/{reverse_adoc → input/html}/cleaner.rb +18 -4
- data/lib/coradoc/input/html/config.rb +75 -0
- data/lib/coradoc/{reverse_adoc → input/html}/converters/a.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/aside.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/audio.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/base.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/blockquote.rb +2 -2
- data/lib/coradoc/{reverse_adoc → input/html}/converters/br.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/bypass.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/code.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/div.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/dl.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/drop.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/em.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/figure.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/h.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/head.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/hr.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/ignore.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/img.rb +7 -7
- data/lib/coradoc/{reverse_adoc → input/html}/converters/li.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/mark.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/markup.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/math.rb +3 -3
- data/lib/coradoc/{reverse_adoc → input/html}/converters/ol.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/p.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/pass_through.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/pre.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/q.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/strong.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/sub.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/sup.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/table.rb +4 -4
- data/lib/coradoc/{reverse_adoc → input/html}/converters/td.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/text.rb +2 -2
- data/lib/coradoc/{reverse_adoc → input/html}/converters/th.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/tr.rb +1 -1
- data/lib/coradoc/{reverse_adoc → input/html}/converters/video.rb +1 -1
- data/lib/coradoc/input/html/converters.rb +57 -0
- data/lib/coradoc/input/html/errors.rb +12 -0
- data/lib/coradoc/{reverse_adoc → input/html}/html_converter.rb +37 -22
- data/lib/coradoc/{reverse_adoc → input/html}/plugin.rb +6 -6
- data/lib/coradoc/{reverse_adoc → input/html}/plugins/plateau.rb +3 -3
- data/lib/coradoc/{reverse_adoc → input/html}/postprocessor.rb +3 -3
- data/lib/coradoc/input/html.rb +59 -0
- data/lib/coradoc/input.rb +12 -0
- data/lib/coradoc/output/adoc.rb +17 -0
- data/lib/coradoc/output/coradoc_tree_debug.rb +19 -0
- data/lib/coradoc/output.rb +11 -0
- data/lib/coradoc/parser/asciidoc/admonition.rb +24 -0
- data/lib/coradoc/parser/asciidoc/attribute_list.rb +67 -0
- data/lib/coradoc/parser/asciidoc/base.rb +101 -13
- data/lib/coradoc/parser/asciidoc/bibliography.rb +30 -0
- data/lib/coradoc/parser/asciidoc/block.rb +82 -0
- data/lib/coradoc/parser/asciidoc/citation.rb +48 -0
- data/lib/coradoc/parser/asciidoc/content.rb +15 -120
- data/lib/coradoc/parser/asciidoc/document_attributes.rb +12 -5
- data/lib/coradoc/parser/asciidoc/header.rb +1 -4
- data/lib/coradoc/parser/asciidoc/inline.rb +72 -0
- data/lib/coradoc/parser/asciidoc/list.rb +81 -0
- data/lib/coradoc/parser/asciidoc/paragraph.rb +33 -0
- data/lib/coradoc/parser/asciidoc/section.rb +36 -31
- data/lib/coradoc/parser/asciidoc/table.rb +32 -0
- data/lib/coradoc/parser/asciidoc/term.rb +23 -0
- data/lib/coradoc/parser/base.rb +39 -4
- data/lib/coradoc/transformer.rb +353 -82
- data/lib/coradoc/util.rb +1 -1
- data/lib/coradoc/version.rb +1 -1
- data/lib/coradoc.rb +8 -5
- data/lib/reverse_adoc.rb +6 -6
- data/utils/parser_analyzer.rb +66 -0
- data/utils/round_trip.rb +37 -0
- metadata +112 -54
- data/.docker/Makefile +0 -35
- data/.docker/docker-compose.yml +0 -14
- data/Makefile +0 -1
- data/README.md +0 -73
- data/docker-compose.yml +0 -1
- data/lib/coradoc/reverse_adoc/config.rb +0 -73
- data/lib/coradoc/reverse_adoc/converters.rb +0 -55
- data/lib/coradoc/reverse_adoc/errors.rb +0 -10
- data/lib/coradoc/reverse_adoc.rb +0 -30
- /data/{.docker/Dockerfile → Dockerfile} +0 -0
- /data/lib/coradoc/{reverse_adoc → input/html}/LICENSE.txt +0 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
module Coradoc
|
2
|
+
module Parser
|
3
|
+
module Asciidoc
|
4
|
+
module Paragraph
|
5
|
+
|
6
|
+
def paragraph_text_line
|
7
|
+
(asciidoc_char_with_id.absent? | text_id ) >>
|
8
|
+
literal_space? >>
|
9
|
+
(text_formatted.as(:text) # >>
|
10
|
+
) | term | term2
|
11
|
+
end
|
12
|
+
|
13
|
+
def paragraph
|
14
|
+
( block_id.maybe >>
|
15
|
+
block_title.maybe >>
|
16
|
+
(attribute_list >> newline).maybe >>
|
17
|
+
(paragraph_text_line.repeat(1,1) >> any.absent? |
|
18
|
+
(paragraph_text_line >> newline_single.as(:line_break)).repeat(1) >>
|
19
|
+
(paragraph_text_line.repeat(1,1)).repeat(0,1)
|
20
|
+
).as(:lines) >>
|
21
|
+
newline.repeat(0)
|
22
|
+
).as(:paragraph)
|
23
|
+
end
|
24
|
+
|
25
|
+
def paragraph_attributes
|
26
|
+
str("[") >>
|
27
|
+
keyword.as(:key) >> str("=") >>
|
28
|
+
word.as(:value) >> str("]") >> newline
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -1,15 +1,34 @@
|
|
1
|
-
require_relative "base"
|
2
|
-
require_relative "content"
|
3
|
-
|
4
1
|
module Coradoc
|
5
2
|
module Parser
|
6
3
|
module Asciidoc
|
7
4
|
module Section
|
8
|
-
|
9
|
-
|
5
|
+
|
6
|
+
def contents
|
7
|
+
(
|
8
|
+
citation |
|
9
|
+
term | term2 |
|
10
|
+
bib_entry |
|
11
|
+
block_image |
|
12
|
+
tag |
|
13
|
+
comment_block |
|
14
|
+
comment_line |
|
15
|
+
include_directive |
|
16
|
+
admonition_line |
|
17
|
+
block.as(:block) |
|
18
|
+
table.as(:table) |
|
19
|
+
highlight.as(:highlight) |
|
20
|
+
glossaries.as(:glossaries) |
|
21
|
+
paragraph |
|
22
|
+
list |
|
23
|
+
empty_line.as(:line_break)
|
24
|
+
).repeat(1)
|
25
|
+
end
|
10
26
|
|
11
27
|
def section_block(level = 2)
|
28
|
+
return nil if level > 8
|
29
|
+
(attribute_list >> newline).maybe >>
|
12
30
|
section_id.maybe >>
|
31
|
+
(attribute_list >> newline).maybe >>
|
13
32
|
section_title(level).as(:title) >>
|
14
33
|
contents.as(:contents).maybe
|
15
34
|
end
|
@@ -23,37 +42,23 @@ module Coradoc
|
|
23
42
|
# Heading
|
24
43
|
def section_title(level = 2, max_level = 8)
|
25
44
|
match("=").repeat(level, max_level).as(:level) >>
|
26
|
-
|
45
|
+
str('=').absent? >>
|
46
|
+
space? >> text.as(:text) >> endline.as(:line_break)
|
27
47
|
end
|
28
48
|
|
29
49
|
# section
|
30
|
-
def section
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
50
|
+
def section(level = 2)
|
51
|
+
r = section_block(level)
|
52
|
+
if level < 8
|
53
|
+
r = r >> section(level + 1).as(:section).repeat(0).as(:sections)
|
54
|
+
end
|
55
|
+
if level == 2
|
56
|
+
(r).as(:section)
|
57
|
+
else
|
58
|
+
r
|
59
|
+
end
|
40
60
|
end
|
41
61
|
|
42
|
-
def third_level_section
|
43
|
-
sub_section(4) >> fourth_level_section.repeat.maybe.as(:sections)
|
44
|
-
end
|
45
|
-
|
46
|
-
def fourth_level_section
|
47
|
-
sub_section(5) >> fifth_level_section.repeat.maybe.as(:sections)
|
48
|
-
end
|
49
|
-
|
50
|
-
def fifth_level_section
|
51
|
-
sub_section(6) >> sixth_level_section.repeat.maybe.as(:sections)
|
52
|
-
end
|
53
|
-
|
54
|
-
def sixth_level_section
|
55
|
-
sub_section(7) >> sub_section(8).repeat.maybe.as(:sections)
|
56
|
-
end
|
57
62
|
end
|
58
63
|
end
|
59
64
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Coradoc
|
2
|
+
module Parser
|
3
|
+
module Asciidoc
|
4
|
+
module Table
|
5
|
+
# include Coradoc::Parser::Asciidoc::Base
|
6
|
+
|
7
|
+
def table
|
8
|
+
block_id.maybe >>
|
9
|
+
(attribute_list >> newline).maybe >>
|
10
|
+
block_title.maybe >>
|
11
|
+
(attribute_list >> newline).maybe >>
|
12
|
+
str("|===") >> line_ending >>
|
13
|
+
table_row.repeat(1).as(:rows) >>
|
14
|
+
str("|===") >> line_ending
|
15
|
+
end
|
16
|
+
|
17
|
+
def table_row
|
18
|
+
(literal_space? >> str("|") >> (cell_content | empty_cell_content))
|
19
|
+
.repeat(1).as(:cols) >> line_ending
|
20
|
+
end
|
21
|
+
|
22
|
+
def empty_cell_content
|
23
|
+
str("|").absent? >> literal_space.as(:text)
|
24
|
+
end
|
25
|
+
|
26
|
+
def cell_content
|
27
|
+
str("|").absent? >> literal_space? >> rich_texts.as(:text)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Coradoc
|
2
|
+
module Parser
|
3
|
+
module Asciidoc
|
4
|
+
module Term
|
5
|
+
def term_type
|
6
|
+
(str("alt") | str("deprecated") | str("domain")).as(:term_type)
|
7
|
+
end
|
8
|
+
|
9
|
+
def term
|
10
|
+
term_type >> str(':[') >>
|
11
|
+
match('[^\]]').repeat(1).as(:term) >>
|
12
|
+
str("]") >> str("\n").repeat(1).as(:line_break)
|
13
|
+
end
|
14
|
+
|
15
|
+
def term2
|
16
|
+
match('^\[') >> term_type >> str(']#') >>
|
17
|
+
match('[^\#]').repeat(1).as(:term2) >> str('#') >>
|
18
|
+
str("\n").repeat(1).as(:line_break)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/coradoc/parser/base.rb
CHANGED
@@ -1,22 +1,55 @@
|
|
1
1
|
require "parslet"
|
2
2
|
require "parslet/convenience"
|
3
3
|
|
4
|
-
require_relative "asciidoc/
|
4
|
+
require_relative "asciidoc/attribute_list"
|
5
|
+
require_relative "asciidoc/base"
|
6
|
+
require_relative "asciidoc/block"
|
7
|
+
require_relative "asciidoc/citation"
|
8
|
+
require_relative "asciidoc/content"
|
5
9
|
require_relative "asciidoc/document_attributes"
|
10
|
+
require_relative "asciidoc/header"
|
11
|
+
require_relative "asciidoc/inline"
|
12
|
+
require_relative "asciidoc/list"
|
13
|
+
require_relative "asciidoc/paragraph"
|
6
14
|
require_relative "asciidoc/section"
|
15
|
+
require_relative "asciidoc/table"
|
16
|
+
require_relative "asciidoc/term"
|
7
17
|
|
8
18
|
module Coradoc
|
9
19
|
module Parser
|
10
20
|
class Base < Parslet::Parser
|
11
|
-
include Coradoc::Parser::Asciidoc::
|
21
|
+
include Coradoc::Parser::Asciidoc::AttributeList
|
22
|
+
include Coradoc::Parser::Asciidoc::Base
|
23
|
+
include Coradoc::Parser::Asciidoc::Block
|
24
|
+
include Coradoc::Parser::Asciidoc::Citation
|
25
|
+
include Coradoc::Parser::Asciidoc::Content
|
12
26
|
include Coradoc::Parser::Asciidoc::DocumentAttributes
|
27
|
+
include Coradoc::Parser::Asciidoc::Header
|
28
|
+
include Coradoc::Parser::Asciidoc::Inline
|
29
|
+
include Coradoc::Parser::Asciidoc::List
|
30
|
+
include Coradoc::Parser::Asciidoc::Paragraph
|
13
31
|
include Coradoc::Parser::Asciidoc::Section
|
32
|
+
include Coradoc::Parser::Asciidoc::Table
|
33
|
+
include Coradoc::Parser::Asciidoc::Term
|
14
34
|
|
15
35
|
root :document
|
16
36
|
rule(:document) do
|
17
37
|
(
|
18
|
-
|
38
|
+
admonition_line |
|
39
|
+
bib_entry |
|
40
|
+
block_image |
|
41
|
+
term | term2 |
|
42
|
+
citation |
|
43
|
+
tag |
|
44
|
+
comment_block |
|
45
|
+
comment_line |
|
46
|
+
block.as(:block) |
|
19
47
|
section.as(:section) |
|
48
|
+
include_directive |
|
49
|
+
document_attributes |
|
50
|
+
list |
|
51
|
+
table.as(:table) |
|
52
|
+
paragraph |
|
20
53
|
header.as(:header) |
|
21
54
|
empty_line.as(:line_break) |
|
22
55
|
any.as(:unparsed)
|
@@ -25,7 +58,9 @@ module Coradoc
|
|
25
58
|
|
26
59
|
def self.parse(filename)
|
27
60
|
content = File.read(filename)
|
28
|
-
new.
|
61
|
+
new.parse(content)
|
62
|
+
rescue Parslet::ParseFailed => e
|
63
|
+
puts e.parse_failure_cause.ascii_tree
|
29
64
|
end
|
30
65
|
end
|
31
66
|
end
|