mirror of
https://github.com/SharpeTronics/jekyll-spaceship.git
synced 2025-06-24 00:01:24 -04:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
8ca6d144a4 | ||
|
7847cac8c4 | ||
|
6973d6ab7e |
@ -966,7 +966,7 @@ Automatically adds a `target="_blank" rel="noopener noreferrer"` attribute to al
|
|||||||
jekyll-spaceship:
|
jekyll-spaceship:
|
||||||
element-processor:
|
element-processor:
|
||||||
css:
|
css:
|
||||||
- a: # Replce all `a` tags
|
- a: # Replace all `a` tags
|
||||||
props:
|
props:
|
||||||
class: ['(^.*$)', '\0 ext-link'] # Add `ext-link` to class by regex pattern
|
class: ['(^.*$)', '\0 ext-link'] # Add `ext-link` to class by regex pattern
|
||||||
target: _blank # Replace `target` value to `_blank`
|
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:
|
jekyll-spaceship:
|
||||||
element-processor:
|
element-processor:
|
||||||
css:
|
css:
|
||||||
- a: # Replce all `a` tags
|
- a: # Replace all `a` tags
|
||||||
props: #
|
props: #
|
||||||
loading: lazy # Replace `loading` value to `lazy`
|
loading: lazy # Replace `loading` value to `lazy`
|
||||||
```
|
```
|
||||||
@ -997,7 +997,7 @@ See the following examples to prevent lazy loading.
|
|||||||
jekyll-spaceship:
|
jekyll-spaceship:
|
||||||
element-processor:
|
element-processor:
|
||||||
css:
|
css:
|
||||||
- a: # Replce all `a` tags
|
- a: # Replace all `a` tags
|
||||||
props: #
|
props: #
|
||||||
loading: eager # Replace `loading` value to `eager`
|
loading: eager # Replace `loading` value to `eager`
|
||||||
```
|
```
|
||||||
|
@ -116,7 +116,7 @@ module Jekyll::Spaceship
|
|||||||
if self.respond_to? method
|
if self.respond_to? method
|
||||||
@page.content = self.pre_exclude @page.content
|
@page.content = self.pre_exclude @page.content
|
||||||
@page.content = self.send method, @page.content
|
@page.content = self.send method, @page.content
|
||||||
@page.content = self.after_exclude @page.content
|
@page.content = self.post_exclude @page.content
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if Type.html? output_ext
|
if Type.html? output_ext
|
||||||
@ -151,8 +151,8 @@ module Jekyll::Spaceship
|
|||||||
logger.log file
|
logger.log file
|
||||||
end
|
end
|
||||||
|
|
||||||
def pre_exclude(content)
|
def exclusion_regexs()
|
||||||
@exclusion_store = []
|
regexs = []
|
||||||
@exclusions.each do |type|
|
@exclusions.each do |type|
|
||||||
regex = nil
|
regex = nil
|
||||||
if type == :code
|
if type == :code
|
||||||
@ -162,7 +162,14 @@ module Jekyll::Spaceship
|
|||||||
elsif type == :liquid_filter
|
elsif type == :liquid_filter
|
||||||
regex = /((?<!\\)((\{\{[^\n]*?\}\})|(\{%[^\n]*?%\})))/
|
regex = /((?<!\\)((\{\{[^\n]*?\}\})|(\{%[^\n]*?%\})))/
|
||||||
end
|
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|
|
content.scan(regex) do |match_data|
|
||||||
match = match_data[0]
|
match = match_data[0]
|
||||||
id = @exclusion_store.size
|
id = @exclusion_store.size
|
||||||
@ -173,7 +180,7 @@ module Jekyll::Spaceship
|
|||||||
content
|
content
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_exclude(content)
|
def post_exclude(content)
|
||||||
while @exclusion_store.size > 0
|
while @exclusion_store.size > 0
|
||||||
match = @exclusion_store.pop
|
match = @exclusion_store.pop
|
||||||
id = @exclusion_store.size
|
id = @exclusion_store.size
|
||||||
|
@ -305,10 +305,12 @@ module Jekyll::Spaceship
|
|||||||
cvter = self.converter('markdown')
|
cvter = self.converter('markdown')
|
||||||
return if cvter.nil?
|
return if cvter.nil?
|
||||||
content = cell.inner_html
|
content = cell.inner_html
|
||||||
|
content = self.pre_exclude(content, [/(\<code.*\>.*\<\/code\>)/])
|
||||||
.gsub(/(?<!\\)\|/, '\\|')
|
.gsub(/(?<!\\)\|/, '\\|')
|
||||||
.gsub(/^\s+|\s+$/, '')
|
.gsub(/^\s+|\s+$/, '')
|
||||||
.gsub(/</, '<')
|
.gsub(/</, '<')
|
||||||
.gsub(/>/, '>')
|
.gsub(/>/, '>')
|
||||||
|
content = self.post_exclude(content)
|
||||||
content = cvter.convert(content)
|
content = cvter.convert(content)
|
||||||
content = Nokogiri::HTML.fragment(content)
|
content = Nokogiri::HTML.fragment(content)
|
||||||
if content.children.first&.name == 'p'
|
if content.children.first&.name == 'p'
|
||||||
|
@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
module Jekyll
|
module Jekyll
|
||||||
module Spaceship
|
module Spaceship
|
||||||
VERSION = "0.9.2"
|
VERSION = "0.9.3"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user