Skip to content

Commit 27c6b8f

Browse files
zeripathsapk
authored andcommitted
Add documentation to add Mermaid.js to Gitea (#9872)
* Add documentation to add mermaid to Gitea * Update documentation Co-authored-by: Antoine GIRARD <[email protected]>
1 parent 1920e5b commit 27c6b8f

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

docs/content/doc/advanced/customizing-gitea.en-us.md

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,45 @@ Apart from `extra_links.tmpl` and `extra_tabs.tmpl`, there are other useful temp
100100
- `body_outer_post.tmpl`, before the bottom `<footer>` element.
101101
- `footer.tmpl`, right before the end of the `<body>` tag, a good place for additional Javascript.
102102

103+
#### Example: Mermaid.js
104+
105+
If you would like to add [mermaid.js](https://mermaid-js.github.io/) support to Gitea's markdown you simply add:
106+
107+
```html
108+
{{if .RequireHighlightJS}}
109+
<script src="https://unpkg.com/[email protected]/dist/mermaid.min.js"></script>
110+
<!-- or wherever you have placed it -->
111+
<script>mermaid.init(".language-mermaid")</script>
112+
{{end}}
113+
```
114+
115+
to `custom/footer.tmpl`. You then can add blocks
116+
like below to your markdown:
117+
118+
```mermaid
119+
stateDiagram
120+
[*] --> Active
121+
122+
state Active {
123+
[*] --> NumLockOff
124+
NumLockOff --> NumLockOn : EvNumLockPressed
125+
NumLockOn --> NumLockOff : EvNumLockPressed
126+
--
127+
[*] --> CapsLockOff
128+
CapsLockOff --> CapsLockOn : EvCapsLockPressed
129+
CapsLockOn --> CapsLockOff : EvCapsLockPressed
130+
--
131+
[*] --> ScrollLockOff
132+
ScrollLockOff --> ScrollLockOn : EvCapsLockPressed
133+
ScrollLockOn --> ScrollLockOff : EvCapsLockPressed
134+
}
135+
```
136+
137+
If you want to use Mermaid.js outside of markdown, e.g. in other templates or HTML files,
138+
you would need to remove `{{if .RequireHighlightJS}}` and `{{end}}`.
139+
140+
Mermaid will detect and use tags with `class="language-mermaid"`.
141+
103142
## Customizing Gitea mails
104143

105144
The `custom/templates/mail` folder allows changing the body of every mail of Gitea.
@@ -112,8 +151,6 @@ full path structure matching source.
112151
Any statement contained inside `{{` and `}}` are Gitea's template
113152
syntax and shouldn't be touched without fully understanding these components.
114153

115-
116-
117154
## Adding Analytics to Gitea
118155

119156
Google Analytics, Matomo (previously Piwik), and other analytics services can be added to Gitea. To add the tracking code, refer to the `Other additions to the page` section of this document, and add the JavaScript to the `custom/templates/custom/header.tmpl` file.

0 commit comments

Comments
 (0)