syntax-tree / mdast-util-to-markdown

mdast utility to serialize markdown
http://unifiedjs.com
MIT License
100 stars 20 forks source link

The image link has an extra \ added during the conversion process #64

Closed hyoban closed 3 weeks ago

hyoban commented 3 weeks ago

Initial checklist

Affected packages and versions

2.1.2

Link to runnable example

https://codesandbox.io/p/sandbox/remark-debug-formatted-autolink-simple-forked-mhn96l

Steps to reproduce

const sourceMarkdown =
  "![](https://image-proxy.zslren.com/img-proxy/?k=3507a87d&u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2Ftc9Zic7wWc9BZCDeUpBKjNhykdf3v3OKrGjF1mYlX8BEm3zCWWkhMH4S362huEz93Dz9qqIhJHmH4aLqiaOQa2jQ%2F0%3Fwx_fmt%3Djpeg)";

const mdast = remark().parse(sourceMarkdown);
const contents = toMarkdown(mdast);

Expected behavior

The image link should be

https://image-proxy.zslren.com/img-proxy/?k=3507a87d&u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2Ftc9Zic7wWc9BZCDeUpBKjNhykdf3v3OKrGjF1mYlX8BEm3zCWWkhMH4S362huEz93Dz9qqIhJHmH4aLqiaOQa2jQ%2F0%3Fwx_fmt%3Djpeg

Actual behavior

The image link is

https://image-proxy.zslren.com/img-proxy/?k=3507a87d\&u=https%3A%2F%2Fmmbiz.qpic.cn%2Fmmbiz_jpg%2Ftc9Zic7wWc9BZCDeUpBKjNhykdf3v3OKrGjF1mYlX8BEm3zCWWkhMH4S362huEz93Dz9qqIhJHmH4aLqiaOQa2jQ%2F0%3Fwx_fmt%3Djpeg

An extra \ appears before &u=, causing the image to not be displayed correctly.

Affected runtime and version

node@22.11.0

Affected package manager and version

No response

Affected OS and version

No response

Build and bundle tools

No response

wooorm commented 3 weeks ago

causing the image to not be displayed correctly.

If that happens, that is a bug in the tools you are using. You can raise problems with the tools you are using to preview/render markdown, with those tools themselves.

In markdown, that slash is allowed there. In markdown, it’s good to have that slash there.

github-actions[bot] commented 3 weeks ago

Hi! This was closed. Team: If this was fixed, please add phase/solved. Otherwise, please add one of the no/* labels.