gatsby - gatsby-plugin-mdx 上标和下标支持
问题描述
我在获取一些 HTML 元素时遇到了麻烦<sup>
,<sub>
例如gatsby-plugin-mdx
.
我在 gatsby-plugin-mdx 文档中找到了以下代码。您可以像这样将本机备注插件添加到 gatsby-plugin-mdx:
https://www.gatsbyjs.org/packages/gatsby-plugin-mdx/#md-plugins
module.exports = {
plugins: [
{
resolve: `gatsby-plugin-mdx`,
options: {
remarkPlugins: [require("remark-abbr")],
},
},
],
}
沿着这些思路,我添加remark-sub-super
到我的项目中并将其放入我的 gatsby-config 中,如下所示:
const remarkSubSuper = require('remark-sub-super');
module.exports = {
plugins: [
{
resolve: `gatsby-plugin-mdx`,
options: {
extensions: [`.mdx`, `.md`],
remarkPlugins: [remarkSubSuper],
},
],
}
尽管如此,我仍然看到一些看起来<sup>
与<sub>
标签有关的错误。
"gatsby-plugin-mdx" threw an error while running the onCreateNode lifecycle:
unknown: Unterminated JSX contents (17:16)
15 | <em><sup>1 </sup>https://example.com/</em>
16 | <em><sup>2 </sup>https://example.com/</em>
> 17 | </MDXLayout>
| ^
18 | )
19 | };
20 | MDXContent.isMDXComponent = true/<PATH>: unknown: Unterminated JSX contents (17:16)
15 | <em><sup>1 </sup>https://example.com/</em>
16 | <em><sup>2 </sup>https://example.com/</em>
> 17 | </MDXLayout>
| ^
18 | )
19 | };
20 | MDXContent.isMDXComponent = true
一些版本信息:
"gatsby": "^2.19.18",
"gatsby-plugin-mdx": "^1.0.73",
"remark-sub-super": "^1.0.19",
有谁知道我在这里做错了什么?
解决方案
问题确实是提供给gatsby-plugin-mdx
.
显然<img />
标签需要关闭。关闭图像标签后,我需要进入引发错误的降价文件并手动检查 HTML。由于此内容来自 WordPress,因此某些格式有点问题。例如,这个:
<blockquote>How
you
doin</blockquote>
运行 Markdown 处理器后会变成这样:
<blockquote>How
<p>you</p>
<p>doin</blockquote></p>
推荐阅读
- wordpress - Woocommerce 订单数据未显示,例如送货地址
- html - 调整 html 页面长度
- go - 如何使用 API 平滑光栅化 PDF?
- javascript - 如何在移动设备上发送推送通知(Android Crome)PWA
- spring - 没有找到能够从 [java.lang.String] 类型转换为 [java.util.LinkedHashMap] 类型的转换器
] - laravel - 使用哪种授权类型来验证第三方客户端的 API 访问权限?
- magento - 单个商店的 Magento 多个动态自定义路由
- c# - 没有 BlockingCollection 的简单生产者-消费者集合
- maven - 交互模式下的 Maven 配置文件激活
- php - 为什么 Symfony 3.4 在 PHP 通知中抛出 ContextErrorException 而 Symfony 2.8 在相同的代码上运行良好?