Compare commits

...

3 Commits

Author SHA1 Message Date
jeffreytse
8ca6d144a4 release: v0.9.3 2020-10-07 18:46:06 +08:00
jeffreytse
7847cac8c4 fix: inline code corrupted in table (#27) 2020-10-07 18:41:45 +08:00
jeffreytse
6973d6ab7e docs: update README.md 2020-10-03 09:22:31 +08:00
4 changed files with 18 additions and 9 deletions

View File

@ -966,7 +966,7 @@ Automatically adds a `target="_blank" rel="noopener noreferrer"` attribute to al
jekyll-spaceship:
element-processor:
css:
- a: # Replce all `a` tags
- a: # Replace all `a` tags
props:
class: ['(^.*$)', '\0 ext-link'] # Add `ext-link` to class by regex pattern
target: _blank # Replace `target` value to `_blank`
@ -982,7 +982,7 @@ Automatically adds `loading="lazy"` to `img` and `iframe` tags to natively load
jekyll-spaceship:
element-processor:
css:
- a: # Replce all `a` tags
- a: # Replace all `a` tags
props: #
loading: lazy # Replace `loading` value to `lazy`
```
@ -997,7 +997,7 @@ See the following examples to prevent lazy loading.
jekyll-spaceship:
element-processor:
css:
- a: # Replce all `a` tags
- a: # Replace all `a` tags
props: #
loading: eager # Replace `loading` value to `eager`
```

View File

@ -116,7 +116,7 @@ module Jekyll::Spaceship
if self.respond_to? method
@page.content = self.pre_exclude @page.content
@page.content = self.send method, @page.content
@page.content = self.after_exclude @page.content
@page.content = self.post_exclude @page.content
end
else
if Type.html? output_ext
@ -151,8 +151,8 @@ module Jekyll::Spaceship
logger.log file
end
def pre_exclude(content)
@exclusion_store = []
def exclusion_regexs()
regexs = []
@exclusions.each do |type|
regex = nil
if type == :code
@ -162,7 +162,14 @@ module Jekyll::Spaceship
elsif type == :liquid_filter
regex = /((?<!\\)((\{\{[^\n]*?\}\})|(\{%[^\n]*?%\})))/
end
next if regex.nil?
regexs.push regex unless regex.nil?
end
regexs
end
def pre_exclude(content, regexs = self.exclusion_regexs())
@exclusion_store = []
regexs.each do |regex|
content.scan(regex) do |match_data|
match = match_data[0]
id = @exclusion_store.size
@ -173,7 +180,7 @@ module Jekyll::Spaceship
content
end
def after_exclude(content)
def post_exclude(content)
while @exclusion_store.size > 0
match = @exclusion_store.pop
id = @exclusion_store.size

View File

@ -305,10 +305,12 @@ module Jekyll::Spaceship
cvter = self.converter('markdown')
return if cvter.nil?
content = cell.inner_html
content = self.pre_exclude(content, [/(\<code.*\>.*\<\/code\>)/])
.gsub(/(?<!\\)\|/, '\\|')
.gsub(/^\s+|\s+$/, '')
.gsub(/&lt;/, '<')
.gsub(/&gt;/, '>')
content = self.post_exclude(content)
content = cvter.convert(content)
content = Nokogiri::HTML.fragment(content)
if content.children.first&.name == 'p'

View File

@ -2,6 +2,6 @@
module Jekyll
module Spaceship
VERSION = "0.9.2"
VERSION = "0.9.3"
end
end