Skip to content

Commit 5015fde

Browse files
committed
style(core): avoid using < or > within capture tag
This interferes with the work of the editor Liquid-HTML plugin
1 parent de2dff3 commit 5015fde

File tree

1 file changed

+40
-45
lines changed

1 file changed

+40
-45
lines changed

_includes/refactor-content.html

Lines changed: 40 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,18 @@
3232
<!-- Change the icon of checkbox -->
3333
{% if _content contains '<input type="checkbox"' %}
3434
{% assign _content = _content
35-
| replace:
36-
'<input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />',
37-
'<i class="fas fa-check-circle fa-fw checked"></i>'
38-
| replace:
39-
'<input type="checkbox" class="task-list-item-checkbox" disabled="disabled" />',
40-
'<i class="far fa-circle fa-fw"></i>'
35+
| replace: '<input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />',
36+
'<i class="fas fa-check-circle fa-fw checked"></i>'
37+
| replace: '<input type="checkbox" class="task-list-item-checkbox" disabled="disabled" />',
38+
'<i class="far fa-circle fa-fw"></i>'
4139
%}
4240
{% endif %}
4341

4442
<!-- images -->
4543
{% assign IMG_TAG = '<img ' %}
4644

4745
{% if _content contains IMG_TAG %}
48-
{% assign _img_content = nil %}
46+
{% assign _img_content = null %}
4947
{% assign _img_snippets = _content | split: IMG_TAG %}
5048

5149
<!-- CDN URL -->
@@ -81,10 +79,10 @@
8179
{% assign _left = _left | remove: ' /' | replace: ' w=', ' width=' | replace: ' h=', ' height=' %}
8280
{% assign _attrs = _left | split: '" ' %}
8381

84-
{% assign _width = nil %}
85-
{% assign _height = nil %}
86-
{% assign _lqip = nil %}
87-
{% assign _class = nil %}
82+
{% assign _width = null %}
83+
{% assign _height = null %}
84+
{% assign _lqip = null %}
85+
{% assign _class = null %}
8886

8987
{% for _attr in _attrs %}
9088
{% unless _attr contains '=' %}
@@ -115,7 +113,7 @@
115113
{% assign _left = _left | remove: _old_class %}
116114
{% endif %}
117115

118-
{% assign _final_src = nil %}
116+
{% assign _final_src = null %}
119117

120118
{% unless _src contains '//' %}
121119
{% assign _final_src = _path_prefix | append: _src %}
@@ -136,7 +134,7 @@
136134
<!-- lazy-load images <https://github.com/aFarkas/lazysizes#readme> -->
137135
{% assign _left = _left | replace: 'src=', 'data-src=' %}
138136
{% if _left contains 'class=' %}
139-
{% assign _left = _left | replace: 'class="', 'class="lazyload '%}
137+
{% assign _left = _left | replace: 'class="', 'class="lazyload ' %}
140138
{% else %}
141139
{% assign _left = _left | append: ' class="lazyload"' %}
142140
{% endif %}
@@ -150,7 +148,7 @@
150148
{%- capture _svg -%}
151149
src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 {{ _width }} {{ _height }}'%3E%3C/svg%3E"
152150
{%- endcapture -%}
153-
{% assign _left = _svg | append: ' ' | append: _left %}
151+
{% assign _left = _svg | append: ' ' | append: _left %}
154152
{% assign _class = _class | append: ' shimmer' %}
155153
{% endif %}
156154
{% endif %}
@@ -160,9 +158,8 @@
160158

161159
{% if page.layout == 'home' %}
162160
<!-- create the image wrapper -->
163-
{%- capture _wrapper_start -%}
164-
<div class="preview-img {{ _class | strip }}">
165-
{%- endcapture -%}
161+
{% assign _wrapper_start = '<div class="preview-img ' | append: _class | append: '">' %}
162+
166163
{% assign _img_content = _img_content | append: _wrapper_start %}
167164
{% assign _right = _right | prepend: '></div' %}
168165

@@ -176,26 +173,29 @@
176173
{% capture _class %}
177174
class="img-link{% unless _lqip %} shimmer{% endunless %}"
178175
{% endcapture %}
179-
{% assign _img_content = _img_content | slice: 0, _size | append: _class | append: '>' %}
176+
{% assign _img_content = _img_content | slice: 0, _size | append: _class | append: '>' %}
180177
{% else %}
181178
<!-- create the image wrapper -->
182-
{%- capture _wrapper_start -%}
183-
<a href="{{ _final_src | default: _src }}" class="popup img-link {{ _class }}">
184-
{%- endcapture -%}
179+
{% assign _wrapper_start = _final_src
180+
| default: _src
181+
| prepend: '<a href="'
182+
| append: '" class="popup img-link '
183+
| append: _class
184+
| append: '">'
185+
%}
186+
185187
{% assign _img_content = _img_content | append: _wrapper_start %}
186188
{% assign _right = _right | prepend: '></a' %}
187189
{% endif %}
188190
{% endif %}
189191

