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

Bug: Whitespace not respected as single space between elements #16

Closed
NfNitLoop opened this issue Jul 8, 2021 · 1 comment
Closed

Comments

@NfNitLoop
Copy link

NfNitLoop commented Jul 8, 2021

import * as nhm from "https://cdn.skypack.dev/[email protected]"

const service = new nhm.NodeHtmlMarkdown({})
function example(html: string) {
    console.log("input:")
    console.log(html)
    console.log("output:")
    console.log(service.translate(html))
}

// The space between these two links disappears:
example(`
    <a href="http://www.google.com">Link One</a> <a href="https://www.wikipedia.org/">Link Two</a>
`)

Output:

input:

    <a href="http://www.google.com">Link One</a> <a href="https://www.wikipedia.org/">Link Two</a>

output:
[Link One](http://www.google.com)[Link Two](https://www.wikipedia.org/)

Maintainer's Note

This issue is due to the fact that trailing whitespace should be treated as a space between any element.

Therefore, this has a broader range of impact that a tags. Example: <span>test</span> <span>test2</span> improperly renders as testtest2

Our upstream parser does not add nodes or range information in order to get the whitespace. I am submitting a PR to fix this.

@nonara nonara added bug Something isn't working awaiting-upstream-fix and removed bug Something isn't working labels Jul 11, 2021
@nonara
Copy link
Collaborator

nonara commented Jul 11, 2021

Thanks for the report! Looks like this is another upstream issue with the parser. I'm filing an issue, and I'll look into a PR

@nonara nonara added bug Something isn't working and removed awaiting-upstream-fix labels Jul 11, 2021
@nonara nonara changed the title Bug: Spaces are dropped between links. Bug: Whitespace not respected as single space between elements Jul 11, 2021
@nonara nonara removed the bug Something isn't working label Jul 12, 2021
@nonara nonara closed this as completed in a7abf81 Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants