我正在尝试更新<p>
中包含的<blockquote>
的类,但是我无法使用液体的“替换”命令来访问它
我似乎找不到合适的解决方案
<section class="section">
<div class="container is-fluid ">
<div class="columns is-medium content is-multiline is-centered">
<div class="column is-10 ">
{{ content | markdownify | smartify
| replace: '<table', '<table class="table is-narrow is-bordered is-hoverable is-striped is-size-6 column is-8 is-offset-2"'
| replace: '<blockquote', '<blockquote class="column is-8 is-offset-2"'
| replace: '<p', '<p class="column is-8 is-offset-2"'
| replace: '<h1', '<h1 class="column is-8 is-offset-2"'
| replace: '<h2', '<h2 class="column is-8 is-offset-2"'
| replace: '<h3', '<h3 class="column is-8 is-offset-2"'
| replace: '<h4', '<h4 class="column is-8 is-offset-2"'
| replace: '<h5', '<h5 class="column is-8 is-offset-2"'
| replace: '<h6', '<h6 class="column is-8 is-offset-2"'
| replace: '<ul', '<ul class="column is-8 is-offset-2" style=" padding-left: 3em;"'
| replace: '<bloquote p', '<blockquote p class=""'
}}
</div>
</div>
</div>
</section>
<section class="section is-normal has-background-light">
{% include post-nav-buttons.html %}
</section>
现在的问题是此解决方案
<p class="column is-8 is-offset-2"'> Some text </p>
<blockquote class="column is-8 is-offset-2"'>
<p class="column is-8 is-offset-2"'>
My quote text
</p>
</blockquote>
我不想将class="column is-8 is-offset-2"'
中的<p>
应用于<blockquote>
如果有人知道我可以使用该液体过滤器定位那些特定的p?
答案 0 :(得分:1)
如果缩进完全相同,则类似的事情可能会起作用:
{%- capture editable_part -%}
<blockquote class="column is-8 is-offset-2">
<p class="column is-8 is-offset-2">
{%- endcapture -%}
{%- capture new_part -%}
<blockquote class="column is-8 is-offset-2">
<p>
{%- endcapture -%}
{% if content contains '<blockquote class="column is-8 is-offset-2">' %}
{{ content | replace: editable_part,new_part }}
{% else %}
{{ content }}
{% endif %}