Line Numbers

How to enable line numbers in code blocks using Sugar-High.

Sugar-HighReactMarkdownMDX

Preview

Preparing...

Usage

Component

Add the lineNumbers prop to the CodeBlockSugarHigh component:

Code Block with Line Numbers
<CodeBlockSugarHigh lineNumbers={true} code={code} />

Markdown/MDX

Add sh-line-numbers class to the PreSugarHighComponent:

.tsx
<CodeBlockContent>
  <pre className="sh-line-numbers">
    <code dangerouslySetInnerHTML={{ __html: codeHTML }} />
  </pre>
</CodeBlockContent>