Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copying code blocks from markdown removes new lines on Firefox #1883

Closed
innocenzi opened this issue Feb 4, 2023 · 4 comments · Fixed by nuxt-modules/mdc#62
Closed

Copying code blocks from markdown removes new lines on Firefox #1883

innocenzi opened this issue Feb 4, 2023 · 4 comments · Fixed by nuxt-modules/mdc#62

Comments

@innocenzi
Copy link

Environment

Irrelevant

Reproduction

https://content.nuxtjs.org/get-started

Describe the bug

When writing code blocks in markdown, the generated HTML uses <span class="line"> elements to represent a line.

This would be perfectly fine if Firefox was taking display: block into account and was rendering new lines when copying, like Chrome or Safari, but it does not.

For instance, copying a multi-line code block from the docs from Firefox would copy that:

export default defineNuxtConfig({  modules: [    '@nuxt/content'  ],  content: {    // https://content.nuxtjs.org/api/configuration  }})

The expected result would be, of course, the original snippet:

export default defineNuxtConfig({
  modules: [
    '@nuxt/content'
  ],
  content: {
    // https://content.nuxtjs.org/api/configuration
  }
})

If there's a CSS work-around for adding new lines, this would be a potential fix. Otherwise, I suggest replacing the generated span with div, which behaves as expected.

Additional context

No response

Logs

No response

@nobkd
Copy link
Contributor

nobkd commented Feb 4, 2023

If you want to copy the whole block, you can use the copy button in the corner. That preserves the newlines.

But you're right, that this should be fixed somehow.

@nobkd
Copy link
Contributor

nobkd commented Feb 4, 2023

Line breaks are only removed (in Firefox), when a code block is highlighted

@innocenzi
Copy link
Author

innocenzi commented Feb 5, 2023

Is the copy button a Docus thing? I don't have it in my own app.

EDIT: looks like it's a nuxt-themes/typography thing.

@farnabaz
Copy link
Member

farnabaz commented Mar 8, 2023

Released in v2.5.0 thanks to @nobkd 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants