@@ -302,7 +302,11 @@ fn layout_with_base(title: &str, body: &str, base_path: &str) -> String {
302302 }});
303303 }}
304304 }})();
305- if (window.hljs && window.hljs.highlightAll) {{ window.hljs.highlightAll(); }}
305+ if (window.hljs) {{
306+ window.hljs.highlightAll();
307+ // Configure hljs for better language detection
308+ window.hljs.configure({{ignoreUnescapedHTML: true}});
309+ }}
306310</script>"# , body) ,
307311 logo = logo_src,
308312 home = home_href,
@@ -782,12 +786,31 @@ fn render_impl(imp: &ImplInfo, tree: &BTreeMap<String, String>, base_path: &str)
782786 case 'go': return 'go';
783787 case 'js': return 'javascript';
784788 case 'ts': return 'typescript';
789+ case 'jsx': return 'jsx';
790+ case 'tsx': return 'tsx';
785791 case 'json': return 'json';
786792 case 'md': return 'markdown';
787793 case 'c': return 'c';
788- case 'h': return 'c';
794+ case 'cpp': case 'cc': case 'cxx': return 'cpp';
795+ case 'h': case 'hpp': return 'c';
796+ case 'java': return 'java';
797+ case 'kt': return 'kotlin';
798+ case 'swift': return 'swift';
799+ case 'rb': return 'ruby';
800+ case 'php': return 'php';
801+ case 'sh': case 'bash': return 'bash';
802+ case 'ps1': return 'powershell';
803+ case 'xml': case 'html': return 'xml';
804+ case 'css': return 'css';
805+ case 'scss': case 'sass': return 'scss';
806+ case 'yaml': case 'yml': return 'yaml';
807+ case 'toml': return 'toml';
808+ case 'dockerfile': return 'dockerfile';
809+ case 'sql': return 'sql';
789810 case 'txt': return 'plaintext';
790- case 'santa': return 'plaintext';
811+ case 'santa': case 'santat': return 'plaintext';
812+ case 'makefile': case 'mk': return 'makefile';
813+ case '': return (name.toLowerCase() === 'makefile' || name.toLowerCase() === 'dockerfile') ? name.toLowerCase() : 'plaintext';
791814 default: return 'plaintext';
792815 }}
793816 }}
@@ -804,8 +827,19 @@ fn render_impl(imp: &ImplInfo, tree: &BTreeMap<String, String>, base_path: &str)
804827 btn.classList.toggle('bg-white/10', isActive);
805828 btn.classList.toggle('text-white', isActive);
806829 }});
807- // Re-highlight
808- if (window.hljs && window.hljs.highlightElement) {{ window.hljs.highlightElement(code); }}
830+ // Reset scroll position to top
831+ const codeContainer = code.closest('pre');
832+ if (codeContainer) {{
833+ codeContainer.scrollTop = 0;
834+ }}
835+
836+ // Re-highlight with proper language detection
837+ if (window.hljs) {{
838+ // Clear previous highlighting
839+ code.removeAttribute('data-highlighted');
840+ // Apply new highlighting
841+ window.hljs.highlightElement(code);
842+ }}
809843 }}
810844 document.querySelectorAll('[data-file]').forEach(btn => {{
811845 btn.addEventListener('click', () => {{
@@ -844,7 +878,15 @@ fn render_impl(imp: &ImplInfo, tree: &BTreeMap<String, String>, base_path: &str)
844878 setTimeout(() => copyBtn.textContent = 'Copy', 1200);
845879 }}
846880 }});
881+ // Initialize with first file and ensure highlighting
847882 setFile({init_name});
883+
884+ // Ensure initial highlighting is applied after page load
885+ setTimeout(() => {{
886+ if (window.hljs) {{
887+ window.hljs.highlightAll();
888+ }}
889+ }}, 100);
848890</script>"# ,
849891 sidebar = files_sidebar,
850892 fname = html_escape:: encode_text( & initial_file. 0 ) ,
@@ -873,8 +915,15 @@ fn render_impl(imp: &ImplInfo, tree: &BTreeMap<String, String>, base_path: &str)
873915 if (which === 'journal') {{ j.style.display = ''; c.style.display = 'none'; tabs[0].classList.add('tab-active'); }}
874916 else {{ j.style.display = 'none'; c.style.display = ''; tabs[1].classList.add('tab-active'); }}
875917 // Re-run syntax highlighting when switching tabs
876- if (window.hljs && window.hljs.highlightAll) {{
877- window.hljs.highlightAll();
918+ if (window.hljs) {{
919+ // Re-highlight all code blocks in the current tab
920+ setTimeout(() => {{
921+ const visibleCodeBlocks = document.querySelectorAll('#tab-code:not([style*=\"display: none\"]) code[class*=\"language-\"], #tab-journal:not([style*=\"display: none\"]) code[class*=\"language-\"]');
922+ visibleCodeBlocks.forEach(block => {{
923+ block.removeAttribute('data-highlighted');
924+ window.hljs.highlightElement(block);
925+ }});
926+ }}, 10);
878927 }}
879928 }}
880929 document.querySelectorAll('.tab').forEach(b => {{
0 commit comments