Giter Club home page Giter Club logo

Comments (14)

MACDfree avatar MACDfree commented on June 11, 2024 3

@olOwOlo 使用js只是替换掉em标签,但现在遇到如下问题:$$\left\{ { x }_{ 1 },{ x }_{ 2 },{ x }_{ 3 },...{ x }_{ n } \right\}$$ 其中\{被转义为{,导致公式解析出错,现在我的解决方式为自定义一个shortcode,如下:

{{ if len .Params | eq 1 }}{{ .Get 0 }}{{ end }}

md中公式替换为:

{{< pure "$$\left\{ { x }_{ 1 },{ x }_{ 2 },{ x }_{ 3 },...{ x }_{ n } \right\}$$" >}}

from hugo-theme-even.

MACDfree avatar MACDfree commented on June 11, 2024 1

此问题问题比较久远,有点记不清了。大致原因是转移导致公式出错,解决问题的目标就是如何防止被转义,我的做法是利用hugo里的 shortcode 功能,将公式通过shortcode输出,可以防止被转义。

做法上就是个性化even主题
image

使用
image

from hugo-theme-even.

zzrrxx avatar zzrrxx commented on June 11, 2024 1

这个问题困扰了我好久, 刚刚在 gohugo.org/doc/tutorials/mathjax/ 看到可以通过使用 <div> 将数学公式包起来结局,希望能帮助到同样有这个问题的人

from hugo-theme-even.

olOwOlo avatar olOwOlo commented on June 11, 2024

两个 _ 是 markdown 语法,用转义字符 \_ 试试

from hugo-theme-even.

huxiyu avatar huxiyu commented on June 11, 2024

vscode或有些网站的mathjax是不用\_转义的。不同环境下转换起来很崩溃。

看了下官网有多种解决方法:
https://gohugo.io/content-management/formats/#mmark

第一种我使用mmark,但会导致页面toc目录无法显示。

---
title: My Post
date: 2017-04-01
markup: mmark
---

另一种方法修改代码还没试...

from hugo-theme-even.

huxiyu avatar huxiyu commented on June 11, 2024

或者再增加个 KaTeX ,代替 MathJax
http://nosubstance.me/post/a-great-toolset-for-static-blogging/

from hugo-theme-even.

olOwOlo avatar olOwOlo commented on June 11, 2024

或者再增加个 KaTeX ,代替 MathJax

KaTeX 能识别 <em>{k}{G</em> 这样的 ❓


粗暴点直接替换也是可以的(笑)

document.querySelector('.post .post-content').innerHTML.match(/\$\$.*(<em>(.*)<\/em>).*\$\$/)

from hugo-theme-even.

olOwOlo avatar olOwOlo commented on June 11, 2024

可以试试在 mathjax 之前加入这段代码~

var postContainer = document.querySelector('.post .post-content');
postContainer.innerHTML = postContainer.innerHTML.replace(/\$\$.*(?:<em>.*<\/em>.*)+\$\$/g, function (match) {
  return match.replace(/<\/?em>/g, '_');
});

from hugo-theme-even.

huxiyu avatar huxiyu commented on June 11, 2024

@olOwOlo 这个替换的方式可以用

from hugo-theme-even.

hoasxyz avatar hoasxyz commented on June 11, 2024

我遇到了同样的问题,可是您的解释我有些看不懂,可以给些提示吗? @MACDfree

from hugo-theme-even.

hoasxyz avatar hoasxyz commented on June 11, 2024

@MACDfree 学到了,谢谢~

from hugo-theme-even.

scarletsky avatar scarletsky commented on June 11, 2024

升级 hugo 后,hugo 默认的 markdown 解析器换成了 goldmark,但这会导致用 <div> 包围的公式显示不了,要换回 blackfriday 才行:

[markup]
defaultMarkdownHandler = "blackfriday"

from hugo-theme-even.

yesiare-cn avatar yesiare-cn commented on June 11, 2024

katex

\_

所有的反斜杠都被转义了,导致katex解析错误,有办法解决么?

from hugo-theme-even.

stale avatar stale commented on June 11, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.

from hugo-theme-even.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.