# Manual syntax highlighting in code blocks?

**URL:** <https://discourse.gohugo.io/t/manual-syntax-highlighting-in-code-blocks/46354>\
**Category:** support\
**Created:** [September 22, 2023, 7:13pm UTC](https://discourse.gohugo.io/t/manual-syntax-highlighting-in-code-blocks/46354 "2023-09-22T19:13:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![acut3](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/acut3/32/20398_2.png) [@acut3](https://discourse.gohugo.io/u/acut3)\
**Post date:** [September 22, 2023, 7:13pm UTC](https://discourse.gohugo.io/t/manual-syntax-highlighting-in-code-blocks/46354/1 "2023-09-22T19:13:26Z")

</div>

Is there a way to manually highlight parts of a plaintext code block with Hugo?

What I’d like is something similar to the `escape` lexer in Jekyll/rougify, where I can do:

````plaintext
```escape
https://app.target.com/users?id=<!123456!>
`​``

````

It will be rendered like a plaintext code block, except `123456` (the text between `<!` and `!>`) will be highlighted in red:

 ![Screen Shot 2023-09-22 at 21.07.13](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/3X/e/4/e44bd4feab3556bb997fff924621b6fc582ea2dc.png)

---

<div class="post-metadata">

**Author:** ![jmooring](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/jmooring/32/4214_2.png) [@jmooring](https://discourse.gohugo.io/u/jmooring)\
**Post date:** [September 22, 2023, 7:28pm UTC](https://discourse.gohugo.io/t/manual-syntax-highlighting-in-code-blocks/46354/2 "2023-09-22T19:28:25Z")

</div>

We use [Chroma](https://github.com/alecthomas/chroma) to perform syntax highlighting. I suggest you create a proposal to add a new lexer, referencing:

[https://github.com/rouge-ruby/rouge/blob/master/lib/rouge/lexers/escape.rb](https://github.com/rouge-ruby/rouge/blob/master/lib/rouge/lexers/escape.rb)

---

<div class="post-metadata">

**Author:** ![acut3](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/acut3/32/20398_2.png) [@acut3](https://discourse.gohugo.io/u/acut3)\
**Post date:** [September 23, 2023, 9:18am UTC](https://discourse.gohugo.io/t/manual-syntax-highlighting-in-code-blocks/46354/3 "2023-09-23T09:18:59Z")

</div>

Thanks for your suggestion. In the meantime, I’ve created a custom shortcode in `layouts/shortcodes/hl.html`:

```html
<span class="{{ index .Params 0 | default "k" }}">{{ .Inner }}</span>

```

which I can use as follows:

````plaintext
```plaintext
Some text with a {{<hl>}}Keyword{{</hl>}} and a {{<hl s>}}LiteralString{{</hl>}}.
```

````
