vim-markdown icon indicating copy to clipboard operation
vim-markdown copied to clipboard

Markdown file with YAML key that has underscore "_" in key break all syntax highlighting in the rest of the file

Open caseydiers opened this issue 1 year ago • 0 comments

The presence of an underscore in the key of a yaml key value pair breaks all formatting for the remainder of the document.

I have tracked this down to the logical syntax highlighting of the underscore expecting his to be Italic and looking for a closing underscore.

https://github.com/preservim/vim-markdown/blob/8f6cb3a6ca4e3b6bcda0730145a0b700f3481b51/syntax/markdown.vim#L54

However, I do not know enough about vimscript to understand how to clear this syntax rule within the yaml frontmatter section.

I have confirmed this with the following example:

Example:

---
title:
- Title of Document Here
subtitle:
- Subtitle of Document Here
author:
- Casey Diers
date:
- 12/06/2024
place_name:
- Home
coordinates:
- [44.4444, -88.8888]
logo:
- logo.jpg
logo2:
-
---

\tableofcontents
\pagebreak

# What is this all about

## Shelves

Note: Currently all 9 shelves have the same dimensions, however they are shown separately here as they will likely have different feed points and therefore need to be individually ID'ed prior to ordering materials.

| Shelf ID | Length (in) | Depth (in) | Thickness | Feed Location |
| -------- | ----------- | ---------- | --------- | ------------- |
| 1        | 43          | 9          | 1/2       | TBD           |
| 2        | 43          | 9          | 1/2       | TBD           |
| 3        | 43          | 9          | 1/2       | TBD           |
| 4        | 43          | 9          | 1/2       | TBD           |
| 5        | 43          | 9          | 1/2       | TBD           |
| 6        | 43          | 9          | 1/2       | TBD           |
| 7        | 43          | 9          | 1/2       | TBD           |
| 8        | 43          | 9          | 1/2       | TBD           |
| 9        | 43          | 9          | 1/2       | TBD           |

\pagebreak

## Product Specifications

### Option A - Use this Product

![](./images/image-20241202135915564.png){ height=200px }
...

In this example, there is no syntax highlighting after the place_name yaml key.

Running the vim command on the local buffer :syn clear mkdItalic makes the rest of the synatx highlighting return for the entirety of the document (except, of course, Italics).

I tried adding this to this if statement, but that doesn't appear to be the correct syntax / way to do it.

https://github.com/preservim/vim-markdown/blob/8f6cb3a6ca4e3b6bcda0730145a0b700f3481b51/syntax/markdown.vim#L121C1-L125C6

I'm happy to work on this and submit a pull request, but I don't quite know enough about vimscript to navigate this markdown.vim file.

caseydiers avatar Dec 06 '24 17:12 caseydiers