mirror of
https://github.com/godotengine/godot-docs.git
synced 2025-12-31 17:49:03 +03:00
Automatically convert spaces to tabs in codeblocks
• Adds codeblock css rule for tab-size • Only applies to GDScript/C++ • Fix some inconsistent cpp codeblock filters
This commit is contained in:
@@ -846,6 +846,7 @@ code,
|
||||
|
||||
.highlight {
|
||||
background-color: var(--highlight-background-color);
|
||||
tab-size: 4;
|
||||
}
|
||||
|
||||
/* Emphasized lines */
|
||||
|
||||
@@ -291,6 +291,19 @@ $(document).ready(() => {
|
||||
}
|
||||
}
|
||||
|
||||
// Change indentation from spaces to tabs for codeblocks.
|
||||
const codeBlocks = document.querySelectorAll('.rst-content div[class^="highlight"] pre');
|
||||
for (const codeBlock of codeBlocks) {
|
||||
const classList = codeBlock.parentNode.parentNode.classList;
|
||||
if (!classList.contains('highlight-gdscript') && !classList.contains('highlight-cpp')) {
|
||||
// Only change indentation for GDScript and C++.
|
||||
continue;
|
||||
}
|
||||
let html = codeBlock.innerHTML;
|
||||
html = html.replace(/(?<=^(<span class="w">)?( {4})*)( {4})/gm, '\t');
|
||||
codeBlock.innerHTML = html;
|
||||
}
|
||||
|
||||
// See `godot_is_latest` in conf.py
|
||||
const isLatest = document.querySelector('meta[name=doc_is_latest]').content.toLowerCase() === 'true';
|
||||
if (isLatest) {
|
||||
|
||||
Reference in New Issue
Block a user