Skip to content

Commit

Permalink
Updated bundled files
Browse files Browse the repository at this point in the history
  • Loading branch information
DreierF committed Jul 29, 2023
1 parent 626b738 commit aae4d6e
Show file tree
Hide file tree
Showing 7 changed files with 433 additions and 440 deletions.
286 changes: 142 additions & 144 deletions lib/marked.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
Expand All @@ -28,9 +27,18 @@ var __copyProps = (to, from, except, desc) => {
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __publicField = (obj, key, value) => {
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
var __accessCheck = (obj, member, msg) => {
if (!member.has(obj))
throw TypeError("Cannot " + msg);
};
var __privateAdd = (obj, member, value) => {
if (member.has(obj))
throw TypeError("Cannot add the same private member more than once");
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
};
var __privateMethod = (obj, member, method) => {
__accessCheck(obj, member, "access private method");
return method;
};

// src/marked.ts
Expand Down Expand Up @@ -337,9 +345,6 @@ function indentCodeCompensation(raw, text) {
}).join("\n");
}
var _Tokenizer = class {
options;
rules;
lexer;
constructor(options2) {
this.options = options2 || _defaults;
}
Expand Down Expand Up @@ -1095,11 +1100,6 @@ function mangle(text) {
return out;
}
var _Lexer = class {
tokens;
options;
state;
tokenizer;
inlineQueue;
constructor(options2) {
this.tokens = [];
this.tokens.links = /* @__PURE__ */ Object.create(null);
Expand Down Expand Up @@ -1468,7 +1468,6 @@ var _Lexer = class {

// src/Renderer.ts
var _Renderer = class {
options;
constructor(options2) {
this.options = options2 || _defaults;
}
Expand Down Expand Up @@ -1619,7 +1618,6 @@ var _TextRenderer = class {

// src/Slugger.ts
var _Slugger = class {
seen;
constructor() {
this.seen = {};
}
Expand Down Expand Up @@ -1656,10 +1654,6 @@ var _Slugger = class {

// src/Parser.ts
var _Parser = class {
options;
renderer;
textRenderer;
slugger;
constructor(options2) {
this.options = options2 || _defaults;
this.options.renderer = this.options.renderer || new _Renderer();
Expand Down Expand Up @@ -1894,7 +1888,6 @@ var _Parser = class {

// src/Hooks.ts
var _Hooks = class {
options;
constructor(options2) {
this.options = options2 || _defaults;
}
Expand All @@ -1911,27 +1904,30 @@ var _Hooks = class {
return html;
}
};
__publicField(_Hooks, "passThroughHooks", /* @__PURE__ */ new Set([
_Hooks.passThroughHooks = /* @__PURE__ */ new Set([
"preprocess",
"postprocess"
]));
]);

// src/Instance.ts
var _parseMarkdown, parseMarkdown_fn, _onError, onError_fn;
var Marked = class {
defaults = _getDefaults();
options = this.setOptions;
parse = this.#parseMarkdown(_Lexer.lex, _Parser.parse);
parseInline = this.#parseMarkdown(_Lexer.lexInline, _Parser.parseInline);
Parser = _Parser;
parser = _Parser.parse;
Renderer = _Renderer;
TextRenderer = _TextRenderer;
Lexer = _Lexer;
lexer = _Lexer.lex;
Tokenizer = _Tokenizer;
Slugger = _Slugger;
Hooks = _Hooks;
constructor(...args) {
__privateAdd(this, _parseMarkdown);
__privateAdd(this, _onError);
this.defaults = _getDefaults();
this.options = this.setOptions;
this.parse = __privateMethod(this, _parseMarkdown, parseMarkdown_fn).call(this, _Lexer.lex, _Parser.parse);
this.parseInline = __privateMethod(this, _parseMarkdown, parseMarkdown_fn).call(this, _Lexer.lexInline, _Parser.parseInline);
this.Parser = _Parser;
this.parser = _Parser.parse;
this.Renderer = _Renderer;
this.TextRenderer = _TextRenderer;
this.Lexer = _Lexer;
this.lexer = _Lexer.lex;
this.Tokenizer = _Tokenizer;
this.Slugger = _Slugger;
this.Hooks = _Hooks;
this.use(...args);
}
/**
Expand Down Expand Up @@ -2098,131 +2094,133 @@ var Marked = class {
this.defaults = { ...this.defaults, ...opt };
return this;
}
#parseMarkdown(lexer2, parser2) {
return (src, optOrCallback, callback) => {
if (typeof optOrCallback === "function") {
callback = optOrCallback;
optOrCallback = null;
}
const origOpt = { ...optOrCallback };
const opt = { ...this.defaults, ...origOpt };
const throwError = this.#onError(!!opt.silent, !!opt.async, callback);
if (typeof src === "undefined" || src === null) {
return throwError(new Error("marked(): input parameter is undefined or null"));
}
if (typeof src !== "string") {
return throwError(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected"));
}
checkDeprecations(opt, callback);
if (opt.hooks) {
opt.hooks.options = opt;
}
if (callback) {
const highlight = opt.highlight;
let tokens;
try {
if (opt.hooks) {
src = opt.hooks.preprocess(src);
}
tokens = lexer2(src, opt);
} catch (e) {
return throwError(e);
}
const done = (err) => {
let out;
if (!err) {
try {
if (opt.walkTokens) {
this.walkTokens(tokens, opt.walkTokens);
}
out = parser2(tokens, opt);
if (opt.hooks) {
out = opt.hooks.postprocess(out);
}
} catch (e) {
err = e;
}
}
opt.highlight = highlight;
return err ? throwError(err) : callback(null, out);
};
if (!highlight || highlight.length < 3) {
return done();
}
delete opt.highlight;
if (!tokens.length)
return done();
let pending = 0;
this.walkTokens(tokens, (token) => {
if (token.type === "code") {
pending++;
setTimeout(() => {
highlight(token.text, token.lang, (err, code) => {
if (err) {
return done(err);
}
if (code != null && code !== token.text) {
token.text = code;
token.escaped = true;
}
pending--;
if (pending === 0) {
done();
}
});
}, 0);
}
});
if (pending === 0) {
done();
}
return;
}
if (opt.async) {
return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then((src2) => lexer2(src2, opt)).then((tokens) => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens).then((tokens) => parser2(tokens, opt)).then((html) => opt.hooks ? opt.hooks.postprocess(html) : html).catch(throwError);
}
};
_parseMarkdown = new WeakSet();
parseMarkdown_fn = function(lexer2, parser2) {
return (src, optOrCallback, callback) => {
if (typeof optOrCallback === "function") {
callback = optOrCallback;
optOrCallback = null;
}
const origOpt = { ...optOrCallback };
const opt = { ...this.defaults, ...origOpt };
const throwError = __privateMethod(this, _onError, onError_fn).call(this, !!opt.silent, !!opt.async, callback);
if (typeof src === "undefined" || src === null) {
return throwError(new Error("marked(): input parameter is undefined or null"));
}
if (typeof src !== "string") {
return throwError(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected"));
}
checkDeprecations(opt, callback);
if (opt.hooks) {
opt.hooks.options = opt;
}
if (callback) {
const highlight = opt.highlight;
let tokens;
try {
if (opt.hooks) {
src = opt.hooks.preprocess(src);
}
const tokens = lexer2(src, opt);
if (opt.walkTokens) {
this.walkTokens(tokens, opt.walkTokens);
}
let html = parser2(tokens, opt);
if (opt.hooks) {
html = opt.hooks.postprocess(html);
}
return html;
tokens = lexer2(src, opt);
} catch (e) {
return throwError(e);
}
};
}
#onError(silent, async, callback) {
return (e) => {
e.message += "\nPlease report this to https://github.com/markedjs/marked.";
if (silent) {
const msg = "<p>An error occurred:</p><pre>" + escape(e.message + "", true) + "</pre>";
if (async) {
return Promise.resolve(msg);
const done = (err) => {
let out;
if (!err) {
try {
if (opt.walkTokens) {
this.walkTokens(tokens, opt.walkTokens);
}
out = parser2(tokens, opt);
if (opt.hooks) {
out = opt.hooks.postprocess(out);
}
} catch (e) {
err = e;
}
}
if (callback) {
callback(null, msg);
return;
opt.highlight = highlight;
return err ? throwError(err) : callback(null, out);
};
if (!highlight || highlight.length < 3) {
return done();
}
delete opt.highlight;
if (!tokens.length)
return done();
let pending = 0;
this.walkTokens(tokens, (token) => {
if (token.type === "code") {
pending++;
setTimeout(() => {
highlight(token.text, token.lang, (err, code) => {
if (err) {
return done(err);
}
if (code != null && code !== token.text) {
token.text = code;
token.escaped = true;
}
pending--;
if (pending === 0) {
done();
}
});
}, 0);
}
return msg;
});
if (pending === 0) {
done();
}
return;
}
if (opt.async) {
return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then((src2) => lexer2(src2, opt)).then((tokens) => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens).then((tokens) => parser2(tokens, opt)).then((html) => opt.hooks ? opt.hooks.postprocess(html) : html).catch(throwError);
}
try {
if (opt.hooks) {
src = opt.hooks.preprocess(src);
}
const tokens = lexer2(src, opt);
if (opt.walkTokens) {
this.walkTokens(tokens, opt.walkTokens);
}
let html = parser2(tokens, opt);
if (opt.hooks) {
html = opt.hooks.postprocess(html);
}
return html;
} catch (e) {
return throwError(e);
}
};
};
_onError = new WeakSet();
onError_fn = function(silent, async, callback) {
return (e) => {
e.message += "\nPlease report this to https://github.com/markedjs/marked.";
if (silent) {
const msg = "<p>An error occurred:</p><pre>" + escape(e.message + "", true) + "</pre>";
if (async) {
return Promise.reject(e);
return Promise.resolve(msg);
}
if (callback) {
callback(e);
callback(null, msg);
return;
}
throw e;
};
}
return msg;
}
if (async) {
return Promise.reject(e);
}
if (callback) {
callback(e);
return;
}
throw e;
};
};

// src/marked.ts
Expand Down
2 changes: 1 addition & 1 deletion lib/marked.cjs.map

Large diffs are not rendered by default.

Loading

0 comments on commit aae4d6e

Please sign in to comment.