raindown 0.21.2 → 0.22.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/lib/raindown/code.rb +15 -3
- data/lib/raindown/code_blocks.rb +4 -2
- data/lib/raindown/yjit.rb +15 -7
- data/lib/raindown.rb +5 -3
- data/lib/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 96b04a893baf519b6fe2a26bb1d4a27c90a030e7b0be6d754696860495db7e08
|
|
4
|
+
data.tar.gz: 5f43ba40f8569ae40697c3207fec8fc698328d28089502177c55d63471218323
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 63b1e3a97e370a10ac1880aa108263b89d862244804c886f0d729c2f5e3dcaf3ae53abfeda7ce81c8fd13212207de6cce89d3f9a7eaf5621fe1deef9462f3e75
|
|
7
|
+
data.tar.gz: 2c8f75f680a003171854195b33d37e82c532858d0f5d82547750a2af24066eadedc445a1ca31a7e3fb22e14d0da56b7d7126758f939abe4ebf4ed4b0167b5a19
|
data/lib/raindown/code.rb
CHANGED
|
@@ -5,8 +5,9 @@ require_relative 'code_blocks'
|
|
|
5
5
|
module Raindown
|
|
6
6
|
# Finds code in Markdown the way Commonmarker reads it: code spans and fenced, indented or quoted code blocks.
|
|
7
7
|
module Code
|
|
8
|
-
# A code span on one line, like `{x}`, between runs of the same number of backticks.
|
|
9
|
-
SPAN =
|
|
8
|
+
# A code span on one line, like `{x}`, between runs of the same number of backticks, from the run it opens with.
|
|
9
|
+
SPAN = /\G(`+)(?!`).+?(?<!`)\1(?!`)/n
|
|
10
|
+
NOT_BACKTICK = /[^`]/n
|
|
10
11
|
|
|
11
12
|
module_function
|
|
12
13
|
|
|
@@ -47,8 +48,19 @@ module Raindown
|
|
|
47
48
|
ranges
|
|
48
49
|
end
|
|
49
50
|
|
|
51
|
+
# The line's spans, each matched from its next run of backticks, which byteindex finds without a regex, so the
|
|
52
|
+
# text between spans is never scanned, and nor is a line without a backtick, as most are. A run that opens no span
|
|
53
|
+
# is passed over whole.
|
|
50
54
|
def span_ranges(line, start)
|
|
51
|
-
line.b
|
|
55
|
+
bytes = line.b
|
|
56
|
+
ranges = []
|
|
57
|
+
from = 0
|
|
58
|
+
while (open = bytes.byteindex('`', from))
|
|
59
|
+
from = SPAN.match(bytes, open)&.end(0)
|
|
60
|
+
ranges << ((start + open)...(start + from)) if from
|
|
61
|
+
from ||= bytes.byteindex(NOT_BACKTICK, open) || break
|
|
62
|
+
end
|
|
63
|
+
ranges
|
|
52
64
|
end
|
|
53
65
|
|
|
54
66
|
def range(position, line_offsets)
|
data/lib/raindown/code_blocks.rb
CHANGED
|
@@ -15,8 +15,10 @@ module Raindown
|
|
|
15
15
|
|
|
16
16
|
# The block opening at index, closed by a fence of the same character that's at least as long.
|
|
17
17
|
def at(lines, index)
|
|
18
|
-
fence,
|
|
19
|
-
return unless
|
|
18
|
+
# Most lines open no fence, and match? makes no match to find that out.
|
|
19
|
+
return unless lines[index]&.match?(FENCE)
|
|
20
|
+
|
|
21
|
+
fence, language = lines[index].match(FENCE).captures
|
|
20
22
|
|
|
21
23
|
close = (index + 1...lines.length).find { |i| lines[i].match?(CLOSINGS[fence]) }
|
|
22
24
|
{ open: index, close:, language:, body: lines[index + 1...close].join } if close
|
data/lib/raindown/yjit.rb
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Raindown
|
|
4
|
-
# Ruby leaves YJIT off unless asked, which makes nodes that compute in loops several times faster.
|
|
4
|
+
# Ruby leaves YJIT off unless asked, which makes nodes that compute in loops several times faster. A Ruby built
|
|
5
|
+
# without it, like ruby.wasm's, has no RubyVM::YJIT.
|
|
5
6
|
module Yjit
|
|
7
|
+
# The runtime a macOS binary carries, signed to allow YJIT, as its folder in tebako's cache and its SHA-256, which
|
|
8
|
+
# rakelib's tebako task writes into the package.
|
|
9
|
+
RUNTIME = File.expand_path('../../yjit_runtime', __dir__)
|
|
10
|
+
|
|
6
11
|
module_function
|
|
7
12
|
|
|
8
13
|
def enable
|
|
9
|
-
RubyVM::YJIT.enable if
|
|
14
|
+
RubyVM::YJIT.enable if defined?(RubyVM::YJIT) && allowed?
|
|
10
15
|
end
|
|
11
16
|
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
def
|
|
15
|
-
return
|
|
17
|
+
# macOS kills a binary as soon as it runs code YJIT compiled, unless its runtime's signed to allow it. The binary
|
|
18
|
+
# carries one that is, but tebako runs the one it cached first, which an earlier binary may have left, tebako's own.
|
|
19
|
+
def allowed?
|
|
20
|
+
return true unless RUBY_PLATFORM.include?('darwin') && __dir__.start_with?('/__tfs__/')
|
|
21
|
+
return false unless File.exist?(RUNTIME)
|
|
16
22
|
|
|
17
|
-
|
|
23
|
+
folder, digest = File.read(RUNTIME).split
|
|
24
|
+
cached = File.join(Dir.home, '.tebako', 'runtimes', folder, 'sha256')
|
|
25
|
+
File.exist?(cached) && File.read(cached).start_with?(digest)
|
|
18
26
|
end
|
|
19
27
|
end
|
|
20
28
|
end
|
data/lib/raindown.rb
CHANGED
|
@@ -70,7 +70,8 @@ module Raindown
|
|
|
70
70
|
output = Directives.render("#{html.chomp}\n")
|
|
71
71
|
next output if commonmark
|
|
72
72
|
|
|
73
|
-
output
|
|
73
|
+
# With tr, as a regex of the placeholders reads the output a character at a time, taking three times as long.
|
|
74
|
+
output.tr(CODE_BRACES.values.join, CODE_BRACES.keys.join)
|
|
74
75
|
end
|
|
75
76
|
end
|
|
76
77
|
end
|
|
@@ -119,8 +120,9 @@ module Raindown
|
|
|
119
120
|
preserve_code(doc:)
|
|
120
121
|
|
|
121
122
|
html = highlight_code? ? doc.to_html(options: HTML_OPTIONS) : unhighlighted_html(doc:)
|
|
122
|
-
html.gsub('<!-- ANTLERS', '<{').gsub('ANTLERS -->', '}>')
|
|
123
|
-
|
|
123
|
+
html = html.gsub('<!-- ANTLERS', '<{').gsub('ANTLERS -->', '}>')
|
|
124
|
+
# Each placeholder's found as text, which is several times faster than a regex of both.
|
|
125
|
+
CODE_BRACE_ENTITIES.reduce(html) { |text, (brace, entity)| text.gsub(brace, entity) }
|
|
124
126
|
end
|
|
125
127
|
|
|
126
128
|
# Code blocks without highlighting, with a language class for highlighting in the browser.
|
data/lib/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: raindown
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.22.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- maedi
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: antlers
|
|
@@ -381,14 +381,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
381
381
|
requirements:
|
|
382
382
|
- - ">="
|
|
383
383
|
- !ruby/object:Gem::Version
|
|
384
|
-
version:
|
|
384
|
+
version: 4.0.0
|
|
385
385
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
386
386
|
requirements:
|
|
387
387
|
- - ">="
|
|
388
388
|
- !ruby/object:Gem::Version
|
|
389
389
|
version: '0'
|
|
390
390
|
requirements: []
|
|
391
|
-
rubygems_version:
|
|
391
|
+
rubygems_version: 4.0.20
|
|
392
392
|
specification_version: 4
|
|
393
393
|
summary: Markup your markdown with a template and annotation layer
|
|
394
394
|
test_files: []
|