rojer95 / katex-mini Goto Github PK
View Code? Open in Web Editor NEW在微信小程序上渲染Latex公式(不依赖服务端渲染,使用KaTeX)
在微信小程序上渲染Latex公式(不依赖服务端渲染,使用KaTeX)
小程序集成了该库, 转换效果挺好的 , 但是现在遇到一个问题.
index.wxml
... ...
index.wxss ->
...
.latex-container {
word-break:break-all;
width: 100%;
height: 100%;
padding: 6px;
color: #323232;
font-size: 12px;
}
...
index.js ->
import parse from '@rojer/katex-mini'
Page{
data: {
nodes: [],
latex:9. 用简便方法计算下面各题. 3.8 \\times 1.45+0.38 \\times 4.2+0.038 \\times 13" \\frac{1}{2}+\\frac{1}{4}+\\frac{1}{8}+\\ldots \\ldots+\\frac{1}{128}
,
},onShow() {
this.renderLatex()
},renderLatex: function () {
var content = this.data.latex;
console.log(content)
if (content.includes('\(') && content.includes('\)')) {
content = content.replace(/\(/g, '').replace(/\)/g, '');
}if (content.includes('\\[') && content.includes('\\]')) { content = content.replace(/\\\[/g, '').replace(/\\\]/g, ''); } if (content.includes('\\\\')) { content = content.replace(/\\\\/g, '').replace(/\n/g, ''); } ...
}
}
请问大佬有解决方法吗?
非常感谢 !
富文本中含有latex,也有上传的图片,怎样保证解析出来的内容都正常显示
前端使用了colorui的界面。 目前渲染是正常的。 但是wxml调试器里看不到选然后的richtext,放到view里,view就不见了。如何控制样式? 比如text-align:center
\begin{matrix}` 0 & 1 \\ 1 & 0 \end{matrix}\quad
\begin{pmatrix} 0 & -i \\ i & 0 \end{pmatrix}\\
\begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix}\quad
\begin{Bmatrix} 1 & 0 \\ 0 & -1 \end{Bmatrix}\\
\begin{vmatrix} a & b \\ c & d \end{vmatrix}\quad
\begin{Vmatrix} i & 0 \\ 0 & -i \end{Vmatrix}
在此版本前的版本能正常渲染,该版本渲染结果缺失了以下节点:
这个问题似乎是src/index.ts的153行if (!type) return null;
导致的,丢失的节点似乎不是"text" | "span" | "svg" | "anchor" | "line" | "path"其中任何一种类型,且删去153行后渲染正常。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.