Define HighlightJS definition for Aiken.

This commit is contained in:
KtorZ 2022-12-16 23:55:09 +01:00
parent e1065e892a
commit e7f729c61b
No known key found for this signature in database
GPG Key ID: 33173CB6F77F4277
4 changed files with 25 additions and 13 deletions

View File

@ -185,8 +185,8 @@ fn generate_static_assets(search_indexes: Vec<SearchIndex>) -> Vec<DocFile> {
});
assets.push(DocFile {
path: PathBuf::from("js/highlightjs-gleam.js"),
content: std::include_str!("../templates/js/highlightjs-gleam.js").to_string(),
path: PathBuf::from("js/highlightjs-aiken.js"),
content: std::include_str!("../templates/js/highlightjs-aiken.js").to_string(),
});
assets.push(DocFile {

View File

@ -252,11 +252,11 @@
</svg>
<script src="{{ breadcrumbs }}/js/highlight.min.js?v={{ aiken_version }}"></script>
<script src="{{ breadcrumbs }}/js/highlightjs-gleam.js?v={{ aiken_version }}"></script>
<script src="{{ breadcrumbs }}/js/highlightjs-aiken.js?v={{ aiken_version }}"></script>
<script>
document.querySelectorAll("pre code").forEach((elem) => {
if (elem.className === "") {
elem.classList.add("gleam");
elem.classList.add("aiken");
}
});
hljs.highlightAll();

View File

@ -1,7 +1,6 @@
hljs.registerLanguage("gleam", function (hljs) {
hljs.registerLanguage("aiken", function (hljs) {
const KEYWORDS =
"as assert case const external fn if import let " +
"use opaque pub todo try tuple type";
"as assert when is const fn if let use opaque pub assert check todo type";
const STRING = {
className: "string",
variants: [{ begin: /"/, end: /"/ }],
@ -42,8 +41,8 @@ hljs.registerLanguage("gleam", function (hljs) {
};
return {
name: "Gleam",
aliases: ["gleam"],
name: "Aiken",
aliases: ["aiken"],
contains: [
hljs.C_LINE_COMMENT_MODE,
STRING,
@ -80,6 +79,19 @@ hljs.registerLanguage("gleam", function (hljs) {
},
],
},
{
className: "keyword",
beginKeywords: "use",
end: "\n",
excludeEnd: true,
contains: [
{
className: "title",
begin: "[a-z][a-z0-9_/]*\\w*",
relevance: 0,
},
],
},
{
className: "keyword",
beginKeywords: KEYWORDS,

View File

@ -57,7 +57,7 @@
</div>
<div class="custom-type-constructors">
<div class="rendered-markdown">{{ type_info.documentation|safe }}</div>
<pre><code class="hljs gleam">{{ type_info.definition }}</code></pre>
<pre><code class="hljs aiken">{{ type_info.definition }}</code></pre>
{% if !type_info.constructors.is_empty() %}
<h3>
Constructors
@ -67,7 +67,7 @@
<li class="constructor-item">
<div class="constructor-row">
<svg class="icon icon-star"><use xlink:href="#icon-star"></use></svg>
<pre class="constructor-name"><code class="hljs gleam">{{ constructor.definition }}</code></pre>
<pre class="constructor-name"><code class="hljs aiken">{{ constructor.definition }}</code></pre>
</div>
<div class="constructor-item-docs">
@ -124,7 +124,7 @@
</a>
{% endif %}
</div>
<pre><code class="hljs gleam">{{ constant.definition }}</code></pre>
<pre><code class="hljs aiken">{{ constant.definition }}</code></pre>
<div class="rendered-markdown">{{ constant.documentation|safe }}</div>
</div>
{% endfor %}
@ -150,7 +150,7 @@
</a>
{% endif %}
</div>
<pre><code class="hljs gleam">{{ function.signature }}</code></pre>
<pre><code class="hljs aiken">{{ function.signature }}</code></pre>
<div class="rendered-markdown">{{ function.documentation|safe }}</div>
</div>
{% endfor %}