coradoc-markdown 1.0.13 → 1.0.15
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/lib/coradoc/markdown/behaviors/admonition.rb +21 -0
- data/lib/coradoc/markdown/behaviors/attribute_list.rb +81 -0
- data/lib/coradoc/markdown/behaviors/document.rb +34 -0
- data/lib/coradoc/markdown/behaviors/extension.rb +69 -0
- data/lib/coradoc/markdown/behaviors/heading.rb +33 -0
- data/lib/coradoc/markdown/behaviors/math.rb +32 -0
- data/lib/coradoc/markdown/behaviors/text.rb +14 -0
- data/lib/coradoc/markdown/behaviors.rb +18 -0
- data/lib/coradoc/markdown/lint/duplicate_headings.rb +30 -0
- data/lib/coradoc/markdown/lint/heading_levels.rb +27 -0
- data/lib/coradoc/markdown/lint.rb +17 -0
- data/lib/coradoc/markdown/model/admonition.rb +1 -8
- data/lib/coradoc/markdown/model/attribute_list.rb +1 -63
- data/lib/coradoc/markdown/model/document.rb +1 -16
- data/lib/coradoc/markdown/model/extension.rb +1 -61
- data/lib/coradoc/markdown/model/hard_line_break.rb +0 -3
- data/lib/coradoc/markdown/model/heading.rb +1 -22
- data/lib/coradoc/markdown/model/math.rb +1 -16
- data/lib/coradoc/markdown/model/text.rb +1 -3
- data/lib/coradoc/markdown/parser/ast_processor.rb +8 -10
- data/lib/coradoc/markdown/parser/attribute_lists.rb +48 -0
- data/lib/coradoc/markdown/parser/block_parser.rb +12 -45
- data/lib/coradoc/markdown/parser/inline_parser.rb +41 -19
- data/lib/coradoc/markdown/parser/parsanol_atoms.rb +15 -114
- data/lib/coradoc/markdown/schema/definition.rb +81 -0
- data/lib/coradoc/markdown/schema/loader.rb +68 -0
- data/lib/coradoc/markdown/schema/parity.rb +101 -0
- data/lib/coradoc/markdown/schema.rb +44 -0
- data/lib/coradoc/markdown/serializer/registrations.rb +2 -0
- data/lib/coradoc/markdown/serializer/serializers/text.rb +19 -0
- data/lib/coradoc/markdown/transform/from_core_model.rb +18 -0
- data/lib/coradoc/markdown/transform/to_core_model.rb +14 -5
- data/lib/coradoc/markdown/transformer.rb +73 -2
- data/lib/coradoc/markdown/version.rb +1 -1
- data/lib/coradoc/markdown.rb +12 -0
- data/schemas/blocks.yml +73 -0
- data/schemas/document.yml +55 -0
- data/schemas/inline.yml +57 -0
- data/schemas/lists.yml +35 -0
- data/schemas/tables.yml +11 -0
- metadata +27 -5
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'yaml'
|
|
4
|
+
|
|
5
|
+
module Coradoc
|
|
6
|
+
module Markdown
|
|
7
|
+
# Declarative schemas (coradoc-markdown/schemas/*.yml) for the Markdown
|
|
8
|
+
# model set, and the machinery that turns them into lutaml-model classes
|
|
9
|
+
# through lutaml-model's schema pipeline.
|
|
10
|
+
#
|
|
11
|
+
# Schema.load_generated(namespace: 'Coradoc::Markdown::Generated')
|
|
12
|
+
#
|
|
13
|
+
# Generated classes inherit from the hand-written Coradoc::Markdown::Base
|
|
14
|
+
# and get their hand-written behavior from Coradoc::Markdown::Behaviors.
|
|
15
|
+
module Schema
|
|
16
|
+
SCHEMA_DIR = File.expand_path('../../../schemas', __dir__)
|
|
17
|
+
|
|
18
|
+
autoload :Definition, 'coradoc/markdown/schema/definition'
|
|
19
|
+
autoload :Loader, 'coradoc/markdown/schema/loader'
|
|
20
|
+
autoload :Parity, 'coradoc/markdown/schema/parity'
|
|
21
|
+
|
|
22
|
+
class << self
|
|
23
|
+
# @return [Array<String>] paths of all schema files
|
|
24
|
+
def files
|
|
25
|
+
Dir[File.join(SCHEMA_DIR, '*.yml')]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Replace the hand-written model classes with generated ones in
|
|
29
|
+
# Coradoc::Markdown itself (behind CORADOC_MARKDOWN_GENERATED=1).
|
|
30
|
+
def install!
|
|
31
|
+
load_generated(namespace: 'Coradoc::Markdown')
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Compile the schemas and load the resulting classes.
|
|
35
|
+
#
|
|
36
|
+
# @param namespace [String] module that hosts the generated classes
|
|
37
|
+
# @return [Array<Class>] the generated classes
|
|
38
|
+
def load_generated(namespace: Loader::DEFAULT_NAMESPACE)
|
|
39
|
+
Loader.new(Definition.read(files), namespace: namespace).load
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -12,6 +12,7 @@ require_relative 'serializers/image'
|
|
|
12
12
|
require_relative 'serializers/horizontal_rule'
|
|
13
13
|
require_relative 'serializers/table'
|
|
14
14
|
require_relative 'serializers/emphasis'
|
|
15
|
+
require_relative 'serializers/text'
|
|
15
16
|
require_relative 'serializers/strong'
|
|
16
17
|
require_relative 'serializers/code'
|
|
17
18
|
require_relative 'serializers/strikethrough'
|
|
@@ -58,6 +59,7 @@ module Coradoc
|
|
|
58
59
|
Serializers::HorizontalRule,
|
|
59
60
|
Serializers::Table,
|
|
60
61
|
Serializers::Emphasis,
|
|
62
|
+
Serializers::Text,
|
|
61
63
|
Serializers::Strong,
|
|
62
64
|
Serializers::Code,
|
|
63
65
|
Serializers::Strikethrough,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../element_serializer'
|
|
4
|
+
|
|
5
|
+
module Coradoc
|
|
6
|
+
module Markdown
|
|
7
|
+
class Serializer
|
|
8
|
+
module Serializers
|
|
9
|
+
class Text < ElementSerializer
|
|
10
|
+
handles_type ::Coradoc::Markdown::Text
|
|
11
|
+
|
|
12
|
+
def call(element, _ctx)
|
|
13
|
+
element.content.to_s
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -93,6 +93,7 @@ module Coradoc
|
|
|
93
93
|
def transform_document(doc)
|
|
94
94
|
blocks, frontmatter = extract_frontmatter(Array(doc.children))
|
|
95
95
|
blocks = blocks.flat_map { |child| flatten_result(transform(child)) }
|
|
96
|
+
blocks = prepend_title_heading(doc.title, blocks)
|
|
96
97
|
|
|
97
98
|
Coradoc::Markdown::Document.new(
|
|
98
99
|
id: doc.id,
|
|
@@ -101,6 +102,23 @@ module Coradoc
|
|
|
101
102
|
)
|
|
102
103
|
end
|
|
103
104
|
|
|
105
|
+
# The document title renders as a leading "# {title}" H1. Skipped
|
|
106
|
+
# when the body already opens with a heading of the same text —
|
|
107
|
+
# a Markdown→CoreModel pass keeps its first heading (of any
|
|
108
|
+
# level) both as the title and as a section, and emitting the
|
|
109
|
+
# title again would duplicate it.
|
|
110
|
+
def prepend_title_heading(title, blocks)
|
|
111
|
+
return blocks if title.nil? || title.to_s.strip.empty?
|
|
112
|
+
return blocks if title_heading_duplicated?(title, blocks)
|
|
113
|
+
|
|
114
|
+
[Coradoc::Markdown::Heading.new(level: 1, text: title.to_s), *blocks]
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def title_heading_duplicated?(title, blocks)
|
|
118
|
+
first = blocks.first
|
|
119
|
+
first.is_a?(Coradoc::Markdown::Heading) && first.text == title.to_s
|
|
120
|
+
end
|
|
121
|
+
|
|
104
122
|
# If the first CoreModel child is a FrontmatterBlock, serialize
|
|
105
123
|
# it to YAML text via Codec (single source of truth) and pop
|
|
106
124
|
# it from the children list. Returns [remaining_children,
|
|
@@ -38,6 +38,8 @@ module Coradoc
|
|
|
38
38
|
transform_image(model)
|
|
39
39
|
when Coradoc::Markdown::Link
|
|
40
40
|
transform_link(model)
|
|
41
|
+
when Coradoc::Markdown::Text
|
|
42
|
+
Coradoc::CoreModel::TextContent.new(text: model.content)
|
|
41
43
|
when Coradoc::Markdown::Emphasis
|
|
42
44
|
transform_inline(model, 'italic')
|
|
43
45
|
when Coradoc::Markdown::Strong
|
|
@@ -64,8 +66,6 @@ module Coradoc
|
|
|
64
66
|
transform_attribute_list(model)
|
|
65
67
|
when Coradoc::Markdown::Comment
|
|
66
68
|
Coradoc::CoreModel::CommentBlock.new(content: model.text.to_s)
|
|
67
|
-
when Coradoc::Markdown::Text
|
|
68
|
-
model.content.to_s
|
|
69
69
|
when Array
|
|
70
70
|
model.map { |item| transform(item) }
|
|
71
71
|
else
|
|
@@ -114,7 +114,8 @@ module Coradoc
|
|
|
114
114
|
content = extract_text(para.text)
|
|
115
115
|
|
|
116
116
|
Coradoc::CoreModel::ParagraphBlock.new(
|
|
117
|
-
content: content
|
|
117
|
+
content: content,
|
|
118
|
+
children: para.children.map { |child| transform(child) }
|
|
118
119
|
)
|
|
119
120
|
end
|
|
120
121
|
|
|
@@ -137,7 +138,8 @@ module Coradoc
|
|
|
137
138
|
Coradoc::CoreModel::ListItem.new(
|
|
138
139
|
content: extract_text(item.text),
|
|
139
140
|
marker: list.ordered ? '1.' : '*',
|
|
140
|
-
nested_list: nested
|
|
141
|
+
nested_list: nested,
|
|
142
|
+
children: inline_children(item)
|
|
141
143
|
)
|
|
142
144
|
end
|
|
143
145
|
|
|
@@ -147,13 +149,20 @@ module Coradoc
|
|
|
147
149
|
)
|
|
148
150
|
end
|
|
149
151
|
|
|
152
|
+
# Carry inline models (bold, italic, code) parsed from the item
|
|
153
|
+
# text through to the CoreModel item as styled children.
|
|
154
|
+
def inline_children(item)
|
|
155
|
+
Array(item.children).map { |child| transform(child) }
|
|
156
|
+
end
|
|
157
|
+
|
|
150
158
|
def transform_table(table)
|
|
151
159
|
# Convert Markdown table to CoreModel table
|
|
152
160
|
rows = []
|
|
153
161
|
|
|
154
|
-
# Add header row if present
|
|
162
|
+
# Add header row if present (GFM tables always lead with one)
|
|
155
163
|
if table.headers.any?
|
|
156
164
|
rows << Coradoc::CoreModel::TableRow.new(
|
|
165
|
+
header: true,
|
|
157
166
|
cells: table.headers.map do |h|
|
|
158
167
|
Coradoc::CoreModel::TableCell.new(content: h.to_s, header: true)
|
|
159
168
|
end
|
|
@@ -279,7 +279,8 @@ module Coradoc
|
|
|
279
279
|
|
|
280
280
|
if element.key?(:p)
|
|
281
281
|
text = extract_text_from_p(element[:p])
|
|
282
|
-
paragraph = Paragraph.new(text: text
|
|
282
|
+
paragraph = Paragraph.new(text: text,
|
|
283
|
+
children: inline_models_for(element[:p]))
|
|
283
284
|
apply_ial_to_element(paragraph, element[:ial]) if element.key?(:ial)
|
|
284
285
|
return paragraph
|
|
285
286
|
end
|
|
@@ -345,12 +346,14 @@ module Coradoc
|
|
|
345
346
|
def transform_list_item(li)
|
|
346
347
|
nodes = normalize_list_item_nodes(li)
|
|
347
348
|
text_parts = []
|
|
349
|
+
inline_children = []
|
|
348
350
|
sublist = nil
|
|
349
351
|
nodes.each do |n|
|
|
350
352
|
case n
|
|
351
353
|
when Hash
|
|
352
354
|
if n.key?(:p)
|
|
353
355
|
text_parts << extract_text_from_p(n[:p])
|
|
356
|
+
inline_children.concat(inline_models_for(n[:p]))
|
|
354
357
|
elsif n.key?(:ul)
|
|
355
358
|
sublist = transform_list(n[:ul], ordered: false)
|
|
356
359
|
elsif n.key?(:ol)
|
|
@@ -360,7 +363,8 @@ module Coradoc
|
|
|
360
363
|
text_parts << n.to_s
|
|
361
364
|
end
|
|
362
365
|
end
|
|
363
|
-
item = ListItem.new(text: text_parts.join(' ').strip
|
|
366
|
+
item = ListItem.new(text: text_parts.join(' ').strip,
|
|
367
|
+
children: inline_children)
|
|
364
368
|
item.sublist = sublist if sublist
|
|
365
369
|
item
|
|
366
370
|
end
|
|
@@ -511,6 +515,73 @@ module Coradoc
|
|
|
511
515
|
end
|
|
512
516
|
end
|
|
513
517
|
|
|
518
|
+
# Inline models for a paragraph's raw lines: runs the InlineParser
|
|
519
|
+
# over each line so emphasis/code/link survive to CoreModel as
|
|
520
|
+
# InlineElements instead of flattened marker text.
|
|
521
|
+
def inline_models_for(p)
|
|
522
|
+
lines = if p.is_a?(Hash)
|
|
523
|
+
[p[:ln]]
|
|
524
|
+
else
|
|
525
|
+
Array(p).map { |l| l.is_a?(Hash) ? l[:ln] : l }
|
|
526
|
+
end
|
|
527
|
+
lines.compact.flat_map.with_index do |line, idx|
|
|
528
|
+
models = build_inline_models(line.to_s)
|
|
529
|
+
if idx.zero?
|
|
530
|
+
models
|
|
531
|
+
else
|
|
532
|
+
[Text.new(content: "\n"), *models]
|
|
533
|
+
end
|
|
534
|
+
end
|
|
535
|
+
end
|
|
536
|
+
|
|
537
|
+
def build_inline_models(line)
|
|
538
|
+
Coradoc::Markdown.parse_inline(line).flat_map { |el| inline_model(el) }
|
|
539
|
+
end
|
|
540
|
+
|
|
541
|
+
# Build Markdown model(s) for one inline-parser node. Emphasis
|
|
542
|
+
# subtrees (nested strong/emph/code/text) collapse to the
|
|
543
|
+
# outermost style with their literal text — CoreModel inline
|
|
544
|
+
# nodes carry flat content, matching the DOCX-side shape where
|
|
545
|
+
# each run becomes a single InlineElement.
|
|
546
|
+
def inline_model(el)
|
|
547
|
+
return Text.new(content: el.to_s) unless el.is_a?(Hash)
|
|
548
|
+
|
|
549
|
+
if el.key?(:strong)
|
|
550
|
+
Strong.new(text: flatten_inline_text(el[:strong]))
|
|
551
|
+
elsif el.key?(:emph)
|
|
552
|
+
Emphasis.new(text: flatten_inline_text(el[:emph]))
|
|
553
|
+
elsif el.key?(:code)
|
|
554
|
+
Code.new(text: el[:code].to_s)
|
|
555
|
+
elsif el.key?(:text)
|
|
556
|
+
Text.new(content: el[:text].to_s)
|
|
557
|
+
else
|
|
558
|
+
Text.new(content: flatten_inline_text([el]))
|
|
559
|
+
end
|
|
560
|
+
end
|
|
561
|
+
|
|
562
|
+
# Recursively flatten any inline subtree (arrays, nested
|
|
563
|
+
# strong/emph hashes, code spans, Parsanol slices) to its
|
|
564
|
+
# literal text. Inner style markers survive as characters so
|
|
565
|
+
# the round trip stays stable.
|
|
566
|
+
def flatten_inline_text(subtree)
|
|
567
|
+
case subtree
|
|
568
|
+
when Array
|
|
569
|
+
subtree.map { |n| flatten_inline_text(n) }.join
|
|
570
|
+
when Hash
|
|
571
|
+
if subtree.key?(:text)
|
|
572
|
+
subtree[:text].to_s
|
|
573
|
+
elsif subtree.key?(:code)
|
|
574
|
+
"`#{subtree[:code]}`"
|
|
575
|
+
else
|
|
576
|
+
subtree.values.map { |v| flatten_inline_text(v) }.join
|
|
577
|
+
end
|
|
578
|
+
when Parsanol::Slice
|
|
579
|
+
subtree.to_s
|
|
580
|
+
else
|
|
581
|
+
subtree.to_s
|
|
582
|
+
end
|
|
583
|
+
end
|
|
584
|
+
|
|
514
585
|
# Extract code from code_block structure
|
|
515
586
|
def extract_code(code_block)
|
|
516
587
|
case code_block
|
data/lib/coradoc/markdown.rb
CHANGED
|
@@ -35,6 +35,9 @@ module Coradoc
|
|
|
35
35
|
autoload :Heading, 'coradoc/markdown/model/heading'
|
|
36
36
|
autoload :Paragraph, 'coradoc/markdown/model/paragraph'
|
|
37
37
|
autoload :Text, 'coradoc/markdown/model/text'
|
|
38
|
+
|
|
39
|
+
# Registration side effect: loading registers rules into Coradoc::Lint.registry.
|
|
40
|
+
autoload :Lint, 'coradoc/markdown/lint'
|
|
38
41
|
autoload :List, 'coradoc/markdown/model/list'
|
|
39
42
|
autoload :ListItem, 'coradoc/markdown/model/list_item'
|
|
40
43
|
autoload :CodeBlock, 'coradoc/markdown/model/code_block'
|
|
@@ -72,6 +75,10 @@ module Coradoc
|
|
|
72
75
|
autoload :Literal, 'coradoc/markdown/model/literal'
|
|
73
76
|
autoload :HardLineBreak, 'coradoc/markdown/model/hard_line_break'
|
|
74
77
|
|
|
78
|
+
# Declarative schemas + generated classes; hand-written behavior modules
|
|
79
|
+
autoload :Schema, 'coradoc/markdown/schema'
|
|
80
|
+
autoload :Behaviors, 'coradoc/markdown/behaviors'
|
|
81
|
+
|
|
75
82
|
# Serializer
|
|
76
83
|
autoload :Serializer, 'coradoc/markdown/serializer'
|
|
77
84
|
|
|
@@ -90,6 +97,7 @@ module Coradoc
|
|
|
90
97
|
|
|
91
98
|
# Parser module namespace
|
|
92
99
|
module Parser
|
|
100
|
+
autoload :AttributeLists, 'coradoc/markdown/parser/attribute_lists'
|
|
93
101
|
autoload :BlockParser, 'coradoc/markdown/parser/block_parser'
|
|
94
102
|
autoload :InlineParser, 'coradoc/markdown/parser/inline_parser'
|
|
95
103
|
autoload :ParsanolAtoms, 'coradoc/markdown/parser/parsanol_atoms'
|
|
@@ -194,6 +202,10 @@ module Coradoc
|
|
|
194
202
|
end
|
|
195
203
|
end
|
|
196
204
|
|
|
205
|
+
# Opt-in: replace the hand-written model classes with the ones generated
|
|
206
|
+
# from coradoc-markdown/schemas/*.yml (see Coradoc::Markdown::Schema).
|
|
207
|
+
Markdown::Schema.install! if ENV['CORADOC_MARKDOWN_GENERATED'] == '1'
|
|
208
|
+
|
|
197
209
|
# Register the Markdown format with Coradoc
|
|
198
210
|
register_format(:markdown, Markdown,
|
|
199
211
|
aliases: %w[md markdown mdown mkd],
|
data/schemas/blocks.yml
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# coradoc-markdown model schema: headings and block-level nodes.
|
|
2
|
+
# Source of truth for generated classes (see Coradoc::Markdown::Schema).
|
|
3
|
+
# Types: string|integer|boolean are scalars; anything else names a model class.
|
|
4
|
+
# `behaviors` names modules in Coradoc::Markdown::Behaviors prepended after load.
|
|
5
|
+
classes:
|
|
6
|
+
Heading:
|
|
7
|
+
parent: Base
|
|
8
|
+
behaviors: [Heading]
|
|
9
|
+
attributes:
|
|
10
|
+
level: { type: integer, default: 1 }
|
|
11
|
+
text: { type: string }
|
|
12
|
+
Paragraph:
|
|
13
|
+
parent: Base
|
|
14
|
+
attributes:
|
|
15
|
+
text: { type: string }
|
|
16
|
+
children: { type: Base, collection: true, default: [] }
|
|
17
|
+
CodeBlock:
|
|
18
|
+
parent: Base
|
|
19
|
+
attributes:
|
|
20
|
+
language: { type: string }
|
|
21
|
+
code: { type: string }
|
|
22
|
+
Blockquote:
|
|
23
|
+
parent: Base
|
|
24
|
+
attributes:
|
|
25
|
+
content: { type: string }
|
|
26
|
+
HorizontalRule:
|
|
27
|
+
parent: Base
|
|
28
|
+
attributes:
|
|
29
|
+
style: { type: string, default: '---' }
|
|
30
|
+
Admonition:
|
|
31
|
+
parent: Base
|
|
32
|
+
behaviors: [Admonition]
|
|
33
|
+
attributes:
|
|
34
|
+
admonition_type: { type: string }
|
|
35
|
+
content: { type: string }
|
|
36
|
+
title: { type: string }
|
|
37
|
+
children: { type: Base, collection: true, default: [] }
|
|
38
|
+
ExampleBlock:
|
|
39
|
+
parent: Base
|
|
40
|
+
attributes:
|
|
41
|
+
content: { type: string }
|
|
42
|
+
caption: { type: string }
|
|
43
|
+
children: { type: Base, collection: true, default: [] }
|
|
44
|
+
OpenBlock:
|
|
45
|
+
parent: Base
|
|
46
|
+
attributes:
|
|
47
|
+
children: { type: Base, collection: true, default: [] }
|
|
48
|
+
Sidebar:
|
|
49
|
+
parent: Base
|
|
50
|
+
attributes:
|
|
51
|
+
content: { type: string }
|
|
52
|
+
title: { type: string }
|
|
53
|
+
children: { type: Base, collection: true, default: [] }
|
|
54
|
+
Verse:
|
|
55
|
+
parent: Base
|
|
56
|
+
attributes:
|
|
57
|
+
content: { type: string }
|
|
58
|
+
attribution: { type: string }
|
|
59
|
+
citetitle: { type: string }
|
|
60
|
+
Pass:
|
|
61
|
+
parent: Base
|
|
62
|
+
attributes:
|
|
63
|
+
content: { type: string }
|
|
64
|
+
Literal:
|
|
65
|
+
parent: Base
|
|
66
|
+
attributes:
|
|
67
|
+
content: { type: string }
|
|
68
|
+
Math:
|
|
69
|
+
parent: Base
|
|
70
|
+
behaviors: [Math]
|
|
71
|
+
attributes:
|
|
72
|
+
content: { type: string }
|
|
73
|
+
inline: { type: boolean, default: false }
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# coradoc-markdown model schema: document container, metadata and reference-like nodes.
|
|
2
|
+
# Source of truth for generated classes (see Coradoc::Markdown::Schema).
|
|
3
|
+
# Types: string|integer|boolean are scalars; anything else names a model class.
|
|
4
|
+
# `behaviors` names modules in Coradoc::Markdown::Behaviors prepended after load.
|
|
5
|
+
classes:
|
|
6
|
+
Document:
|
|
7
|
+
parent: Base
|
|
8
|
+
behaviors: [Document]
|
|
9
|
+
attributes:
|
|
10
|
+
blocks: { type: Base, collection: true }
|
|
11
|
+
frontmatter: { type: string }
|
|
12
|
+
NamedValue:
|
|
13
|
+
parent: Base
|
|
14
|
+
attributes:
|
|
15
|
+
name: { type: string }
|
|
16
|
+
value: { type: string }
|
|
17
|
+
AttributeList:
|
|
18
|
+
parent: Base
|
|
19
|
+
behaviors: [AttributeList]
|
|
20
|
+
attributes:
|
|
21
|
+
id: { type: string }
|
|
22
|
+
classes: { type: string, collection: true, default: [] }
|
|
23
|
+
attributes: { type: NamedValue, collection: true, default: [] }
|
|
24
|
+
name: { type: string }
|
|
25
|
+
Extension:
|
|
26
|
+
parent: Base
|
|
27
|
+
behaviors: [Extension]
|
|
28
|
+
attributes:
|
|
29
|
+
name: { type: string }
|
|
30
|
+
options: { type: NamedValue, collection: true, default: [] }
|
|
31
|
+
content: { type: string }
|
|
32
|
+
body: { type: string }
|
|
33
|
+
Comment:
|
|
34
|
+
parent: Base
|
|
35
|
+
attributes:
|
|
36
|
+
text: { type: string }
|
|
37
|
+
Abbreviation:
|
|
38
|
+
parent: Base
|
|
39
|
+
attributes:
|
|
40
|
+
term: { type: string }
|
|
41
|
+
definition: { type: string }
|
|
42
|
+
Footnote:
|
|
43
|
+
parent: Base
|
|
44
|
+
attributes:
|
|
45
|
+
content: { type: string }
|
|
46
|
+
inline_content: { type: string, collection: true }
|
|
47
|
+
backlink: { type: boolean, default: true }
|
|
48
|
+
FootnoteReference:
|
|
49
|
+
parent: Base
|
|
50
|
+
attributes: {}
|
|
51
|
+
CrossReference:
|
|
52
|
+
parent: Base
|
|
53
|
+
attributes:
|
|
54
|
+
text: { type: string }
|
|
55
|
+
target: { type: string }
|
data/schemas/inline.yml
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# coradoc-markdown model schema: inline nodes.
|
|
2
|
+
# Source of truth for generated classes (see Coradoc::Markdown::Schema).
|
|
3
|
+
# Types: string|integer|boolean are scalars; anything else names a model class.
|
|
4
|
+
# `behaviors` names modules in Coradoc::Markdown::Behaviors prepended after load.
|
|
5
|
+
classes:
|
|
6
|
+
Text:
|
|
7
|
+
parent: Base
|
|
8
|
+
behaviors: [Text]
|
|
9
|
+
attributes:
|
|
10
|
+
content: { type: string }
|
|
11
|
+
Emphasis:
|
|
12
|
+
parent: Base
|
|
13
|
+
attributes:
|
|
14
|
+
text: { type: string }
|
|
15
|
+
Strong:
|
|
16
|
+
parent: Base
|
|
17
|
+
attributes:
|
|
18
|
+
text: { type: string }
|
|
19
|
+
Code:
|
|
20
|
+
parent: Base
|
|
21
|
+
attributes:
|
|
22
|
+
text: { type: string }
|
|
23
|
+
Link:
|
|
24
|
+
parent: Base
|
|
25
|
+
attributes:
|
|
26
|
+
text: { type: string }
|
|
27
|
+
url: { type: string }
|
|
28
|
+
title: { type: string }
|
|
29
|
+
Image:
|
|
30
|
+
parent: Base
|
|
31
|
+
attributes:
|
|
32
|
+
alt: { type: string }
|
|
33
|
+
src: { type: string }
|
|
34
|
+
title: { type: string }
|
|
35
|
+
Strikethrough:
|
|
36
|
+
parent: Base
|
|
37
|
+
attributes:
|
|
38
|
+
text: { type: string }
|
|
39
|
+
Highlight:
|
|
40
|
+
parent: Base
|
|
41
|
+
attributes:
|
|
42
|
+
text: { type: string }
|
|
43
|
+
Subscript:
|
|
44
|
+
parent: Base
|
|
45
|
+
attributes:
|
|
46
|
+
text: { type: string }
|
|
47
|
+
Superscript:
|
|
48
|
+
parent: Base
|
|
49
|
+
attributes:
|
|
50
|
+
text: { type: string }
|
|
51
|
+
Underline:
|
|
52
|
+
parent: Base
|
|
53
|
+
attributes:
|
|
54
|
+
text: { type: string }
|
|
55
|
+
HardLineBreak:
|
|
56
|
+
parent: Base
|
|
57
|
+
attributes: {}
|
data/schemas/lists.yml
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# coradoc-markdown model schema: ordered/unordered and definition lists.
|
|
2
|
+
# Source of truth for generated classes (see Coradoc::Markdown::Schema).
|
|
3
|
+
# Types: string|integer|boolean are scalars; anything else names a model class.
|
|
4
|
+
# `behaviors` names modules in Coradoc::Markdown::Behaviors prepended after load.
|
|
5
|
+
classes:
|
|
6
|
+
List:
|
|
7
|
+
parent: Base
|
|
8
|
+
attributes:
|
|
9
|
+
ordered: { type: boolean, default: false }
|
|
10
|
+
items: { type: ListItem, collection: true }
|
|
11
|
+
start_number: { type: integer, default: 1 }
|
|
12
|
+
ListItem:
|
|
13
|
+
parent: Base
|
|
14
|
+
attributes:
|
|
15
|
+
text: { type: string }
|
|
16
|
+
checked: { type: boolean }
|
|
17
|
+
sublist: { type: List }
|
|
18
|
+
children: { type: Base, collection: true, default: [] }
|
|
19
|
+
DefinitionList:
|
|
20
|
+
parent: Base
|
|
21
|
+
attributes:
|
|
22
|
+
items: { type: DefinitionTerm, collection: true }
|
|
23
|
+
DefinitionTerm:
|
|
24
|
+
parent: Base
|
|
25
|
+
attributes:
|
|
26
|
+
text: { type: string }
|
|
27
|
+
definitions: { type: DefinitionItem, collection: true, default: [] }
|
|
28
|
+
text_children: { type: Base, collection: true, default: [] }
|
|
29
|
+
nested: { type: DefinitionList }
|
|
30
|
+
DefinitionItem:
|
|
31
|
+
parent: Base
|
|
32
|
+
attributes:
|
|
33
|
+
content: { type: string }
|
|
34
|
+
inline_content: { type: Base, collection: true, default: [] }
|
|
35
|
+
blocks: { type: string, collection: true }
|
data/schemas/tables.yml
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# coradoc-markdown model schema: tables.
|
|
2
|
+
# Source of truth for generated classes (see Coradoc::Markdown::Schema).
|
|
3
|
+
# Types: string|integer|boolean are scalars; anything else names a model class.
|
|
4
|
+
# `behaviors` names modules in Coradoc::Markdown::Behaviors prepended after load.
|
|
5
|
+
classes:
|
|
6
|
+
Table:
|
|
7
|
+
parent: Base
|
|
8
|
+
attributes:
|
|
9
|
+
headers: { type: string, collection: true }
|
|
10
|
+
rows: { type: string, collection: true, default: [] }
|
|
11
|
+
alignments: { type: string, collection: true }
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: coradoc-markdown
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.15
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -41,16 +41,16 @@ dependencies:
|
|
|
41
41
|
name: parsanol
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
|
43
43
|
requirements:
|
|
44
|
-
- - "
|
|
44
|
+
- - "~>"
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version:
|
|
46
|
+
version: 1.3.123
|
|
47
47
|
type: :runtime
|
|
48
48
|
prerelease: false
|
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
|
-
- - "
|
|
51
|
+
- - "~>"
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version:
|
|
53
|
+
version: 1.3.123
|
|
54
54
|
- !ruby/object:Gem::Dependency
|
|
55
55
|
name: rspec
|
|
56
56
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -104,7 +104,18 @@ extra_rdoc_files: []
|
|
|
104
104
|
files:
|
|
105
105
|
- LICENSE.txt
|
|
106
106
|
- lib/coradoc/markdown.rb
|
|
107
|
+
- lib/coradoc/markdown/behaviors.rb
|
|
108
|
+
- lib/coradoc/markdown/behaviors/admonition.rb
|
|
109
|
+
- lib/coradoc/markdown/behaviors/attribute_list.rb
|
|
110
|
+
- lib/coradoc/markdown/behaviors/document.rb
|
|
111
|
+
- lib/coradoc/markdown/behaviors/extension.rb
|
|
112
|
+
- lib/coradoc/markdown/behaviors/heading.rb
|
|
113
|
+
- lib/coradoc/markdown/behaviors/math.rb
|
|
114
|
+
- lib/coradoc/markdown/behaviors/text.rb
|
|
107
115
|
- lib/coradoc/markdown/errors.rb
|
|
116
|
+
- lib/coradoc/markdown/lint.rb
|
|
117
|
+
- lib/coradoc/markdown/lint/duplicate_headings.rb
|
|
118
|
+
- lib/coradoc/markdown/lint/heading_levels.rb
|
|
108
119
|
- lib/coradoc/markdown/model/abbreviation.rb
|
|
109
120
|
- lib/coradoc/markdown/model/admonition.rb
|
|
110
121
|
- lib/coradoc/markdown/model/attribute_list.rb
|
|
@@ -148,12 +159,17 @@ files:
|
|
|
148
159
|
- lib/coradoc/markdown/model/verse.rb
|
|
149
160
|
- lib/coradoc/markdown/parser.rb
|
|
150
161
|
- lib/coradoc/markdown/parser/ast_processor.rb
|
|
162
|
+
- lib/coradoc/markdown/parser/attribute_lists.rb
|
|
151
163
|
- lib/coradoc/markdown/parser/block_parser.rb
|
|
152
164
|
- lib/coradoc/markdown/parser/frontmatter_parser.rb
|
|
153
165
|
- lib/coradoc/markdown/parser/html_entities.rb
|
|
154
166
|
- lib/coradoc/markdown/parser/inline_parser.rb
|
|
155
167
|
- lib/coradoc/markdown/parser/parsanol_atoms.rb
|
|
156
168
|
- lib/coradoc/markdown/parser_util.rb
|
|
169
|
+
- lib/coradoc/markdown/schema.rb
|
|
170
|
+
- lib/coradoc/markdown/schema/definition.rb
|
|
171
|
+
- lib/coradoc/markdown/schema/loader.rb
|
|
172
|
+
- lib/coradoc/markdown/schema/parity.rb
|
|
157
173
|
- lib/coradoc/markdown/serializer.rb
|
|
158
174
|
- lib/coradoc/markdown/serializer/builder.rb
|
|
159
175
|
- lib/coradoc/markdown/serializer/config.rb
|
|
@@ -196,6 +212,7 @@ files:
|
|
|
196
212
|
- lib/coradoc/markdown/serializer/serializers/subscript.rb
|
|
197
213
|
- lib/coradoc/markdown/serializer/serializers/superscript.rb
|
|
198
214
|
- lib/coradoc/markdown/serializer/serializers/table.rb
|
|
215
|
+
- lib/coradoc/markdown/serializer/serializers/text.rb
|
|
199
216
|
- lib/coradoc/markdown/serializer/serializers/underline.rb
|
|
200
217
|
- lib/coradoc/markdown/serializer/serializers/verse.rb
|
|
201
218
|
- lib/coradoc/markdown/serializer/strategies/admonition/base.rb
|
|
@@ -225,6 +242,11 @@ files:
|
|
|
225
242
|
- lib/coradoc/markdown/transform/to_core_model.rb
|
|
226
243
|
- lib/coradoc/markdown/transformer.rb
|
|
227
244
|
- lib/coradoc/markdown/version.rb
|
|
245
|
+
- schemas/blocks.yml
|
|
246
|
+
- schemas/document.yml
|
|
247
|
+
- schemas/inline.yml
|
|
248
|
+
- schemas/lists.yml
|
|
249
|
+
- schemas/tables.yml
|
|
228
250
|
homepage: https://github.com/metanorma/coradoc
|
|
229
251
|
licenses:
|
|
230
252
|
- MIT
|