diff options
author | Samy Pesse <samypesse@gmail.com> | 2015-09-12 19:23:07 +0200 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2015-09-12 19:23:07 +0200 |
commit | 08ff39fd0b95eed935241da96dcd43ef660f8860 (patch) | |
tree | 812001333acb90c75fc5ba7adc94a4736050fe8a | |
parent | 82a6ee3875bca2b068d76ccc894c4313d1006b77 (diff) | |
download | gitbook-08ff39fd0b95eed935241da96dcd43ef660f8860.zip gitbook-08ff39fd0b95eed935241da96dcd43ef660f8860.tar.gz gitbook-08ff39fd0b95eed935241da96dcd43ef660f8860.tar.bz2 |
Remove highlight.js dependency
-rw-r--r-- | lib/utils/code.js | 36 | ||||
-rw-r--r-- | lib/utils/page.js | 6 | ||||
-rw-r--r-- | package.json | 1 | ||||
-rwxr-xr-x | theme/stylesheets/ebook.less | 1 | ||||
-rw-r--r-- | theme/stylesheets/ebook/highlight.less | 90 | ||||
-rw-r--r-- | theme/stylesheets/website/highlight/night.less | 92 | ||||
-rw-r--r-- | theme/stylesheets/website/highlight/sepia.less | 107 | ||||
-rw-r--r-- | theme/stylesheets/website/highlight/white.less | 90 | ||||
-rwxr-xr-x | theme/stylesheets/website/markdown.less | 8 |
9 files changed, 1 insertions, 430 deletions
diff --git a/lib/utils/code.js b/lib/utils/code.js deleted file mode 100644 index 0d98869..0000000 --- a/lib/utils/code.js +++ /dev/null @@ -1,36 +0,0 @@ -var hljs = require('highlight.js'); - -var MAP = { - 'py': 'python', - 'js': 'javascript', - 'json': 'javascript', - 'rb': 'ruby', - 'csharp': 'cs', -}; - -function normalize(lang) { - if(!lang) { return null; } - - var lower = lang.toLowerCase(); - return MAP[lower] || lower; -} - -function highlight(lang, code) { - if(!lang) return code; - - // Normalize lang - lang = normalize(lang); - - try { - return hljs.highlight(lang, code).value; - } catch(e) { } - - return code; -} - -// Exports -module.exports = { - highlight: highlight, - normalize: normalize, - MAP: MAP -}; diff --git a/lib/utils/page.js b/lib/utils/page.js index e2a7cd5..2400480 100644 --- a/lib/utils/page.js +++ b/lib/utils/page.js @@ -11,7 +11,6 @@ var links = require('./links'); var imgUtils = require('./images'); var fs = require('./fs'); var batch = require('./batch'); -var code = require('./code'); var parsableExtensions = require('gitbook-parsers').extensions; @@ -242,10 +241,7 @@ function normalizeHtml(src, options) { .value(); if (lang) { - var html = code.highlight( - lang, - $(this).text() - ); + var html = $(this).text(); $(this).html(html); } diff --git a/package.json b/package.json index 9f401a7..8d34ea1 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ "npm": "2.4.1", "dom-serializer": "0.1.0", "spawn-cmd": "0.0.2", - "highlight.js": "8.8.0", "escape-string-regexp": "1.0.3" }, "devDependencies": { diff --git a/theme/stylesheets/ebook.less b/theme/stylesheets/ebook.less index 3d547f7..92bc915 100755 --- a/theme/stylesheets/ebook.less +++ b/theme/stylesheets/ebook.less @@ -1,7 +1,6 @@ @import "mixins.less"; @import "ebook/variables.less"; -@import "ebook/highlight.less"; .page { &.page-toc { diff --git a/theme/stylesheets/ebook/highlight.less b/theme/stylesheets/ebook/highlight.less deleted file mode 100644 index 26078cb..0000000 --- a/theme/stylesheets/ebook/highlight.less +++ /dev/null @@ -1,90 +0,0 @@ -/* http://jmblog.github.io/color-themes-for-highlightjs */ - -/* Tomorrow Comment */ -.hljs-comment, -.hljs-title { - color: #8e908c; -} - -/* Tomorrow Red */ -.hljs-variable, -.hljs-attribute, -.hljs-tag, -.hljs-regexp, -.ruby .hljs-constant, -.xml .hljs-tag .hljs-title, -.xml .hljs-pi, -.xml .hljs-doctype, -.html .hljs-doctype, -.css .hljs-id, -.css .hljs-class, -.css .hljs-pseudo { - color: #c82829; -} - -/* Tomorrow Orange */ -.hljs-number, -.hljs-preprocessor, -.hljs-pragma, -.hljs-built_in, -.hljs-literal, -.hljs-params, -.hljs-constant { - color: #f5871f; -} - -/* Tomorrow Yellow */ -.ruby .hljs-class .hljs-title, -.css .hljs-rules .hljs-attribute { - color: #eab700; -} - -/* Tomorrow Green */ -.hljs-string, -.hljs-value, -.hljs-inheritance, -.hljs-header, -.ruby .hljs-symbol, -.xml .hljs-cdata { - color: #718c00; -} - -/* Tomorrow Aqua */ -.css .hljs-hexcolor { - color: #3e999f; -} - -/* Tomorrow Blue */ -.hljs-function, -.python .hljs-decorator, -.python .hljs-title, -.ruby .hljs-function .hljs-title, -.ruby .hljs-title .hljs-keyword, -.perl .hljs-sub, -.javascript .hljs-title, -.coffeescript .hljs-title { - color: #4271ae; -} - -/* Tomorrow Purple */ -.hljs-keyword, -.javascript .hljs-function { - color: #8959a8; -} - -.hljs { - display: block; - background: white; - color: #4d4d4c; - padding: 0.5em; -} - -.coffeescript .javascript, -.javascript .xml, -.tex .hljs-formula, -.xml .javascript, -.xml .vbscript, -.xml .css, -.xml .hljs-cdata { - opacity: 0.5; -} diff --git a/theme/stylesheets/website/highlight/night.less b/theme/stylesheets/website/highlight/night.less deleted file mode 100644 index 8e06c2a..0000000 --- a/theme/stylesheets/website/highlight/night.less +++ /dev/null @@ -1,92 +0,0 @@ -/* Tomorrow Night Bright Theme */ -/* Original theme - https://github.com/chriskempson/tomorrow-theme */ -/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */ - -/* Tomorrow Comment */ -.hljs-comment, -.hljs-title { - color: #969896; -} - -/* Tomorrow Red */ -.hljs-variable, -.hljs-attribute, -.hljs-tag, -.hljs-regexp, -.ruby .hljs-constant, -.xml .hljs-tag .hljs-title, -.xml .hljs-pi, -.xml .hljs-doctype, -.html .hljs-doctype, -.css .hljs-id, -.css .hljs-class, -.css .hljs-pseudo { - color: #d54e53; -} - -/* Tomorrow Orange */ -.hljs-number, -.hljs-preprocessor, -.hljs-pragma, -.hljs-built_in, -.hljs-literal, -.hljs-params, -.hljs-constant { - color: #e78c45; -} - -/* Tomorrow Yellow */ -.ruby .hljs-class .hljs-title, -.css .hljs-rules .hljs-attribute { - color: #e7c547; -} - -/* Tomorrow Green */ -.hljs-string, -.hljs-value, -.hljs-inheritance, -.hljs-header, -.ruby .hljs-symbol, -.xml .hljs-cdata { - color: #b9ca4a; -} - -/* Tomorrow Aqua */ -.css .hljs-hexcolor { - color: #70c0b1; -} - -/* Tomorrow Blue */ -.hljs-function, -.python .hljs-decorator, -.python .hljs-title, -.ruby .hljs-function .hljs-title, -.ruby .hljs-title .hljs-keyword, -.perl .hljs-sub, -.javascript .hljs-title, -.coffeescript .hljs-title { - color: #7aa6da; -} - -/* Tomorrow Purple */ -.hljs-keyword, -.javascript .hljs-function { - color: #c397d8; -} - -.hljs { - display: block; - background: black; - color: #eaeaea; - padding: 0.5em; -} - -.coffeescript .javascript, -.javascript .xml, -.tex .hljs-formula, -.xml .javascript, -.xml .vbscript, -.xml .css, -.xml .hljs-cdata { - opacity: 0.5; -}
\ No newline at end of file diff --git a/theme/stylesheets/website/highlight/sepia.less b/theme/stylesheets/website/highlight/sepia.less deleted file mode 100644 index 3d9dddb..0000000 --- a/theme/stylesheets/website/highlight/sepia.less +++ /dev/null @@ -1,107 +0,0 @@ -/* - -Orginal Style from ethanschoonover.com/solarized (c) Jeremy Hull <sourdrums@gmail.com> - -*/ - -.hljs { - display: block; - padding: 0.5em; - background: #fdf6e3; - color: #657b83; -} - -.hljs-comment, -.hljs-template_comment, -.diff .hljs-header, -.hljs-doctype, -.hljs-pi, -.lisp .hljs-string, -.hljs-javadoc { - color: #93a1a1; -} - -/* Solarized Green */ -.hljs-keyword, -.hljs-winutils, -.method, -.hljs-addition, -.css .hljs-tag, -.hljs-request, -.hljs-status, -.nginx .hljs-title { - color: #859900; -} - -/* Solarized Cyan */ -.hljs-number, -.hljs-command, -.hljs-string, -.hljs-tag .hljs-value, -.hljs-rules .hljs-value, -.hljs-phpdoc, -.tex .hljs-formula, -.hljs-regexp, -.hljs-hexcolor, -.hljs-link_url { - color: #2aa198; -} - -/* Solarized Blue */ -.hljs-title, -.hljs-localvars, -.hljs-chunk, -.hljs-decorator, -.hljs-built_in, -.hljs-identifier, -.vhdl .hljs-literal, -.hljs-id, -.css .hljs-function { - color: #268bd2; -} - -/* Solarized Yellow */ -.hljs-attribute, -.hljs-variable, -.lisp .hljs-body, -.smalltalk .hljs-number, -.hljs-constant, -.hljs-class .hljs-title, -.hljs-parent, -.haskell .hljs-type, -.hljs-link_reference { - color: #b58900; -} - -/* Solarized Orange */ -.hljs-preprocessor, -.hljs-preprocessor .hljs-keyword, -.hljs-pragma, -.hljs-shebang, -.hljs-symbol, -.hljs-symbol .hljs-string, -.diff .hljs-change, -.hljs-special, -.hljs-attr_selector, -.hljs-subst, -.hljs-cdata, -.clojure .hljs-title, -.css .hljs-pseudo, -.hljs-header { - color: #cb4b16; -} - -/* Solarized Red */ -.hljs-deletion, -.hljs-important { - color: #dc322f; -} - -/* Solarized Violet */ -.hljs-link_label { - color: #6c71c4; -} - -.tex .hljs-formula { - background: #eee8d5; -}
\ No newline at end of file diff --git a/theme/stylesheets/website/highlight/white.less b/theme/stylesheets/website/highlight/white.less deleted file mode 100644 index ae9d1f8..0000000 --- a/theme/stylesheets/website/highlight/white.less +++ /dev/null @@ -1,90 +0,0 @@ -/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */ - -/* Tomorrow Comment */ -.hljs-comment, -.hljs-title { - color: #8e908c; -} - -/* Tomorrow Red */ -.hljs-variable, -.hljs-attribute, -.hljs-tag, -.hljs-regexp, -.ruby .hljs-constant, -.xml .hljs-tag .hljs-title, -.xml .hljs-pi, -.xml .hljs-doctype, -.html .hljs-doctype, -.css .hljs-id, -.css .hljs-class, -.css .hljs-pseudo { - color: #c82829; -} - -/* Tomorrow Orange */ -.hljs-number, -.hljs-preprocessor, -.hljs-pragma, -.hljs-built_in, -.hljs-literal, -.hljs-params, -.hljs-constant { - color: #f5871f; -} - -/* Tomorrow Yellow */ -.ruby .hljs-class .hljs-title, -.css .hljs-rules .hljs-attribute { - color: #eab700; -} - -/* Tomorrow Green */ -.hljs-string, -.hljs-value, -.hljs-inheritance, -.hljs-header, -.ruby .hljs-symbol, -.xml .hljs-cdata { - color: #718c00; -} - -/* Tomorrow Aqua */ -.css .hljs-hexcolor { - color: #3e999f; -} - -/* Tomorrow Blue */ -.hljs-function, -.python .hljs-decorator, -.python .hljs-title, -.ruby .hljs-function .hljs-title, -.ruby .hljs-title .hljs-keyword, -.perl .hljs-sub, -.javascript .hljs-title, -.coffeescript .hljs-title { - color: #4271ae; -} - -/* Tomorrow Purple */ -.hljs-keyword, -.javascript .hljs-function { - color: #8959a8; -} - -.hljs { - display: block; - background: white; - color: #4d4d4c; - padding: 0.5em; -} - -.coffeescript .javascript, -.javascript .xml, -.tex .hljs-formula, -.xml .javascript, -.xml .vbscript, -.xml .css, -.xml .hljs-cdata { - opacity: 0.5; -}
\ No newline at end of file diff --git a/theme/stylesheets/website/markdown.less b/theme/stylesheets/website/markdown.less index b5b0121..e710683 100755 --- a/theme/stylesheets/website/markdown.less +++ b/theme/stylesheets/website/markdown.less @@ -5,10 +5,6 @@ .book .book-body .page-wrapper .page-inner section.normal { .markdown-content(@content-color, @content-line-height); - pre, code { - @import "./highlight/white.less"; - } - .glossary-term { cursor: help; text-decoration: underline; @@ -51,8 +47,6 @@ background: @page-pre-background-1; color: @page-pre-color-1; border-color: @page-pre-border-color-1; - - @import "./highlight/sepia.less"; } .highlight { @@ -112,8 +106,6 @@ color: @page-pre-color-2; background: @page-pre-background-2; border-color: @page-pre-border-color-2; - - @import "./highlight/night.less"; } .highlight { |