Fixing formatting of code block and adding language

This commit is contained in:
2026-03-15 15:51:10 +01:00
parent decc46064e
commit d5044a9c28
2 changed files with 23 additions and 5 deletions

View File

@@ -605,6 +605,10 @@ class MultiLineCode extends Symbol {
* @type {string}
*/
text: string = "";
/**
* @type {string}
*/
language: string = "";
/**
*
* @param {string} line
@@ -622,7 +626,7 @@ class MultiLineCode extends Symbol {
*/
static create(lineFeed: LineFeed): Symbol {
const instance = new MultiLineCode();
const line = lineFeed.claim().trim();
const line = lineFeed.claim();
const lineWithoutStartTag = line.slice(3, line.length);
const sameLineContainsEnding = lineWithoutStartTag.includes("```");
@@ -640,7 +644,8 @@ class MultiLineCode extends Symbol {
instance.text = text;
return instance;
}
const lines = [lineWithoutStartTag];
instance.language = lineWithoutStartTag
const lines = [];
const endTokenFound = false;
while (!endTokenFound && !lineFeed.isEmpty()) {
@@ -665,15 +670,18 @@ class MultiLineCode extends Symbol {
/**
*
* @param {string} assetDirectory
* @param {string} _assetDirectory
* @returns {void}
*/
process(assetDirectory: string): void {
// NOTE: Needed to adhere to interface
// eslint-disable-next-line @typescript-eslint/no-unused-vars
process(_assetDirectory: string): void {
return;
}
render() {
return `<pre><code>${this.text}</code></pre>`;
const codeLanguage = this.language.length > 0 ? `<pre class="code-language">${this.language}</pre>` : "";
return `${codeLanguage}<pre><code style="white-space: pre;">${this.text}</code></pre>`;
}
}

View File

@@ -35,8 +35,18 @@
width: fit-content;
max-width: 100%;
white-space: normal;
margin-top: 0;
}
pre.code-language {
padding: 0.1rem 1rem 0 1rem;
margin: 0;
border-bottom: none;
color: #00FFFF;
font-weight:bold;
text-transform: capitalize;
}
img {
max-width: 100%;
border-radius: 4px;