棱镜代码渲染和JSX Markdown在静态HTML页面上不起作用

发布于 2025-02-06 16:14:48 字数 614 浏览 3 评论 0原文

我一直在尝试在静态HTML页面上实施棱镜,以显示基本技能投资组合网站的代码块。我已经将Prism进口到脚本标签和CSS链接标签中的页面上的相关位置。我还完成了所需的

<pre>
    <code class="language-jsx">  
     
    </code>
  </pre>

浏览器,我得到了呈现的代码块的米色背景,并且JS被高光照射,因为Prism应该这样做。

但是,浏览器将将代码返回的JSX Markdown作为HTML。我已经看到了Prism网站的一部分,该网站讨论了HTML的渲染,并且我确实认为JSX实际上是HTML Markup,但我认为Prism是解决这个问题的一种方式。

const SomeReactComponent = (props) => {
             return(
                <ThisWontRender />
             )
           }

我要避免的是必须与&amp; lt;

我错过了什么吗?

I have been trying to implement prism on a static HTML page to show code blocks for a basic skills portfolio site. I have imported Prism into the relevant places on the page in a script tag and in a CSS link tag. I also did the required

<pre>
    <code class="language-jsx">  
     
    </code>
  </pre>

In the browser I'm getting the beige background of the code block rendered and the js is being high-lighted as Prism is supposed to do.

However the jsx markdown that is to be returned by the code is being taken as HTML by the browser. I have seen the part of the Prism website that discusses the rendering of HTML and I do get that jsx is in reality HTML markup but I would have thought that Prism is a way round this issue.

const SomeReactComponent = (props) => {
             return(
                <ThisWontRender />
             )
           }

What I'm trying to avoid is having to escape the HTML with & lt;

Have I missed something?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文