Skip to content

Don't remove stars from alt attribute of an image #44

Closed
@talatkuyuk

Description

@talatkuyuk

Initial checklist

Affected package

mdast-util-from-markdown

Steps to reproduce

const input = '![*text*](image.png "*title*")';

console.dir(fromMarkdown(input), {depth: null});

Actual behavior

It removes the stars from "alt", keeps stars in "title"

{
  "alt": "text",
  "title": "*title*",
  "type": "image",
  "url": "image.png",
},

Expected behavior

It should keep stars in "alt" as well.

{
  "alt": "*text*",
  "title": "*title*",
  "type": "image",
  "url": "image.png",
},

But, I see that commonmark specs also removes stars from "alt". I couldn't get the rationale of removing stars from "alt", whileas doesn't remove stars from "title". It would be better to keep stars in "alt", so I would use it as a directive for images for transformation in a plugin.

I know, you will close the issue pointing commonmark specs. I just wanted to know the rationale in commonmark specs?

(why I opened this issue is because the next question will be why curly braces are also removed from "alt" attribute of an image when remark-mdx parse it; at least I would expect curly braces are kept in "alt" when remark-mdx parse it since commonmark specs also keeps the curly braces in alt attribute. This issue is critic for me because of this discussion)

Runtime

node@latest

Package manager

npm@latest

Operating system

macos@latest

Build and bundle tools

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    👎 phase/noPost cannot or will not be acted on🙋 no/questionThis does not need any changes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions