prettier / prettier/prettier

Markdown: Escape tags break CSS identifiers for images (using Ruby jekyll)

Open
#8,897 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

lang:markdown
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/
---

![headshot](/assets/cv-headshot.jpg){:class="cv__headshot"}

# Hello

About me.


Output:

---
layout: page
title: C.V. (Résumé)
permalink: /cv/
---

![headshot](/assets/cv-headshot.jpg){: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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.