Markdown: Escape tags break CSS identifiers for images (using Ruby jekyll)
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 52.3k
- Forks
- 5k
- Avg merge
- 19h 2m
- Merged PRs (30d)
- 117
Description
Prettier 2.0.5
Playground link
--parser markdown
Input:
---
layout: page
title: C.V. (Résumé)
permalink: /cv/
---
{:class="cv__headshot"}
# Hello
About me.
Output:
---
layout: page
title: C.V. (Résumé)
permalink: /cv/
---
{:class="cv\_\_headshot"}
# Hello
About me.
Expected behavior:
Naively, I would expect this CSS class inside a string literal to be left alone by prettier. Instead, the underscores are escaped and this broke the CSS on my page as the class had the slashes inside them, e.g.
<img src="/assets/cv-headshot.jpg" alt="headshot" class="cv\_\_headshot">
I'm using jekyll 3.8.5.
Notes
There was a long discussion on bug #6213 which seems related but there was no conclusion, other than locking the thread so I'm not even sure a PR for this issue is desired.
My takeaway from the comments there was that the currently behavior is strictly correct based on the Markdown standard but breaks how it was actually used in practice by a large ecosystem of tools. As a user, it definitely is surprisingly that seemingly unnecessary escaping is added to a file.
Thanks for any info and help you can provide.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the Markdown case in the linked Prettier Playground with the markdown parser, then read the discussion in bug #6213 for the unresolved standards and ecosystem tradeoff. Done means the Jekyll image class no longer gains unwanted backslashes while existing Markdown escaping behavior remains covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, jekyll, markdown
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100