katex生成的上标未正确显示。样式虽然在数据库中正确保存,但未在显示页面中显示,但在编辑操作中正确显示。在简单函数3 ^ 5中,显示页面中的5不是'上标'
db中保存的内容:
<p><span class=\"ql-formula\" data-value=\"3^5\" contenteditable=\"false\"><span class=\"katex\"><span class=\"katex-mathml\"><math><semantics><mrow><msup><mn>3</mn><mn>5</mn></msup></mrow><annotation encoding=\"application/x-tex\">3^5</annotation></semantics></math></span><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"strut\" style=\"height: 0.814108em;\"></span><span class=\"strut bottom\" style=\"height: 0.814108em; vertical-align: 0em;\"></span><span class=\"base textstyle uncramped\"><span class=\"mord\"><span class=\"mord mathrm\">3</span><span class=\"msupsub\"><span class=\"vlist\"><span class=\"\" style=\"top: -0.363em; margin-right: 0.05em;\"><span class=\"fontsize-ensurer reset-size5 size5\"><span class=\"\" style=\"font-size: 0em;\"></span></span><span class=\"reset-textstyle scriptstyle uncramped mtight\"><span class=\"mord mathrm mtight\">5</span></span></span><span class=\"baseline-fix\"><span class=\"fontsize-ensurer reset-size5 size5\"><span class=\"\" style=\"font-size: 0em;\"></span></span></span></span></span></span></span></span></span></span></p>"
编辑页面中显示的内容
<span class="ql-formula" data-value="3^5" contenteditable="false"><span class="katex"><span class="katex-mathml"><math><semantics><mrow><msup><mn>3</mn><mn>5</mn></msup></mrow><annotation encoding="application/x-tex">3^5</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height: 0.814108em;"></span><span class="strut bottom" style="height: 0.814108em; vertical-align: 0em;"></span><span class="base textstyle uncramped"><span class="mord"><span class="mord mathrm">3</span><span class="msupsub"><span class="vlist"><span class="" style="top: -0.363em; margin-right: 0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span class="" style="font-size: 0em;">​</span></span><span class="reset-textstyle scriptstyle uncramped mtight"><span class="mord mathrm mtight">5</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span class="" style="font-size: 0em;">​</span></span>​</span></span></span></span></span></span></span></span>
显示页面中显示的内容
<span class="ql-formula" data-value="3^5" contenteditable="false"><span class="katex"><span class="katex-mathml"><math><semantics><mrow><msup><mn>3</mn><mn>5</mn></msup></mrow><annotation encoding="application/x-tex">3^5</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height: 0.814108em;"></span><span class="strut bottom" style="height: 0.814108em; vertical-align: 0em;"></span><span class="base textstyle uncramped"><span class="mord"><span class="mord mathrm">3</span><span class="msupsub"><span class="vlist"><span class="" style=""><span class="fontsize-ensurer reset-size5 size5"><span class="" style="font-size: 0em;">​</span></span><span class="reset-textstyle scriptstyle uncramped mtight"><span class="mord mathrm mtight">5</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span class="" style="font-size: 0em;">​</span></span>​</span></span></span></span></span></span></span></span>
唯一的区别似乎是style="top: -0.363em; margin-right: 0.05em
,它没有出现在展示页面中。
我尝试将top和margin权限添加为允许属性,但它没有帮助。
我的编辑动作的santizing功能:
<%= raw sanitize @post.description, tags: %w(strong em span div a p br ul ol li math semantics mi mo mrow msup mn), attributes: %w(href class style data-value contenteditable) %>
我对show动作的santizing功能:
<%= raw sanitize @post.description, tags: %w(strong em span div a p br ul ol li math semantics mi mo mrow msup annotation mn), attributes: %w(href class style data-value contenteditable encoding aria-hidden top margin-right ) %>