microsoft / vscode-markdown-tm-grammar

VS Code built-in markdown extension's Textmate grammar
MIT License
64 stars 50 forks source link

Inconsistent syntax highlighting for markdown footnotes #87

Open d0rf3n opened 3 years ago

d0rf3n commented 3 years ago

The following:

[^1]: [link](yoyoyo.test)
[^2]: [a link](yoyoyo.test)
[^3]: testNoSpace
[^4]: test with space

Highlights as: image

As long as there is no spaces anytwhere in the footnote definition, the [^#] is scoped as a "constant". As soon as a space is added it scopes as "string.other.link.title.markdown". As can be seen this also affects the highlighting of the rest of the line.

Purple is: markup.underline.link.markdown Red is: string.other.link White is: No theme selector Orange is: constant (constant.other.reference.link.markdown) Blue is: string.other.link.title.markdown

Expected to keep highlighting the same regardless of footnote content.

gledos commented 8 months ago

I've encountered this issue as well. Due to the extensive use of footnotes in the Markdown documents I write, the visual appearance becomes quite messy.

If footnotes could be recognized correctly, perhaps I could customize their color using the following approach to darken the color, focus more on writing.

"editor.tokenColorCustomizations": {
  "[YOUR COLOR SCHEME]": {
     "textMateRules": [
      {
        "scope": "markup.heading.markdown",
        "settings": {
          "foreground": "#729098",
        }
      }
    ]
  }
}

This method is derived from AnsonH.

gledos commented 5 months ago

Below is an example with a moderate number of footnotes and reference links. (from wikipedia SIL Open Font License)

The **SIL Open Font License** (or **OFL** in short) is one of the major open font licenses,
which allows embedding, or "bundling",[^4] of the font in commercially sold products.[^5]

[^4]: Spalinger, Nicolas; Gaultney, Victor (November 27, 2023). ["Question: 1.15 What about distributing fonts with a document? Within a compressed folder structure? Is it distribution, bundling or embedding?"](https://openfontlicense.org/ofl-faq/). _OFL-FAQ web version (1.1-update7)_. [SIL International](https://en.wikipedia.org/wiki/SIL_International "SIL International").

[^5]: Garish, Matt; Gylling, Markus (2013). [_Epub 3 Best Practices_](<http://www.uvm.edu/~choman/ebooks/EPUB 3 Best Practices.pdf>) (PDF). [O’Reilly Media, Inc.](https://en.wikipedia.org/wiki/O’Reilly_Media,_Inc. "O’Reilly Media, Inc.") p. 139. [ISBN](https://en.wikipedia.org/wiki/ISBN_(identifier) "ISBN (identifier)") [978-1-449-32914-3](https://en.wikipedia.org/wiki/Special:BookSources/978-1-449-32914-3 "Special:BookSources/978-1-449-32914-3"). [Archived](<https://web.archive.org/web/20191103091907/http://www.uvm.edu/~choman/ebooks/EPUB 3 Best Practices.pdf>) (PDF) from the original on November 3, 2019.

OFL is a [free][] and [open source license][].[^6][^7] It was created by [SIL International][],
the organization behind _[Ethnologue][]_.

[free]: https://en.wikipedia.org/wiki/Free_software_license "Free software license"

[open source license]: https://en.wikipedia.org/wiki/Open_source_license "Open source license"

[^6]: ["OFL fonts"](https://openfontlicense.org/ofl-fonts/). _SIL Open Font License_. Retrieved December 11, 2023.

[^7]: ["Open Source License Comparison Grid"](https://www.cmu.edu/cttec/forms/opensourcelicensegrid.pdf) (PDF). [CMU](https://en.wikipedia.org/wiki/Carnegie_Mellon_University "Carnegie Mellon University"). [Archived](https://web.archive.org/web/20170921141728/http://www.cmu.edu/cttec/forms/opensourcelicensegrid.pdf) (PDF) from the original on September 21, 2017. Retrieved November 3, 2019.

[SIL International]: https://en.wikipedia.org/wiki/SIL_International "SIL International"

[Ethnologue]: https://en.wikipedia.org/wiki/Ethnologue "Ethnologue"

You can see that the content is very confusing and it is difficult to find paragraphs quickly.

It may be possible to place reference content such as footnotes at the bottom of the article, but this actually increases the complexity of editing the text. Because a long text may be hundreds of lines long, the same footnote may be cited multiple times.