react-syntax-highlighter new line in Clojure code sample

时间:2018-02-03 08:15:01

标签: javascript reactjs syntax-highlighting

Hi I cannot find anywhere on how to add new lines into this code sample:

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

Using:

import SyntaxHighlighter from 'react-syntax-highlighter'; import { darcula, docco } from 'react-syntax-highlighter/styles/hljs';

Thanks

1 个答案:

答案 0 :(得分:1)

The only solution that I've found is to do it this way:

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

Also you can put text into the const

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