mirror of
https://github.com/danbee/danbarber.me
synced 2025-03-04 08:59:10 +00:00
Fix up code blocks with syntax highlighting.
This commit is contained in:
parent
5f5b397038
commit
1b20f7717d
@ -1,160 +0,0 @@
|
|||||||
.highlight
|
|
||||||
background: #ffffff
|
|
||||||
.c
|
|
||||||
color: #999988
|
|
||||||
font-style: italic
|
|
||||||
.err
|
|
||||||
color: #a61717
|
|
||||||
background-color: #e3d2d2
|
|
||||||
.k, .o
|
|
||||||
font-weight: bold
|
|
||||||
.cm
|
|
||||||
color: #999988
|
|
||||||
font-style: italic
|
|
||||||
.cp
|
|
||||||
color: #999999
|
|
||||||
font-weight: bold
|
|
||||||
.c1
|
|
||||||
color: #999988
|
|
||||||
font-style: italic
|
|
||||||
.cs
|
|
||||||
color: #999999
|
|
||||||
font-weight: bold
|
|
||||||
font-style: italic
|
|
||||||
.gd
|
|
||||||
color: #000000
|
|
||||||
background-color: #ffdddd
|
|
||||||
.x
|
|
||||||
color: #000000
|
|
||||||
background-color: #ffaaaa
|
|
||||||
.ge
|
|
||||||
font-style: italic
|
|
||||||
.gr
|
|
||||||
color: #aa0000
|
|
||||||
.gh
|
|
||||||
color: #999999
|
|
||||||
.gi
|
|
||||||
color: #000000
|
|
||||||
background-color: #ddffdd
|
|
||||||
.x
|
|
||||||
color: #000000
|
|
||||||
background-color: #aaffaa
|
|
||||||
.go
|
|
||||||
color: #888888
|
|
||||||
.gp
|
|
||||||
color: #555555
|
|
||||||
.gs
|
|
||||||
font-weight: bold
|
|
||||||
.gu
|
|
||||||
color: #aaaaaa
|
|
||||||
.gt
|
|
||||||
color: #aa0000
|
|
||||||
.kc, .kd, .kp, .kr
|
|
||||||
font-weight: bold
|
|
||||||
.kt
|
|
||||||
color: #445588
|
|
||||||
font-weight: bold
|
|
||||||
.m
|
|
||||||
color: #009999
|
|
||||||
.s
|
|
||||||
color: #dd1144
|
|
||||||
.na
|
|
||||||
color: teal
|
|
||||||
.nb
|
|
||||||
color: #0086b3
|
|
||||||
.nc
|
|
||||||
color: #445588
|
|
||||||
font-weight: bold
|
|
||||||
.no
|
|
||||||
color: teal
|
|
||||||
.ni
|
|
||||||
color: purple
|
|
||||||
.ne, .nf
|
|
||||||
color: #990000
|
|
||||||
font-weight: bold
|
|
||||||
.nn
|
|
||||||
color: #555555
|
|
||||||
.nt
|
|
||||||
color: navy
|
|
||||||
.nv
|
|
||||||
color: teal
|
|
||||||
.ow
|
|
||||||
font-weight: bold
|
|
||||||
.w
|
|
||||||
color: #bbbbbb
|
|
||||||
.mf, .mh, .mi, .mo
|
|
||||||
color: #009999
|
|
||||||
.sb, .sc, .sd, .s2, .se, .sh, .si, .sx
|
|
||||||
color: #dd1144
|
|
||||||
.sr
|
|
||||||
color: #009926
|
|
||||||
.s1
|
|
||||||
color: #dd1144
|
|
||||||
.ss
|
|
||||||
color: #990073
|
|
||||||
.bp
|
|
||||||
color: #999999
|
|
||||||
.vc, .vg, .vi
|
|
||||||
color: teal
|
|
||||||
.il
|
|
||||||
color: #009999
|
|
||||||
|
|
||||||
/* Comment
|
|
||||||
/* Error
|
|
||||||
/* Keyword
|
|
||||||
/* Operator
|
|
||||||
/* Comment.Multiline
|
|
||||||
/* Comment.Preproc
|
|
||||||
/* Comment.Single
|
|
||||||
/* Comment.Special
|
|
||||||
/* Generic.Deleted
|
|
||||||
/* Generic.Deleted.Specific
|
|
||||||
/* Generic.Emph
|
|
||||||
/* Generic.Error
|
|
||||||
/* Generic.Heading
|
|
||||||
/* Generic.Inserted
|
|
||||||
/* Generic.Inserted.Specific
|
|
||||||
/* Generic.Output
|
|
||||||
/* Generic.Prompt
|
|
||||||
/* Generic.Strong
|
|
||||||
/* Generic.Subheading
|
|
||||||
/* Generic.Traceback
|
|
||||||
/* Keyword.Constant
|
|
||||||
/* Keyword.Declaration
|
|
||||||
/* Keyword.Pseudo
|
|
||||||
/* Keyword.Reserved
|
|
||||||
/* Keyword.Type
|
|
||||||
/* Literal.Number
|
|
||||||
/* Literal.String
|
|
||||||
/* Name.Attribute
|
|
||||||
/* Name.Builtin
|
|
||||||
/* Name.Class
|
|
||||||
/* Name.Constant
|
|
||||||
/* Name.Entity
|
|
||||||
/* Name.Exception
|
|
||||||
/* Name.Function
|
|
||||||
/* Name.Namespace
|
|
||||||
/* Name.Tag
|
|
||||||
/* Name.Variable
|
|
||||||
/* Operator.Word
|
|
||||||
/* Text.Whitespace
|
|
||||||
/* Literal.Number.Float
|
|
||||||
/* Literal.Number.Hex
|
|
||||||
/* Literal.Number.Integer
|
|
||||||
/* Literal.Number.Oct
|
|
||||||
/* Literal.String.Backtick
|
|
||||||
/* Literal.String.Char
|
|
||||||
/* Literal.String.Doc
|
|
||||||
/* Literal.String.Double
|
|
||||||
/* Literal.String.Escape
|
|
||||||
/* Literal.String.Heredoc
|
|
||||||
/* Literal.String.Interpol
|
|
||||||
/* Literal.String.Other
|
|
||||||
/* Literal.String.Regex
|
|
||||||
/* Literal.String.Single
|
|
||||||
/* Literal.String.Symbol
|
|
||||||
/* Name.Builtin.Pseudo
|
|
||||||
/* Name.Variable.Class
|
|
||||||
/* Name.Variable.Global
|
|
||||||
/* Name.Variable.Instance
|
|
||||||
/* Literal.Number.Integer.Long
|
|
||||||
@ -16,10 +16,10 @@ $header-subtitle-font-family: $heading-font-family !default
|
|||||||
*Though I'd like a smidgeon of credit, so just leave this bit in here. K?
|
*Though I'd like a smidgeon of credit, so just leave this bit in here. K?
|
||||||
|
|
||||||
/*Pick Your Fonts
|
/*Pick Your Fonts
|
||||||
body, h4, h5, h6, .run-in, dt
|
body, h5, h6, .run-in, dt
|
||||||
font-family: $serif
|
font-family: $serif
|
||||||
|
|
||||||
h1, h2, h3, .pullquote, .sidenote h1, aside h1, .pullquote, .drop-cap, cite
|
h1, h2, h3, h4, .pullquote, .sidenote h1, aside h1, .pullquote, .drop-cap, cite
|
||||||
font-family: $heading-font-family
|
font-family: $heading-font-family
|
||||||
|
|
||||||
/*Nav Fonts
|
/*Nav Fonts
|
||||||
@ -54,13 +54,16 @@ h3
|
|||||||
font-size: 1.125em
|
font-size: 1.125em
|
||||||
|
|
||||||
h4
|
h4
|
||||||
font-weight: bold
|
|
||||||
font-size: 1em
|
font-size: 1em
|
||||||
|
|
||||||
h1, h2, h3, h4, h5, h6
|
h1, h2, h3
|
||||||
font-weight: 500
|
font-weight: 500
|
||||||
text-rendering: optimizelegibility
|
text-rendering: optimizelegibility
|
||||||
|
|
||||||
|
h4, h5, h6
|
||||||
|
font-weight: 700
|
||||||
|
text-rendering: optimizelegibility
|
||||||
|
|
||||||
article h1
|
article h1
|
||||||
font-size: 1.5em
|
font-size: 1.5em
|
||||||
|
|
||||||
@ -127,10 +130,25 @@ cite:before
|
|||||||
|
|
||||||
pre,code,tt
|
pre,code,tt
|
||||||
font-family: $mono
|
font-family: $mono
|
||||||
font-weight: 300
|
font-weight: 500
|
||||||
|
|
||||||
|
code
|
||||||
|
border: 1px solid #ddd
|
||||||
|
border-radius: 0.25em
|
||||||
|
display: inline-block
|
||||||
|
font-size: 0.75em
|
||||||
|
line-height: 1.5em
|
||||||
|
padding: 0 0.3em
|
||||||
|
|
||||||
|
.highlight
|
||||||
|
margin: 1.5em 0
|
||||||
|
overflow: auto
|
||||||
|
padding: 0.5em 0.75em
|
||||||
|
border-radius: 0.25em
|
||||||
pre
|
pre
|
||||||
margin: 1.5em
|
margin: 0
|
||||||
|
code
|
||||||
|
border: none
|
||||||
|
|
||||||
dl
|
dl
|
||||||
margin: 1.75em 0 1.75em
|
margin: 1.75em 0 1.75em
|
||||||
|
|||||||
117
_assets/stylesheets/lib/solarized-dark.css.scss
Normal file
117
_assets/stylesheets/lib/solarized-dark.css.scss
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
/* Solarized Dark
|
||||||
|
|
||||||
|
For use with Jekyll and Pygments
|
||||||
|
|
||||||
|
http://ethanschoonover.com/solarized
|
||||||
|
|
||||||
|
SOLARIZED HEX ROLE
|
||||||
|
--------- -------- ------------------------------------------
|
||||||
|
base03 #002b36 background
|
||||||
|
base01 #586e75 comments / secondary content
|
||||||
|
base1 #93a1a1 body text / default code / primary content
|
||||||
|
orange #cb4b16 constants
|
||||||
|
red #dc322f regex, special keywords
|
||||||
|
blue #268bd2 reserved keywords
|
||||||
|
cyan #2aa198 strings, numbers
|
||||||
|
green #859900 operators, other keywords
|
||||||
|
*/
|
||||||
|
|
||||||
|
$base03: #002b36 !default; //darkest blue
|
||||||
|
$base02: #073642 !default; //dark blue
|
||||||
|
$base01: #586e75 !default; //darkest gray
|
||||||
|
$base00: #657b83 !default; //dark gray
|
||||||
|
$base0: #839496 !default; //medium gray
|
||||||
|
$base1: #93a1a1 !default; //medium light gray
|
||||||
|
$base2: #eee8d5 !default; //cream
|
||||||
|
$base3: #fdf6e3 !default; //white
|
||||||
|
|
||||||
|
$solar-yellow: #b58900 !default;
|
||||||
|
$solar-orange: #cb4b16 !default;
|
||||||
|
$solar-red: #dc322f !default;
|
||||||
|
$solar-magenta: #d33682 !default;
|
||||||
|
$solar-violet: #6c71c4 !default;
|
||||||
|
$solar-blue: #268bd2 !default;
|
||||||
|
$solar-cyan: #2aa198 !default;
|
||||||
|
$solar-green: #859900 !default;
|
||||||
|
|
||||||
|
$solarized: dark !default;
|
||||||
|
|
||||||
|
@if $solarized == light {
|
||||||
|
$_base03: $base03; $_base02: $base02; $_base01: $base01; $_base00: $base00; $_base0: $base0; $_base1: $base1; $_base2: $base2; $_base3: $base3;
|
||||||
|
$base03: $_base3; $base02: $_base2; $base01: $_base1; $base00: $_base0; $base0: $_base00; $base1: $_base01; $base2: $_base02; $base3: $_base03;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* non highlighted code colors */
|
||||||
|
$pre-bg: $base03 !default;
|
||||||
|
$pre-border: darken($base02, 5) !default;
|
||||||
|
$pre-color: $base1 !default;
|
||||||
|
|
||||||
|
.highlight { background-color: $base03; color: $base1 }
|
||||||
|
.highlight .c { color: $base01 } /* Comment */
|
||||||
|
.highlight .err { color: $base1 } /* Error */
|
||||||
|
.highlight .g { color: $base1 } /* Generic */
|
||||||
|
.highlight .k { color: $solar-green } /* Keyword */
|
||||||
|
.highlight .l { color: $base1 } /* Literal */
|
||||||
|
.highlight .n { color: $base1 } /* Name */
|
||||||
|
.highlight .o { color: $solar-green } /* Operator */
|
||||||
|
.highlight .x { color: $solar-orange } /* Other */
|
||||||
|
.highlight .p { color: $base1 } /* Punctuation */
|
||||||
|
.highlight .cm { color: $base01 } /* Comment.Multiline */
|
||||||
|
.highlight .cp { color: $solar-green } /* Comment.Preproc */
|
||||||
|
.highlight .c1 { color: $base01 } /* Comment.Single */
|
||||||
|
.highlight .cs { color: $solar-green } /* Comment.Special */
|
||||||
|
.highlight .gd { color: $solar-cyan } /* Generic.Deleted */
|
||||||
|
.highlight .ge { color: $base1; font-style: italic } /* Generic.Emph */
|
||||||
|
.highlight .gr { color: $solar-red } /* Generic.Error */
|
||||||
|
.highlight .gh { color: $solar-orange } /* Generic.Heading */
|
||||||
|
.highlight .gi { color: $solar-green } /* Generic.Inserted */
|
||||||
|
.highlight .go { color: $base1 } /* Generic.Output */
|
||||||
|
.highlight .gp { color: $base1 } /* Generic.Prompt */
|
||||||
|
.highlight .gs { color: $base1; font-weight: bold } /* Generic.Strong */
|
||||||
|
.highlight .gu { color: $solar-orange } /* Generic.Subheading */
|
||||||
|
.highlight .gt { color: $base1 } /* Generic.Traceback */
|
||||||
|
.highlight .kc { color: $solar-orange } /* Keyword.Constant */
|
||||||
|
.highlight .kd { color: $solar-blue } /* Keyword.Declaration */
|
||||||
|
.highlight .kn { color: $solar-green } /* Keyword.Namespace */
|
||||||
|
.highlight .kp { color: $solar-green } /* Keyword.Pseudo */
|
||||||
|
.highlight .kr { color: $solar-blue } /* Keyword.Reserved */
|
||||||
|
.highlight .kt { color: $solar-red } /* Keyword.Type */
|
||||||
|
.highlight .ld { color: $base1 } /* Literal.Date */
|
||||||
|
.highlight .m { color: $solar-cyan } /* Literal.Number */
|
||||||
|
.highlight .s { color: $solar-cyan } /* Literal.String */
|
||||||
|
.highlight .na { color: $base1 } /* Name.Attribute */
|
||||||
|
.highlight .nb { color: $solar-yellow } /* Name.Builtin */
|
||||||
|
.highlight .nc { color: $solar-blue } /* Name.Class */
|
||||||
|
.highlight .no { color: $solar-orange } /* Name.Constant */
|
||||||
|
.highlight .nd { color: $solar-blue } /* Name.Decorator */
|
||||||
|
.highlight .ni { color: $solar-orange } /* Name.Entity */
|
||||||
|
.highlight .ne { color: $solar-orange } /* Name.Exception */
|
||||||
|
.highlight .nf { color: $solar-blue } /* Name.Function */
|
||||||
|
.highlight .nl { color: $base1 } /* Name.Label */
|
||||||
|
.highlight .nn { color: $base1 } /* Name.Namespace */
|
||||||
|
.highlight .nx { color: $base1 } /* Name.Other */
|
||||||
|
.highlight .py { color: $base1 } /* Name.Property */
|
||||||
|
.highlight .nt { color: $solar-blue } /* Name.Tag */
|
||||||
|
.highlight .nv { color: $solar-blue } /* Name.Variable */
|
||||||
|
.highlight .ow { color: $solar-green } /* Operator.Word */
|
||||||
|
.highlight .w { color: $base1 } /* Text.Whitespace */
|
||||||
|
.highlight .mf { color: $solar-cyan } /* Literal.Number.Float */
|
||||||
|
.highlight .mh { color: $solar-cyan } /* Literal.Number.Hex */
|
||||||
|
.highlight .mi { color: $solar-cyan } /* Literal.Number.Integer */
|
||||||
|
.highlight .mo { color: $solar-cyan } /* Literal.Number.Oct */
|
||||||
|
.highlight .sb { color: $base01 } /* Literal.String.Backtick */
|
||||||
|
.highlight .sc { color: $solar-cyan } /* Literal.String.Char */
|
||||||
|
.highlight .sd { color: $base1 } /* Literal.String.Doc */
|
||||||
|
.highlight .s2 { color: $solar-cyan } /* Literal.String.Double */
|
||||||
|
.highlight .se { color: $solar-orange } /* Literal.String.Escape */
|
||||||
|
.highlight .sh { color: $base1 } /* Literal.String.Heredoc */
|
||||||
|
.highlight .si { color: $solar-cyan } /* Literal.String.Interpol */
|
||||||
|
.highlight .sx { color: $solar-cyan } /* Literal.String.Other */
|
||||||
|
.highlight .sr { color: $solar-red } /* Literal.String.Regex */
|
||||||
|
.highlight .s1 { color: $solar-cyan } /* Literal.String.Single */
|
||||||
|
.highlight .ss { color: $solar-cyan } /* Literal.String.Symbol */
|
||||||
|
.highlight .bp { color: $solar-blue } /* Name.Builtin.Pseudo */
|
||||||
|
.highlight .vc { color: $solar-blue } /* Name.Variable.Class */
|
||||||
|
.highlight .vg { color: $solar-blue } /* Name.Variable.Global */
|
||||||
|
.highlight .vi { color: $solar-blue } /* Name.Variable.Instance */
|
||||||
|
.highlight .il { color: $solar-cyan } /* Literal.Number.Integer.Long */
|
||||||
@ -1,57 +0,0 @@
|
|||||||
$base03: #002b36 !default
|
|
||||||
|
|
||||||
//darkest blue
|
|
||||||
$base02: #073642 !default
|
|
||||||
|
|
||||||
//dark blue
|
|
||||||
$base01: #586e75 !default
|
|
||||||
|
|
||||||
//darkest gray
|
|
||||||
$base00: #657b83 !default
|
|
||||||
|
|
||||||
//dark gray
|
|
||||||
$base0: #839496 !default
|
|
||||||
|
|
||||||
//medium gray
|
|
||||||
$base1: #93a1a1 !default
|
|
||||||
|
|
||||||
//medium light gray
|
|
||||||
$base2: #eee8d5 !default
|
|
||||||
|
|
||||||
//cream
|
|
||||||
$base3: #fdf6e3 !default
|
|
||||||
|
|
||||||
//white
|
|
||||||
$solar-yellow: #b58900 !default
|
|
||||||
$solar-orange: #cb4b16 !default
|
|
||||||
$solar-red: #dc322f !default
|
|
||||||
$solar-magenta: #d33682 !default
|
|
||||||
$solar-violet: #6c71c4 !default
|
|
||||||
$solar-blue: #268bd2 !default
|
|
||||||
$solar-cyan: #2aa198 !default
|
|
||||||
$solar-green: #859900 !default
|
|
||||||
|
|
||||||
$solarized: dark !default
|
|
||||||
|
|
||||||
@if $solarized == light
|
|
||||||
$_base03: $base03
|
|
||||||
$_base02: $base02
|
|
||||||
$_base01: $base01
|
|
||||||
$_base00: $base00
|
|
||||||
$_base0: $base0
|
|
||||||
$_base1: $base1
|
|
||||||
$_base2: $base2
|
|
||||||
$_base3: $base3
|
|
||||||
$base03: $_base3
|
|
||||||
$base02: $_base2
|
|
||||||
$base01: $_base1
|
|
||||||
$base00: $_base0
|
|
||||||
$base0: $_base00
|
|
||||||
$base1: $_base01
|
|
||||||
$base2: $_base02
|
|
||||||
$base3: $_base03
|
|
||||||
|
|
||||||
/* non highlighted code colors
|
|
||||||
$pre-bg: $base03 !default
|
|
||||||
$pre-border: darken($base02, 5) !default
|
|
||||||
$pre-color: $base1 !default
|
|
||||||
@ -1,14 +1,13 @@
|
|||||||
@import 'bourbon'
|
@import 'bourbon'
|
||||||
|
|
||||||
@import 'includes/syntax.css.sass'
|
|
||||||
@import 'includes/main.css.sass'
|
@import 'includes/main.css.sass'
|
||||||
@import 'includes/colors.css.sass'
|
@import 'includes/colors.css.sass'
|
||||||
@import 'includes/typography.css.sass'
|
@import 'includes/typography.css.sass'
|
||||||
@import 'includes/icons.css.sass'
|
@import 'includes/icons.css.sass'
|
||||||
@import 'includes/layout.css.sass'
|
@import 'includes/layout.css.sass'
|
||||||
@import 'lib/solarized.css.sass'
|
@import 'lib/solarized.css.sass'
|
||||||
@import 'includes/syntax.css.sass'
|
|
||||||
@import 'includes/styles.css.sass'
|
@import 'includes/styles.css.sass'
|
||||||
|
@import 'lib/solarized-dark.css.scss'
|
||||||
|
|
||||||
@import 'parts/post.css.sass'
|
@import 'parts/post.css.sass'
|
||||||
@import 'parts/archive.css.sass'
|
@import 'parts/archive.css.sass'
|
||||||
|
|||||||
@ -1,8 +1,7 @@
|
|||||||
url: http://danbarber.me
|
url: http://danbarber.me
|
||||||
title: Dan Barber
|
title: Dan Barber
|
||||||
author: Dan Barber
|
author: Dan Barber
|
||||||
markdown: kramdown
|
markdown: KramdownPygments
|
||||||
highlighter: pygments
|
|
||||||
|
|
||||||
simple_search: https://duckduckgo.com/
|
simple_search: https://duckduckgo.com/
|
||||||
|
|
||||||
|
|||||||
92
_plugins/kramdown_pygments.rb
Normal file
92
_plugins/kramdown_pygments.rb
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
# We define the an additional option for the kramdown parser to look for
|
||||||
|
module Kramdown
|
||||||
|
module Options
|
||||||
|
define(:kramdown_default_lang, Symbol, nil, <<EOF)
|
||||||
|
Sets the default language for highlighting code blocks
|
||||||
|
|
||||||
|
If no language is set for a code block, the default language is used
|
||||||
|
instead. The value has to be one of the languages supported by pygments
|
||||||
|
or nil if no default language should be used.
|
||||||
|
|
||||||
|
Default: nil
|
||||||
|
Used by: PygmentsHtml converter
|
||||||
|
EOF
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# This class is a plugin for kramdown, to make it use pygments instead of coderay
|
||||||
|
# It has nothing to do with Jekyll, it is simply used by the custom converter below
|
||||||
|
module Kramdown
|
||||||
|
module Converter
|
||||||
|
class PygmentsHtml < Html
|
||||||
|
|
||||||
|
begin
|
||||||
|
require 'pygments'
|
||||||
|
rescue LoadError
|
||||||
|
STDERR.puts 'You are missing a library required for syntax highlighting. Please run:'
|
||||||
|
STDERR.puts ' $ [sudo] gem install pygments'
|
||||||
|
raise FatalException.new("Missing dependency: Pygments")
|
||||||
|
end
|
||||||
|
|
||||||
|
def convert_codeblock(el, indent)
|
||||||
|
attr = el.attr.dup
|
||||||
|
lang = extract_code_language!(attr) || @options[:kramdown_default_lang]
|
||||||
|
code = pygmentize(el.value, lang)
|
||||||
|
code_attr = {}
|
||||||
|
code_attr['class'] = "language-#{lang}" if lang
|
||||||
|
"#{' '*indent}<div class=\"highlight\"><pre#{html_attributes(attr)}><code#{html_attributes(code_attr)}>#{code}</code></pre></div>\n"
|
||||||
|
end
|
||||||
|
|
||||||
|
def convert_codespan(el, indent)
|
||||||
|
attr = el.attr.dup
|
||||||
|
lang = extract_code_language!(attr) || @options[:kramdown_default_lang]
|
||||||
|
code = pygmentize(el.value, lang)
|
||||||
|
if lang
|
||||||
|
attr['class'] = "highlight"
|
||||||
|
if attr.has_key?('class')
|
||||||
|
attr['class'] += " language-#{lang}"
|
||||||
|
else
|
||||||
|
attr['class'] = "language-#{lang}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
"<code#{html_attributes(attr)}>#{code}</code>"
|
||||||
|
end
|
||||||
|
|
||||||
|
def pygmentize(code, lang)
|
||||||
|
if lang
|
||||||
|
Pygments.highlight(code,
|
||||||
|
:lexer => lang,
|
||||||
|
:options => { :startinline => true, :encoding => 'utf-8', :nowrap => true })
|
||||||
|
else
|
||||||
|
escape_html(code)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# This class is the actual custom Jekyll converter.
|
||||||
|
class Jekyll::Converters::Markdown::KramdownPygments
|
||||||
|
|
||||||
|
def initialize(config)
|
||||||
|
require 'kramdown'
|
||||||
|
@config = config
|
||||||
|
rescue LoadError
|
||||||
|
STDERR.puts 'You are missing a library required for Markdown. Please run:'
|
||||||
|
STDERR.puts ' $ [sudo] gem install kramdown'
|
||||||
|
raise FatalException.new("Missing dependency: kramdown")
|
||||||
|
end
|
||||||
|
|
||||||
|
def convert(content)
|
||||||
|
html = Kramdown::Document.new(content, {
|
||||||
|
:auto_ids => @config['kramdown']['auto_ids'],
|
||||||
|
:footnote_nr => @config['kramdown']['footnote_nr'],
|
||||||
|
:entity_output => @config['kramdown']['entity_output'],
|
||||||
|
:toc_levels => @config['kramdown']['toc_levels'],
|
||||||
|
:smart_quotes => @config['kramdown']['smart_quotes'],
|
||||||
|
:kramdown_default_lang => @config['kramdown']['default_lang'],
|
||||||
|
:input => @config['kramdown']['input']
|
||||||
|
}).to_pygments_html
|
||||||
|
return html;
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Reference in New Issue
Block a user