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.

New line with `\` not respected

See original GitHub issue

Hey 👋 ,

I noticed an interesting situation with line breaks. Take this example:

RUN bash -lc "rvm install ruby-2.5.1 && \
              rvm use ruby-ruby-2.5.1 --default"

It renders as follows:

image

Adding a second \ to the code block as in this snippet renders as expected:

RUN bash -lc "rvm install ruby-2.5.1 && \\
              rvm use ruby-ruby-2.5.1 --default"

image

I couldn’t find a related issue. Has anyone seen that and has a potential fix?

🙏

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Cahllagerfeldcommented, Jul 4, 2022

Thought: Might this be caused by returning the code with the @html decorator from svelte?

I came up with a potential fix, by returning the highlighted code with a JSON.stringify.


import { defineMDSveXConfig as defineConfig, escapeSvelte } from "mdsvex";
import Prism from "prismjs";
import "prismjs/components/prism-bash.js";

const config = defineConfig({
  extensions: [".svelte.md", ".md", ".svx"],
  highlight: {
    highlighter: async (code, lang) => {
      const highlighted = escapeSvelte(
        Prism.highlight(code, Prism.languages["bash"], "bash")
      );
      return `<pre class="language-${lang}"><code class="language-${lang}">{@html ${JSON.stringify(
        highlighted
      )}}</code></pre>`;
    },
  },
  smartypants: {
    dashes: "oldschool",
  },

  remarkPlugins: [],
  rehypePlugins: [],
});

export default config;

Thats the sample repo for it

1reaction
mikeniklescommented, Apr 3, 2021

Thanks again for going way down the stack to help figure out what’s going on 🙏 . We are working towards a tight deadline to release the project. I’ll focus on launching the site next week, then come back to this issue with a link to the source code which will be open source.

The hint about Dockerfile vs dockerfile was great, thank you! The project is a migration from Gatsby (via Sapper) to Svelte Kit and the Gatsby code highlighter plugin seemed fine with a capital D in Dockerfile. All good on that front now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Line break in HTML with '\n' - Stack Overflow
This is to show new line and return carriage in HTML, then you don't need to do it explicitly. You can do it...
Read more >
Make A Block Of Text Respect A New Line - Today I Learned
The first rule, word-wrap: break-word , ensures that long lines of text uninterrupted by new lines respect the boundaries of our wrapping ...
Read more >
Multiline block quotes does not respect new lines - GitLab
When using markdown I've noticed that block quotes both normal and multiline do not behave well with newlines.
Read more >
Cat command does not respect new line - UNIX and Linux ...
The thread title is VERY misleading - cat WILL act correctly on newline chars! PLEASE make sure the thread title does reflect the...
Read more >
white-space - CSS-Tricks
Interestingly, the final line break is not honored. As per the CSS 2.1 spec: “Lines are broken at preserved newline characters, ...
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