commonmark / commonmark/cmark

Tracking backslash escapes?

Open
#450 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
2k
Forks
691
Avg merge
1d 16h
Merged PRs (30d)
1

Description

I think this is similar/related to #131 and #292, but one thing I noticed is that bare square brackets do not roundtrip:

Input:

[unescaped brackets],  \[escaped brackets\] and [a link](https://example.com)

Output:

\[unescaped brackets\],  \[escaped brackets\] and [a link](https://example.com)

Is there a way to add an attribute that can track the position of escaped characters in a line?

This is useful for me because I'm trying to parse and rewrite documents that have reference links in child documents, and I have to backtrack to identify and protect these links from being overwritten.

(originally reported this in https://github.com/r-lib/commonmark/issues/20)

Contributor guide

No contributing guide indexed for this repository

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

Start by reproducing the markdown example in the issue and inspect cmark's parsing and rendering paths for escaped characters and links. Determine whether the proposed attribute can preserve escape positions through parsing, then verify that bare and escaped brackets round-trip correctly without changing link handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, markdown
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.