red_quilt 0.7.2 → 0.8.0
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.md +23 -0
- data/README.md +38 -0
- data/docs/api.md +11 -0
- data/lib/red_quilt/arena.rb +96 -0
- data/lib/red_quilt/block_parser.rb +22 -384
- data/lib/red_quilt/cli.rb +8 -2
- data/lib/red_quilt/code_block.rb +139 -0
- data/lib/red_quilt/document.rb +18 -4
- data/lib/red_quilt/footnote_anchors.rb +24 -0
- data/lib/red_quilt/footnote_pass.rb +6 -2
- data/lib/red_quilt/frontmatter.rb +54 -0
- data/lib/red_quilt/html_block.rb +161 -0
- data/lib/red_quilt/indentation.rb +35 -0
- data/lib/red_quilt/inline/builder.rb +9 -186
- data/lib/red_quilt/inline/emphasis_resolver.rb +184 -0
- data/lib/red_quilt/inline/url_sanitizer.rb +64 -0
- data/lib/red_quilt/line.rb +6 -1
- data/lib/red_quilt/lint_pass.rb +2 -2
- data/lib/red_quilt/node_ref.rb +20 -11
- data/lib/red_quilt/renderer/html.rb +32 -20
- data/lib/red_quilt/renderer/mdast.rb +11 -11
- data/lib/red_quilt/table.rb +97 -0
- data/lib/red_quilt/version.rb +1 -1
- data/lib/red_quilt.rb +19 -4
- data/sig/red_quilt.rbs +18 -0
- metadata +9 -2
data/lib/red_quilt.rb
CHANGED
|
@@ -15,17 +15,24 @@ require_relative "red_quilt/theme"
|
|
|
15
15
|
require_relative "red_quilt/document"
|
|
16
16
|
require_relative "red_quilt/inline"
|
|
17
17
|
require_relative "red_quilt/inline/html_entities"
|
|
18
|
+
require_relative "red_quilt/frontmatter"
|
|
18
19
|
require_relative "red_quilt/reference_definition"
|
|
19
20
|
require_relative "red_quilt/footnote_registry"
|
|
21
|
+
require_relative "red_quilt/footnote_anchors"
|
|
20
22
|
require_relative "red_quilt/footnote_definition"
|
|
21
23
|
require_relative "red_quilt/list"
|
|
22
24
|
require_relative "red_quilt/blockquote"
|
|
25
|
+
require_relative "red_quilt/html_block"
|
|
26
|
+
require_relative "red_quilt/table"
|
|
27
|
+
require_relative "red_quilt/code_block"
|
|
23
28
|
require_relative "red_quilt/block_parser"
|
|
24
29
|
require_relative "red_quilt/inline/token_kind"
|
|
25
30
|
require_relative "red_quilt/inline/tokens"
|
|
26
31
|
require_relative "red_quilt/inline/flanking"
|
|
27
32
|
require_relative "red_quilt/inline/lexer"
|
|
28
33
|
require_relative "red_quilt/inline/link_scanner"
|
|
34
|
+
require_relative "red_quilt/inline/url_sanitizer"
|
|
35
|
+
require_relative "red_quilt/inline/emphasis_resolver"
|
|
29
36
|
require_relative "red_quilt/inline/builder"
|
|
30
37
|
require_relative "red_quilt/inline_pass"
|
|
31
38
|
require_relative "red_quilt/footnote_pass"
|
|
@@ -38,8 +45,13 @@ module RedQuilt
|
|
|
38
45
|
class Error < StandardError; end
|
|
39
46
|
|
|
40
47
|
class << self
|
|
41
|
-
def parse(source, allow_html: false, disallow_raw_html: false, extended_autolinks: false, footnotes: false, lint: false)
|
|
48
|
+
def parse(source, allow_html: false, disallow_raw_html: false, extended_autolinks: false, footnotes: false, lint: false, frontmatter: false)
|
|
42
49
|
normalized = normalize_input(source)
|
|
50
|
+
frontmatter_diagnostics = []
|
|
51
|
+
if frontmatter
|
|
52
|
+
frontmatter_data, normalized =
|
|
53
|
+
Frontmatter.extract(normalized, diagnostics: frontmatter_diagnostics)
|
|
54
|
+
end
|
|
43
55
|
arena = Arena.new(normalized)
|
|
44
56
|
footnote_registry = FootnoteRegistry.new if footnotes
|
|
45
57
|
block_parser = BlockParser.new(arena, footnotes: footnote_registry)
|
|
@@ -48,7 +60,9 @@ module RedQuilt
|
|
|
48
60
|
allow_html: allow_html,
|
|
49
61
|
disallow_raw_html: disallow_raw_html,
|
|
50
62
|
references: block_parser.references,
|
|
51
|
-
footnotes: footnote_registry
|
|
63
|
+
footnotes: footnote_registry,
|
|
64
|
+
frontmatter: frontmatter_data)
|
|
65
|
+
document.diagnostics.concat(frontmatter_diagnostics)
|
|
52
66
|
document.diagnostics.concat(block_parser.diagnostics)
|
|
53
67
|
InlinePass.new(document).apply
|
|
54
68
|
FootnotePass.new(document).apply if footnote_registry
|
|
@@ -57,13 +71,14 @@ module RedQuilt
|
|
|
57
71
|
document
|
|
58
72
|
end
|
|
59
73
|
|
|
60
|
-
def render_html(source, allow_html: false, disallow_raw_html: false, extended_autolinks: false, footnotes: false, lint: false, heading_ids: false, mermaid: false)
|
|
74
|
+
def render_html(source, allow_html: false, disallow_raw_html: false, extended_autolinks: false, footnotes: false, lint: false, frontmatter: false, heading_ids: false, mermaid: false)
|
|
61
75
|
parse(source,
|
|
62
76
|
allow_html: allow_html,
|
|
63
77
|
disallow_raw_html: disallow_raw_html,
|
|
64
78
|
extended_autolinks: extended_autolinks,
|
|
65
79
|
footnotes: footnotes,
|
|
66
|
-
lint: lint
|
|
80
|
+
lint: lint,
|
|
81
|
+
frontmatter: frontmatter).to_html(heading_ids: heading_ids, mermaid: mermaid)
|
|
67
82
|
end
|
|
68
83
|
|
|
69
84
|
private
|
data/sig/red_quilt.rbs
CHANGED
|
@@ -61,6 +61,7 @@ module RedQuilt
|
|
|
61
61
|
def walk: () { (NodeRef) -> void } -> void
|
|
62
62
|
| () -> Enumerator[NodeRef, void]
|
|
63
63
|
def text: () -> String?
|
|
64
|
+
def info: () -> String
|
|
64
65
|
def source_span: () -> SourceSpan?
|
|
65
66
|
def find_all: (Symbol type) -> Array[NodeRef]
|
|
66
67
|
def source_location: () -> { start_line: Integer, start_column: Integer, end_line: Integer, end_column: Integer }?
|
|
@@ -115,6 +116,23 @@ module RedQuilt
|
|
|
115
116
|
def source_span: (Integer id) -> SourceSpan?
|
|
116
117
|
def text: (Integer id) -> String?
|
|
117
118
|
|
|
119
|
+
# Semantic payload accessors (per-NodeType column conventions)
|
|
120
|
+
def heading_level: (Integer id) -> Integer
|
|
121
|
+
def list_ordered?: (Integer id) -> bool
|
|
122
|
+
def list_start: (Integer id) -> Integer
|
|
123
|
+
def list_tight?: (Integer id) -> bool
|
|
124
|
+
def list_delimiter: (Integer id) -> String?
|
|
125
|
+
def table_row_header?: (Integer id) -> bool
|
|
126
|
+
def table_cell_header?: (Integer id) -> bool
|
|
127
|
+
def code_block_info: (Integer id) -> String?
|
|
128
|
+
def link_destination: (Integer id) -> String?
|
|
129
|
+
def link_title: (Integer id) -> String?
|
|
130
|
+
def footnote_number: (Integer id) -> Integer
|
|
131
|
+
def footnote_occurrence: (Integer id) -> Integer
|
|
132
|
+
def footnote_label: (Integer id) -> String?
|
|
133
|
+
def footnote_total_references: (Integer id) -> Integer
|
|
134
|
+
def resolve_footnote_definition: (Integer id, Integer number, Integer total_references) -> void
|
|
135
|
+
|
|
118
136
|
# Traversal
|
|
119
137
|
def each_child: (Integer id) { (Integer child_id) -> void } -> self
|
|
120
138
|
def child_ids: (Integer id) -> Enumerator[Integer, void]
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: red_quilt
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- takahashim
|
|
@@ -38,21 +38,27 @@ files:
|
|
|
38
38
|
- lib/red_quilt/blockquote.rb
|
|
39
39
|
- lib/red_quilt/browser_launcher.rb
|
|
40
40
|
- lib/red_quilt/cli.rb
|
|
41
|
+
- lib/red_quilt/code_block.rb
|
|
41
42
|
- lib/red_quilt/diagnostic.rb
|
|
42
43
|
- lib/red_quilt/document.rb
|
|
43
44
|
- lib/red_quilt/extended_autolink_pass.rb
|
|
45
|
+
- lib/red_quilt/footnote_anchors.rb
|
|
44
46
|
- lib/red_quilt/footnote_definition.rb
|
|
45
47
|
- lib/red_quilt/footnote_pass.rb
|
|
46
48
|
- lib/red_quilt/footnote_registry.rb
|
|
49
|
+
- lib/red_quilt/frontmatter.rb
|
|
50
|
+
- lib/red_quilt/html_block.rb
|
|
47
51
|
- lib/red_quilt/indentation.rb
|
|
48
52
|
- lib/red_quilt/inline.rb
|
|
49
53
|
- lib/red_quilt/inline/builder.rb
|
|
54
|
+
- lib/red_quilt/inline/emphasis_resolver.rb
|
|
50
55
|
- lib/red_quilt/inline/flanking.rb
|
|
51
56
|
- lib/red_quilt/inline/html_entities.rb
|
|
52
57
|
- lib/red_quilt/inline/lexer.rb
|
|
53
58
|
- lib/red_quilt/inline/link_scanner.rb
|
|
54
59
|
- lib/red_quilt/inline/token_kind.rb
|
|
55
60
|
- lib/red_quilt/inline/tokens.rb
|
|
61
|
+
- lib/red_quilt/inline/url_sanitizer.rb
|
|
56
62
|
- lib/red_quilt/inline_pass.rb
|
|
57
63
|
- lib/red_quilt/line.rb
|
|
58
64
|
- lib/red_quilt/lint_pass.rb
|
|
@@ -66,6 +72,7 @@ files:
|
|
|
66
72
|
- lib/red_quilt/slug.rb
|
|
67
73
|
- lib/red_quilt/source_map.rb
|
|
68
74
|
- lib/red_quilt/source_span.rb
|
|
75
|
+
- lib/red_quilt/table.rb
|
|
69
76
|
- lib/red_quilt/theme.rb
|
|
70
77
|
- lib/red_quilt/themes/default.css
|
|
71
78
|
- lib/red_quilt/tilt.rb
|
|
@@ -94,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
94
101
|
- !ruby/object:Gem::Version
|
|
95
102
|
version: '0'
|
|
96
103
|
requirements: []
|
|
97
|
-
rubygems_version:
|
|
104
|
+
rubygems_version: 4.0.10
|
|
98
105
|
specification_version: 4
|
|
99
106
|
summary: CommonMark-based Markdown processor written in pure Ruby
|
|
100
107
|
test_files: []
|