|
32 | 32 | <!-- Change the icon of checkbox --> |
33 | 33 | {% if _content contains '<input type="checkbox"' %} |
34 | 34 | {% 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>' |
41 | 39 | %} |
42 | 40 | {% endif %} |
43 | 41 |
|
44 | 42 | <!-- images --> |
45 | 43 | {% assign IMG_TAG = '<img ' %} |
46 | 44 |
|
47 | 45 | {% if _content contains IMG_TAG %} |
48 | | - {% assign _img_content = nil %} |
| 46 | + {% assign _img_content = null %} |
49 | 47 | {% assign _img_snippets = _content | split: IMG_TAG %} |
50 | 48 |
|
51 | 49 | <!-- CDN URL --> |
|
81 | 79 | {% assign _left = _left | remove: ' /' | replace: ' w=', ' width=' | replace: ' h=', ' height=' %} |
82 | 80 | {% assign _attrs = _left | split: '" ' %} |
83 | 81 |
|
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 %} |
88 | 86 |
|
89 | 87 | {% for _attr in _attrs %} |
90 | 88 | {% unless _attr contains '=' %} |
|
115 | 113 | {% assign _left = _left | remove: _old_class %} |
116 | 114 | {% endif %} |
117 | 115 |
|
118 | | - {% assign _final_src = nil %} |
| 116 | + {% assign _final_src = null %} |
119 | 117 |
|
120 | 118 | {% unless _src contains '//' %} |
121 | 119 | {% assign _final_src = _path_prefix | append: _src %} |
|
136 | 134 | <!-- lazy-load images <https://github.com/aFarkas/lazysizes#readme> --> |
137 | 135 | {% assign _left = _left | replace: 'src=', 'data-src=' %} |
138 | 136 | {% if _left contains 'class=' %} |
139 | | - {% assign _left = _left | replace: 'class="', 'class="lazyload '%} |
| 137 | + {% assign _left = _left | replace: 'class="', 'class="lazyload ' %} |
140 | 138 | {% else %} |
141 | 139 | {% assign _left = _left | append: ' class="lazyload"' %} |
142 | 140 | {% endif %} |
|
150 | 148 | {%- capture _svg -%} |
151 | 149 | src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 {{ _width }} {{ _height }}'%3E%3C/svg%3E" |
152 | 150 | {%- endcapture -%} |
153 | | - {% assign _left = _svg | append: ' ' | append: _left %} |
| 151 | + {% assign _left = _svg | append: ' ' | append: _left %} |
154 | 152 | {% assign _class = _class | append: ' shimmer' %} |
155 | 153 | {% endif %} |
156 | 154 | {% endif %} |
|
160 | 158 |
|
161 | 159 | {% if page.layout == 'home' %} |
162 | 160 | <!-- 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 | + |
166 | 163 | {% assign _img_content = _img_content | append: _wrapper_start %} |
167 | 164 | {% assign _right = _right | prepend: '></div' %} |
168 | 165 |
|
|
176 | 173 | {% capture _class %} |
177 | 174 | class="img-link{% unless _lqip %} shimmer{% endunless %}" |
178 | 175 | {% 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: '>' %} |
180 | 177 | {% else %} |
181 | 178 | <!-- 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 | + |
185 | 187 | {% assign _img_content = _img_content | append: _wrapper_start %} |
186 | 188 | {% assign _right = _right | prepend: '></a' %} |
187 | 189 | {% endif %} |
188 | 190 | {% endif %} |
189 | 191 |
|
190 | 192 | <!-- combine --> |
191 | 193 | {% assign _img_content = _img_content | append: debug | append: IMG_TAG | append: _left | append: _right %} |
192 | | - |
193 | 194 | {% endfor %} |
194 | 195 |
|
195 | 196 | {% if _img_content %} |
196 | 197 | {% assign _content = _img_content %} |
197 | 198 | {% endif %} |
198 | | - |
199 | 199 | {% endif %} |
200 | 200 |
|
201 | 201 | <!-- Add header for code snippets --> |
|
205 | 205 | {% assign _new_content = '' %} |
206 | 206 |
|
207 | 207 | {% for _snippet in _code_spippets %} |
208 | | - |
209 | 208 | {% if forloop.last %} |
210 | 209 | {% assign _new_content = _new_content | append: _snippet %} |
211 | 210 |
|
212 | 211 | {% else %} |
213 | | - |
214 | | - {% assign _left = _snippet | split: '><' | last%} |
| 212 | + {% assign _left = _snippet | split: '><' | last %} |
215 | 213 |
|
216 | 214 | {% if _left contains 'file="' %} |
217 | 215 | {% assign _label_text = _left | split: 'file="' | last | split: '"' | first %} |
|
226 | 224 | <span data-label-text="{{ _label_text | strip }}"><i class="{{ _label_icon }}"></i></span> |
227 | 225 | {% endcapture %} |
228 | 226 |
|
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>' |
236 | 235 | %} |
237 | | - |
238 | 236 | {% endif %} |
239 | | - |
240 | 237 | {% endfor %} |
241 | 238 |
|
242 | 239 | {% assign _content = _new_content %} |
243 | | - |
244 | 240 | {% endif %} |
245 | 241 |
|
246 | 242 | <!-- Create heading anchors --> |
|
249 | 245 | {% assign _heading_content = _content %} |
250 | 246 |
|
251 | 247 | {% 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: '>' %} |
254 | 250 |
|
255 | 251 | {% if _heading_content contains mark_start %} |
256 | | - {% assign _new_content = nil %} |
| 252 | + {% assign _new_content = null %} |
257 | 253 | {% assign heading_snippets = _heading_content | split: mark_start %} |
258 | 254 |
|
259 | 255 | {% for snippet in heading_snippets %} |
|
263 | 259 | {% endif %} |
264 | 260 |
|
265 | 261 | {% 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 | + %} |
267 | 266 |
|
268 | 267 | {% assign left = snippet | split: mark_end | first %} |
269 | 268 | {% assign right = snippet | slice: left.size, snippet.size %} |
270 | 269 | {% assign left = left | replace_first: '">', '"><span class="me-2">' | append: '</span>' %} |
271 | 270 |
|
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 %} |
276 | 272 | {% endfor %} |
277 | 273 |
|
278 | 274 | {% assign _heading_content = _new_content %} |
279 | | - |
280 | 275 | {% endif %} |
281 | 276 | {% endfor %} |
282 | 277 |
|
|
0 commit comments