syntax-tree/mdast

Whitespace in URL in link

yueqing-wolai opened this issue · 5 comments

The link is parsed into to textNode, when link contains Chinese and followed by space.

Expected behavior

The ast generated by http://textlint.github.io/markdown-to-ast/.

{
    "type": "Document",
    "children": [
        {
            "type": "Paragraph",
            "children": [
                {
                    "type": "Link",
                    "title": null,
                    "url": "测试 108dd9de283145b6b2990c3d1f767ce2/子页面 fe18a4304c854cb39ae3fe5c8b1019a6.md",
                    "children": [
                        {
                            "type": "Str",
                            "value": "子页面",
                            "loc": {
                                "start": {
                                    "line": 1,
                                    "column": 1
                                },
                                "end": {
                                    "line": 1,
                                    "column": 4
                                }
                            },
                            "range": [
                                1,
                                4
                            ],
                            "raw": "子页面"
                        }
                    ],

Actual behavior

Remark convert the link to a textNode in ast tree.

Remark Ast

                            {
                                "type": "paragraph",
                                "children": [
                                    {
                                        "type": "text",
                                        "value": "[子页面](测试 108dd9de283145b6b2990c3d1f767ce2/子页面 fe18a4304c854cb39ae3fe5c8b1019a6.md)",
                                        "position": {
                                            "start": {
                                                "line": 12,
                                                "column": 5,
                                                "offset": 57
                                            },
                                            "end": {
                                                "line": 12,
                                                "column": 87,
                                                "offset": 139
                                            }
                                        }
                                    }
                                ],

Hi! It seems some of the things asked in the template are missing? Please edit your post to fill out everything.

  • Initial checklist (missing)
  • Steps to reproduce (missing)
  • Expected behavior
  • Actual behavior

You won’t get any more notifications from me, but I’ll keep on updating this comment, and remove it when done!

If you need it, here’s the original template
<!--
  Please check the needed checkboxes ([ ] -> [x]) and fill out the TODOs.
  Leave the comments as they are: they won’t show on GitHub.

  Some general tips:
  - Is this really a problem?
  - Is this a problem here?
  - Can this be solved in a different way?
-->

### Initial checklist

*   [ ] I read the support docs <!-- https://github.com/syntax-tree/.github/blob/main/support.md -->
*   [ ] I read the contributing guide <!-- https://github.com/syntax-tree/.github/blob/main/contributing.md -->
*   [ ] I agree to follow the code of conduct <!-- https://github.com/syntax-tree/.github/blob/main/code-of-conduct.md -->
*   [ ] I searched issues and couldn’t find anything (or linked relevant results below) <!-- https://github.com/search?q=user%3Asyntax-tree&type=Issues -->

<!--
  Please test using the latest version of the relevant packages to make sure
  your issue has not already been fixed. Also make sure you’re on recent versions
  of Node and npm.
-->

Affected packages and versions: TODO

### Steps to reproduce

<!--
  How did this happen?
  Please provide a minimal, reproducible example:
  https://stackoverflow.com/help/minimal-reproducible-example
  Issues without reproduction steps or code examples may be immediately closed
  as not actionable.

  Here are some starters on codesandbox:
  - remark only (for markdown to markdown): https://codesandbox.io/s/remark-debug-ikwvx
  - remark and rehype (for markdown to html): https://codesandbox.io/s/remark-rehype-debug-4cz8v
  - react-markdown: https://codesandbox.io/s/react-markdown-debug-9n4eg

  Either link to runnable code (not your whole repo) or post the code inline.
-->

1.  TODO
2.  TODO

Link to code example: TODO

### Expected behavior

<!--What should happen?-->

TODO

### Actual behavior

<!--What happens instead?-->

TODO

<!--do not edit: bug-->

Thanks,
— bb

Markdown only allows spaces in a URL if it is enclosed with pointy brackets https://spec.commonmark.org/0.29/#example-484

[子页面](<测试 108dd9de283145b6b2990c3d1f767ce2/子页面 fe18a4304c854cb39ae3fe5c8b1019a6.md>)

will parse as expected https://astexplorer.net/#/gist/c955051977a03daf49cf297ac1733dbf/b34b71078897c30780c702acc09912f281989f1a

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

Hi team! I don’t know what’s up as there’s no phase label. Please add one so I know where it’s at.

Thanks,
— bb

Hi! Thanks for reaching out! Because we treat issues as our backlog, we close issues that are questions since they don’t represent a task to be completed.

See our support docs for how and where to ask questions.

Thanks,
— bb