newLISP-Documentation-Highlight

Provide syntax hightlighting in newLISP documentation

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         newLISP-Documentation-Highlight
// @namespace    https://github.com/kosh04/userscript
// @version      0.20181005
// @description  Provide syntax hightlighting in newLISP documentation
// @grant        GM_addStyle
// @grant        GM_getResourceText
// @match        http://www.newlisp.org/*/newlisp_manual.html
// @match        http://www.newlisp.org/*/CodePatterns.html
// @match        http://newlisp.nfshost.com/*/newlisp_manual.html
// @match        http://newlisp.nfshost.com/*/CodePatterns.html
// @require              http://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js
// @require              http://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/languages/lisp.min.js
// @resource default.css http://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css
// @resource github.css  http://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css
// @resource zenburn.css http://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/zenburn.min.css
// @author       KOBAYASHI Shigeru (kosh)
// @license      Public domain
// ==/UserScript==

/* global hljs */

GM_addStyle(GM_getResourceText("default.css"));
GM_addStyle(`
code {
  /* font-size: 110%; */
  font-family: Consolas, 'Courier New', Courier, Monaco, monospace;
}
.arw {
  color: inherit;
}
`);

document.querySelectorAll("pre").forEach(pre => {
    const code = document.createElement("code");
    code.classList.add("lisp"); // assume lang=lisp

    // wrapInner: <pre>...</pre> => <pre><code>...</code></pre>
    code.innerHTML = pre.innerHTML;
    pre.innerHTML = code.outerHTML;
});

hljs.configure({languages:["lisp", "c", "bash"]});
hljs.initHighlighting();