Skip to content
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

Fix: use named exports only for ESM build #2226

Merged
merged 1 commit into from
Oct 7, 2021
Merged
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
158 changes: 84 additions & 74 deletions lib/marked.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* The code in this file is generated from files in ./src/
*/

var marked$1 = {exports: {}};
var esmEntry$1 = {exports: {}};

var defaults$5 = {exports: {}};

Expand Down Expand Up @@ -1360,7 +1360,7 @@ var rules = {
inline: inline$1
};

const Tokenizer$1 = Tokenizer_1$1;
const Tokenizer$2 = Tokenizer_1$1;
const { defaults: defaults$3 } = defaults$5.exports;
const { block, inline } = rules;
const { repeatString } = helpers;
Expand Down Expand Up @@ -1414,7 +1414,7 @@ var Lexer_1$1 = class Lexer {
this.tokens = [];
this.tokens.links = Object.create(null);
this.options = options || defaults$3;
this.options.tokenizer = this.options.tokenizer || new Tokenizer$1();
this.options.tokenizer = this.options.tokenizer || new Tokenizer$2();
this.tokenizer = this.options.tokenizer;
this.tokenizer.options = this.options;
this.tokenizer.lexer = this;
Expand Down Expand Up @@ -2114,9 +2114,9 @@ var Slugger_1$1 = class Slugger {
}
};

