Skip to content

Throw error for highlight shortcode #225

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

Merged
merged 2 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions assets/css/v2/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
--color-shadow: #d2d2d2;
--color-codeblock-border: #888;
--color-codeblock-shadow: #e5e5e5;
--color-codeblock-highlight: #fffed9;
--color-footer: #1d1d1d;
--color-footer-text: #e2e2e2;
--color-product-title: #8d8d8d;
Expand Down Expand Up @@ -1449,6 +1450,12 @@ ul .code-block {
padding: 0;
}

.highlight code .hl {
width: fit-content;
min-width: 100%;
background-color: var(--color-codeblock-highlight);
}

/* MARK: Images
*/
figure {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
description: Code Blocks - highlighting
title: Highlighting
weight: 200
---

{{<warning>}}
There is an option to use the `highlight` shortcode from Hugo but we have disabled that feature as it is redundant to using ticks. All usage will throw an error in the Hugo build.
{{</warning>}}

## Example with highlighting one line
```hcl {linenos=false,hl_lines=[16]}
resource "azurerm_nginx_certificate" "cert1" {
name = "examplecert"
nginx_deployment_id = azurerm_nginx_deployment.test.id
key_virtual_path = "/src/cert/soservermekey.key"
certificate_virtual_path = "/src/cert/server.cert"
key_vault_secret_id = azurerm_key_vault_certificate.test.secret_id
}
```

## Example with highlighting multiple consecutive lines (2-4)
```hcl {linenos=true,hl_lines="2-4"}
resource "azurerm_nginx_certificate" "cert1" {
name = "examplecert"
nginx_deployment_id = azurerm_nginx_deployment.test.id
key_virtual_path = "/src/cert/soservermekey.key"
certificate_virtual_path = "/src/cert/server.cert"
key_vault_secret_id = azurerm_key_vault_certificate.test.secret_id
}
```
{{<call-out "side-callout" "Note">}}
Values you can use for `hl_lines` are all non-zero positive integers. If you include a line number in `hl_lines` that does not exist (e.g. `16` in this example), it will highlight until the end.
{{</call-out>}}

## Example with highlighting multiple non-consecutive lines
```hcl {linenos=true,hl_lines=[2,4,6]}
resource "azurerm_nginx_certificate" "cert1" {
name = "examplecert"
nginx_deployment_id = azurerm_nginx_deployment.test.id
key_virtual_path = "/src/cert/soservermekey.key"
certificate_virtual_path = "/src/cert/server.cert"
key_vault_secret_id = azurerm_key_vault_certificate.test.secret_id
}
```
1 change: 1 addition & 0 deletions layouts/shortcodes/highlight.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ errorf "'<highlight></highlight>' is deprecated. Use codeblock shortcode (via triple ticks and setting 'hl_lines') instead."}}
Loading