【问题标题】:react-syntax-highlighter new line in Clojure code sampleClojure 代码示例中的 react-syntax-highlighter 新行
【发布时间】:2018-02-03 08:15:00
【问题描述】:

您好,我在任何地方都找不到有关如何在此代码示例中添加新行的信息:

<SyntaxHighlighter language='clojure' style={darcula} showLineNumbers={true} wrapLines={true}> 
  (def a 2) *add a new line break here* 
  (def b 3)
</SyntaxHighlighter>

使用:

从 'react-syntax-highlighter' 导入 SyntaxHighlighter; 从 'react-syntax-highlighter/styles/hljs' 导入 { darcula, docco };

谢谢

【问题讨论】:

    标签: javascript reactjs syntax-highlighting


    【解决方案1】:

    我发现的唯一解决方案就是这样做:

    <SyntaxHighlighter language='clojure' style={darcula} showLineNumbers={true} wrapLines={true}>
            {`first line \nsecond line`}
    </SyntaxHighlighter>
    

    你也可以将文本放入 const

    const code = `(def a 2) *add a new line break here*
    (def b 3)`;
    

    【讨论】:

      猜你喜欢
      • 2021-03-10
      • 1970-01-01
      • 2022-11-30
      • 2023-02-04
      • 1970-01-01
      • 2022-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多