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

Dash in front-matter keys breaks the syntax highlighting of the title #1595

Closed
feliksik opened this issue Apr 9, 2024 · 5 comments
Closed
Labels

Comments

@feliksik
Copy link

feliksik commented Apr 9, 2024

Observed vs. expected behavior

When using frontmatter, the title is not highlighted in the editor (it's black). This makes it look like you're doing it wrong -- but you're doing it exactly right.

I expect it to be Blue, like it is without frontmatter.

Additionally, like the VS Code asciidoc plugin, I would expect squiggly error-lines and the "level 0 sections can only be used when doctype is book" error when the asciidoc is incorrect.

Steps to reproduce

Correct frontmatter, incorrect highlighting:

---
this: is frontmatter
key: value
---
= My title

The title is black, should be blue. 

In the document below, blue highlighting of title makes it look correct, but this is incorrect asciidoc for non-book doctype ("asciidoctor: ERROR: ../myfile.adoc: line 0: level 0 sections can only be used when doctype is book")

---
this: is frontmatter
key: value
---

= My title

The title is blue, but is incorrect asciidoc for non-book format. 

Environment

Plugin Version: 0.41.13

IntelliJ Details: IntelliJ IDEA 2023.3.5 (Ultimate Edition) Build #IU-233.14808.21, built on March 12, 2024

@feliksik feliksik added the bug label Apr 9, 2024
@ahus1
Copy link
Contributor

ahus1 commented Apr 13, 2024

Thanks for reporting this. I'm trying to reproduce it locally, but yet without success, so I might be missing something. Some additional information might help:

  • Please share a screenshot of the editor + its preview
  • Do you have an .asciidoctorconfig file? I wonder if its contents interfere here - it should work as long as you only for example set attributes there.

I would expect squiggly error-lines and the "level 0 sections can only be used when doctype is book" error when the asciidoc is incorrect.

I don't agree that the level 0 section warning is expected with the example you provided: While only a book is allowed to have multiple level 0 sections, an article is allowed to have a title which looks basically the same. As long as there is only a title, then there shouldn't be a warning.

This is what I see:

image

@feliksik
Copy link
Author

You are correct, my example was wrong.

It turns out it's a dash in a frontmatter key breaks the highlighting; so it's a subtle bug.

---
dashed-key-breaks-highting: blah
this: is frontmatter
key: value
---
= My title

The title is black, should be blue.
image

@feliksik feliksik changed the title Syntax highlighting of title is incorrect whn frontmatter is used Dash in front-matter keys breaks the syntax highlighting of the title Apr 23, 2024
@ahus1
Copy link
Contributor

ahus1 commented May 2, 2024

The next version of the plugin will use a better heuristic to recognize YAML in the frontmatter.

I'll update this issue once a pre-release is available.

@feliksik
Copy link
Author

feliksik commented May 2, 2024

Thanks!!

@ahus1
Copy link
Contributor

ahus1 commented May 3, 2024

Plugin-version 0.41.14 is now available with a fix. It should be available from the JetBrains markeplace soon.

The it is also available from GitHub releases.

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

No branches or pull requests

2 participants