summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Wiens <jordan@psifertex.com>2025-07-31 18:03:27 -0400
committerJordan Wiens <jordan@psifertex.com>2025-07-31 18:03:27 -0400
commitf252933553de86be26c25710ca314bc1f15e93b6 (patch)
tree811a4252d602aee75490e8b4620182579a8ea167
parent27223cecc131198166e02b7a3387b65d04daca00 (diff)
support for multi-language code block tab syncing
-rw-r--r--docs/tabsync.js34
-rw-r--r--mkdocs.yml5
2 files changed, 37 insertions, 2 deletions
diff --git a/docs/tabsync.js b/docs/tabsync.js
new file mode 100644
index 00000000..86e54b1c
--- /dev/null
+++ b/docs/tabsync.js
@@ -0,0 +1,34 @@
+document.addEventListener("DOMContentLoaded", function () {
+ const tabSync = () => {
+ const tabs = document.querySelectorAll(".tabbed-set > input, .tabbed-alternate input");
+
+ for (const tab of tabs) {
+ tab.addEventListener("click", () => {
+ const currentLabel = document.querySelector(`label[for="${tab.id}"]`);
+ if (!currentLabel) return;
+
+ const pos = currentLabel.getBoundingClientRect().top;
+ const labelText = currentLabel.textContent.trim();
+
+ const allLabels = document.querySelectorAll(
+ ".tabbed-set > label, .tabbed-alternate > .tabbed-labels > label"
+ );
+
+ for (const label of allLabels) {
+ if (label.textContent.trim() === labelText) {
+ const inputId = label.getAttribute("for");
+ const input = document.getElementById(inputId);
+ if (input && input !== tab) {
+ input.click();
+ }
+ }
+ }
+
+ const delta = currentLabel.getBoundingClientRect().top - pos;
+ window.scrollBy(0, delta);
+ });
+ }
+ };
+
+ tabSync();
+}); \ No newline at end of file
diff --git a/mkdocs.yml b/mkdocs.yml
index c70be12b..0f9dd11c 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -7,7 +7,7 @@ site_description: 'Documentation for the Binary Ninja reverse engineering platfo
site_author: 'Vector 35 Inc'
use_directory_urls: false
extra_css: ['docs.css', 'github.min.css', 'juxtapose.min.css']
-extra_javascript: ['highlight.min.js', 'cpp.min.js', 'python.min.js', 'juxtapose.min.js']
+extra_javascript: ['highlight.min.js', 'cpp.min.js', 'python.min.js', 'juxtapose.min.js', 'tabsync.js']
theme:
name: material
custom_dir: overrides
@@ -76,7 +76,8 @@ markdown_extensions:
- codehilite
- admonition
- pymdownx.details
- - pymdownx.superfences
+ - pymdownx.superfences:
+ preserve_tabs: true
- pymdownx.tabbed:
alternate_style: true
- toc: