Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
caseydiers opened this issue Dec 6, 2024 · 0 comments

Comments

@caseydiers
Copy link

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.

syn region mkdItalic matchgroup=mkdItalic start="\%(\*\|_\)" end="\%(\*\|_\)"

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant