Skip to content

Markdown fix #294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 39 additions & 39 deletions live-view/extensions/markdown/dev-marked-alert.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(function(n, s) {
typeof exports == "object" && typeof module < "u" ? module.exports = s() : typeof define == "function" && define.amd ? define(s) : (n = typeof globalThis < "u" ? globalThis : n || self, n.markedAlert = s())
(function(i, n) {
typeof exports == "object" && typeof module < "u" ? module.exports = n() : typeof define == "function" && define.amd ? define(n) : (i = typeof globalThis < "u" ? globalThis : i || self, i.markedAlert = n())
})(this, function() {
"use strict";
const n = [{
const i = [{
type: "note",
icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M11 7H13V9H11V7ZM11 11H13V17H11V11ZM12 2C6.48 2 2 6.48 2 12C2 17.52 6.48 22 12 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 12 2ZM12 20C7.59 20 4 16.41 4 12C4 7.59 7.59 4 12 4C16.41 4 20 7.59 20 12C20 16.41 16.41 20 12 20Z" fill="currentColor"></path> </svg>'
}, {
Expand All @@ -19,73 +19,73 @@
icon: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M11 15H13V17H11V15ZM11 7H13V13H11V7ZM11.99 2C6.47 2 2 6.48 2 12C2 17.52 6.47 22 11.99 22C17.52 22 22 17.52 22 12C22 6.48 17.52 2 11.99 2ZM12 20C7.58 20 4 16.42 4 12C4 7.58 7.58 4 12 4C16.42 4 20 7.58 20 12C20 16.42 16.42 20 12 20Z" fill="currentColor"></path> </svg>'
}];

function s(a) {
return a.length ? Object.values([...n, ...a].reduce((r, o) => (r[o.type] = o, r), {})) : n
function n(a) {
return a.length ? Object.values([...i, ...a].reduce((s, c) => (s[c.type] = c, s), {})) : i
}

function c(a) {
return `^(?:\\[\\!${a.toUpperCase()}\\])s*?
?`
function d(a) {
return `^(?:\\[!${a.toUpperCase()}])\\s*?
*`
}

function u(a) {
function g(a) {
return a.slice(0, 1).toUpperCase() + a.slice(1).toLowerCase()
}

function f(a = {}) {
function m(a = {}) {
const {
className: r = "markdown-alert",
variants: o = []
} = a, g = s(o);
className: s = "markdown-alert",
variants: c = []
} = a, w = n(c);
return {
walkTokens(e) {
var t, p, d;
var t, v, u, f;
if (e.type !== "blockquote") return;
const l = g.find(({
type: i
}) => new RegExp(c(i)).test(e.text));
if (l) {
const o = w.find(({
type: r
}) => new RegExp(d(r)).test(e.text));
if (o) {
const {
type: i,
icon: m,
title: w = u(i),
titleClassName: Z = `${r}-title`
} = l;
type: r,
icon: Z,
title: x = g(r),
titleClassName: y = `${s}-title`
} = o, h = new RegExp(d(r));
Object.assign(e, {
type: "alert",
meta: {
className: r,
variant: i,
icon: m,
title: w,
titleClassName: Z
className: s,
variant: r,
icon: Z,
title: x,
titleClassName: y
}
});
const v = (t = e.tokens) == null ? void 0 : t[0];
if ((p = v.raw) == null ? void 0 : p.replace(new RegExp(c(i)), "").trim()) {
const h = v.tokens[0];
Object.assign(h, {
raw: h.raw.replace(new RegExp(c(i)), ""),
text: h.text.replace(new RegExp(c(i)), "")
})
} else(d = e.tokens) == null || d.shift()
const l = (t = e.tokens) == null ? void 0 : t[0];
if ((v = l.raw) == null ? void 0 : v.replace(h, "").trim()) {
const p = l.tokens[0];
Object.assign(p, {
raw: p.raw.replace(h, ""),
text: p.text.replace(h, "")
}), ((u = l.tokens[1]) == null ? void 0 : u.type) === "br" && l.tokens.splice(1, 1)
} else(f = e.tokens) == null || f.shift()
}
},
extensions: [{
name: "alert",
level: "block",
renderer({
meta: e,
tokens: l = []
tokens: o = []
}) {
let t = `<div class="${e.className} ${e.className}-${e.variant}">
`;
return t += `<p class="${e.titleClassName}">`, t += e.icon, t += e.title, t += `</p>
`, t += this.parser.parse(l), t += `</div>
`, t += this.parser.parse(o), t += `</div>
`, t
}
}]
}
}
return f
return m
});
4 changes: 2 additions & 2 deletions live-view/extensions/markdown/marked.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion service-worker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

// update worker name when updating cached files
const WORKER_NAME = 'codeit-worker-v784';
const WORKER_NAME = 'codeit-worker-v785';


self.importScripts('/worker/client-channel.js');
Expand Down