Skip to content

Commit

Permalink
Merge branch '529-feature-request-syntax-highlighting-of-code-blocks'…
Browse files Browse the repository at this point in the history
… into 'main'

Resolve "Feature Request: syntax highlighting of code blocks"

Closes #529

See merge request pub/terrareg!408
  • Loading branch information
MatthewJohn committed Jun 19, 2024
2 parents 5071a40 + 90aa335 commit ee1f81c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
36 changes: 36 additions & 0 deletions docs/modules/best_practices.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,42 @@ Terrareg has been extensively tested with Terraform modules of all shapes and si

However, to get the _most_ out of Terrareg, there are some practices/guides that will help.

## Markdown

Markdown files can be indexed and shown as tabs.

The README.md in a root module, sub-modules and examples are indexed by default.

Additional markdown files can be indexed and shown as tabs using [ADDITIONAL_MODULE_TABS](../CONFIG.md#additional_module_tabs)

Code blocks are shown with syntax highlighting, with the following supported languages:

* `hcl`
* `css`
* `bash`
* `batch`
* `docker`
* `hcl`
* `plsql`
* `powershell`
* `python`
* `sql`

Auto-detection of languages is used, but it's safest to write with language-helper markup, e.g.:
````
```hcl
terraform {
required_version = "0.1.2
}
```
```bash
#!/bin/bash
echo Some bash script
```
````

## Terrareg metadata file

A metadata file can be provided each an uploaded module's archive to provide additional metadata to terrareg.
Expand Down
4 changes: 3 additions & 1 deletion terrareg/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ def sanitise_html_content(text, allow_markdown_html=False):
# Custom allowed attributes
'h1': ['id'], 'h2': ['id'], 'h3': ['id'],
'h4': ['id'], 'h5': ['id'], 'h6': ['id'],
'img': ['src']
'img': ['src'],
'code': ['class']
}

return (
bleach.clean(
text, **kwargs
Expand Down

0 comments on commit ee1f81c

Please sign in to comment.