mirror of
https://github.com/SharpeTronics/jekyll-spaceship.git
synced 2025-12-17 00:03:13 -05:00
fix: math expression within pipline broken (#14)
This commit is contained in:
parent
68cc44e2bd
commit
a3a1cc2b88
@ -158,7 +158,7 @@ module Jekyll::Spaceship
|
|||||||
if type == :code
|
if type == :code
|
||||||
regex = /((`+)\s*(\w*)((?:.|\n)*?)\2)/
|
regex = /((`+)\s*(\w*)((?:.|\n)*?)\2)/
|
||||||
elsif type == :math
|
elsif type == :math
|
||||||
regex = /(?<=^|\n)[^\n\|]*(((?<!\\)\${1,2})[^\n]*\2)[^\n\|]*/
|
regex = /(((?<!\\)\${1,2})[^\n]*?\1)/
|
||||||
end
|
end
|
||||||
next if regex.nil?
|
next if regex.nil?
|
||||||
content.scan(regex) do |match_data|
|
content.scan(regex) do |match_data|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ module Jekyll::Spaceship
|
|||||||
def on_handle_markdown(content)
|
def on_handle_markdown(content)
|
||||||
# pre-handle reference-style links
|
# pre-handle reference-style links
|
||||||
references = {}
|
references = {}
|
||||||
content.scan(/(\[(.*)\]:\s*(.*))/) do |match_data|
|
content.scan(/\n\s*(\[(.*)\]:\s*(\S+(\s+".*?")?))/) do |match_data|
|
||||||
ref_name = match_data[1]
|
ref_name = match_data[1]
|
||||||
ref_value = match_data[2]
|
ref_value = match_data[2]
|
||||||
references[ref_name] = ref_value
|
references[ref_name] = ref_value
|
||||||
@ -33,9 +33,12 @@ module Jekyll::Spaceship
|
|||||||
|
|
||||||
# escape * and _ and $ etc.
|
# escape * and _ and $ etc.
|
||||||
content.scan(/[^\n]*(?<!\\)\|[^\n]*/) do |result|
|
content.scan(/[^\n]*(?<!\\)\|[^\n]*/) do |result|
|
||||||
|
# skip for math expression within pipeline
|
||||||
|
next unless result
|
||||||
|
.gsub(/((?<!\\)\${1,2})[^\n]*?\1/, '')
|
||||||
|
.match(/(?<!\\)\|/)
|
||||||
replace = result.gsub(
|
replace = result.gsub(
|
||||||
/(?<!(?<!\\)\\)(\*|\$|\[|\(|\"|_)/,
|
/(?<!(?<!\\)\\)(\*|\$|\[|\(|\"|_)/, '\\\\\\\\\1')
|
||||||
'\\\\\\\\\1')
|
|
||||||
next if result == replace
|
next if result == replace
|
||||||
content = content.gsub(result, replace)
|
content = content.gsub(result, replace)
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user