From 5573c118ebe4b2b5328b328170c21bf77cc9f2e8 Mon Sep 17 00:00:00 2001 From: Olivier Hallot Date: Fri, 4 Mar 2022 13:31:51 -0300 Subject: Update prism.js used in the Help version 1.2.7 Change-Id: Ibec037314046a2f17a9c6c2b9c67d9353c761319 Reviewed-on: https://gerrit.libreoffice.org/c/help/+/131028 Tested-by: Jenkins Reviewed-by: Olivier Hallot --- help3xsl/README.prism.js.txt | 10 +- help3xsl/prism.css | 274 +------- help3xsl/prism.js | 1531 +----------------------------------------- 3 files changed, 25 insertions(+), 1790 deletions(-) (limited to 'help3xsl') diff --git a/help3xsl/README.prism.js.txt b/help3xsl/README.prism.js.txt index fe0acc0d2b..d23a5b6581 100644 --- a/help3xsl/README.prism.js.txt +++ b/help3xsl/README.prism.js.txt @@ -39,6 +39,14 @@ Add class 'language-visual-basic' and 'line-numbers' to as in
-
+ +
+
+ +
+ +
+
+
diff --git a/help3xsl/prism.css b/help3xsl/prism.css index 8bd96d9cc3..e10549dfe6 100644 --- a/help3xsl/prism.css +++ b/help3xsl/prism.css @@ -1,270 +1,4 @@ -/* PrismJS 1.20.0 -https://prismjs.com/download.html#themes=prism-coy&languages=markup+css+clike+javascript+python+visual-basic&plugins=line-numbers+normalize-whitespace */ -/** - * prism.js Coy theme for JavaScript, CoffeeScript, CSS and HTML - * Based on https://github.com/tshedor/workshop-wp-theme (Example: http://workshop.kansan.com/category/sessions/basics or http://workshop.timshedor.com/category/sessions/basics); - * @author Tim Shedor - */ - -code[class*="language-"], -pre[class*="language-"] { - color: black; - background: none; - font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; - font-size: 1em; - text-align: left; - white-space: pre; - word-spacing: normal; - word-break: normal; - word-wrap: normal; - line-height: 1.5; - - -moz-tab-size: 4; - -o-tab-size: 4; - tab-size: 4; - - -webkit-hyphens: none; - -moz-hyphens: none; - -ms-hyphens: none; - hyphens: none; -} - -/* Code blocks */ -pre[class*="language-"] { - position: relative; - margin: .5em 0; - overflow: visible; - padding: 0; -} -pre[class*="language-"]>code { - position: relative; - border-left: 10px solid #358ccb; - box-shadow: -1px 0px 0px 0px #358ccb, 0px 0px 0px 1px #dfdfdf; - background-color: #fdfdfd; - background-image: linear-gradient(transparent 50%, rgba(69, 142, 209, 0.04) 50%); - background-size: 3em 3em; - background-origin: content-box; - background-attachment: local; -} - -code[class*="language"] { - max-height: inherit; - height: inherit; - padding: 0 1em; - display: block; - overflow: auto; -} - -/* Margin bottom to accommodate shadow */ -:not(pre) > code[class*="language-"], -pre[class*="language-"] { - background-color: #fdfdfd; - -webkit-box-sizing: border-box; - -moz-box-sizing: border-box; - box-sizing: border-box; - margin-bottom: 1em; -} - -/* Inline code */ -:not(pre) > code[class*="language-"] { - position: relative; - padding: .2em; - border-radius: 0.3em; - color: #c92c2c; - border: 1px solid rgba(0, 0, 0, 0.1); - display: inline; - white-space: normal; -} - -pre[class*="language-"]:before, -pre[class*="language-"]:after { - content: ''; - z-index: -2; - display: block; - position: absolute; - bottom: 0.75em; - left: 0.18em; - width: 40%; - height: 20%; - max-height: 13em; - box-shadow: 0px 13px 8px #979797; - -webkit-transform: rotate(-2deg); - -moz-transform: rotate(-2deg); - -ms-transform: rotate(-2deg); - -o-transform: rotate(-2deg); - transform: rotate(-2deg); -} - -:not(pre) > code[class*="language-"]:after, -pre[class*="language-"]:after { - right: 0.75em; - left: auto; - -webkit-transform: rotate(2deg); - -moz-transform: rotate(2deg); - -ms-transform: rotate(2deg); - -o-transform: rotate(2deg); - transform: rotate(2deg); -} - -.token.comment, -.token.block-comment, -.token.prolog, -.token.doctype, -.token.cdata { - color: #7D8B99; -} - -.token.punctuation { - color: #5F6364; -} - -.token.property, -.token.tag, -.token.boolean, -.token.number, -.token.function-name, -.token.constant, -.token.symbol, -.token.deleted { - color: #c92c2c; -} - -.token.selector, -.token.attr-name, -.token.string, -.token.char, -.token.function, -.token.builtin, -.token.inserted { - color: #2f9c0a; -} - -.token.operator, -.token.entity, -.token.url, -.token.variable { - color: #a67f59; - background: rgba(255, 255, 255, 0.5); -} - -.token.atrule, -.token.attr-value, -.token.keyword, -.token.class-name { - color: #1990b8; -} - -.token.regex, -.token.important { - color: #e90; -} - -.language-css .token.string, -.style .token.string { - color: #a67f59; - background: rgba(255, 255, 255, 0.5); -} - -.token.important { - font-weight: normal; -} - -.token.bold { - font-weight: bold; -} -.token.italic { - font-style: italic; -} - -.token.entity { - cursor: help; -} - -.token.namespace { - opacity: .7; -} - -@media screen and (max-width: 767px) { - pre[class*="language-"]:before, - pre[class*="language-"]:after { - bottom: 14px; - box-shadow: none; - } - -} - -/* Plugin styles */ -.token.tab:not(:empty):before, -.token.cr:before, -.token.lf:before { - color: #e0d7d1; -} - -/* Plugin styles: Line Numbers */ -pre[class*="language-"].line-numbers.line-numbers { - padding-left: 0; -} - -pre[class*="language-"].line-numbers.line-numbers code { - padding-left: 3.8em; -} - -pre[class*="language-"].line-numbers.line-numbers .line-numbers-rows { - left: 0; -} - -/* Plugin styles: Line Highlight */ -pre[class*="language-"][data-line] { - padding-top: 0; - padding-bottom: 0; - padding-left: 0; -} -pre[data-line] code { - position: relative; - padding-left: 4em; -} -pre .line-highlight { - margin-top: 0; -} - -pre[class*="language-"].line-numbers { - position: relative; - padding-left: 3.8em; - counter-reset: linenumber; -} - -pre[class*="language-"].line-numbers > code { - position: relative; - white-space: inherit; -} - -.line-numbers .line-numbers-rows { - position: absolute; - pointer-events: none; - top: 0; - font-size: 100%; - left: -3.8em; - width: 3em; /* works for line-numbers below 1000 lines */ - letter-spacing: -1px; - border-right: 1px solid #999; - - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - -} - - .line-numbers-rows > span { - display: block; - counter-increment: linenumber; - } - - .line-numbers-rows > span:before { - content: counter(linenumber); - color: #999; - display: block; - padding-right: 0.8em; - text-align: right; - } - +/* PrismJS 1.27.0 +https://prismjs.com/download.html#themes=prism-coy&languages=markup+css+clike+javascript+basic+python+visual-basic&plugins=line-numbers+normalize-whitespace */ +code[class*=language-],pre[class*=language-]{color:#000;background:0 0;font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]{position:relative;margin:.5em 0;overflow:visible;padding:1px}pre[class*=language-]>code{position:relative;z-index:1;border-left:10px solid #358ccb;box-shadow:-1px 0 0 0 #358ccb,0 0 0 1px #dfdfdf;background-color:#fdfdfd;background-image:linear-gradient(transparent 50%,rgba(69,142,209,.04) 50%);background-size:3em 3em;background-origin:content-box;background-attachment:local}code[class*=language-]{max-height:inherit;height:inherit;padding:0 1em;display:block;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{background-color:#fdfdfd;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;margin-bottom:1em}:not(pre)>code[class*=language-]{position:relative;padding:.2em;border-radius:.3em;color:#c92c2c;border:1px solid rgba(0,0,0,.1);display:inline;white-space:normal}pre[class*=language-]:after,pre[class*=language-]:before{content:'';display:block;position:absolute;bottom:.75em;left:.18em;width:40%;height:20%;max-height:13em;box-shadow:0 13px 8px #979797;-webkit-transform:rotate(-2deg);-moz-transform:rotate(-2deg);-ms-transform:rotate(-2deg);-o-transform:rotate(-2deg);transform:rotate(-2deg)}pre[class*=language-]:after{right:.75em;left:auto;-webkit-transform:rotate(2deg);-moz-transform:rotate(2deg);-ms-transform:rotate(2deg);-o-transform:rotate(2deg);transform:rotate(2deg)}.token.block-comment,.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#7d8b99}.token.punctuation{color:#5f6364}.token.boolean,.token.constant,.token.deleted,.token.function-name,.token.number,.token.property,.token.symbol,.token.tag{color:#c92c2c}.token.attr-name,.token.builtin,.token.char,.token.function,.token.inserted,.token.selector,.token.string{color:#2f9c0a}.token.entity,.token.operator,.token.url,.token.variable{color:#a67f59;background:rgba(255,255,255,.5)}.token.atrule,.token.attr-value,.token.class-name,.token.keyword{color:#1990b8}.token.important,.token.regex{color:#e90}.language-css .token.string,.style .token.string{color:#a67f59;background:rgba(255,255,255,.5)}.token.important{font-weight:400}.token.bold{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}.token.namespace{opacity:.7}@media screen and (max-width:767px){pre[class*=language-]:after,pre[class*=language-]:before{bottom:14px;box-shadow:none}}pre[class*=language-].line-numbers.line-numbers{padding-left:0}pre[class*=language-].line-numbers.line-numbers code{padding-left:3.8em}pre[class*=language-].line-numbers.line-numbers .line-numbers-rows{left:0}pre[class*=language-][data-line]{padding-top:0;padding-bottom:0;padding-left:0}pre[data-line] code{position:relative;padding-left:4em}pre .line-highlight{margin-top:0} +pre[class*=language-].line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}pre[class*=language-].line-numbers>code{position:relative;white-space:inherit}.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:0;font-size:100%;left:-3.8em;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.line-numbers-rows>span{display:block;counter-increment:linenumber}.line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right} diff --git a/help3xsl/prism.js b/help3xsl/prism.js index 1080118885..7d2faf61f1 100644 --- a/help3xsl/prism.js +++ b/help3xsl/prism.js @@ -1,1519 +1,12 @@ -/* PrismJS 1.20.0 -https://prismjs.com/download.html#themes=prism-coy&languages=markup+css+clike+javascript+python+visual-basic&plugins=line-numbers+normalize-whitespace */ -var _self = (typeof window !== 'undefined') - ? window // if in browser - : ( - (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) - ? self // if in worker - : {} // if in node js - ); - -/** - * Prism: Lightweight, robust, elegant syntax highlighting - * MIT license http://www.opensource.org/licenses/mit-license.php/ - * @author Lea Verou http://lea.verou.me - */ - -var Prism = (function (_self){ - -// Private helper vars -var lang = /\blang(?:uage)?-([\w-]+)\b/i; -var uniqueId = 0; - - -var _ = { - manual: _self.Prism && _self.Prism.manual, - disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler, - util: { - encode: function encode(tokens) { - if (tokens instanceof Token) { - return new Token(tokens.type, encode(tokens.content), tokens.alias); - } else if (Array.isArray(tokens)) { - return tokens.map(encode); - } else { - return tokens.replace(/&/g, '&').replace(/' + env.content + ''; -}; - -/** - * @param {string} text - * @param {LinkedList} tokenList - * @param {any} grammar - * @param {LinkedListNode} startNode - * @param {number} startPos - * @param {boolean} [oneshot=false] - * @param {string} [target] - */ -function matchGrammar(text, tokenList, grammar, startNode, startPos, oneshot, target) { - for (var token in grammar) { - if (!grammar.hasOwnProperty(token) || !grammar[token]) { - continue; - } - - var patterns = grammar[token]; - patterns = Array.isArray(patterns) ? patterns : [patterns]; - - for (var j = 0; j < patterns.length; ++j) { - if (target && target == token + ',' + j) { - return; - } - - var pattern = patterns[j], - inside = pattern.inside, - lookbehind = !!pattern.lookbehind, - greedy = !!pattern.greedy, - lookbehindLength = 0, - alias = pattern.alias; - - if (greedy && !pattern.pattern.global) { - // Without the global flag, lastIndex won't work - var flags = pattern.pattern.toString().match(/[imsuy]*$/)[0]; - pattern.pattern = RegExp(pattern.pattern.source, flags + 'g'); - } - - pattern = pattern.pattern || pattern; - - for ( // iterate the token list and keep track of the current token/string position - var currentNode = startNode.next, pos = startPos; - currentNode !== tokenList.tail; - pos += currentNode.value.length, currentNode = currentNode.next - ) { - - var str = currentNode.value; - - if (tokenList.length > text.length) { - // Something went terribly wrong, ABORT, ABORT! - return; - } - - if (str instanceof Token) { - continue; - } - - var removeCount = 1; // this is the to parameter of removeBetween - - if (greedy && currentNode != tokenList.tail.prev) { - pattern.lastIndex = pos; - var match = pattern.exec(text); - if (!match) { - break; - } - - var from = match.index + (lookbehind && match[1] ? match[1].length : 0); - var to = match.index + match[0].length; - var p = pos; - - // find the node that contains the match - p += currentNode.value.length; - while (from >= p) { - currentNode = currentNode.next; - p += currentNode.value.length; - } - // adjust pos (and p) - p -= currentNode.value.length; - pos = p; - - // the current node is a Token, then the match starts inside another Token, which is invalid - if (currentNode.value instanceof Token) { - continue; - } - - // find the last node which is affected by this match - for ( - var k = currentNode; - k !== tokenList.tail && (p < to || (typeof k.value === 'string' && !k.prev.value.greedy)); - k = k.next - ) { - removeCount++; - p += k.value.length; - } - removeCount--; - - // replace with the new match - str = text.slice(pos, p); - match.index -= pos; - } else { - pattern.lastIndex = 0; - - var match = pattern.exec(str); - } - - if (!match) { - if (oneshot) { - break; - } - - continue; - } - - if (lookbehind) { - lookbehindLength = match[1] ? match[1].length : 0; - } - - var from = match.index + lookbehindLength, - match = match[0].slice(lookbehindLength), - to = from + match.length, - before = str.slice(0, from), - after = str.slice(to); - - var removeFrom = currentNode.prev; - - if (before) { - removeFrom = addAfter(tokenList, removeFrom, before); - pos += before.length; - } - - removeRange(tokenList, removeFrom, removeCount); - - var wrapped = new Token(token, inside ? _.tokenize(match, inside) : match, alias, match, greedy); - currentNode = addAfter(tokenList, removeFrom, wrapped); - - if (after) { - addAfter(tokenList, currentNode, after); - } - - - if (removeCount > 1) - matchGrammar(text, tokenList, grammar, currentNode.prev, pos, true, token + ',' + j); - - if (oneshot) - break; - } - } - } -} - -/** - * @typedef LinkedListNode - * @property {T} value - * @property {LinkedListNode | null} prev The previous node. - * @property {LinkedListNode | null} next The next node. - * @template T - */ - -/** - * @template T - */ -function LinkedList() { - /** @type {LinkedListNode} */ - var head = { value: null, prev: null, next: null }; - /** @type {LinkedListNode} */ - var tail = { value: null, prev: head, next: null }; - head.next = tail; - - /** @type {LinkedListNode} */ - this.head = head; - /** @type {LinkedListNode} */ - this.tail = tail; - this.length = 0; -} - -/** - * Adds a new node with the given value to the list. - * @param {LinkedList} list - * @param {LinkedListNode} node - * @param {T} value - * @returns {LinkedListNode} The added node. - * @template T - */ -function addAfter(list, node, value) { - // assumes that node != list.tail && values.length >= 0 - var next = node.next; - - var newNode = { value: value, prev: node, next: next }; - node.next = newNode; - next.prev = newNode; - list.length++; - - return newNode; -} -/** - * Removes `count` nodes after the given node. The given node will not be removed. - * @param {LinkedList} list - * @param {LinkedListNode} node - * @param {number} count - * @template T - */ -function removeRange(list, node, count) { - var next = node.next; - for (var i = 0; i < count && next !== list.tail; i++) { - next = next.next; - } - node.next = next; - next.prev = node; - list.length -= i; -} -/** - * @param {LinkedList} list - * @returns {T[]} - * @template T - */ -function toArray(list) { - var array = []; - var node = list.head.next; - while (node !== list.tail) { - array.push(node.value); - node = node.next; - } - return array; -} - - -if (!_self.document) { - if (!_self.addEventListener) { - // in Node.js - return _; - } - - if (!_.disableWorkerMessageHandler) { - // In worker - _self.addEventListener('message', function (evt) { - var message = JSON.parse(evt.data), - lang = message.language, - code = message.code, - immediateClose = message.immediateClose; - - _self.postMessage(_.highlight(code, _.languages[lang], lang)); - if (immediateClose) { - _self.close(); - } - }, false); - } - - return _; -} - -//Get current script and highlight -var script = _.util.currentScript(); - -if (script) { - _.filename = script.src; - - if (script.hasAttribute('data-manual')) { - _.manual = true; - } -} - -function highlightAutomaticallyCallback() { - if (!_.manual) { - _.highlightAll(); - } -} - -if (!_.manual) { - // If the document state is "loading", then we'll use DOMContentLoaded. - // If the document state is "interactive" and the prism.js script is deferred, then we'll also use the - // DOMContentLoaded event because there might be some plugins or languages which have also been deferred and they - // might take longer one animation frame to execute which can create a race condition where only some plugins have - // been loaded when Prism.highlightAll() is executed, depending on how fast resources are loaded. - // See https://github.com/PrismJS/prism/issues/2102 - var readyState = document.readyState; - if (readyState === 'loading' || readyState === 'interactive' && script && script.defer) { - document.addEventListener('DOMContentLoaded', highlightAutomaticallyCallback); - } else { - if (window.requestAnimationFrame) { - window.requestAnimationFrame(highlightAutomaticallyCallback); - } else { - window.setTimeout(highlightAutomaticallyCallback, 16); - } - } -} - -return _; - -})(_self); - -if (typeof module !== 'undefined' && module.exports) { - module.exports = Prism; -} - -// hack for components to work correctly in node.js -if (typeof global !== 'undefined') { - global.Prism = Prism; -} -; -Prism.languages.markup = { - 'comment': //, - 'prolog': /<\?[\s\S]+?\?>/, - 'doctype': { - // https://www.w3.org/TR/xml/#NT-doctypedecl - pattern: /"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|)*\]\s*)?>/i, - greedy: true, - inside: { - 'internal-subset': { - pattern: /(\[)[\s\S]+(?=\]>$)/, - lookbehind: true, - greedy: true, - inside: null // see below - }, - 'string': { - pattern: /"[^"]*"|'[^']*'/, - greedy: true - }, - 'punctuation': /^$|[[\]]/, - 'doctype-tag': /^DOCTYPE/, - 'name': /[^\s<>'"]+/ - } - }, - 'cdata': //i, - 'tag': { - pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/, - greedy: true, - inside: { - 'tag': { - pattern: /^<\/?[^\s>\/]+/, - inside: { - 'punctuation': /^<\/?/, - 'namespace': /^[^\s>\/:]+:/ - } - }, - 'attr-value': { - pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/, - inside: { - 'punctuation': [ - { - pattern: /^=/, - alias: 'attr-equals' - }, - /"|'/ - ] - } - }, - 'punctuation': /\/?>/, - 'attr-name': { - pattern: /[^\s>\/]+/, - inside: { - 'namespace': /^[^\s>\/:]+:/ - } - } - - } - }, - 'entity': [ - { - pattern: /&[\da-z]{1,8};/i, - alias: 'named-entity' - }, - /&#x?[\da-f]{1,8};/i - ] -}; - -Prism.languages.markup['tag'].inside['attr-value'].inside['entity'] = - Prism.languages.markup['entity']; -Prism.languages.markup['doctype'].inside['internal-subset'].inside = Prism.languages.markup; - -// Plugin to make entity title show the real entity, idea by Roman Komarov -Prism.hooks.add('wrap', function (env) { - - if (env.type === 'entity') { - env.attributes['title'] = env.content.replace(/&/, '&'); - } -}); - -Object.defineProperty(Prism.languages.markup.tag, 'addInlined', { - /** - * Adds an inlined language to markup. - * - * An example of an inlined language is CSS with `