Syntax Highlighting
What about the syntax
Kitabu uses Route as the syntax highlight formatter. It emits an output compatible with stylesheets designed for pygments, the Python library used by many.
To highlight a code block, use the fenced block syntax. The following example would be formatted as Ruby.
```ruby
class User
attr_accessor :name, :email
def initialize(name, email)
@name = name
@email = email
end
end
```
The output would be something like this:
class User
attr_accessor :name, :email
def initialize(name, email)
@name = name
@email = email
end
end
If you’re using Sublime Text, make sure you install the Markdown Extended plugin; it enables code syntax highlighting on your Markdown files.
You can also provide inline options such as line numbers and inline rendering.
```ruby?line_numbers=1
class User
attr_accessor :name, :email
def initialize(name, email)
@name = name
@email = email
end
end
```
This would be rendered like this:
1
2
3
4
5
6
7
8 |
class User
attr_accessor :name, :email
def initialize(name, email)
@name = name
@email = email
end
end
|
Lexers
Rouge comes with dozens of lexers. Check out this list, generated dynamically when you export your e-book.
-
Apache
apache
configuration files for Apache web server
-
AppleScript
applescript
The AppleScript scripting language by Apple Inc. (http://developer.apple.com/applescript/)
-
C
c
The C programming language
-
Clojure
clojure
The Clojure programming language (clojure.org)
-
CoffeeScript
coffeescript
The Coffeescript programming language (coffeescript.org)
-
Common Lisp
common_lisp
The Common Lisp variant of Lisp (common-lisp.net)
-
Config File
conf
A generic lexer for configuration files
-
C++
cpp
The C++ programming language
-
C#
csharp
a multi-paradigm language targeting .NET
-
CSS
css
Cascading Style Sheets, used to style web pages
-
Dart
dart
The Dart programming language (dartlang.com)
-
diff
diff
Lexes unified diffs or patches
-
Elixir
elixir
Elixir language (elixir-lang.org)
-
ERB
erb
Embedded ruby template files
-
Erlang
erlang
The Erlang programming language (erlang.org)
-
Factor
factor
Factor, the practical stack language (factorcode.org)
-
Gherkin
gherkin
A business-readable spec DSL ( github.com/cucumber/cucumber/wiki/Gherkin )
-
Go
go
The Go programming language (http://golang.org)
-
Groovy
groovy
The Groovy programming language (groovy.codehaus.org)
-
Haml
haml
The Haml templating system for Ruby (haml.info)
-
Handlebars
handlebars
the Handlebars and Mustache templating languages
-
Haskell
haskell
The Haskell programming language (haskell.org)
-
HTML
html
HTML, the markup language of the web
-
HTTP
http
http requests and responses
-
INI
ini
the INI configuration format
-
Io
io
The IO programming language (http://iolanguage.com)
-
Java
java
The Java programming language (java.com)
-
JavaScript
javascript
JavaScript, the browser scripting language
-
Json
json
JavaScript Object Notation (json.org)
-
Liquid
liquid
Liquid is a templating engine for Ruby (liquidmarkup.org)
-
Literate CoffeeScript
literate_coffeescript
Literate coffeescript
-
Literate Haskell
literate_haskell
Literate haskell
-
LLVM
llvm
The LLVM Compiler Infrastructure (http://llvm.org/)
-
Lua
lua
Lua (http://www.lua.org)
-
Make
make
Makefile syntax
-
Markdown
markdown
Markdown, a light-weight markup language for authors
-
MATLAB
matlab
Matlab
-
MoonScript
moonscript
Moonscript (http://www.moonscript.org)
-
nginx
nginx
configuration files for the nginx web server (nginx.org)
-
Nim
nim
The Nim programming language (http://nim-lang.org/)
-
Objective-C
objective_c
an extension of C commonly used to write Apple software
-
OCaml
ocaml
Objective CAML (ocaml.org)
-
Perl
perl
The Perl scripting language (perl.org)
-
PHP
php
The PHP scripting language (php.net)
-
Plain Text
plaintext
A boring lexer that doesn’t highlight anything
-
Prolog
prolog
The Prolog programming language (http://en.wikipedia.org/wiki/Prolog)
-
.properties
properties
.properties config files for Java
-
Puppet
puppet
The Puppet configuration management language (puppetlabs.org)
-
Python
python
The Python programming language (python.org)
-
QML
qml
QML, a UI markup language
-
R
r
The R statistics language (r-project.org)
-
Racket
racket
Racket is a Lisp descended from Scheme (racket-lang.org)
-
Ruby
ruby
The Ruby programming language (ruby-lang.org)
-
Rust
rust
The Rust programming language (rust-lang.org)
-
Sass
sass
The Sass stylesheet language language (sass-lang.com)
-
Scala
scala
The Scala programming language (scala-lang.org)
-
Scheme
scheme
The Scheme variant of Lisp
-
SCSS
scss
SCSS stylesheets (sass-lang.com)
-
sed
sed
sed, the ultimate stream editor
-
shell
shell
Various shell languages, including sh and bash
-
Slim
slim
The Slim template language
-
Smalltalk
smalltalk
The Smalltalk programming language
-
SML
sml
Standard ML
-
SQL
sql
Structured Query Language, for relational databases
-
Swift
swift
Multi paradigm, compiled programming language developed by Apple for iOS and OS X development. (developer.apple.com/swift)
-
Tcl
tcl
The Tool Command Language (tcl.tk)
-
TeX
tex
The TeX typesetting system
-
TOML
toml
the TOML configuration format (https://github.com/mojombo/toml)
-
Visual Basic
vb
Visual Basic
-
VimL
viml
VimL, the scripting language for the Vim editor (vim.org)
-
XML
xml
XML
-
YAML
yaml
Yaml Ain’t Markup Language (yaml.org)
And if what you want is not on this list, make you open a ticket on the project.