Skip to content

Commit 1c46572

Browse files
committed
Use pygments-pre-commit to highlight docs
1 parent fc6b022 commit 1c46572

File tree

3 files changed

+75
-38
lines changed

3 files changed

+75
-38
lines changed

index.mako

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,26 @@ The first time pre-commit runs on a file it will automatically download,
253253
install, and run the hook. Note that running a hook for the first time may be
254254
slow. For example: If the machine does not have node installed, pre-commit
255255
will download and build a copy of node.
256+
257+
```pre-commit
258+
$ pre-commit install
259+
pre-commit installed at /home/asottile/workspace/pytest/.git/hooks/pre-commit
260+
$ git commit -m "Add super awesome feature"
261+
black....................................................................Passed
262+
blacken-docs.........................................(no files to check)Skipped
263+
Trim Trailing Whitespace.................................................Passed
264+
Fix End of Files.........................................................Passed
265+
Check Yaml...........................................(no files to check)Skipped
266+
Debug Statements (Python)................................................Passed
267+
Flake8...................................................................Passed
268+
Reorder python imports...................................................Passed
269+
pyupgrade................................................................Passed
270+
rst ``code`` is two backticks........................(no files to check)Skipped
271+
rst..................................................(no files to check)Skipped
272+
changelog filenames..................................(no files to check)Skipped
273+
[master 146c6c2c] Add super awesome feature
274+
1 file changed, 1 insertion(+)
275+
```
256276
''')}
257277
</div>
258278

@@ -352,7 +372,7 @@ directory while developing hooks.
352372
enabling a quick way to try out a repository. Here's how one might work
353373
interactively:
354374
355-
```console
375+
```pre-commit
356376
~/work/hook-repo $ git checkout origin/master -b feature
357377
358378
# ... make some changes
@@ -1052,7 +1072,7 @@ whitelisted.
10521072
When cloning repos over ssh (`repo: git@github.com:...`), `git` requires the
10531073
`SSH_AUTH_SOCK` variable and will otherwise fail:
10541074
1055-
```
1075+
```pre-commit
10561076
[INFO] Initializing environment for git@github.com:pre-commit/pre-commit-hooks.
10571077
An unexpected error has occurred: CalledProcessError: Command: ('/usr/bin/git', 'clone', '--no-checkout', 'git@github.com:pre-commit/pre-commit-hooks', '/home/asottile/.cache/pre-commit/repofdkwkq_v')
10581078
Return code: 128

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ libsass
44
markdown-code-blocks
55
markdown-to-presentation>=0.0.12
66
pre-commit>=0.13.6
7+
pygments-pre-commit

scss/main.scss

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -145,39 +145,55 @@ h1,
145145
}
146146

147147
// vs.css: https://github.com/richleland/pygments-css
148-
.highlight .hll { background-color: #ffc; }
149-
.highlight .c { color: #008000; } /* Comment */
150-
.highlight .err { border: 1px solid #ff0; } /* Error */
151-
.highlight .k { color: #00f; } /* Keyword */
152-
.highlight .cm { color: #008000; } /* Comment.Multiline */
153-
.highlight .cp { color: #00f; } /* Comment.Preproc */
154-
.highlight .c1 { color: #008000; } /* Comment.Single */
155-
.highlight .cs { color: #008000; } /* Comment.Special */
156-
.highlight .ge { font-style: italic; } /* Generic.Emph */
157-
.highlight .gh { font-weight: bold; } /* Generic.Heading */
158-
.highlight .gp { font-weight: bold; } /* Generic.Prompt */
159-
.highlight .gs { font-weight: bold; } /* Generic.Strong */
160-
.highlight .gu { font-weight: bold; } /* Generic.Subheading */
161-
.highlight .kc { color: #00f; } /* Keyword.Constant */
162-
.highlight .kd { color: #00f; } /* Keyword.Declaration */
163-
.highlight .kn { color: #00f; } /* Keyword.Namespace */
164-
.highlight .kp { color: #00f; } /* Keyword.Pseudo */
165-
.highlight .kr { color: #00f; } /* Keyword.Reserved */
166-
.highlight .kt { color: #2b91af; } /* Keyword.Type */
167-
.highlight .s { color: #a31515; } /* Literal.String */
168-
.highlight .nc { color: #2b91af; } /* Name.Class */
169-
.highlight .ow { color: #00f; } /* Operator.Word */
170-
.highlight .sb { color: #a31515; } /* Literal.String.Backtick */
171-
.highlight .sc { color: #a31515; } /* Literal.String.Char */
172-
.highlight .sd { color: #a31515; } /* Literal.String.Doc */
173-
.highlight .s2 { color: #a31515; } /* Literal.String.Double */
174-
.highlight .se { color: #a31515; } /* Literal.String.Escape */
175-
.highlight .sh { color: #a31515; } /* Literal.String.Heredoc */
176-
.highlight .si { color: #a31515; } /* Literal.String.Interpol */
177-
.highlight .sx { color: #a31515; } /* Literal.String.Other */
178-
.highlight .sr { color: #a31515; } /* Literal.String.Regex */
179-
.highlight .s1 { color: #a31515; } /* Literal.String.Single */
180-
.highlight .ss { color: #a31515; } /* Literal.String.Symbol */
181-
// git diff highlights
182-
.highlight .gi { color: #070; }
183-
.highlight .gd { color: #911; }
148+
.highlight.yaml,
149+
.highlight.ini,
150+
.highlight.bash {
151+
.hll { background-color: #ffc; }
152+
.c { color: #008000; } /* Comment */
153+
.err { border: 1px solid #ff0; } /* Error */
154+
.k { color: #00f; } /* Keyword */
155+
.cm { color: #008000; } /* Comment.Multiline */
156+
.cp { color: #00f; } /* Comment.Preproc */
157+
.c1 { color: #008000; } /* Comment.Single */
158+
.cs { color: #008000; } /* Comment.Special */
159+
.ge { font-style: italic; } /* Generic.Emph */
160+
.gh { font-weight: bold; } /* Generic.Heading */
161+
.gp { font-weight: bold; } /* Generic.Prompt */
162+
.gs { font-weight: bold; } /* Generic.Strong */
163+
.gu { font-weight: bold; } /* Generic.Subheading */
164+
.kc { color: #00f; } /* Keyword.Constant */
165+
.kd { color: #00f; } /* Keyword.Declaration */
166+
.kn { color: #00f; } /* Keyword.Namespace */
167+
.kp { color: #00f; } /* Keyword.Pseudo */
168+
.kr { color: #00f; } /* Keyword.Reserved */
169+
.kt { color: #2b91af; } /* Keyword.Type */
170+
.s { color: #a31515; } /* Literal.String */
171+
.nc { color: #2b91af; } /* Name.Class */
172+
.ow { color: #00f; } /* Operator.Word */
173+
.sb { color: #a31515; } /* Literal.String.Backtick */
174+
.sc { color: #a31515; } /* Literal.String.Char */
175+
.sd { color: #a31515; } /* Literal.String.Doc */
176+
.s2 { color: #a31515; } /* Literal.String.Double */
177+
.se { color: #a31515; } /* Literal.String.Escape */
178+
.sh { color: #a31515; } /* Literal.String.Heredoc */
179+
.si { color: #a31515; } /* Literal.String.Interpol */
180+
.sx { color: #a31515; } /* Literal.String.Other */
181+
.sr { color: #a31515; } /* Literal.String.Regex */
182+
.s1 { color: #a31515; } /* Literal.String.Single */
183+
.ss { color: #a31515; } /* Literal.String.Symbol */
184+
// git diff highlights
185+
.gi { color: #070; }
186+
.gd { color: #911; }
187+
}
188+
189+
// pygments-pre-commit
190+
.highlight.pre-commit,
191+
.highlight.console {
192+
pre { border: 0; background-color: #2d0922; color: #fff; }
193+
194+
// scss-lint:disable SelectorFormat
195+
.-Color-BGRed { background-color: #c00; }
196+
.-Color-BGGreen { background-color: #4e9a06; }
197+
.-Color-BlackBGYellow { background-color: #c4a000; color: #2e3436; }
198+
.-Color-BlackBGCyan { background-color: #06989a; color: #2e3436; }
199+
}

0 commit comments

Comments
 (0)