Skip to content

Striping <br> joins newlines in markdown output #83

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

Closed
4 tasks done
carloslenz opened this issue Jan 27, 2025 · 4 comments
Closed
4 tasks done

Striping <br> joins newlines in markdown output #83

carloslenz opened this issue Jan 27, 2025 · 4 comments
Labels
💪 phase/solved Post is done

Comments

@carloslenz
Copy link

carloslenz commented Jan 27, 2025

Initial checklist

Affected package

[email protected]

Steps to reproduce

import rehypeParse from "rehype-parse";
import rehypeRemark from "rehype-remark";
import remarkStringify from "remark-stringify";
import { unified } from "unified";

const processor = unified()
  .use(rehypeParse)
  .use(rehypeRemark)
  .use(remarkStringify, {
    fences: true,
  });

const main = async () => {
  const vfile = await processor.process(`<p>A<span><br /><span>B</p>`);
  console.log("RESULT", vfile.value);
};

main().catch(console.error);

Actual behavior

RESULT AB

Expected behavior

RESULT A\
B

Runtime

No response

Package manager

No response

Operating system

No response

Build and bundle tools

No response

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Jan 27, 2025
@carloslenz
Copy link
Author

carloslenz commented Jan 27, 2025

I believe #66 introduced this.

Basically a <br> might not be directly under <p> but under <span> and under such conditions removing it breaks the output.

I found this while processing clipboard data that came from MS Word.

@wooorm wooorm closed this as completed in d6cab31 Jan 28, 2025
@wooorm wooorm added the 💪 phase/solved Post is done label Jan 28, 2025
@github-actions github-actions bot removed the 🤞 phase/open Post is being triaged manually label Jan 28, 2025
@wooorm
Copy link
Member

wooorm commented Jan 28, 2025

Thanks!

Note: your input HTML does not close its spans. That is likely not what you mean.
I also recommend not using superfluous things such as the / on the br — it seems like it does things but it does not

@wooorm
Copy link
Member

wooorm commented Jan 28, 2025

released in 10.1.2!

@carloslenz
Copy link
Author

Thanks!

Note: your input HTML does not close its spans. That is likely not what you mean. I also recommend not using superfluous things such as the / on the br — it seems like it does things but it does not

You're right, sorry I was a bit too quick with the sample.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 phase/solved Post is done
Development

No branches or pull requests

2 participants