question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TOML lang line breaks on section

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
gomorizsoltcommented, Mar 15, 2021

Thanks @RunDevelopment for the guess. Indeed, there were additional styles applied to redirect. In my case, Tailwind CSS was the culprit because when you use the @tailwind utilities directive it injects a .table class whose display property is set to table (hence the line breaks because table is a block-level element).

In order to get around this “style glitch”, I simply overrode the display property with initial:

@layer utilities {
  .table {
    display: initial;
  }
}
0reactions
RunDevelopmentcommented, Mar 14, 2021

Looking at the issue again, my best guess is that display: block got applied to redirects. The HTML of redirects is <span class="token table class-name">redirects</span> and you probably have a .table rule (or similar) in your stylesheets.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Proposal: Allow newlines and trailing commas in inline tables ...
Most new comers to TOML will be familiar with a table/object being defined this way and it'd click, until they realize it breaks...
Read more >
Entering a two-line value for a configuraton key in config.toml
I am simply changing values in the config.toml file for the Icarus theme in Hugo. This file is part of the hugo-icarus-theme and...
Read more >
TOML: Tom's Obvious Minimal Language
(a single sentence with no line breaks). Literal strings are surrounded by single quotes. No escaping is performed so what you see is...
Read more >
Create new line on TOML file - Stack Overflow
I am trying to understand the TOML structure and
Read more >
Learn toml in Y Minutes
TOML should be easy to parse into data structures in a wide variety of languages. ... The first newline is trimmed in raw...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found