mirror of
https://github.com/wassname/template.git
synced 2026-06-27 20:23:34 +08:00
Adding a few more languages.
This commit is contained in:
+9
-2
@@ -1,8 +1,15 @@
|
||||
import Prism from "prismjs";
|
||||
import "prismjs/components/prism-python"
|
||||
import "prismjs/components/prism-clike"
|
||||
import "prismjs/components/prism-python";
|
||||
import "prismjs/components/prism-clike";
|
||||
import "prismjs/components/prism-lua";
|
||||
import "prismjs/components/prism-bash";
|
||||
import "prismjs/components/prism-go";
|
||||
import "prismjs/components/prism-markdown";
|
||||
import "prismjs/components/prism-julia";
|
||||
|
||||
|
||||
export default function(dom, data) {
|
||||
console.log(Prism.languages);
|
||||
let codeElements = [].slice.call(dom.querySelectorAll("dt-code"));
|
||||
codeElements.forEach(el => {
|
||||
let content = el.textContent;
|
||||
|
||||
Vendored
+309
-115
@@ -284,8 +284,6 @@ function Type$2(tag, options) {
|
||||
|
||||
var type = Type$2;
|
||||
|
||||
/*eslint-disable max-len*/
|
||||
|
||||
var common$4 = common$1;
|
||||
var YAMLException$3 = exception;
|
||||
var Type$1 = type;
|
||||
@@ -897,8 +895,6 @@ function createCommonjsModule(fn, module) {
|
||||
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
||||
}
|
||||
|
||||
/*eslint-disable no-bitwise*/
|
||||
|
||||
var NodeBuffer;
|
||||
|
||||
try {
|
||||
@@ -1356,8 +1352,6 @@ var default_full = Schema$6.DEFAULT = new Schema$6({
|
||||
]
|
||||
});
|
||||
|
||||
/*eslint-disable max-len,no-use-before-define*/
|
||||
|
||||
var common = common$1;
|
||||
var YAMLException$1 = exception;
|
||||
var Mark = mark;
|
||||
@@ -2949,8 +2943,6 @@ var loader$1 = {
|
||||
safeLoad: safeLoad_1
|
||||
};
|
||||
|
||||
/*eslint-disable no-use-before-define*/
|
||||
|
||||
var common$7 = common$1;
|
||||
var YAMLException$5 = exception;
|
||||
var DEFAULT_FULL_SCHEMA$2 = default_full;
|
||||
@@ -5229,11 +5221,6 @@ var favicon = "iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAGXRFWHRTb2Z0d2FyZ
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
* @private
|
||||
*/
|
||||
|
||||
var matchHtmlRegExp = /["'&<>]/;
|
||||
|
||||
/**
|
||||
@@ -8304,6 +8291,11 @@ var sigmas$1 = {
|
||||
axisHeight: [0.250, 0.250, 0.250] // sigma22
|
||||
};
|
||||
|
||||
// These font metrics are extracted from TeX by using
|
||||
// \font\a=cmex10
|
||||
// \showthe\fontdimenX\a
|
||||
// where X is the corresponding variable number. These correspond to the font
|
||||
// parameters of the extension fonts (family 3). See the TeXbook, page 441.
|
||||
var xi8 = 0.04;
|
||||
var xi9 = 0.111;
|
||||
var xi10 = 0.166;
|
||||
@@ -8512,14 +8504,6 @@ var fontMetrics$1 = {
|
||||
getCharacterMetrics: getCharacterMetrics
|
||||
};
|
||||
|
||||
/**
|
||||
* This file contains information and classes for the various kinds of styles
|
||||
* used in TeX. It provides a generic `Style` class, which holds information
|
||||
* about a specific style. It then provides instances of all the different kinds
|
||||
* of styles possible, and provides functions to move between them and get
|
||||
* information about them.
|
||||
*/
|
||||
|
||||
var sigmas = fontMetrics$1.sigmas;
|
||||
|
||||
var metrics = [{}, {}, {}];
|
||||
@@ -8769,15 +8753,6 @@ var utils$4 = {
|
||||
clearNode: clearNode
|
||||
};
|
||||
|
||||
/**
|
||||
* These objects store the data about the DOM nodes we create, as well as some
|
||||
* extra data. They can then be transformed into real DOM nodes with the
|
||||
* `toNode` function or HTML markup using `toMarkup`. They are useful for both
|
||||
* storing extra properties on the nodes, as well as providing a way to easily
|
||||
* work with the DOM.
|
||||
*
|
||||
* Similar functions for working with MathML nodes exist in mathMLTree.js.
|
||||
*/
|
||||
var unicodeRegexes$2 = unicodeRegexes;
|
||||
var utils$3 = utils$4;
|
||||
|
||||
@@ -9795,12 +9770,6 @@ defineSymbol(text, main, textord, "\u201c", "“");
|
||||
defineSymbol(text, main, textord, "\u201d", "”");
|
||||
});
|
||||
|
||||
/* eslint no-console:0 */
|
||||
/**
|
||||
* This module contains general functions that can be used for building
|
||||
* different kinds of domTree nodes in a consistent manner.
|
||||
*/
|
||||
|
||||
var domTree$1 = domTree$2;
|
||||
var fontMetrics$3 = fontMetrics$1;
|
||||
var symbols = symbols$1;
|
||||
@@ -10276,28 +10245,6 @@ var buildCommon$2 = {
|
||||
spacingFunctions: spacingFunctions
|
||||
};
|
||||
|
||||
/**
|
||||
* This file deals with creating delimiters of various sizes. The TeXbook
|
||||
* discusses these routines on page 441-442, in the "Another subroutine sets box
|
||||
* x to a specified variable delimiter" paragraph.
|
||||
*
|
||||
* There are three main routines here. `makeSmallDelim` makes a delimiter in the
|
||||
* normal font, but in either text, script, or scriptscript style.
|
||||
* `makeLargeDelim` makes a delimiter in textstyle, but in one of the Size1,
|
||||
* Size2, Size3, or Size4 fonts. `makeStackedDelim` makes a delimiter out of
|
||||
* smaller pieces that are stacked on top of one another.
|
||||
*
|
||||
* The functions take a parameter `center`, which determines if the delimiter
|
||||
* should be centered around the axis.
|
||||
*
|
||||
* Then, there are three exposed functions. `sizedDelim` makes a delimiter in
|
||||
* one of the given sizes. This is used for things like `\bigl`.
|
||||
* `customSizedDelim` makes a delimiter with a given total height+depth. It is
|
||||
* called in places like `\sqrt`. `leftRightDelim` makes an appropriate
|
||||
* delimiter which surrounds an expression of a given height an depth. It is
|
||||
* used in `\left` and `\right`.
|
||||
*/
|
||||
|
||||
var ParseError$3 = ParseError_1;
|
||||
var Style$4 = Style_1;
|
||||
|
||||
@@ -10827,14 +10774,6 @@ var delimiter$1 = {
|
||||
leftRightDelim: makeLeftRightDelim
|
||||
};
|
||||
|
||||
/* eslint no-console:0 */
|
||||
/**
|
||||
* This file does the main work of building a domTree structure from a parse
|
||||
* tree. The entry point is the `buildHTML` function, which takes a parse tree.
|
||||
* Then, the buildExpression, buildGroup, and various groupTypes functions are
|
||||
* called, to produce a final HTML tree.
|
||||
*/
|
||||
|
||||
var ParseError$2 = ParseError_1;
|
||||
var Style$1 = Style_1;
|
||||
|
||||
@@ -12397,16 +12336,6 @@ var buildHTML$1 = function(tree, options) {
|
||||
|
||||
var buildHTML_1 = buildHTML$1;
|
||||
|
||||
/**
|
||||
* These objects store data about MathML nodes. This is the MathML equivalent
|
||||
* of the types in domTree.js. Since MathML handles its own rendering, and
|
||||
* since we're mainly using MathML to improve accessibility, we don't manage
|
||||
* any of the styling state that the plain DOM nodes do.
|
||||
*
|
||||
* The `toNode` and `toMarkup` functions work simlarly to how they do in
|
||||
* domTree.js, creating namespaced DOM nodes and HTML text markup respectively.
|
||||
*/
|
||||
|
||||
var utils$8 = utils$4;
|
||||
|
||||
/**
|
||||
@@ -12504,12 +12433,6 @@ var mathMLTree$1 = {
|
||||
TextNode: TextNode
|
||||
};
|
||||
|
||||
/**
|
||||
* This file converts a parse tree into a cooresponding MathML tree. The main
|
||||
* entry point is the `buildMathML` function, which takes a parse tree from the
|
||||
* parser.
|
||||
*/
|
||||
|
||||
var buildCommon$5 = buildCommon$2;
|
||||
var fontMetrics$5 = fontMetrics$1;
|
||||
var mathMLTree = mathMLTree$1;
|
||||
@@ -14306,19 +14229,6 @@ function matchAt$1(re, str, pos) {
|
||||
|
||||
var matchAt_1 = matchAt$1;
|
||||
|
||||
/**
|
||||
* The Lexer class handles tokenizing the input in various ways. Since our
|
||||
* parser expects us to be able to backtrack, the lexer allows lexing from any
|
||||
* given starting point.
|
||||
*
|
||||
* Its main exposed function is the `lex` function, which takes a position to
|
||||
* lex from and a type of token to lex. It defers to the appropriate `_innerLex`
|
||||
* function.
|
||||
*
|
||||
* The various `_innerLex` functions perform the actual lexing of different
|
||||
* kinds.
|
||||
*/
|
||||
|
||||
var matchAt = matchAt_1;
|
||||
|
||||
var ParseError$6 = ParseError_1;
|
||||
@@ -14416,11 +14326,6 @@ Lexer$1.prototype.lex = function() {
|
||||
|
||||
var Lexer_1 = Lexer$1;
|
||||
|
||||
/**
|
||||
* This file contains the “gullet” where macros are expanded
|
||||
* until only non-macro tokens remain.
|
||||
*/
|
||||
|
||||
var Lexer = Lexer_1;
|
||||
|
||||
function MacroExpander$1(input, macros) {
|
||||
@@ -14493,7 +14398,6 @@ MacroExpander$1.prototype.unget = function(token) {
|
||||
|
||||
var MacroExpander_1 = MacroExpander$1;
|
||||
|
||||
/* eslint no-constant-condition:0 */
|
||||
var functions = functions$1;
|
||||
var environments = environments$1;
|
||||
var MacroExpander = MacroExpander_1;
|
||||
@@ -15355,11 +15259,6 @@ Parser$1.prototype.ParseNode = ParseNode;
|
||||
|
||||
var Parser_1 = Parser$1;
|
||||
|
||||
/**
|
||||
* Provides a single function for parsing an expression using a Parser
|
||||
* TODO(emily): Remove this
|
||||
*/
|
||||
|
||||
var Parser = Parser_1;
|
||||
|
||||
/**
|
||||
@@ -15376,15 +15275,6 @@ var parseTree$1 = function(toParse, settings) {
|
||||
|
||||
var parseTree_1 = parseTree$1;
|
||||
|
||||
/* eslint no-console:0 */
|
||||
/**
|
||||
* This is the main entry point for KaTeX. Here, we expose functions for
|
||||
* rendering expressions either to DOM nodes or to markup strings.
|
||||
*
|
||||
* We also expose the ParseError class to check if errors thrown from KaTeX are
|
||||
* errors in the expression, or errors in javascript handling.
|
||||
*/
|
||||
|
||||
var ParseError = ParseError_1;
|
||||
var Settings = Settings_1;
|
||||
|
||||
@@ -17579,7 +17469,311 @@ Prism.languages.js = Prism.languages.javascript;
|
||||
})();
|
||||
});
|
||||
|
||||
Prism.languages.python= {
|
||||
'triple-quoted-string': {
|
||||
pattern: /"""[\s\S]+?"""|'''[\s\S]+?'''/,
|
||||
alias: 'string'
|
||||
},
|
||||
'comment': {
|
||||
pattern: /(^|[^\\])#.*/,
|
||||
lookbehind: true
|
||||
},
|
||||
'string': {
|
||||
pattern: /("|')(?:\\\\|\\?[^\\\r\n])*?\1/,
|
||||
greedy: true
|
||||
},
|
||||
'function' : {
|
||||
pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_][a-zA-Z0-9_]*(?=\()/g,
|
||||
lookbehind: true
|
||||
},
|
||||
'class-name': {
|
||||
pattern: /(\bclass\s+)[a-z0-9_]+/i,
|
||||
lookbehind: true
|
||||
},
|
||||
'keyword' : /\b(?:as|assert|async|await|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|pass|print|raise|return|try|while|with|yield)\b/,
|
||||
'boolean' : /\b(?:True|False)\b/,
|
||||
'number' : /\b-?(?:0[bo])?(?:(?:\d|0x[\da-f])[\da-f]*\.?\d*|\.\d+)(?:e[+-]?\d+)?j?\b/i,
|
||||
'operator' : /[-+%=]=?|!=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]|\b(?:or|and|not)\b/,
|
||||
'punctuation' : /[{}[\];(),.:]/
|
||||
};
|
||||
|
||||
Prism.languages.clike = {
|
||||
'comment': [
|
||||
{
|
||||
pattern: /(^|[^\\])\/\*[\w\W]*?\*\//,
|
||||
lookbehind: true
|
||||
},
|
||||
{
|
||||
pattern: /(^|[^\\:])\/\/.*/,
|
||||
lookbehind: true
|
||||
}
|
||||
],
|
||||
'string': {
|
||||
pattern: /(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
|
||||
greedy: true
|
||||
},
|
||||
'class-name': {
|
||||
pattern: /((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,
|
||||
lookbehind: true,
|
||||
inside: {
|
||||
punctuation: /(\.|\\)/
|
||||
}
|
||||
},
|
||||
'keyword': /\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,
|
||||
'boolean': /\b(true|false)\b/,
|
||||
'function': /[a-z0-9_]+(?=\()/i,
|
||||
'number': /\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,
|
||||
'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,
|
||||
'punctuation': /[{}[\];(),.:]/
|
||||
};
|
||||
|
||||
Prism.languages.lua = {
|
||||
'comment': /^#!.+|--(?:\[(=*)\[[\s\S]*?\]\1\]|.*)/m,
|
||||
// \z may be used to skip the following space
|
||||
'string': {
|
||||
pattern: /(["'])(?:(?!\1)[^\\\r\n]|\\z(?:\r\n|\s)|\\(?:\r\n|[\s\S]))*\1|\[(=*)\[[\s\S]*?\]\2\]/,
|
||||
greedy: true
|
||||
},
|
||||
'number': /\b0x[a-f\d]+\.?[a-f\d]*(?:p[+-]?\d+)?\b|\b\d+(?:\.\B|\.?\d*(?:e[+-]?\d+)?\b)|\B\.\d+(?:e[+-]?\d+)?\b/i,
|
||||
'keyword': /\b(?:and|break|do|else|elseif|end|false|for|function|goto|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/,
|
||||
'function': /(?!\d)\w+(?=\s*(?:[({]))/,
|
||||
'operator': [
|
||||
/[-+*%^&|#]|\/\/?|<[<=]?|>[>=]?|[=~]=?/,
|
||||
{
|
||||
// Match ".." but don't break "..."
|
||||
pattern: /(^|[^.])\.\.(?!\.)/,
|
||||
lookbehind: true
|
||||
}
|
||||
],
|
||||
'punctuation': /[\[\](){},;]|\.+|:+/
|
||||
};
|
||||
|
||||
(function(Prism) {
|
||||
var insideString = {
|
||||
variable: [
|
||||
// Arithmetic Environment
|
||||
{
|
||||
pattern: /\$?\(\([\w\W]+?\)\)/,
|
||||
inside: {
|
||||
// If there is a $ sign at the beginning highlight $(( and )) as variable
|
||||
variable: [{
|
||||
pattern: /(^\$\(\([\w\W]+)\)\)/,
|
||||
lookbehind: true
|
||||
},
|
||||
/^\$\(\(/ ],
|
||||
number: /\b-?(?:0x[\dA-Fa-f]+|\d*\.?\d+(?:[Ee]-?\d+)?)\b/,
|
||||
// Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
|
||||
operator: /--?|-=|\+\+?|\+=|!=?|~|\*\*?|\*=|\/=?|%=?|<<=?|>>=?|<=?|>=?|==?|&&?|&=|\^=?|\|\|?|\|=|\?|:/,
|
||||
// If there is no $ sign at the beginning highlight (( and )) as punctuation
|
||||
punctuation: /\(\(?|\)\)?|,|;/
|
||||
}
|
||||
},
|
||||
// Command Substitution
|
||||
{
|
||||
pattern: /\$\([^)]+\)|`[^`]+`/,
|
||||
inside: {
|
||||
variable: /^\$\(|^`|\)$|`$/
|
||||
}
|
||||
},
|
||||
/\$(?:[a-z0-9_#\?\*!@]+|\{[^}]+\})/i
|
||||
],
|
||||
};
|
||||
|
||||
Prism.languages.bash = {
|
||||
'shebang': {
|
||||
pattern: /^#!\s*\/bin\/bash|^#!\s*\/bin\/sh/,
|
||||
alias: 'important'
|
||||
},
|
||||
'comment': {
|
||||
pattern: /(^|[^"{\\])#.*/,
|
||||
lookbehind: true
|
||||
},
|
||||
'string': [
|
||||
//Support for Here-Documents https://en.wikipedia.org/wiki/Here_document
|
||||
{
|
||||
pattern: /((?:^|[^<])<<\s*)(?:"|')?(\w+?)(?:"|')?\s*\r?\n(?:[\s\S])*?\r?\n\2/g,
|
||||
lookbehind: true,
|
||||
greedy: true,
|
||||
inside: insideString
|
||||
},
|
||||
{
|
||||
pattern: /(["'])(?:\\\\|\\?[^\\])*?\1/g,
|
||||
greedy: true,
|
||||
inside: insideString
|
||||
}
|
||||
],
|
||||
'variable': insideString.variable,
|
||||
// Originally based on http://ss64.com/bash/
|
||||
'function': {
|
||||
pattern: /(^|\s|;|\||&)(?:alias|apropos|apt-get|aptitude|aspell|awk|basename|bash|bc|bg|builtin|bzip2|cal|cat|cd|cfdisk|chgrp|chmod|chown|chroot|chkconfig|cksum|clear|cmp|comm|command|cp|cron|crontab|csplit|cut|date|dc|dd|ddrescue|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|du|egrep|eject|enable|env|ethtool|eval|exec|expand|expect|export|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|getopts|git|grep|groupadd|groupdel|groupmod|groups|gzip|hash|head|help|hg|history|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|jobs|join|kill|killall|less|link|ln|locate|logname|logout|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|make|man|mkdir|mkfifo|mkisofs|mknod|more|most|mount|mtools|mtr|mv|mmv|nano|netstat|nice|nl|nohup|notify-send|npm|nslookup|open|op|passwd|paste|pathchk|ping|pkill|popd|pr|printcap|printenv|printf|ps|pushd|pv|pwd|quota|quotacheck|quotactl|ram|rar|rcp|read|readarray|readonly|reboot|rename|renice|remsync|rev|rm|rmdir|rsync|screen|scp|sdiff|sed|seq|service|sftp|shift|shopt|shutdown|sleep|slocate|sort|source|split|ssh|stat|strace|su|sudo|sum|suspend|sync|tail|tar|tee|test|time|timeout|times|touch|top|traceroute|trap|tr|tsort|tty|type|ulimit|umask|umount|unalias|uname|unexpand|uniq|units|unrar|unshar|uptime|useradd|userdel|usermod|users|uuencode|uudecode|v|vdir|vi|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yes|zip)(?=$|\s|;|\||&)/,
|
||||
lookbehind: true
|
||||
},
|
||||
'keyword': {
|
||||
pattern: /(^|\s|;|\||&)(?:let|:|\.|if|then|else|elif|fi|for|break|continue|while|in|case|function|select|do|done|until|echo|exit|return|set|declare)(?=$|\s|;|\||&)/,
|
||||
lookbehind: true
|
||||
},
|
||||
'boolean': {
|
||||
pattern: /(^|\s|;|\||&)(?:true|false)(?=$|\s|;|\||&)/,
|
||||
lookbehind: true
|
||||
},
|
||||
'operator': /&&?|\|\|?|==?|!=?|<<<?|>>|<=?|>=?|=~/,
|
||||
'punctuation': /\$?\(\(?|\)\)?|\.\.|[{}[\];]/
|
||||
};
|
||||
|
||||
var inside = insideString.variable[1].inside;
|
||||
inside['function'] = Prism.languages.bash['function'];
|
||||
inside.keyword = Prism.languages.bash.keyword;
|
||||
inside.boolean = Prism.languages.bash.boolean;
|
||||
inside.operator = Prism.languages.bash.operator;
|
||||
inside.punctuation = Prism.languages.bash.punctuation;
|
||||
})(Prism);
|
||||
|
||||
Prism.languages.go = Prism.languages.extend('clike', {
|
||||
'keyword': /\b(break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,
|
||||
'builtin': /\b(bool|byte|complex(64|128)|error|float(32|64)|rune|string|u?int(8|16|32|64|)|uintptr|append|cap|close|complex|copy|delete|imag|len|make|new|panic|print(ln)?|real|recover)\b/,
|
||||
'boolean': /\b(_|iota|nil|true|false)\b/,
|
||||
'operator': /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
|
||||
'number': /\b(-?(0x[a-f\d]+|(\d+\.?\d*|\.\d+)(e[-+]?\d+)?)i?)\b/i,
|
||||
'string': /("|'|`)(\\?.|\r|\n)*?\1/
|
||||
});
|
||||
delete Prism.languages.go['class-name'];
|
||||
|
||||
Prism.languages.markdown = Prism.languages.extend('markup', {});
|
||||
Prism.languages.insertBefore('markdown', 'prolog', {
|
||||
'blockquote': {
|
||||
// > ...
|
||||
pattern: /^>(?:[\t ]*>)*/m,
|
||||
alias: 'punctuation'
|
||||
},
|
||||
'code': [
|
||||
{
|
||||
// Prefixed by 4 spaces or 1 tab
|
||||
pattern: /^(?: {4}|\t).+/m,
|
||||
alias: 'keyword'
|
||||
},
|
||||
{
|
||||
// `code`
|
||||
// ``code``
|
||||
pattern: /``.+?``|`[^`\n]+`/,
|
||||
alias: 'keyword'
|
||||
}
|
||||
],
|
||||
'title': [
|
||||
{
|
||||
// title 1
|
||||
// =======
|
||||
|
||||
// title 2
|
||||
// -------
|
||||
pattern: /\w+.*(?:\r?\n|\r)(?:==+|--+)/,
|
||||
alias: 'important',
|
||||
inside: {
|
||||
punctuation: /==+$|--+$/
|
||||
}
|
||||
},
|
||||
{
|
||||
// # title 1
|
||||
// ###### title 6
|
||||
pattern: /(^\s*)#+.+/m,
|
||||
lookbehind: true,
|
||||
alias: 'important',
|
||||
inside: {
|
||||
punctuation: /^#+|#+$/
|
||||
}
|
||||
}
|
||||
],
|
||||
'hr': {
|
||||
// ***
|
||||
// ---
|
||||
// * * *
|
||||
// -----------
|
||||
pattern: /(^\s*)([*-])([\t ]*\2){2,}(?=\s*$)/m,
|
||||
lookbehind: true,
|
||||
alias: 'punctuation'
|
||||
},
|
||||
'list': {
|
||||
// * item
|
||||
// + item
|
||||
// - item
|
||||
// 1. item
|
||||
pattern: /(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,
|
||||
lookbehind: true,
|
||||
alias: 'punctuation'
|
||||
},
|
||||
'url-reference': {
|
||||
// [id]: http://example.com "Optional title"
|
||||
// [id]: http://example.com 'Optional title'
|
||||
// [id]: http://example.com (Optional title)
|
||||
// [id]: <http://example.com> "Optional title"
|
||||
pattern: /!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,
|
||||
inside: {
|
||||
'variable': {
|
||||
pattern: /^(!?\[)[^\]]+/,
|
||||
lookbehind: true
|
||||
},
|
||||
'string': /(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,
|
||||
'punctuation': /^[\[\]!:]|[<>]/
|
||||
},
|
||||
alias: 'url'
|
||||
},
|
||||
'bold': {
|
||||
// **strong**
|
||||
// __strong__
|
||||
|
||||
// Allow only one line break
|
||||
pattern: /(^|[^\\])(\*\*|__)(?:(?:\r?\n|\r)(?!\r?\n|\r)|.)+?\2/,
|
||||
lookbehind: true,
|
||||
inside: {
|
||||
'punctuation': /^\*\*|^__|\*\*$|__$/
|
||||
}
|
||||
},
|
||||
'italic': {
|
||||
// *em*
|
||||
// _em_
|
||||
|
||||
// Allow only one line break
|
||||
pattern: /(^|[^\\])([*_])(?:(?:\r?\n|\r)(?!\r?\n|\r)|.)+?\2/,
|
||||
lookbehind: true,
|
||||
inside: {
|
||||
'punctuation': /^[*_]|[*_]$/
|
||||
}
|
||||
},
|
||||
'url': {
|
||||
// [example](http://example.com "Optional title")
|
||||
// [example] [id]
|
||||
pattern: /!?\[[^\]]+\](?:\([^\s)]+(?:[\t ]+"(?:\\.|[^"\\])*")?\)| ?\[[^\]\n]*\])/,
|
||||
inside: {
|
||||
'variable': {
|
||||
pattern: /(!?\[)[^\]]+(?=\]$)/,
|
||||
lookbehind: true
|
||||
},
|
||||
'string': {
|
||||
pattern: /"(?:\\.|[^"\\])*"(?=\)$)/
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Prism.languages.markdown['bold'].inside['url'] = Prism.util.clone(Prism.languages.markdown['url']);
|
||||
Prism.languages.markdown['italic'].inside['url'] = Prism.util.clone(Prism.languages.markdown['url']);
|
||||
Prism.languages.markdown['bold'].inside['italic'] = Prism.util.clone(Prism.languages.markdown['italic']);
|
||||
Prism.languages.markdown['italic'].inside['bold'] = Prism.util.clone(Prism.languages.markdown['bold']);
|
||||
|
||||
Prism.languages.julia= {
|
||||
'comment': {
|
||||
pattern: /(^|[^\\])#.*/,
|
||||
lookbehind: true
|
||||
},
|
||||
'string': /"""[\s\S]+?"""|'''[\s\S]+?'''|("|')(\\?.)*?\1/,
|
||||
'keyword' : /\b(abstract|baremodule|begin|bitstype|break|catch|ccall|const|continue|do|else|elseif|end|export|finally|for|function|global|if|immutable|import|importall|let|local|macro|module|print|println|quote|return|try|type|typealias|using|while)\b/,
|
||||
'boolean' : /\b(true|false)\b/,
|
||||
'number' : /\b-?(0[box])?(?:[\da-f]+\.?\d*|\.\d+)(?:[efp][+-]?\d+)?j?\b/i,
|
||||
'operator': /\+=?|-=?|\*=?|\/[\/=]?|\\=?|\^=?|%=?|÷=?|!=?=?|&=?|\|[=>]?|\$=?|<(?:<=?|[=:])?|>(?:=|>>?=?)?|==?=?|[~≠≤≥]/,
|
||||
'punctuation' : /[{}[\];(),.:]/
|
||||
};
|
||||
|
||||
var code$1 = function(dom, data) {
|
||||
console.log(prism.languages);
|
||||
var codeElements = [].slice.call(dom.querySelectorAll("dt-code"));
|
||||
codeElements.forEach(function (el) {
|
||||
var content = el.textContent;
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -35,6 +35,22 @@
|
||||
<tr><td>234</td><td>54</td><td>23</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>Here's a javascript code block.</p>
|
||||
<dt-code block language="javascript">
|
||||
var x = 25;
|
||||
function(x){
|
||||
return x * x;
|
||||
}
|
||||
</dt-code>
|
||||
<p>We also support python.</p>
|
||||
<dt-code block language="python">
|
||||
# Python 3: Fibonacci series up to n
|
||||
def fib(n):
|
||||
a, b = 0, 1
|
||||
while a < n:
|
||||
print(a, end=' ')
|
||||
a, b = b, a+b
|
||||
</dt-code>
|
||||
</dt-article>
|
||||
|
||||
<script type="text/bibliography">
|
||||
|
||||
Reference in New Issue
Block a user