update deps: marked.js, codemirror

This commit is contained in:
ed 2022-12-02 21:39:04 +00:00
parent 008d9b1834
commit 4242422898
3 changed files with 59 additions and 77 deletions

View file

@ -1,10 +1,11 @@
FROM alpine:3
# TODO easymde embeds codemirror on 3.17 due to new npm probably
FROM alpine:3.16
WORKDIR /z
ENV ver_asmcrypto=c72492f4a66e17a0e5dd8ad7874de354f3ccdaa5 \
ver_hashwasm=4.9.0 \
ver_marked=4.0.18 \
ver_marked=4.2.3 \
ver_mde=2.18.0 \
ver_codemirror=5.65.9 \
ver_codemirror=5.65.10 \
ver_fontawesome=5.13.0 \
ver_zopfli=1.0.3

View file

@ -1,5 +1,5 @@
diff --git a/src/Lexer.js b/src/Lexer.js
adds linetracking to marked.js v4.0.17;
adds linetracking to marked.js v4.2.3;
add data-ln="%d" to most tags, %d is the source markdown line
--- a/src/Lexer.js
+++ b/src/Lexer.js
@ -123,20 +123,20 @@ add data-ln="%d" to most tags, %d is the source markdown line
+ this.ln++;
lastToken = tokens[tokens.length - 1];
if (lastToken && lastToken.type === 'text') {
@@ -365,4 +396,5 @@ export class Lexer {
@@ -367,4 +398,5 @@ export class Lexer {
if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
src = src.substring(token.raw.length);
+ this.ln = token.ln || this.ln;
tokens.push(token);
return true;
@@ -430,4 +462,6 @@ export class Lexer {
@@ -432,4 +464,6 @@ export class Lexer {
if (token = this.tokenizer.br(src)) {
src = src.substring(token.raw.length);
+ // no need to reset (no more blockTokens anyways)
+ token.ln = this.ln++;
tokens.push(token);
continue;
@@ -472,4 +506,5 @@ export class Lexer {
@@ -474,4 +508,5 @@ export class Lexer {
if (token = this.tokenizer.inlineText(cutSrc, smartypants)) {
src = src.substring(token.raw.length);
+ this.ln = token.ln || this.ln;
@ -234,7 +234,7 @@ index 7c36a75..aa1a53a 100644
- return '<pre><code class="'
+ return '<pre' + this.ln + '><code class="'
+ this.options.langPrefix
+ escape(lang, true)
+ escape(lang)
@@ -43,5 +49,5 @@ export class Renderer {
*/
blockquote(quote) {
@ -293,7 +293,7 @@ diff --git a/src/Tokenizer.js b/src/Tokenizer.js
index e8a69b6..2cc772b 100644
--- a/src/Tokenizer.js
+++ b/src/Tokenizer.js
@@ -302,4 +302,7 @@ export class Tokenizer {
@@ -312,4 +312,7 @@ export class Tokenizer {
const l = list.items.length;
+ // each nested list gets +1 ahead; this hack makes every listgroup -1 but atleast it doesn't get infinitely bad

View file

@ -1,35 +1,35 @@
diff --git a/src/Lexer.js b/src/Lexer.js
--- a/src/Lexer.js
+++ b/src/Lexer.js
@@ -6,5 +6,5 @@ import { repeatString } from './helpers.js';
/**
@@ -7,5 +7,5 @@ import { repeatString } from './helpers.js';
* smartypants text replacement
* @param {string} text
- */
+ *
function smartypants(text) {
return text
@@ -27,5 +27,5 @@ function smartypants(text) {
/**
@@ -29,5 +29,5 @@ function smartypants(text) {
* mangle email addresses
* @param {string} text
- */
+ *
function mangle(text) {
let out = '',
@@ -466,5 +466,5 @@ export class Lexer {
@@ -478,5 +478,5 @@ export class Lexer {
// autolink
- if (token = this.tokenizer.autolink(src, mangle)) {
+ if (token = this.tokenizer.autolink(src)) {
src = src.substring(token.raw.length);
tokens.push(token);
@@ -473,5 +473,5 @@ export class Lexer {
@@ -485,5 +485,5 @@ export class Lexer {
// url (gfm)
- if (!this.state.inLink && (token = this.tokenizer.url(src, mangle))) {
+ if (!this.state.inLink && (token = this.tokenizer.url(src))) {
src = src.substring(token.raw.length);
tokens.push(token);
@@ -494,5 +494,5 @@ export class Lexer {
@@ -506,5 +506,5 @@ export class Lexer {
}
}
- if (token = this.tokenizer.inlineText(cutSrc, smartypants)) {
@ -39,15 +39,15 @@ diff --git a/src/Lexer.js b/src/Lexer.js
diff --git a/src/Renderer.js b/src/Renderer.js
--- a/src/Renderer.js
+++ b/src/Renderer.js
@@ -142,5 +142,5 @@ export class Renderer {
@@ -173,5 +173,5 @@ export class Renderer {
*/
link(href, title, text) {
- href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
+ href = cleanUrl(this.options.baseUrl, href);
if (href === null) {
return text;
@@ -155,5 +155,5 @@ export class Renderer {
@@ -191,5 +191,5 @@ export class Renderer {
*/
image(href, title, text) {
- href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
+ href = cleanUrl(this.options.baseUrl, href);
@ -56,7 +56,7 @@ diff --git a/src/Renderer.js b/src/Renderer.js
diff --git a/src/Tokenizer.js b/src/Tokenizer.js
--- a/src/Tokenizer.js
+++ b/src/Tokenizer.js
@@ -320,14 +320,7 @@ export class Tokenizer {
@@ -352,14 +352,7 @@ export class Tokenizer {
type: 'html',
raw: cap[0],
- pre: !this.options.sanitizer
@ -65,14 +65,14 @@ diff --git a/src/Tokenizer.js b/src/Tokenizer.js
text: cap[0]
};
- if (this.options.sanitize) {
- const text = this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]);
- token.type = 'paragraph';
- token.text = this.options.sanitizer ? this.options.sanitizer(cap[0]) : escape(cap[0]);
- token.tokens = [];
- this.lexer.inline(token.text, token.tokens);
- token.text = text;
- token.tokens = this.lexer.inline(text);
- }
return token;
}
@@ -476,15 +469,9 @@ export class Tokenizer {
@@ -502,15 +495,9 @@ export class Tokenizer {
return {
- type: this.options.sanitize
@ -90,7 +90,7 @@ diff --git a/src/Tokenizer.js b/src/Tokenizer.js
+ text: cap[0]
};
}
@@ -671,10 +658,10 @@ export class Tokenizer {
@@ -699,10 +686,10 @@ export class Tokenizer {
}
- autolink(src, mangle) {
@ -103,7 +103,7 @@ diff --git a/src/Tokenizer.js b/src/Tokenizer.js
+ text = escape(cap[1]);
href = 'mailto:' + text;
} else {
@@ -699,10 +686,10 @@ export class Tokenizer {
@@ -727,10 +714,10 @@ export class Tokenizer {
}
- url(src, mangle) {
@ -116,7 +116,7 @@ diff --git a/src/Tokenizer.js b/src/Tokenizer.js
+ text = escape(cap[0]);
href = 'mailto:' + text;
} else {
@@ -736,12 +723,12 @@ export class Tokenizer {
@@ -764,12 +751,12 @@ export class Tokenizer {
}
- inlineText(src, smartypants) {
@ -135,7 +135,7 @@ diff --git a/src/Tokenizer.js b/src/Tokenizer.js
diff --git a/src/defaults.js b/src/defaults.js
--- a/src/defaults.js
+++ b/src/defaults.js
@@ -9,12 +9,8 @@ export function getDefaults() {
@@ -10,11 +10,7 @@ export function getDefaults() {
highlight: null,
langPrefix: 'language-',
- mangle: true,
@ -144,16 +144,15 @@ diff --git a/src/defaults.js b/src/defaults.js
- sanitize: false,
- sanitizer: null,
silent: false,
smartLists: false,
- smartypants: false,
tokenizer: null,
walkTokens: null,
diff --git a/src/helpers.js b/src/helpers.js
--- a/src/helpers.js
+++ b/src/helpers.js
@@ -64,18 +64,5 @@ export function edit(regex, opt) {
const nonWordAndColonTest = /[^\w:]/g;
const originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
@@ -78,18 +78,5 @@ const originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
* @param {string} href
*/
-export function cleanUrl(sanitize, base, href) {
- if (sanitize) {
- let prot;
@ -171,7 +170,7 @@ diff --git a/src/helpers.js b/src/helpers.js
+export function cleanUrl(base, href) {
if (base && !originIndependentUrl.test(href)) {
href = resolveUrl(base, href);
@@ -227,10 +214,4 @@ export function findClosingBracket(str, b) {
@@ -250,10 +237,4 @@ export function findClosingBracket(str, b) {
}
-export function checkSanitizeDeprecation(opt) {
@ -181,7 +180,7 @@ diff --git a/src/helpers.js b/src/helpers.js
-}
-
// copied from https://stackoverflow.com/a/5450113/806777
export function repeatString(pattern, count) {
/**
diff --git a/src/marked.js b/src/marked.js
--- a/src/marked.js
+++ b/src/marked.js
@ -197,13 +196,13 @@ diff --git a/src/marked.js b/src/marked.js
- checkSanitizeDeprecation(opt);
if (callback) {
@@ -302,5 +300,4 @@ marked.parseInline = function(src, opt) {
@@ -318,5 +316,4 @@ marked.parseInline = function(src, opt) {
opt = merge({}, marked.defaults, opt || {});
- checkSanitizeDeprecation(opt);
try {
@@ -311,5 +308,5 @@ marked.parseInline = function(src, opt) {
@@ -327,5 +324,5 @@ marked.parseInline = function(src, opt) {
return Parser.parseInline(tokens, opt);
} catch (e) {
- e.message += '\nPlease report this to https://github.com/markedjs/marked.';
@ -213,42 +212,24 @@ diff --git a/src/marked.js b/src/marked.js
diff --git a/test/bench.js b/test/bench.js
--- a/test/bench.js
+++ b/test/bench.js
@@ -37,5 +37,4 @@ export async function runBench(options) {
@@ -39,5 +39,4 @@ export async function runBench(options) {
breaks: false,
pedantic: false,
- sanitize: false,
smartLists: false
- sanitize: false
});
@@ -49,5 +48,4 @@ export async function runBench(options) {
if (options.marked) {
@@ -50,5 +49,4 @@ export async function runBench(options) {
breaks: false,
pedantic: false,
- sanitize: false,
smartLists: false
});
@@ -62,5 +60,4 @@ export async function runBench(options) {
breaks: false,
pedantic: false,
- sanitize: false,
smartLists: false
});
@@ -74,5 +71,4 @@ export async function runBench(options) {
breaks: false,
pedantic: false,
- sanitize: false,
smartLists: false
});
@@ -87,5 +83,4 @@ export async function runBench(options) {
breaks: false,
pedantic: true,
- sanitize: false,
smartLists: false
});
@@ -99,5 +94,4 @@ export async function runBench(options) {
breaks: false,
pedantic: true,
- sanitize: false,
smartLists: false
- sanitize: false
});
if (options.marked) {
@@ -61,5 +59,4 @@ export async function runBench(options) {
// breaks: false,
// pedantic: false,
- // sanitize: false
// });
// if (options.marked) {
diff --git a/test/specs/run-spec.js b/test/specs/run-spec.js
--- a/test/specs/run-spec.js
+++ b/test/specs/run-spec.js
@ -269,70 +250,70 @@ diff --git a/test/specs/run-spec.js b/test/specs/run-spec.js
diff --git a/test/unit/Lexer-spec.js b/test/unit/Lexer-spec.js
--- a/test/unit/Lexer-spec.js
+++ b/test/unit/Lexer-spec.js
@@ -635,5 +635,5 @@ paragraph
@@ -712,5 +712,5 @@ paragraph
});
- it('sanitize', () => {
+ /*it('sanitize', () => {
expectTokens({
md: '<div>html</div>',
@@ -653,5 +653,5 @@ paragraph
@@ -730,5 +730,5 @@ paragraph
]
});
- });
+ });*/
});
@@ -698,5 +698,5 @@ paragraph
@@ -810,5 +810,5 @@ paragraph
});
- it('html sanitize', () => {
+ /*it('html sanitize', () => {
expectInlineTokens({
md: '<div>html</div>',
@@ -706,5 +706,5 @@ paragraph
@@ -818,5 +818,5 @@ paragraph
]
});
- });
+ });*/
it('link', () => {
@@ -1017,5 +1017,5 @@ paragraph
@@ -1129,5 +1129,5 @@ paragraph
});
- it('autolink mangle email', () => {
+ /*it('autolink mangle email', () => {
expectInlineTokens({
md: '<test@example.com>',
@@ -1037,5 +1037,5 @@ paragraph
@@ -1149,5 +1149,5 @@ paragraph
]
});
- });
+ });*/
it('url', () => {
@@ -1074,5 +1074,5 @@ paragraph
@@ -1186,5 +1186,5 @@ paragraph
});
- it('url mangle email', () => {
+ /*it('url mangle email', () => {
expectInlineTokens({
md: 'test@example.com',
@@ -1094,5 +1094,5 @@ paragraph
@@ -1206,5 +1206,5 @@ paragraph
]
});
- });
+ });*/
});
@@ -1110,5 +1110,5 @@ paragraph
@@ -1222,5 +1222,5 @@ paragraph
});
- describe('smartypants', () => {
+ /*describe('smartypants', () => {
it('single quotes', () => {
expectInlineTokens({
@@ -1180,5 +1180,5 @@ paragraph
@@ -1292,5 +1292,5 @@ paragraph
});
});
- });