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

Terraform comments are highlighted as errors #2094

Closed
azbpa opened this issue Mar 23, 2022 · 2 comments · Fixed by #2097
Closed

Terraform comments are highlighted as errors #2094

azbpa opened this issue Mar 23, 2022 · 2 comments · Fixed by #2097
Labels
A-lexing area: changes to individual lexers

Comments

@azbpa
Copy link

azbpa commented Mar 23, 2022

The following valid Terraform code gets highlighted with errors: pygmentize -g .\main.tf -f html

terraform {
    required_version = ">= 1.1.0"
}

provider "azurerm" { # (1)
    features {}
} 

module "foo" { # (2)
    source = "../.."
    foo = "bar"
}
<div class="highlight"><pre><span></span><span class="nb">terraform</span> <span class="p">{</span>
    <span class="na">required_version</span> <span class="o">=</span> <span class="s2">&quot;&gt;= 1.1.0&quot;</span>
<span class="p">}</span>

<span class="kr">provider</span> <span class="nv">&quot;azurerm&quot;</span> <span class="p">{</span><span class="err"> # (1)</span>
    <span class="nb">features</span> <span class="p">{}</span>
<span class="p">}</span>

<span class="kr">module</span> <span class="nv">&quot;foo&quot;</span> <span class="p">{</span><span class="err"> # (2)</span>
    <span class="na">source</span> <span class="o">=</span> <span class="s2">&quot;../..&quot;</span>
    <span class="na">foo</span> <span class="o">=</span> <span class="s2">&quot;bar&quot;</span>
<span class="p">}</span>
</pre></div>

Both comments # (1) and # (2) are highlighted as errors: <span class="err"> # (1)</span> / <span class="err"> # (2)</span>.

Using using the following version:

pip show pygments

Name: Pygments
Version: 2.10.0
Summary: Pygments is a syntax highlighting package written in Python.
Home-page: https://pygments.org/
Author: Georg Brandl
Author-email: georg@python.org
@azbpa
Copy link
Author

azbpa commented Mar 23, 2022

Relates the the following issue raised on Mkdocs Material:squidfunk/mkdocs-material#3696

@Anteru
Copy link
Collaborator

Anteru commented Mar 23, 2022

Just checked, reproduces on master as well.

@Anteru Anteru added the A-lexing area: changes to individual lexers label Mar 23, 2022
amitkummer added a commit to amitkummer/Pygments that referenced this issue Mar 27, 2022
The `blockname` state did not have a `#pop` after it's only rule,
which caused outputting errors in pygments#2094.

Instead of adding a `#pop`, I merged the `blockname` state with the
rule that uses it, to achieve the exact same lexing logic, but without
another state in the lexer.
amitkummer added a commit to amitkummer/Pygments that referenced this issue Mar 27, 2022
Anteru pushed a commit that referenced this issue Mar 27, 2022
* Merge unneeded state with it's parent rule

The `blockname` state did not have a `#pop` after it's only rule,
which caused outputting errors in #2094.

Instead of adding a `#pop`, I merged the `blockname` state with the
rule that uses it, to achieve the exact same lexing logic, but without
another state in the lexer.

* Add test for  #2094

* Regenerate tokens for previous tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lexing area: changes to individual lexers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants