阅读这些文档,我遵循了所有的步骤。这里有我的docusaurus.config.js文件。
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion
const lightCodeTheme = require('prism-react-renderer/themes/github');
const darkCodeTheme = require('prism-react-renderer/themes/dracula');
const math = require('remark-math');
const katex = require('rehype-katex');
/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'My Site',
tagline: 'Dinosaurs are cool',
url: 'https://your-docusaurus-test-site.com',
baseUrl: '/',
onBrokenLinks: 'throw',
onBrokenMarkdownLinks: 'warn',
favicon: 'img/favicon.ico',
organizationName: 'facebook', // Usually your GitHub org/user name.
projectName: 'docusaurus', // Usually your repo name.
presets: [
['@docusaurus/preset-classic',
{
docs: {
sidebarPath: require.resolve('./sidebars.js'),
remarkPlugins: [math],
rehypePlugins: [katex],
showLastUpdateTime: true
},
blog: false,
theme: {
customCss: require.resolve('./src/css/custom.css'),
},
},
],
],
stylesheets: [
{
href: 'https://cdn.jsdelivr.net/npm/katex@0.13.24/dist/katex.min.css',
type: 'text/css',
integrity:
'sha384-odtC+0UGzzFL/6PNoE8rX/SPcQDXBJ+uRepguP4QkPCm2LBxH3FA3y+fKSiJ+AmM',
crossorigin: 'anonymous',
},
],
themeConfig:
{
navbar: {
title: 'My Site',
logo: {
alt: 'My Site Logo',
src: 'img/logo.svg',
},
items: [
{
type: 'doc',
docId: 'intro',
position: 'left',
label: 'Tutorial',
},
{to: '/blog', label: 'Blog', position: 'left'},
{
href: 'https://github.com/facebook/docusaurus',
label: 'GitHub',
position: 'right',
},
],
},
footer: {
style: 'dark',
links: [
{
title: 'Docs',
items: [
{
label: 'Tutorial',
to: '/docs/intro',
},
],
},
{
title: 'Community',
items: [
{
label: 'Stack Overflow',
href: 'https://stackoverflow.com/questions/tagged/docusaurus',
},
{
label: 'Discord',
href: 'https://discordapp.com/invite/docusaurus',
},
{
label: 'Twitter',
href: 'https://twitter.com/docusaurus',
},
],
},
{
title: 'More',
items: [
{
label: 'Blog',
to: '/blog',
},
{
label: 'GitHub',
href: 'https://github.com/facebook/docusaurus',
},
],
},
],
copyright: `Copyright © ${new Date().getFullYear()} My Project, Inc. Built with Docusaurus.`,
},
prism: {
theme: lightCodeTheme,
darkTheme: darkCodeTheme,
},
},
};
module.exports = config;我已经安装了remark-math和rehype-katex,但是没有编译代码。这是我的index.md文件
## HEllo
Let $f\colon[a,b]\to\R$ be Riemann integrable. Let $F\colon[a,b]\to\R$ be
$F(x)=\int_{a}^{x} f(t)\,dt$. Then $F$ is continuous, and at all $x$ such that
$f$ is continuous at $x$, $F$ is differentiable at $x$ with $F'(x)=f(x)$.
$$
I = \int_0^{2\pi} \sin(x)\,dx
$$为了获得更多信息,我在本地主机上运行服务器,并试图检查那里的元素。我发现样式表的加载是正确的,但是由于remark-math插件提供了$符号,所以没有正确地呈现。
在检查HTML中的数学时,我发现它呈现为
<p>$$
I = \int_0^{2\pi} \sin(x)\,dx
$$</p>我在整个过程中遗漏了什么?
发布于 2022-07-08 00:04:49
如果您在遵循正式文档时遇到这样的编译错误。
ValidationError:"remarkPlugins1“看起来不像一个有效的MDX插件配置。插件配置条目应该是以下内容之一:
[require("rehype-katex"), { strict: false }],或require("remark-math")您可以这样更改配置。
remarkPlugins: [math,{strict:false}]另一点是不要把你的方程放在代码块中。
解决方案参考:链接
https://stackoverflow.com/questions/71964599
复制相似问题