Skip to content

TOML lang line breaks on section #2443

@MatteoGauthier

Description

@MatteoGauthier

Information

  • Language: TOML
  • Plugins: none

Description
Prism create punctuation element for [[section]] in toml

Code snippet

App.js

import React from "react";
import Prism from "prismjs";
import "prismjs/components/prism-toml";

const App = () => {
  return (
    <PrismCode language="toml">
      {`[[redirects]]
  from = ""
  to = ""
  status = 301`.trim()}
    </PrismCode>
  );
};
export default class PrismCode extends React.Component {
  constructor(props) {
    super(props)
    this.ref = React.createRef()
  }
  componentDidMount() {
    this.highlight()
  }
  componentDidUpdate() {
    this.highlight()
  }
  highlight = () => {
    if (this.ref && this.ref.current) {
      Prism.highlightElement(this.ref.current)
    }
  }
  render() {
    const { children, plugins, language } = this.props
    console.log(children);
    
    return (
      <pre className={!plugins ? "" : plugins.join(" ")}>
        <code ref={this.ref} className={`language-${language}`}>
          {children}
        </code>
      </pre>
    )
  }
}

it render :
image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions