red_quilt 0.7.1 → 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.
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)
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).to_html(heading_ids: heading_ids)
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.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - takahashim
@@ -26,8 +26,11 @@ files:
26
26
  - Rakefile
27
27
  - docs/api.md
28
28
  - docs/architecture.ja.md
29
+ - docs/architecture.md
29
30
  - docs/arena-usage.ja.md
31
+ - docs/arena-usage.md
30
32
  - docs/commonmark-conformance.ja.md
33
+ - docs/commonmark-conformance.md
31
34
  - exe/redquilt
32
35
  - lib/red_quilt.rb
33
36
  - lib/red_quilt/arena.rb
@@ -35,21 +38,27 @@ files:
35
38
  - lib/red_quilt/blockquote.rb
36
39
  - lib/red_quilt/browser_launcher.rb
37
40
  - lib/red_quilt/cli.rb
41
+ - lib/red_quilt/code_block.rb
38
42
  - lib/red_quilt/diagnostic.rb
39
43
  - lib/red_quilt/document.rb
40
44
  - lib/red_quilt/extended_autolink_pass.rb
45
+ - lib/red_quilt/footnote_anchors.rb
41
46
  - lib/red_quilt/footnote_definition.rb
42
47
  - lib/red_quilt/footnote_pass.rb
43
48
  - lib/red_quilt/footnote_registry.rb
49
+ - lib/red_quilt/frontmatter.rb
50
+ - lib/red_quilt/html_block.rb
44
51
  - lib/red_quilt/indentation.rb
45
52
  - lib/red_quilt/inline.rb
46
53
  - lib/red_quilt/inline/builder.rb
54
+ - lib/red_quilt/inline/emphasis_resolver.rb
47
55
  - lib/red_quilt/inline/flanking.rb
48
56
  - lib/red_quilt/inline/html_entities.rb
49
57
  - lib/red_quilt/inline/lexer.rb
50
58
  - lib/red_quilt/inline/link_scanner.rb
51
59
  - lib/red_quilt/inline/token_kind.rb
52
60
  - lib/red_quilt/inline/tokens.rb
61
+ - lib/red_quilt/inline/url_sanitizer.rb
53
62
  - lib/red_quilt/inline_pass.rb
54
63
  - lib/red_quilt/line.rb
55
64
  - lib/red_quilt/lint_pass.rb
@@ -63,6 +72,7 @@ files:
63
72
  - lib/red_quilt/slug.rb
64
73
  - lib/red_quilt/source_map.rb
65
74
  - lib/red_quilt/source_span.rb
75
+ - lib/red_quilt/table.rb
66
76
  - lib/red_quilt/theme.rb
67
77
  - lib/red_quilt/themes/default.css
68
78
  - lib/red_quilt/tilt.rb