html-pipeline-linuxfr 0.14.20 → 0.14.21
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/html/pipeline/svgtex.rb +11 -5
- data/lib/html/pipeline/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73401549a3b0fe54fe2e05bec94d4bd169dcb3d4
|
4
|
+
data.tar.gz: 70b04dea06fcb0af6066fd4e6589dfe8f8f4314d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc19dbac013e43698d510d93f7374a814aa3a8d5bbf4d341d2d10477dda0ed8a8641ec588ab4a25e9bb2df27e6262b99aaba7d61b044565c921b13c49b39f981
|
7
|
+
data.tar.gz: 83da5ac6c1b502399dcaaeacd92dd67f0ba13351101d85aa849e0017145c392ea43a0cd10997a7b7efc36d688b149b88426ebd7dede789459fb7d752532fedf0
|
data/lib/html/pipeline/svgtex.rb
CHANGED
@@ -8,6 +8,12 @@ module HTML
|
|
8
8
|
class SVGTeX
|
9
9
|
|
10
10
|
class PreFilter < TextFilter
|
11
|
+
BLOCK_SVGTEX = /^\$\$([^$]+)\$\$\s*$/
|
12
|
+
INLINE_SVGTEX = /(?<!\p{Word})\$([^$\n]+)\$(?!\p{Word})/
|
13
|
+
INDENTED_CODE = /(\A|\n\r?\n)(((\t|\s{4}).*(\n|\Z))+)(\r?\n|\Z)/
|
14
|
+
FENCED_CODE = /^``` ?(.*?)\r?\n(.+?)\r?\n```\r?$/m
|
15
|
+
INLINE_CODE = /`(.*)`/
|
16
|
+
|
11
17
|
def initialize(text, context = nil, result = nil)
|
12
18
|
super text, context, result
|
13
19
|
@text = @text.gsub "\r", ''
|
@@ -18,12 +24,12 @@ module HTML
|
|
18
24
|
def call
|
19
25
|
extract_fenced_code!
|
20
26
|
extract_indented_code!
|
21
|
-
@text.gsub!(
|
27
|
+
@text.gsub!(BLOCK_SVGTEX) do
|
22
28
|
"\n\n```mathjax\n\\displaystyle{#{$1.gsub "\\", "\\\\\\\\"}}\n```\n\n"
|
23
29
|
end
|
24
30
|
extract_fenced_code!
|
25
31
|
extract_inline_code!
|
26
|
-
@text.gsub!(
|
32
|
+
@text.gsub!(INLINE_SVGTEX) do
|
27
33
|
"`{mathjax} #{$1}`"
|
28
34
|
end
|
29
35
|
reinsert_code!
|
@@ -31,7 +37,7 @@ module HTML
|
|
31
37
|
end
|
32
38
|
|
33
39
|
def extract_inline_code!
|
34
|
-
@text.gsub!(
|
40
|
+
@text.gsub!(INLINE_CODE) do
|
35
41
|
id = Digest::SHA1.hexdigest($1)
|
36
42
|
@inline[id] = $1
|
37
43
|
id
|
@@ -39,7 +45,7 @@ module HTML
|
|
39
45
|
end
|
40
46
|
|
41
47
|
def extract_indented_code!
|
42
|
-
@text.gsub!(
|
48
|
+
@text.gsub!(INDENTED_CODE) do
|
43
49
|
code = $2.gsub(/^(\t|\s{4})/, '').sub(/\r?\n\Z/, '')
|
44
50
|
id = Digest::SHA1.hexdigest(code)
|
45
51
|
@codemap[id] = { :code => code }
|
@@ -49,7 +55,7 @@ module HTML
|
|
49
55
|
|
50
56
|
# Code taken from gollum (http://github.com/github/gollum)
|
51
57
|
def extract_fenced_code!
|
52
|
-
@text.gsub!(
|
58
|
+
@text.gsub!(FENCED_CODE) do
|
53
59
|
id = Digest::SHA1.hexdigest($2)
|
54
60
|
@codemap[id] = { :lang => $1, :code => $2 }
|
55
61
|
id
|