Highlight code blocks in article bodies
arborium (tree-sitter) renders each token as a flat <span class="hl-…">, which the X4's no-descendant-selector stylesheet can still target. The sanitizer strips class attributes, so language hints never reached the database. annotate_hints now copies them onto <pre data-lang> before readability and sanitizing: pre/code classes, Rouge and GitHub wrapper divs, SyntaxHighlighter's brush:, and data-lang style attributes. ammonia keeps only canonical values. Highlighting runs at render time for the web article page and both EPUB editions, so stored articles benefit too. Unhinted blocks are guessed from content (JSON that parses, shebangs, leading <script>/<style>, then betlang at >= 0.5). A borderline block also takes the article's prevailing language when that language is among its top candidates. Anything else stays plain, since wrong colours are worse than none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,11 +6,13 @@ edition = "2024"
|
||||
[dependencies]
|
||||
ammonia = "4.1.4"
|
||||
anyhow = "1.0.104"
|
||||
arborium = { version = "2.18.2", default-features = false, features = ["lang-asm", "lang-awk", "lang-bash", "lang-c", "lang-c-sharp", "lang-clojure", "lang-cmake", "lang-commonlisp", "lang-cpp", "lang-css", "lang-d", "lang-dart", "lang-diff", "lang-dockerfile", "lang-elisp", "lang-elixir", "lang-elm", "lang-erlang", "lang-fish", "lang-fsharp", "lang-gleam", "lang-glsl", "lang-go", "lang-graphql", "lang-groovy", "lang-haskell", "lang-hcl", "lang-html", "lang-ini", "lang-java", "lang-javascript", "lang-jq", "lang-json", "lang-julia", "lang-kotlin", "lang-lean", "lang-lua", "lang-make", "lang-matlab", "lang-nix", "lang-objc", "lang-ocaml", "lang-odin", "lang-perl", "lang-php", "lang-powershell", "lang-prolog", "lang-proto", "lang-python", "lang-r", "lang-ruby", "lang-rust", "lang-scala", "lang-scheme", "lang-scss", "lang-solidity", "lang-sql", "lang-starlark", "lang-swift", "lang-toml", "lang-tsx", "lang-typescript", "lang-verilog", "lang-vhdl", "lang-vim", "lang-x86asm", "lang-xml", "lang-yaml", "lang-zig", "lang-zsh"] }
|
||||
askama = "0.16.0"
|
||||
async-trait = "0.1.92"
|
||||
axum = "0.8.9"
|
||||
axum-login = { git = "https://github.com/maxcountryman/axum-login.git", rev = "151c72d7a1b4646830f86b4332e6bd6e34d719a7", version = "0.18.0" }
|
||||
base64 = "0.23.1"
|
||||
betlang = "0.1.1"
|
||||
clap = { version = "4.6.6", features = ["derive"] }
|
||||
dom_smoothie = "0.18.0"
|
||||
epub-builder = "0.8.3"
|
||||
|
||||
Reference in New Issue
Block a user