const Renderer$1 = Renderer_1$1;
const TextRenderer$1 = TextRenderer_1$1;
const Slugger$1 = Slugger_1$1;
const Renderer$2 = Renderer_1$1;
const TextRenderer$2 = TextRenderer_1$1;
const Slugger$2 = Slugger_1$1;
const { defaults: defaults$1 } = defaults$5.exports;
const {
unescape
Expand All @@ -2128,11 +2128,11 @@ const {
var Parser_1$1 = class Parser {
constructor(options) {
this.options = options || defaults$1;
this.options.renderer = this.options.renderer || new Renderer$1();
this.options.renderer = this.options.renderer || new Renderer$2();
this.renderer = this.options.renderer;
this.renderer.options = this.options;
this.textRenderer = new TextRenderer$1();
this.slugger = new Slugger$1();
this.textRenderer = new TextRenderer$2();
this.slugger = new Slugger$2();
}

/**
Expand Down Expand Up @@ -2401,12 +2401,12 @@ var Parser_1$1 = class Parser {
}
};

const Lexer = Lexer_1$1;
const Parser = Parser_1$1;
const Tokenizer = Tokenizer_1$1;
const Renderer = Renderer_1$1;
const TextRenderer = TextRenderer_1$1;
const Slugger = Slugger_1$1;
const Lexer$1 = Lexer_1$1;
const Parser$1 = Parser_1$1;
const Tokenizer$1 = Tokenizer_1$1;
const Renderer$1 = Renderer_1$1;
const TextRenderer$1 = TextRenderer_1$1;
const Slugger$1 = Slugger_1$1;
const {
merge,
checkSanitizeDeprecation,
Expand All @@ -2421,7 +2421,7 @@ const {
/**
* Marked
*/
function marked(src, opt, callback) {
function marked$1(src, opt, callback) {
// throw error in case of non string input
if (typeof src === 'undefined' || src === null) {
throw new Error('marked(): input parameter is undefined or null');
Expand All @@ -2436,15 +2436,15 @@ function marked(src, opt, callback) {
opt = null;
}

opt = merge({}, marked.defaults, opt || {});
opt = merge({}, marked$1.defaults, opt || {});
checkSanitizeDeprecation(opt);

if (callback) {
const highlight = opt.highlight;
let tokens;

try {
tokens = Lexer.lex(src, opt);
tokens = Lexer$1.lex(src, opt);
} catch (e) {
return callback(e);
}
Expand All @@ -2455,9 +2455,9 @@ function marked(src, opt, callback) {
if (!err) {
try {
if (opt.walkTokens) {
marked.walkTokens(tokens, opt.walkTokens);
marked$1.walkTokens(tokens, opt.walkTokens);
}
out = Parser.parse(tokens, opt);
out = Parser$1.parse(tokens, opt);
} catch (e) {
err = e;
}
Expand All @@ -2479,7 +2479,7 @@ function marked(src, opt, callback) {
if (!tokens.length) return done();

let pending = 0;
marked.walkTokens(tokens, function(token) {
marked$1.walkTokens(tokens, function(token) {
if (token.type === 'code') {
pending++;
setTimeout(() => {
Expand Down Expand Up @@ -2509,11 +2509,11 @@ function marked(src, opt, callback) {
}

try {
const tokens = Lexer.lex(src, opt);
const tokens = Lexer$1.lex(src, opt);
if (opt.walkTokens) {
marked.walkTokens(tokens, opt.walkTokens);
marked$1.walkTokens(tokens, opt.walkTokens);
}
return Parser.parse(tokens, opt);
return Parser$1.parse(tokens, opt);
} catch (e) {
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
if (opt.silent) {
Expand All @@ -2529,24 +2529,24 @@ function marked(src, opt, callback) {
* Options
*/

marked.options =
marked.setOptions = function(opt) {
merge(marked.defaults, opt);
changeDefaults(marked.defaults);
return marked;
marked$1.options =
marked$1.setOptions = function(opt) {
merge(marked$1.defaults, opt);
changeDefaults(marked$1.defaults);
return marked$1;
};

marked.getDefaults = getDefaults;
marked$1.getDefaults = getDefaults;

marked.defaults = defaults;
marked$1.defaults = defaults;

/**
* Use Extension
*/

marked.use = function(...args) {
marked$1.use = function(...args) {
const opts = merge({}, ...args);
const extensions = marked.defaults.extensions || { renderers: {}, childTokens: {} };
const extensions = marked$1.defaults.extensions || { renderers: {}, childTokens: {} };
let hasExtensions;

args.forEach((pack) => {
Expand Down Expand Up @@ -2605,7 +2605,7 @@ marked.use = function(...args) {

// ==-- Parse "overwrite" extensions --== //
if (pack.renderer) {
const renderer = marked.defaults.renderer || new Renderer();
const renderer = marked$1.defaults.renderer || new Renderer$1();
for (const prop in pack.renderer) {
const prevRenderer = renderer[prop];
// Replace renderer with func to run extension, but fall back if false
Expand All @@ -2620,7 +2620,7 @@ marked.use = function(...args) {
opts.renderer = renderer;
}
if (pack.tokenizer) {
const tokenizer = marked.defaults.tokenizer || new Tokenizer();
const tokenizer = marked$1.defaults.tokenizer || new Tokenizer$1();
for (const prop in pack.tokenizer) {
const prevTokenizer = tokenizer[prop];
// Replace tokenizer with func to run extension, but fall back if false
Expand All @@ -2637,7 +2637,7 @@ marked.use = function(...args) {

// ==-- Parse WalkTokens extensions --== //
if (pack.walkTokens) {
const walkTokens = marked.defaults.walkTokens;
const walkTokens = marked$1.defaults.walkTokens;
opts.walkTokens = (token) => {
pack.walkTokens.call(this, token);
if (walkTokens) {
Expand All @@ -2650,40 +2650,40 @@ marked.use = function(...args) {
opts.extensions = extensions;
}

marked.setOptions(opts);
marked$1.setOptions(opts);
});
};

/**
* Run callback for every token
*/

marked.walkTokens = function(tokens, callback) {
marked$1.walkTokens = function(tokens, callback) {
for (const token of tokens) {
callback(token);
switch (token.type) {
case 'table': {
for (const cell of token.header) {
marked.walkTokens(cell.tokens, callback);
marked$1.walkTokens(cell.tokens, callback);
}
for (const row of token.rows) {
for (const cell of row) {
marked.walkTokens(cell.tokens, callback);
marked$1.walkTokens(cell.tokens, callback);
}
}
break;
}
case 'list': {
marked.walkTokens(token.items, callback);
marked$1.walkTokens(token.items, callback);
break;
}
default: {
if (marked.defaults.extensions && marked.defaults.extensions.childTokens && marked.defaults.extensions.childTokens[token.type]) { // Walk any extensions
marked.defaults.extensions.childTokens[token.type].forEach(function(childTokens) {
marked.walkTokens(token[childTokens], callback);
if (marked$1.defaults.extensions && marked$1.defaults.extensions.childTokens && marked$1.defaults.extensions.childTokens[token.type]) { // Walk any extensions
marked$1.defaults.extensions.childTokens[token.type].forEach(function(childTokens) {
marked$1.walkTokens(token[childTokens], callback);
});
} else if (token.tokens) {
marked.walkTokens(token.tokens, callback);
marked$1.walkTokens(token.tokens, callback);
}
}
}
Expand All @@ -2693,7 +2693,7 @@ marked.walkTokens = function(tokens, callback) {
/**
* Parse Inline
*/
marked.parseInline = function(src, opt) {
marked$1.parseInline = function(src, opt) {
// throw error in case of non string input
if (typeof src === 'undefined' || src === null) {
throw new Error('marked.parseInline(): input parameter is undefined or null');
Expand All @@ -2703,15 +2703,15 @@ marked.parseInline = function(src, opt) {
+ Object.prototype.toString.call(src) + ', string expected');
}

opt = merge({}, marked.defaults, opt || {});
opt = merge({}, marked$1.defaults, opt || {});
checkSanitizeDeprecation(opt);

try {
const tokens = Lexer.lexInline(src, opt);
const tokens = Lexer$1.lexInline(src, opt);
if (opt.walkTokens) {
marked.walkTokens(tokens, opt.walkTokens);
marked$1.walkTokens(tokens, opt.walkTokens);
}
return Parser.parseInline(tokens, opt);
return Parser$1.parseInline(tokens, opt);
} catch (e) {
e.message += '\nPlease report this to https://github.com/markedjs/marked.';
if (opt.silent) {
Expand All @@ -2727,27 +2727,37 @@ marked.parseInline = function(src, opt) {
* Expose
*/

marked.Parser = Parser;
marked.parser = Parser.parse;
marked.Renderer = Renderer;
marked.TextRenderer = TextRenderer;
marked.Lexer = Lexer;
marked.lexer = Lexer.lex;
marked.Tokenizer = Tokenizer;
marked.Slugger = Slugger;
marked.parse = marked;

marked$1.exports = marked;
var parse = marked$1.exports.parse = marked;
var Parser_1 = marked$1.exports.Parser = Parser;
var parser = marked$1.exports.parser = Parser.parse;
var Renderer_1 = marked$1.exports.Renderer = Renderer;
var TextRenderer_1 = marked$1.exports.TextRenderer = TextRenderer;
var Lexer_1 = marked$1.exports.Lexer = Lexer;
var lexer = marked$1.exports.lexer = Lexer.lex;
var Tokenizer_1 = marked$1.exports.Tokenizer = Tokenizer;
var Slugger_1 = marked$1.exports.Slugger = Slugger;

var marked_1 = marked$1.exports;

export { Lexer_1 as Lexer, Parser_1 as Parser, Renderer_1 as Renderer, Slugger_1 as Slugger, TextRenderer_1 as TextRenderer, Tokenizer_1 as Tokenizer, marked_1 as default, lexer, parse, parser };
marked$1.Parser = Parser$1;
marked$1.parser = Parser$1.parse;
marked$1.Renderer = Renderer$1;
marked$1.TextRenderer = TextRenderer$1;
marked$1.Lexer = Lexer$1;
marked$1.lexer = Lexer$1.lex;
marked$1.Tokenizer = Tokenizer$1;
marked$1.Slugger = Slugger$1;
marked$1.parse = marked$1;

var marked_1 = marked$1;

const marked = marked_1;
const Lexer = Lexer_1$1;
const Parser = Parser_1$1;
const Tokenizer = Tokenizer_1$1;
const Renderer = Renderer_1$1;
const TextRenderer = TextRenderer_1$1;
const Slugger = Slugger_1$1;

esmEntry$1.exports = marked;
var parse = esmEntry$1.exports.parse = marked;
var Parser_1 = esmEntry$1.exports.Parser = Parser;
var parser = esmEntry$1.exports.parser = Parser.parse;
var Renderer_1 = esmEntry$1.exports.Renderer = Renderer;
var TextRenderer_1 = esmEntry$1.exports.TextRenderer = TextRenderer;
var Lexer_1 = esmEntry$1.exports.Lexer = Lexer;
var lexer = esmEntry$1.exports.lexer = Lexer.lex;
var Tokenizer_1 = esmEntry$1.exports.Tokenizer = Tokenizer;
var Slugger_1 = esmEntry$1.exports.Slugger = Slugger;

var esmEntry = esmEntry$1.exports;

export { Lexer_1 as Lexer, Parser_1 as Parser, Renderer_1 as Renderer, Slugger_1 as Slugger, TextRenderer_1 as TextRenderer, Tokenizer_1 as Tokenizer, esmEntry as default, lexer, parse, parser };
Loading