Pelican 插件 render_math 在 markdown 中不起作用

问题描述 投票:0回答:1

我已经在 VirtualBox 中运行的 Ubuntu 服务器上安装了 Pelican 它工作得很好!但是当我尝试数学方程时,它根本没有渲染它。

我检查了 Pelican 版本:

$ pelican --version
4.9.1

目录结构:

webroot/
  pelicanconf.py
  content/
  output/
  ... etc ...
  plugins/
     ... plugins go here ...

pelicanconf.py:

PLUGIN_PATHS = ['plugins']
PLUGINS = ['render_math']

pelicanconf 中似乎没有任何额外的数学相关设置。

安装的插件:

git clone https://github.com/getpelican/pelican-plugins plugins
$ git log
commit 10a14332c35932b282b1ec63f0e10ae7d45aed8c (HEAD -> master, origin/master, origin/HEAD)
Merge: 50da7ed 252eb86
Author: Justin Mayer <[email protected]>
Date:   Fri Nov 10 18:46:05 2023 +0100

注意:当我启动运行 Pelican 的服务时,系统日志中没有警告或错误。

我使用的主题是“pelican-twitchy”,我对 CSS 做了一些小的更改。 它似乎没有任何额外的配置来实现 mathjax。

基于各种网站,我在我的 markdown 文件中尝试了这些:

$x^2$
$x + y$
$$ s(t) = \int_{-\infty}^{+\infty} {F(f) e^{j 2 \pi f t} } dt $$
\begin{equation} x^2 \end{equation}

它们呈现为纯字符串,根本没有 mathjax。

但后来我注意到 render_math 中的 Readme.md 说:

**注意:此插件已移至其自己的存储库。请 在那里提交任何问题/PR。将所有插件迁移到 新的 Pelican 插件 组织,这个整体 存储库将被存档。

自从我运行 Pelican 4.9.1 以来,我尝试过:

rm -rf plugins
mkdir -p plugins
git clone https://github.com/pelican-plugins/render-math.git plugins/render-math

更新了pelicanconf.py:

PLUGIN_PATHS = ['plugins']
PLUGINS = ['render-math']

当我通过服务重新启动 Pelican 时:

ERROR    Cannot register plugin `render-math`               log.py:94
         module 'render-math' has no attribute 'register'

接下来我应该尝试什么?

mathjax pelican
1个回答
0
投票

去了https://github.com/pelican-plugins/render-math/issues/20 它建议去:https://github.com/pelican-plugins/render-math#enabling-additional-features

该部分说:

MathJAX JavaScript 文件必须添加到 HTML 文件中,可以通过 您的主题的模板配置(如果支持)或通过编辑 直接相关模板文件。当前的 MathJAX CDN 托管于 http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML, 下面提供了将其添加到 HTML 的代码。

只要将此脚本加载到头部或主体中 HTML输出,复杂的表达式也被转换。

我将此行添加到base.html:

<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

这些行(双 $$ 分隔符)现在可以工作:

$$F[f] = 1/N \sum_{k=0,f=0}^{N-1} {s[k] * cos( -j k \theta f / N)  + j sin( -j k \theta f / N)}$$
$$F(f) = \int_{-\infty}^{+\infty} {s(t) e^{-j 2 \pi f t} } dt$$
$$ e^{j\theta} = cos(\theta) + j sin(\theta) $$
$$ s(t) = \int_{-\infty}^{+\infty} {F(f) e^{j 2 \pi f t} } dt $$

单条 $ 行仍然不起作用:

$x^2$
$x + y$
$x \implies y$
test $s(t) = \int_{-\infty}^{+\infty} {F(f) e^{j 2 \pi f t} } dt$ inline

这些不起作用,但符合预期:

<math>x^2</math>
<math>$x^2$</math>
© www.soinside.com 2019 - 2024. All rights reserved.