Commit de80a04
committed
Fix syntax highlighting
Before we switched to kramdown, our syntax highlighting was handled by
a combination of pygments and highlight.js. Basically, pygments output
some esoteric classes throughout each code block, and it also output
the language of the code block (from markdown) into the html.
Highlight.js then read this language indicator, used it to do its own
parsing, and added a different set of classes to each code block. Then,
our css mostly used the highlight.js class names to do the styling, but
we occasionally took advantage of the pygments ones too to make the
styling more precise than just highlight’s classes would have allowed.
Then, with the switch to kramdown, we had to switch our syntax
highlighter from pygments to rouge. Rouge output the same class names
as pygments but, crucially, it didn’t pass through the language name of
each code block to the HTML. That meant that highlight.js had to detect
each automatically language, rather than reading the language code.
That wouldn’t have been a problem except that many of our json code
blocks aren’t strictly json (e.g. they contain comments) and we’d been
using the language code in the HTML to force highlight.js to parse them
as JSON anyway. With that language code gone, highlight.js was failing
to identify the language and so wasn’t highlighting the code at all.
We could’ve tried a few things:
1. Sending a PR to rouge to output the language tag. Even if this PR
were accepted, though, the updated rouge dependency wouldn’t have been
adopted by github pages until after redcarpets support was turned off,
so our highlighting would’ve been broken until then.
2. Pass through the language code some other way. E.g., write `<pre>`
tags manually in our markdown with the relevant class name. This
could’ve worked, but it would have made authoring the markdown messier,
and harder for others to contribute, so I didn’t want to do that.
3. Get highlight.js to auto detect and parse our malformed json
correctly, so that the language codes are unnecessary.
I went with option 3, replacing highlight’s built-in json language
definition with a new definition called “jsonlike” which works on our
site. Then, this commit includes the raw, edited highlight source files
and an updated build. Note: this build uses highlight 8.9.1, because
version 9 contained some backwards-incompatible class name changes.
Lastly, this commit includes some css tweaks to match rouge’s small
changes in the HTML wrapping highlighted code blocks, and our new
highlighting strategy more accurately categorizing comments.1 parent 12931a4 commit de80a04
File tree
407 files changed
+21206
-28
lines changed- _format/1.0
- javascripts
- highlight.customized
- demo
- docs
- _static
- _templates
- src
- languages
- styles
- test
- api
- detect
- 1c
- accesslog
- actionscript
- apache
- applescript
- armasm
- asciidoc
- aspectj
- autohotkey
- autoit
- avrasm
- axapta
- bash
- brainfuck
- cal
- capnproto
- ceylon
- clojure-repl
- clojure
- cmake
- coffeescript
- cpp
- crmsh
- crystal
- css
- cs
- dart
- delphi
- diff
- django
- dns
- dockerfile
- dos
- dust
- d
- elixir
- elm
- erb
- erlang-repl
- erlang
- fix
- fortran
- fsharp
- gams
- gcode
- gherkin
- glsl
- golo
- go
- gradle
- groovy
- haml
- handlebars
- haskell
- haxe
- http
- inform7
- ini
- irpf90
- javascript
- java
- jsonlike
- julia
- kotlin
- lasso
- less
- lisp
- livecodeserver
- livescript
- lua
- makefile
- markdown
- mathematica
- matlab
- mel
- mercury
- mizar
- mojolicious
- monkey
- nginx
- nimrod
- nix
- nsis
- objectivec
- ocaml
- openscad
- oxygene
- parser3
- perl
- pf
- php
- powershell
- processing
- profile
- prolog
- protobuf
- puppet
- python
- q
- rib
- roboconf
- rsl
- ruby
- ruleslanguage
- rust
- r
- scala
- scheme
- scilab
- scss
- smali
- smalltalk
- sml
- sqf
- sql
- stata
- step21
- stylus
- swift
- tcl
- tex
- thrift
- tp
- twig
- typescript
- vala
- vbnet
- vbscript-html
- vbscript
- verilog
- vhdl
- vim
- x86asm
- xl
- xml
- xquery
- zephir
- expect
- markup
- accesslog
- aspectj
- ceylon
- clojure
- coffeescript
- cpp
- crmsh
- crystal
- cs
- dockerfile
- elixir
- fortran
- fsharp
- go
- haml
- haskell
- http
- javascript
- java
- kotlin
- lasso
- lisp
- matlab
- ocaml
- php
- python
- ruby
- rust
- swift
- twig
- typescript
- special
- tools
- stylesheets
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
407 files changed
+21206
-28
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
518 | 518 | | |
519 | 519 | | |
520 | 520 | | |
521 | | - | |
| 521 | + | |
522 | 522 | | |
523 | 523 | | |
524 | 524 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
0 commit comments