raindown 0.25.4 → 0.25.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 902e7d196394f6fe68451f7e7835339fc2db78f1834ee5bc520de6ab89fde600
4
- data.tar.gz: 47e342e68a8999f80af3c00ba226967073af9f79fe22fb12ad0decbb506135fd
3
+ metadata.gz: bc25f6ab6c241d112ddc7bfa9eba374ae62156f1664dfd3fcb236e27253c6d69
4
+ data.tar.gz: e3ebcad9b3481cfa905ac9380440696337cb0991f6e3489d7181d6940bad53f9
5
5
  SHA512:
6
- metadata.gz: 2005574b317e4cf0e9fe8583e5784d3338ac21748931e168d92c87fe4f9ec1c52a0124f016d5d47089907cadabfbcfcec0a5b8ca1e9f698f757a2a4f90cf00d1
7
- data.tar.gz: 9280dcb507dde8d964922b7e101214755d0d55c9901546ac3c08b1821db69a33db8c18a1d1515957e47eae8b59960ecec4c2433b0f09ee9236466f74cf5d8b01
6
+ metadata.gz: 4af4c1dcc4f12de88af50c3dfffe976a44ac36b62eea991f5a63526b2cc9fb3270d79a51f7ae3dbdc7ea8b904facec2afd97ee6e853aa65d1f5515e9885b9371
7
+ data.tar.gz: 4e204309e4aa39e3ac8bb7e50830dda6de508d18db77130ac4415d896382070d7d148c3580cb3e7712628c58f4ab17721fe9837773168b611ece8b7f22fbe9c0
@@ -17,7 +17,7 @@ module Raindown
17
17
  def lexeme(keywords:, **)
18
18
  return { endpoint_def: keywords } if keywords.key?('endpoint:')
19
19
 
20
- { endpoint_end: 'level_1' }
20
+ { endpoint_end: NAMELESS_END }
21
21
  end
22
22
  end
23
23
  end
@@ -60,8 +60,9 @@ module Raindown
60
60
  end
61
61
  alias inspect to_s
62
62
 
63
- def method_missing(*)
64
- nil
63
+ # Antlers' compiled templates read a variable by calling it. Unknown names are nil.
64
+ def method_missing(name, *)
65
+ @values[name.to_sym]
65
66
  end
66
67
 
67
68
  def respond_to_missing?(*)
data/lib/raindown.rb CHANGED
@@ -33,12 +33,16 @@ module Raindown
33
33
  CODE_BRACES = { '{' => "\u{E000}", '}' => "\u{E001}" }.freeze
34
34
  CODE_BRACE_ENTITIES = { "\u{E000}" => '{', "\u{E001}" => '}' }.freeze
35
35
 
36
- # Front matter is metadata, so it's left out of the HTML and the headings.
37
- MARKDOWN_OPTIONS = { extension: { alerts: true, front_matter_delimiter: '---' } }.freeze
38
- # Directives are HTML comments until Antlers renders them, and escaped characters like "\#" stay plain text.
39
- HTML_OPTIONS = { render: { unsafe: true, escaped_char_spans: false } }.freeze
40
- # Without highlighting, code blocks are left for the browser to highlight, like <pre><code class="language-ruby">.
41
- UNHIGHLIGHTED_OPTIONS = { render: { **HTML_OPTIONS[:render], github_pre_lang: false } }.freeze
36
+ # GitHub's extensions and heading ids as Commonmarker is plain CommonMark without them. Front matter is left out.
37
+ MARKDOWN_OPTIONS = {
38
+ extension: { alerts: true, front_matter_delimiter: '---', strikethrough: true, table: true, autolink: true,
39
+ tasklist: true, shortcodes: true, header_ids: '' }
40
+ }.freeze
41
+ # Directives are HTML comments until Antlers renders them and escaped characters like "\#" stay plain text.
42
+ HTML_OPTIONS = { **MARKDOWN_OPTIONS, render: { unsafe: true, hardbreaks: true, escaped_char_spans: false } }.freeze
43
+ # Highlighted code blocks look like <pre lang="ruby" style="…"> and others like <pre><code class="language-ruby">.
44
+ HIGHLIGHTED_OPTIONS = { **HTML_OPTIONS, render: { **HTML_OPTIONS[:render], github_pre_lang: true } }.freeze
45
+ HIGHLIGHTER = { syntax_highlighter: { theme: 'base16-ocean.dark' } }.freeze
42
46
 
43
47
  # Stands in for an app's metadata when there isn't any, so list: lists nothing.
44
48
  module NoMetadata
@@ -118,17 +122,16 @@ module Raindown
118
122
  doc = parse_markdown(hide_directives(markdown: TableFormatter.gfm(markdown)))
119
123
  preserve_code(doc:)
120
124
 
121
- html = highlight_code? ? doc.to_html(options: HTML_OPTIONS) : unhighlighted_html(doc:)
125
+ html = if highlight_code?
126
+ doc.to_html(options: HIGHLIGHTED_OPTIONS, plugins: HIGHLIGHTER)
127
+ else
128
+ doc.to_html(options: HTML_OPTIONS)
129
+ end
122
130
  html = html.gsub('<!-- ANTLERS', '<{').gsub('ANTLERS -->', '}>')
123
131
  # Each placeholder's found as text, which is several times faster than a regex of both.
124
132
  CODE_BRACE_ENTITIES.reduce(html) { |text, (brace, entity)| text.gsub(brace, entity) }
125
133
  end
126
134
 
127
- # Code blocks without highlighting, with a language class for highlighting in the browser.
128
- def unhighlighted_html(doc:)
129
- doc.to_html(options: UNHIGHLIGHTED_OPTIONS, plugins: { syntax_highlighter: nil })
130
- end
131
-
132
135
  # Commonmarker escapes directives, so they're hidden in HTML comments until it's done.
133
136
  def hide_directives(markdown:)
134
137
  markdown.gsub('<{', '<!-- ANTLERS').gsub('}>', 'ANTLERS -->').force_encoding('UTF-8')
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Raindown
4
- VERSION = '0.25.4'
4
+ VERSION = '0.25.5'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raindown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.25.4
4
+ version: 0.25.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - maedi
@@ -15,28 +15,28 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 1.5.1
18
+ version: 1.5.5
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: 1.5.1
25
+ version: 1.5.5
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: commonmarker
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
- - - ">="
30
+ - - "~>"
31
31
  - !ruby/object:Gem::Version
32
- version: '0'
32
+ version: '3.0'
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ">="
37
+ - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0'
39
+ version: '3.0'
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: csv
42
42
  requirement: !ruby/object:Gem::Requirement