Skip to content

Commit 01962b1

Browse files
authored
Throw error for highlight shortcode (#225)
* fix: Update highlight shortcode to error if used + styling * fix: Added example to exampleSite
1 parent 3ff5146 commit 01962b1

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

assets/css/v2/style.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
--color-shadow: #d2d2d2;
6161
--color-codeblock-border: #888;
6262
--color-codeblock-shadow: #e5e5e5;
63+
--color-codeblock-highlight: #fffed9;
6364
--color-footer: #1d1d1d;
6465
--color-footer-text: #e2e2e2;
6566
--color-product-title: #8d8d8d;
@@ -1460,6 +1461,12 @@ ul .code-block {
14601461
padding: 0;
14611462
}
14621463

1464+
.highlight code .hl {
1465+
width: fit-content;
1466+
min-width: 100%;
1467+
background-color: var(--color-codeblock-highlight);
1468+
}
1469+
14631470
/* MARK: Images
14641471
*/
14651472
figure {
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
description: Code Blocks - highlighting
3+
title: Highlighting
4+
weight: 200
5+
---
6+
7+
{{<warning>}}
8+
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.
9+
{{</warning>}}
10+
11+
## Example with highlighting one line
12+
```hcl {linenos=false,hl_lines=[16]}
13+
resource "azurerm_nginx_certificate" "cert1" {
14+
name = "examplecert"
15+
nginx_deployment_id = azurerm_nginx_deployment.test.id
16+
key_virtual_path = "/src/cert/soservermekey.key"
17+
certificate_virtual_path = "/src/cert/server.cert"
18+
key_vault_secret_id = azurerm_key_vault_certificate.test.secret_id
19+
}
20+
```
21+
22+
## Example with highlighting multiple consecutive lines (2-4)
23+
```hcl {linenos=true,hl_lines="2-4"}
24+
resource "azurerm_nginx_certificate" "cert1" {
25+
name = "examplecert"
26+
nginx_deployment_id = azurerm_nginx_deployment.test.id
27+
key_virtual_path = "/src/cert/soservermekey.key"
28+
certificate_virtual_path = "/src/cert/server.cert"
29+
key_vault_secret_id = azurerm_key_vault_certificate.test.secret_id
30+
}
31+
```
32+
{{<call-out "side-callout" "Note">}}
33+
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.
34+
{{</call-out>}}
35+
36+
## Example with highlighting multiple non-consecutive lines
37+
```hcl {linenos=true,hl_lines=[2,4,6]}
38+
resource "azurerm_nginx_certificate" "cert1" {
39+
name = "examplecert"
40+
nginx_deployment_id = azurerm_nginx_deployment.test.id
41+
key_virtual_path = "/src/cert/soservermekey.key"
42+
certificate_virtual_path = "/src/cert/server.cert"
43+
key_vault_secret_id = azurerm_key_vault_certificate.test.secret_id
44+
}
45+
```

layouts/shortcodes/highlight.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{ errorf "'<highlight></highlight>' is deprecated. Use codeblock shortcode (via triple ticks and setting 'hl_lines') instead."}}

0 commit comments

Comments
 (0)