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 { assets.push(DocFile {
path: PathBuf::from("js/highlightjs-gleam.js"), path: PathBuf::from("js/highlightjs-aiken.js"),
content: std::include_str!("../templates/js/highlightjs-gleam.js").to_string(), content: std::include_str!("../templates/js/highlightjs-aiken.js").to_string(),
}); });
assets.push(DocFile { assets.push(DocFile {

View File

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

View File

@ -1,7 +1,6 @@
hljs.registerLanguage("gleam", function (hljs) { hljs.registerLanguage("aiken", function (hljs) {
const KEYWORDS = const KEYWORDS =
"as assert case const external fn if import let " + "as assert when is const fn if let use opaque pub assert check todo type";
"use opaque pub todo try tuple type";
const STRING = { const STRING = {
className: "string", className: "string",
variants: [{ begin: /"/, end: /"/ }], variants: [{ begin: /"/, end: /"/ }],
@ -42,8 +41,8 @@ hljs.registerLanguage("gleam", function (hljs) {
}; };
return { return {
name: "Gleam", name: "Aiken",
aliases: ["gleam"], aliases: ["aiken"],
contains: [ contains: [
hljs.C_LINE_COMMENT_MODE, hljs.C_LINE_COMMENT_MODE,
STRING, 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", className: "keyword",
beginKeywords: KEYWORDS, beginKeywords: KEYWORDS,

View File

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