Closed freakinhippie closed 2 months ago
So..... The README is actually run through the syntax highlighter.. However, I've seen it's not fantastic at detecting languages. For things like example files and such, where there's 100% terraform, it's forced to use HCL syntax highlighting. For the README, it's not (because of the exact fact that it might contain other languages).. so it is enabled.. but unfortunately, if it doesn't detect the language, it doesn't get highlighted Having said that, now I think of it, I've certainly seen things that should look like HCL and it doesn't do it.. so I'll double check
Created gitlab issue: https://gitlab.dockstudios.co.uk/pub/terrareg/-/issues/529 gitlab-issue-id:529
Does it attempt to detect the language by some means of parsing the fenced block, or by using the fence hint (or whatever it is called?
For example, if the code looks like:
resource "aws_instance" "server" { provider = aws.custom
name = "srv01"
}
Does that mean that the parser attempts to detect that is HCL code and apply highlighting? Alternatively, if the code includes the hint:
```terraform
resource "aws_instance" "server" {
provider = aws.custom
name = "srv01"
# other inputs
}
resource "aws_instance" "server" {
provider = aws.custom
name = "srv01"
# other inputs
}
...does that change the behaviour?
Unfortunately, it still seems to have an issue:
Current:
Forcing HCL:
I would be wary of forcing HCL, unless there is a fence hint specifying hcl
or terraform
. Personally, I frequently have other languages as fenced blocks that would not be parsed properly if the highlighting were forced to HCL for all code blocks.
Hey @freakinhippie ,
I've managed to find why it wasn't working. Created a PR: https://gitlab.dockstudios.co.uk/pub/terrareg/-/merge_requests/408 Available at: https://terrareg-529-feature-request-syntax-highlighting-of-cod.gitlab-pr.dockstudios.co.uk/modules/test/example/myfirstmodule
Matt
I'm not sure if this is built on top of the 3.6.0 release, but if not there seems to be a regression in the markdown table handling of inputs/outputs. See here
I see the syntax highlighting in the [Readme] section, but were you planning to add it to the Type and Default sections of [Inputs]? Also, in the [Readme] section there are two identical terraform blocks with one highlighted and one not. I presume that is because the first one (without highlighting) doesn't have the fence block hint. If that is the case, would you please specify which languages/formats will be supported, and what their hint should specifically be (eg terraform
vs. hcl
), somewhere in the documentation?
Thanks again! This is great progress.
I'm not sure if this is built on top of the 3.6.0 release, but if not there seems to be a regression in the markdown table handling of inputs/outputs. See here
Hmm, I did change the Terraform for that demo module, but locally it seems to work fine. I'm creating a demo environment for main to see if there's an issue with the docker version of the app
I see the syntax highlighting in the [Readme] section, but were you planning to add it to the Type and Default sections of [Inputs]? Also, in the [Readme] section there are two identical terraform blocks with one highlighted and one not. I presume that is because the first one (without highlighting) doesn't have the fence block hint. If that is the case, would you please specify which languages/formats will be supported, and what their hint should specifically be (eg terraform vs. hcl), somewhere in the documentation?
These are the ones from yours above, it seems the syntax highlighting library only support hcl
tag - I'll find somewhere to document this (perhaps in https://matthewjohn.github.io/terrareg/modules/best_practices/)
I've found the issue - it was a bug in the original implementation! Fixed here: https://gitlab.dockstudios.co.uk/pub/terrareg/-/merge_requests/410 I'll get that merged, get it into this branch and get the docs updated
Matt
Wonderful! Thank you!
This is now released :) https://github.com/MatthewJohn/terrareg/releases/tag/v3.7.0
It would be amazing if markdown fenced code blocks supported syntax highlighting throughout the UI, such as in the tabs [Readme], [Inputs], [Outputs], etc. The [Usage] field uses syntax highlighting on the generated terraform. Using the same rules in other places would be great.
As a bonus, supporting syntax highlighting of not only terraform code, but other types of code that might be commonly encountered in terraform would be useful as well. Languages and/or formats such as YAML, JSON, python, javascript, etc.