190192
<!-- combine -->
191193
{% assign _img_content = _img_content | append: debug | append: IMG_TAG | append: _left | append: _right %}
192-
193194
{% endfor %}
194195

195196
{% if _img_content %}
196197
{% assign _content = _img_content %}
197198
{% endif %}
198-
199199
{% endif %}
200200

201201
<!-- Add header for code snippets -->
@@ -205,13 +205,11 @@
205205
{% assign _new_content = '' %}
206206

207207
{% for _snippet in _code_spippets %}
208-
209208
{% if forloop.last %}
210209
{% assign _new_content = _new_content | append: _snippet %}
211210

212211
{% else %}
213-
214-
{% assign _left = _snippet | split: '><' | last%}
212+
{% assign _left = _snippet | split: '><' | last %}
215213

216214
{% if _left contains 'file="' %}
217215
{% assign _label_text = _left | split: 'file="' | last | split: '"' | first %}
@@ -226,21 +224,19 @@
226224
<span data-label-text="{{ _label_text | strip }}"><i class="{{ _label_icon }}"></i></span>
227225
{% endcapture %}
228226

229-
{% assign _new_content = _new_content | append: _snippet
230-
| append: '<div class="code-header">'
231-
| append: _label
232-
| append: '<button aria-label="copy" data-title-succeed="'
233-
| append: site.data.locales[include.lang].post.button.copy_code.succeed
234-
| append: '"><i class="far fa-clipboard"></i></button></div>'
235-
| append: '<div class="highlight"><code>'
227+
{% assign _new_content = _new_content
228+
| append: _snippet
229+
| append: '<div class="code-header">'
230+
| append: _label
231+
| append: '<button aria-label="copy" data-title-succeed="'
232+
| append: site.data.locales[include.lang].post.button.copy_code.succeed
233+
| append: '"><i class="far fa-clipboard"></i></button></div>'
234+
| append: '<div class="highlight"><code>'
236235
%}
237-
238236
{% endif %}
239-
240237
{% endfor %}
241238

242239
{% assign _content = _new_content %}
243-
244240
{% endif %}
245241

246242
<!-- Create heading anchors -->
@@ -249,11 +245,11 @@
249245
{% assign _heading_content = _content %}
250246

251247
{% for level in heading_levels %}
252-
{% capture mark_start %}<h{{ level }} id="{% endcapture %}
253-
{% capture mark_end %}</h{{ level }}>{% endcapture %}
248+
{% assign mark_start = '<h' | append: level | append: ' id="' %}
249+
{% assign mark_end = '</h' | append: level | append: '>' %}
254250

255251
{% if _heading_content contains mark_start %}
256-
{% assign _new_content = nil %}
252+
{% assign _new_content = null %}
257253
{% assign heading_snippets = _heading_content | split: mark_start %}
258254

259255
{% for snippet in heading_snippets %}
@@ -263,20 +259,19 @@
263259
{% endif %}
264260

265261
{% assign id = snippet | split: '"' | first %}
266-
{% capture anchor %}<a href="#{{ id }}" class="anchor text-muted"><i class="fas fa-hashtag"></i></a>{% endcapture %}
262+
{% assign anchor = '<a href="#'
263+
| append: id
264+
| append: '" class="anchor text-muted"><i class="fas fa-hashtag"></i></a>'
265+
%}
267266

268267
{% assign left = snippet | split: mark_end | first %}
269268
{% assign right = snippet | slice: left.size, snippet.size %}
270269
{% assign left = left | replace_first: '">', '"><span class="me-2">' | append: '</span>' %}
271270

272-
{% assign _new_content = _new_content | append: mark_start
273-
| append: left | append: anchor | append: right
274-
%}
275-
271+
{% assign _new_content = _new_content | append: mark_start | append: left | append: anchor | append: right %}
276272
{% endfor %}
277273

278274
{% assign _heading_content = _new_content %}
279-
280275
{% endif %}
281276
{% endfor %}
282277

0 commit comments

Comments
 (0)