Skip to main content

sort_svg_attributes

Function sort_svg_attributes 

Source
fn sort_svg_attributes(html: &str) -> String
Expand description

把 <svg> / <path> 开标签的属性按名称排序。

katex-rs 用 HashMap 存 SVG 属性,同一公式两次渲染的属性顺序不同(实测同一 输入 10 次中 9 次不同)。顺序不影响显示,但会让「同一正文渲染结果逐字相同」的 前提失效——富文本往返守卫(posts::roundtrip)靠比较渲染 HTML 判断有损, 含根号 / 矩阵竖线等 SVG 的正文因此永远被误判为有损。KaTeX 产出的这两种标签的 属性值是不含 > 与 " 的双引号字符串,可以直接扫描。