-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v0.13.0: built-in syntax highlighting
- Loading branch information
Showing
31 changed files
with
493 additions
and
347 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* Derived from https://github.com/richleland/pygments-css */ | ||
|
||
.codehilite { | ||
color: $code-color; | ||
.hll { background-color: #ffffcc } | ||
.c { color: #0099FF; font-style: italic } /* Comment */ | ||
.err { color: #AA0000; } /* Error */ | ||
.k { color: #006699; font-weight: bold } /* Keyword */ | ||
.o { color: #555555 } /* Operator */ | ||
.ch { color: #0099FF; font-style: italic } /* Comment.Hashbang */ | ||
.cm { color: #0099FF; font-style: italic } /* Comment.Multiline */ | ||
.cp { color: #009999 } /* Comment.Preproc */ | ||
.cpf { color: #0099FF; font-style: italic } /* Comment.PreprocFile */ | ||
.c1 { color: #0099FF; font-style: italic } /* Comment.Single */ | ||
.cs { color: #0099FF; font-weight: bold; font-style: italic } /* Comment.Special */ | ||
.gd { background-color: #FFCCCC; border: 1px solid #CC0000 } /* Generic.Deleted */ | ||
.ge { font-style: italic } /* Generic.Emph */ | ||
.gr { color: #FF0000 } /* Generic.Error */ | ||
.gh { color: #003300; font-weight: bold } /* Generic.Heading */ | ||
.gi { background-color: #CCFFCC; border: 1px solid #00CC00 } /* Generic.Inserted */ | ||
.go { color: #AAAAAA } /* Generic.Output */ | ||
.gp { color: #000099; font-weight: bold } /* Generic.Prompt */ | ||
.gs { font-weight: bold } /* Generic.Strong */ | ||
.gu { color: #003300; font-weight: bold } /* Generic.Subheading */ | ||
.gt { color: #99CC66 } /* Generic.Traceback */ | ||
.kc { color: #006699; font-weight: bold } /* Keyword.Constant */ | ||
.kd { color: #006699; font-weight: bold } /* Keyword.Declaration */ | ||
.kn { color: #006699; font-weight: bold } /* Keyword.Namespace */ | ||
.kp { color: #006699 } /* Keyword.Pseudo */ | ||
.kr { color: #006699; font-weight: bold } /* Keyword.Reserved */ | ||
.kt { color: #007788; font-weight: bold } /* Keyword.Type */ | ||
.m { color: #FF6600 } /* Literal.Number */ | ||
.s { color: #CC3300 } /* Literal.String */ | ||
.na { color: #330099 } /* Name.Attribute */ | ||
.nb { color: #336666 } /* Name.Builtin */ | ||
.nc { color: #00AA88; font-weight: bold } /* Name.Class */ | ||
.no { color: #336600 } /* Name.Constant */ | ||
.nd { color: #9999FF } /* Name.Decorator */ | ||
.ni { color: #999999; font-weight: bold } /* Name.Entity */ | ||
.ne { color: #CC0000; font-weight: bold } /* Name.Exception */ | ||
.nf { color: #CC00FF } /* Name.Function */ | ||
.nl { color: #9999FF } /* Name.Label */ | ||
.nn { color: #00CCFF; font-weight: bold } /* Name.Namespace */ | ||
.nt { color: #330099; font-weight: bold } /* Name.Tag */ | ||
.nv { color: #003333 } /* Name.Variable */ | ||
.ow { color: #000000; font-weight: bold } /* Operator.Word */ | ||
.w { color: #bbbbbb } /* Text.Whitespace */ | ||
.mb { color: #FF6600 } /* Literal.Number.Bin */ | ||
.mf { color: #FF6600 } /* Literal.Number.Float */ | ||
.mh { color: #FF6600 } /* Literal.Number.Hex */ | ||
.mi { color: #FF6600 } /* Literal.Number.Integer */ | ||
.mo { color: #FF6600 } /* Literal.Number.Oct */ | ||
.sa { color: #CC3300 } /* Literal.String.Affix */ | ||
.sb { color: #CC3300 } /* Literal.String.Backtick */ | ||
.sc { color: #CC3300 } /* Literal.String.Char */ | ||
.dl { color: #CC3300 } /* Literal.String.Delimiter */ | ||
.sd { color: #CC3300; font-style: italic } /* Literal.String.Doc */ | ||
.s2 { color: #CC3300 } /* Literal.String.Double */ | ||
.se { color: #CC3300; font-weight: bold } /* Literal.String.Escape */ | ||
.sh { color: #CC3300 } /* Literal.String.Heredoc */ | ||
.si { color: #AA0000 } /* Literal.String.Interpol */ | ||
.sx { color: #CC3300 } /* Literal.String.Other */ | ||
.sr { color: #33AAAA } /* Literal.String.Regex */ | ||
.s1 { color: #CC3300 } /* Literal.String.Single */ | ||
.ss { color: #FFCC33 } /* Literal.String.Symbol */ | ||
.bp { color: #336666 } /* Name.Builtin.Pseudo */ | ||
.fm { color: #CC00FF } /* Name.Function.Magic */ | ||
.vc { color: #003333 } /* Name.Variable.Class */ | ||
.vg { color: #003333 } /* Name.Variable.Global */ | ||
.vi { color: #003333 } /* Name.Variable.Instance */ | ||
.vm { color: #003333 } /* Name.Variable.Magic */ | ||
.il { color: #FF6600 } /* Literal.Number.Integer.Long */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Font Stacks ================================================================= | ||
@font-face { | ||
font-family: 'Roboto'; | ||
font-style: normal; | ||
font-weight: 400; | ||
font-display: swap; | ||
src: local("Roboto"), url("../font/Roboto-Regular.woff2") format('woff2'), url(https://fonts.gstatic.com/s/roboto/v19/KFOmCnqEu92Fr1Mu4mxK.woff2) format('woff2'); | ||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; | ||
} | ||
@font-face { | ||
font-family: 'Roboto'; | ||
font-style: normal; | ||
font-weight: 700; | ||
font-display: swap; | ||
src: local('Roboto Bold'), local('Roboto-Bold'), url("../font/Roboto-Bold.woff2") format('woff2'), url(https://fonts.gstatic.com/s/roboto/v19/KFOlCnqEu92Fr1MmWUlfBBc4.woff2) format('woff2'); | ||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; | ||
} | ||
$font-family-monospace: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace; | ||
$font-family-sans-serif: -apple-system, system-ui, 'Roboto', sans-serif; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '0.13.0-a2' | ||
__version__ = '0.13.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Code Highlighting | ||
|
||
Dactyl automatically adds syntax highlighting to code blocks when it parses Markdown, using the [Pygments](https://pygments.org/)-derived [CodeHilite](https://python-markdown.github.io/extensions/code_hilite/) extension. Parsing the syntax highlighting at compile time like this is faster and less work for readers' computers than in-browser syntax highlighting such as using [highlight.js](https://highlightjs.readthedocs.io/en/latest/api.html). (If you prefer highlight.js's output, though, you can still run it to overwrite Dactyl's syntax highlighting.) | ||
|
||
Example of a code segment colored by Dactyl's built-in highlighting: | ||
|
||
```py | ||
unacceptable_chars = re.compile(r"[^A-Za-z0-9._ ]+") | ||
whitespace_regex = re.compile(r"\s+") | ||
def slugify(s): | ||
s = re.sub(unacceptable_chars, "", s) | ||
s = re.sub(whitespace_regex, "_", s) | ||
if not s: | ||
s = "_" | ||
return s | ||
``` | ||
|
||
## Requirements | ||
|
||
The highlighting requires a stylesheet to define the colors and styles used. Dactyl's default stylesheet includes an example or you can define your own. You can output one of Pygments' default stylesheets from the commandline as in the following example: | ||
|
||
```sh | ||
$ pygmentize -S default -f html -a .codehilite > default.css | ||
``` | ||
|
||
## Languages | ||
|
||
Dactyl's code highlighting supports the same [programming languages that Pygments supports](https://pygments.org/languages/). By default it attempts to auto-detect the language, but you can add a language code to the first line of a fenced code block to specify the language. | ||
|
||
Example code: | ||
|
||
```js | ||
function slugify(s) { | ||
const unacceptable_chars = /[^A-Za-z0-9._ ]+/ | ||
const whitespace_regex = /\s+/ | ||
s = s.replace(unacceptable_chars, "") | ||
s = s.replace(whitespace_regex, "_") | ||
s = s.toLowerCase() | ||
if (!s) { | ||
s = "_" | ||
} | ||
return s | ||
} | ||
``` | ||
|
||
Output: | ||
|
||
```js | ||
function slugify(s) { | ||
const unacceptable_chars = /[^A-Za-z0-9._ ]+/ | ||
const whitespace_regex = /\s+/ | ||
s = s.replace(unacceptable_chars, "") | ||
s = s.replace(whitespace_regex, "_") | ||
s = s.toLowerCase() | ||
if (!s) { | ||
s = "_" | ||
} | ||
return s | ||
} | ||
``` | ||
|
||
## Disabling | ||
|
||
If for some reason you want to turn off syntax highlighting, you can add `no_highlighting: true` to your config file at the global, target, or page level. |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
template: template-extends.html | ||
related_links: | ||
- with-frontmatter.html | ||
- code-highlighting.html | ||
--- | ||
# Template Extension | ||
|
||
You can extend or include the base templates built into Dactyl. | ||
|
||
For example, this page replaces the right-hand sidebar with a "related pages" module. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Hierarchy Demo | ||
|
||
This page demonstrates how you can use Dactyl's built-in hierarchy features to generate a table of contents automatically. | ||
|
||
Source: | ||
|
||
```jinja | ||
<ul> | ||
{{"{%"}} macro page_w_children(pg) {{"%}"}} | ||
<li class="dactyl-toc-entry"><a href="{{"{{"}} pg.html {{"}}"}}">{{"{{"}} pg.name {{"}}"}}</a></li> | ||
{{"{%"}} if pg.children {{"%}"}} | ||
<ul> | ||
{{"{%"}} for child in pg.children {{"%}"}} | ||
{{"{{"}} page_w_children(child) {{"}}"}} | ||
{{"{%"}} endfor {{"%}"}} | ||
</ul> | ||
{{"{%"}} endif {{"%}"}} | ||
{{"{%"}} endmacro {{"%}"}} | ||
{{"{%"}} for page in pages {{"%}"}} | ||
{{"{%"}} if page.parent is undefined {{"%}"}} | ||
{{"{{"}} page_w_children(page) {{"}}"}} | ||
{{"{%"}} endif {{"%}"}} | ||
{{"{%"}} endfor {{"%}"}} | ||
</ul> | ||
``` | ||
|
||
Results: |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Extending Dactyl | ||
|
||
Dactyl is designed to be customized and extended to each individual project's needs. These pages demonstrate some ways you can extend Dactyl. |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.