diff options
| author | Jordan Wiens <jordan@psifertex.com> | 2025-07-31 18:03:27 -0400 |
|---|---|---|
| committer | Jordan Wiens <jordan@psifertex.com> | 2025-07-31 18:03:27 -0400 |
| commit | f252933553de86be26c25710ca314bc1f15e93b6 (patch) | |
| tree | 811a4252d602aee75490e8b4620182579a8ea167 | |
| parent | 27223cecc131198166e02b7a3387b65d04daca00 (diff) | |
support for multi-language code block tab syncing
| -rw-r--r-- | docs/tabsync.js | 34 | ||||
| -rw-r--r-- | mkdocs.yml | 5 |
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 @@ -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: |
