From 04b9e213303a5fc8be5714f8cad37efb3dfdf12f Mon Sep 17 00:00:00 2001 From: ed Date: Tue, 7 Dec 2021 01:12:32 +0100 Subject: [PATCH] update web-deps --- copyparty/web/browser.js | 2 +- copyparty/web/md.js | 6 +- scripts/deps-docker/Dockerfile | 9 +-- scripts/deps-docker/easymde-marked6.patch | 12 ++++ scripts/deps-docker/marked-ln.patch | 76 ++++++++++---------- scripts/deps-docker/marked.patch | 86 +++++++++++------------ scripts/make-pypi-release.sh | 2 - scripts/make-tgz-release.sh | 2 - 8 files changed, 99 insertions(+), 96 deletions(-) create mode 100644 scripts/deps-docker/easymde-marked6.patch diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index 8b64b097..7dcc382b 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -4773,7 +4773,7 @@ function show_md(md, name, div, url, depth) { try { clmod(div, 'mdo', 1); - div.innerHTML = marked(md, { + div.innerHTML = marked.parse(md, { headerPrefix: 'md-', breaks: true, gfm: true diff --git a/copyparty/web/md.js b/copyparty/web/md.js index ce44d44f..194dbb5a 100644 --- a/copyparty/web/md.js +++ b/copyparty/web/md.js @@ -40,8 +40,8 @@ var md_plug = {}; // add navbar (function () { var parts = get_evpath().split('/'), link = '', o; - for (var a = 0; a < parts.length - 1; a++) { - link += parts[a] + '/'; + for (var a = 0, aa = parts.length - 2; a <= aa; a++) { + link += parts[a] + (a < aa ? '/' : ''); o = mknod('a'); o.setAttribute('href', link); o.textContent = uricom_dec(parts[a])[0] || 'top'; @@ -250,7 +250,7 @@ function convert_markdown(md_text, dest_dom) { Object.assign(marked_opts, ext[0]); try { - var md_html = marked(md_text, marked_opts); + var md_html = marked.parse(md_text, marked_opts); } catch (ex) { if (ext) diff --git a/scripts/deps-docker/Dockerfile b/scripts/deps-docker/Dockerfile index 608a3679..d542f84a 100644 --- a/scripts/deps-docker/Dockerfile +++ b/scripts/deps-docker/Dockerfile @@ -1,10 +1,10 @@ -FROM alpine:3.14 +FROM alpine:3.15 WORKDIR /z ENV ver_asmcrypto=5b994303a9d3e27e0915f72a10b6c2c51535a4dc \ ver_hashwasm=4.9.0 \ - ver_marked=3.0.4 \ + ver_marked=4.0.6 \ ver_mde=2.15.0 \ - ver_codemirror=5.62.3 \ + ver_codemirror=5.64.0 \ ver_fontawesome=5.13.0 \ ver_zopfli=1.0.3 @@ -82,7 +82,6 @@ RUN cd marked-$ver_marked \ && patch -p1 < /z/marked.patch \ && npm run build \ && cp -pv marked.min.js /z/dist/marked.js \ - && cp -pv lib/marked.js /z/dist/marked.full.js \ && mkdir -p /z/nodepkgs \ && ln -s $(pwd) /z/nodepkgs/marked # && npm run test \ @@ -98,8 +97,10 @@ RUN cd CodeMirror-$ver_codemirror \ # build easymde +COPY easymde-marked6.patch /z/ COPY easymde.patch /z/ RUN cd easy-markdown-editor-$ver_mde \ + && patch -p1 < /z/easymde-marked6.patch \ && patch -p1 < /z/easymde.patch \ && sed -ri 's`https://registry.npmjs.org/marked/-/marked-[0-9\.]+.tgz`file:/z/nodepkgs/marked`' package-lock.json \ && sed -ri 's`("marked": ")[^"]+`\1file:/z/nodepkgs/marked`' ./package.json \ diff --git a/scripts/deps-docker/easymde-marked6.patch b/scripts/deps-docker/easymde-marked6.patch new file mode 100644 index 00000000..914a418c --- /dev/null +++ b/scripts/deps-docker/easymde-marked6.patch @@ -0,0 +1,12 @@ +diff --git a/src/js/easymde.js b/src/js/easymde.js +--- a/src/js/easymde.js ++++ b/src/js/easymde.js +@@ -1962,7 +1962,7 @@ EasyMDE.prototype.markdown = function (text) { + marked.setOptions(markedOptions); + + // Convert the markdown to HTML +- var htmlText = marked(text); ++ var htmlText = marked.parse(text); + + // Sanitize HTML + if (this.options.renderingConfig && typeof this.options.renderingConfig.sanitizerFunction === 'function') { diff --git a/scripts/deps-docker/marked-ln.patch b/scripts/deps-docker/marked-ln.patch index 552457fd..dffbfae2 100644 --- a/scripts/deps-docker/marked-ln.patch +++ b/scripts/deps-docker/marked-ln.patch @@ -1,15 +1,15 @@ diff --git a/src/Lexer.js b/src/Lexer.js -adds linetracking to marked.js v3.0.4; +adds linetracking to marked.js v4.0.6; add data-ln="%d" to most tags, %d is the source markdown line --- a/src/Lexer.js +++ b/src/Lexer.js @@ -50,4 +50,5 @@ function mangle(text) { - module.exports = class Lexer { + export class Lexer { constructor(options) { + this.ln = 1; // like most editors, start couting from 1 this.tokens = []; this.tokens.links = Object.create(null); -@@ -127,4 +128,15 @@ module.exports = class Lexer { +@@ -127,4 +128,15 @@ export class Lexer { } + set_ln(token, ln = this.ln) { @@ -25,7 +25,7 @@ add data-ln="%d" to most tags, %d is the source markdown line + /** * Lexing -@@ -134,7 +146,11 @@ module.exports = class Lexer { +@@ -134,7 +146,11 @@ export class Lexer { src = src.replace(/^ +$/gm, ''); } - let token, lastToken, cutSrc, lastParagraphClipped; @@ -38,105 +38,105 @@ add data-ln="%d" to most tags, %d is the source markdown line + if (this.options.extensions && this.options.extensions.block -@@ -142,4 +158,5 @@ module.exports = class Lexer { +@@ -142,4 +158,5 @@ export class Lexer { if (token = extTokenizer.call({ lexer: this }, src, tokens)) { src = src.substring(token.raw.length); + this.set_ln(token, ln); tokens.push(token); return true; -@@ -153,4 +170,5 @@ module.exports = class Lexer { +@@ -153,4 +170,5 @@ export class Lexer { if (token = this.tokenizer.space(src)) { src = src.substring(token.raw.length); + this.set_ln(token, ln); // is \n if not type if (token.type) { tokens.push(token); -@@ -162,4 +180,5 @@ module.exports = class Lexer { +@@ -162,4 +180,5 @@ export class Lexer { if (token = this.tokenizer.code(src)) { src = src.substring(token.raw.length); + this.set_ln(token, ln); lastToken = tokens[tokens.length - 1]; // An indented code block cannot interrupt a paragraph. -@@ -177,4 +196,5 @@ module.exports = class Lexer { +@@ -177,4 +196,5 @@ export class Lexer { if (token = this.tokenizer.fences(src)) { src = src.substring(token.raw.length); + this.set_ln(token, ln); tokens.push(token); continue; -@@ -184,4 +204,5 @@ module.exports = class Lexer { +@@ -184,4 +204,5 @@ export class Lexer { if (token = this.tokenizer.heading(src)) { src = src.substring(token.raw.length); + this.set_ln(token, ln); tokens.push(token); continue; -@@ -191,4 +212,5 @@ module.exports = class Lexer { +@@ -191,4 +212,5 @@ export class Lexer { if (token = this.tokenizer.hr(src)) { src = src.substring(token.raw.length); + this.set_ln(token, ln); tokens.push(token); continue; -@@ -198,4 +220,5 @@ module.exports = class Lexer { +@@ -198,4 +220,5 @@ export class Lexer { if (token = this.tokenizer.blockquote(src)) { src = src.substring(token.raw.length); + this.set_ln(token, ln); tokens.push(token); continue; -@@ -205,4 +228,5 @@ module.exports = class Lexer { +@@ -205,4 +228,5 @@ export class Lexer { if (token = this.tokenizer.list(src)) { src = src.substring(token.raw.length); + this.set_ln(token, ln); tokens.push(token); continue; -@@ -212,4 +236,5 @@ module.exports = class Lexer { +@@ -212,4 +236,5 @@ export class Lexer { if (token = this.tokenizer.html(src)) { src = src.substring(token.raw.length); + this.set_ln(token, ln); tokens.push(token); continue; -@@ -219,4 +244,5 @@ module.exports = class Lexer { +@@ -219,4 +244,5 @@ export class Lexer { if (token = this.tokenizer.def(src)) { src = src.substring(token.raw.length); + this.set_ln(token, ln); lastToken = tokens[tokens.length - 1]; if (lastToken && (lastToken.type === 'paragraph' || lastToken.type === 'text')) { -@@ -236,4 +262,5 @@ module.exports = class Lexer { +@@ -236,4 +262,5 @@ export class Lexer { if (token = this.tokenizer.table(src)) { src = src.substring(token.raw.length); + this.set_ln(token, ln); tokens.push(token); continue; -@@ -243,4 +270,5 @@ module.exports = class Lexer { +@@ -243,4 +270,5 @@ export class Lexer { if (token = this.tokenizer.lheading(src)) { src = src.substring(token.raw.length); + this.set_ln(token, ln); tokens.push(token); continue; -@@ -263,4 +291,5 @@ module.exports = class Lexer { +@@ -263,4 +291,5 @@ export class Lexer { } if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) { + this.set_ln(token, ln); lastToken = tokens[tokens.length - 1]; if (lastParagraphClipped && lastToken.type === 'paragraph') { -@@ -280,4 +309,6 @@ module.exports = class Lexer { +@@ -280,4 +309,6 @@ export class Lexer { if (token = this.tokenizer.text(src)) { src = src.substring(token.raw.length); + this.set_ln(token, ln); + this.ln++; lastToken = tokens[tokens.length - 1]; if (lastToken && lastToken.type === 'text') { -@@ -355,4 +386,5 @@ module.exports = class Lexer { +@@ -355,4 +386,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; -@@ -420,4 +452,6 @@ module.exports = class Lexer { +@@ -420,4 +452,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; -@@ -462,4 +496,5 @@ module.exports = class Lexer { +@@ -462,4 +496,5 @@ export class Lexer { if (token = this.tokenizer.inlineText(cutSrc, smartypants)) { src = src.substring(token.raw.length); + this.ln = token.ln || this.ln; @@ -145,13 +145,13 @@ add data-ln="%d" to most tags, %d is the source markdown line diff --git a/src/Parser.js b/src/Parser.js --- a/src/Parser.js +++ b/src/Parser.js -@@ -18,4 +18,5 @@ module.exports = class Parser { +@@ -18,4 +18,5 @@ export class Parser { this.textRenderer = new TextRenderer(); this.slugger = new Slugger(); + this.ln = 0; // error indicator; should always be set >=1 from tokens } -@@ -64,4 +65,8 @@ module.exports = class Parser { +@@ -64,4 +65,8 @@ export class Parser { for (i = 0; i < l; i++) { token = tokens[i]; + // take line-numbers from tokens whenever possible @@ -160,7 +160,7 @@ diff --git a/src/Parser.js b/src/Parser.js + this.renderer.tag_ln(this.ln); // Run any renderer extensions -@@ -124,7 +129,10 @@ module.exports = class Parser { +@@ -124,7 +129,10 @@ export class Parser { } - body += this.renderer.tablerow(cell); @@ -173,7 +173,7 @@ diff --git a/src/Parser.js b/src/Parser.js + out += this.renderer.tag_ln(token.ln).table(header, body); continue; } -@@ -167,8 +175,12 @@ module.exports = class Parser { +@@ -167,8 +175,12 @@ export class Parser { itemBody += this.parse(item.tokens, loose); - body += this.renderer.listitem(itemBody, task, checked); @@ -188,7 +188,7 @@ diff --git a/src/Parser.js b/src/Parser.js + out += this.renderer.tag_ln(token.ln).list(body, ordered, start); continue; } -@@ -179,5 +191,6 @@ module.exports = class Parser { +@@ -179,5 +191,6 @@ export class Parser { } case 'paragraph': { - out += this.renderer.paragraph(this.parseInline(token.tokens)); @@ -196,7 +196,7 @@ diff --git a/src/Parser.js b/src/Parser.js + out += this.renderer.tag_ln(token.ln).paragraph(t); continue; } -@@ -221,4 +234,7 @@ module.exports = class Parser { +@@ -221,4 +234,7 @@ export class Parser { token = tokens[i]; + // another thing that only affects
and other inlines @@ -207,7 +207,7 @@ diff --git a/src/Parser.js b/src/Parser.js diff --git a/src/Renderer.js b/src/Renderer.js --- a/src/Renderer.js +++ b/src/Renderer.js -@@ -11,6 +11,12 @@ module.exports = class Renderer { +@@ -11,6 +11,12 @@ export class Renderer { constructor(options) { this.options = options || defaults; + this.ln = ""; @@ -220,7 +220,7 @@ diff --git a/src/Renderer.js b/src/Renderer.js + code(code, infostring, escaped) { const lang = (infostring || '').match(/\S*/)[0]; -@@ -26,10 +32,10 @@ module.exports = class Renderer { +@@ -26,10 +32,10 @@ export class Renderer { if (!lang) { - return '
'
@@ -233,55 +233,55 @@ diff --git a/src/Renderer.js b/src/Renderer.js
 +    return '' + text + '\n';
 +    return '' + text + '\n';
    }
  
-@@ -75,5 +82,5 @@ module.exports = class Renderer {
+@@ -75,5 +82,5 @@ export class Renderer {
  
    listitem(text) {
 -    return '
  • ' + text + '
  • \n'; + return '' + text + '\n'; } -@@ -87,5 +94,5 @@ module.exports = class Renderer { +@@ -87,5 +94,5 @@ export class Renderer { paragraph(text) { - return '

    ' + text + '

    \n'; + return '' + text + '

    \n'; } -@@ -102,5 +109,5 @@ module.exports = class Renderer { +@@ -102,5 +109,5 @@ export class Renderer { tablerow(content) { - return '\n' + content + '\n'; + return '\n' + content + '\n'; } -@@ -127,5 +134,5 @@ module.exports = class Renderer { +@@ -127,5 +134,5 @@ export class Renderer { br() { - return this.options.xhtml ? '
    ' : '
    '; + return this.options.xhtml ? '' : ''; } -@@ -153,5 +160,5 @@ module.exports = class Renderer { +@@ -153,5 +160,5 @@ export class Renderer { } - let out = '' + text + ' { const before = process.hrtime(); -@@ -53,3 +48,2 @@ runSpecs('Original', './original', false, { gfm: false, pedantic: true }); +@@ -56,3 +51,2 @@ runSpecs('Original', './original', false, { gfm: false, pedantic: true }); runSpecs('New', './new'); runSpecs('ReDOS', './redos'); -runSpecs('Security', './security', false, { silent: true }); // silent - do not show deprecation warning 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 -@@ -589,5 +589,5 @@ paragraph +@@ -635,5 +635,5 @@ paragraph }); - it('sanitize', () => { + /*it('sanitize', () => { expectTokens({ md: '
    html
    ', -@@ -607,5 +607,5 @@ paragraph +@@ -653,5 +653,5 @@ paragraph ] }); - }); + });*/ }); -@@ -652,5 +652,5 @@ paragraph +@@ -698,5 +698,5 @@ paragraph }); - it('html sanitize', () => { + /*it('html sanitize', () => { expectInlineTokens({ md: '
    html
    ', -@@ -660,5 +660,5 @@ paragraph +@@ -706,5 +706,5 @@ paragraph ] }); - }); + });*/ it('link', () => { -@@ -971,5 +971,5 @@ paragraph +@@ -1017,5 +1017,5 @@ paragraph }); - it('autolink mangle email', () => { + /*it('autolink mangle email', () => { expectInlineTokens({ md: '', -@@ -991,5 +991,5 @@ paragraph +@@ -1037,5 +1037,5 @@ paragraph ] }); - }); + });*/ it('url', () => { -@@ -1028,5 +1028,5 @@ paragraph +@@ -1074,5 +1074,5 @@ paragraph }); - it('url mangle email', () => { + /*it('url mangle email', () => { expectInlineTokens({ md: 'test@example.com', -@@ -1048,5 +1048,5 @@ paragraph +@@ -1094,5 +1094,5 @@ paragraph ] }); - }); + });*/ }); -@@ -1064,5 +1064,5 @@ paragraph +@@ -1110,5 +1110,5 @@ paragraph }); - describe('smartypants', () => { + /*describe('smartypants', () => { it('single quotes', () => { expectInlineTokens({ -@@ -1134,5 +1134,5 @@ paragraph +@@ -1180,5 +1180,5 @@ paragraph }); }); - }); diff --git a/scripts/make-pypi-release.sh b/scripts/make-pypi-release.sh index 7ede6f7b..6a568051 100755 --- a/scripts/make-pypi-release.sh +++ b/scripts/make-pypi-release.sh @@ -86,8 +86,6 @@ function have() { python -c "import $1; $1; $1.__version__" } -mv copyparty/web/deps/marked.full.js.gz srv/ || true - . buildenv/bin/activate have setuptools have wheel diff --git a/scripts/make-tgz-release.sh b/scripts/make-tgz-release.sh index ea465d6e..eafae00d 100755 --- a/scripts/make-tgz-release.sh +++ b/scripts/make-tgz-release.sh @@ -35,8 +35,6 @@ ver="$1" exit 1 } -mv copyparty/web/deps/marked.full.js.gz srv/ || true - mkdir -p dist zip_path="$(pwd)/dist/copyparty-$ver.zip" tgz_path="$(pwd)/dist/copyparty-$ver.tar.gz"