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

chore(deps): bump marked from 12.0.2 to 15.0.4 #305

Merged
merged 5 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
21 changes: 12 additions & 9 deletions lib/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ function mangleEmail(text) {

const renderer = {
// Add id attribute to headings
heading(text, level) {
heading({ tokens, depth: level }) {
let text = this.parser.parseInline(tokens);
const { anchorAlias, headerIds, modifyAnchors, _headingId } = this.options;

if (!headerIds) {
Expand Down Expand Up @@ -67,7 +68,8 @@ const renderer = {
return `<h${level} id="${id}"><a href="#${id}" class="headerlink" title="${stripHTML(text)}"></a>${text}</h${level}>`;
},

link(href, title, text) {
link({ tokens, href, title }) {
const text = this.parser.parseInline(tokens);
const { external_link, sanitizeUrl, hexo, mangle } = this.options;
const { url: urlCfg } = hexo.config;

Expand Down Expand Up @@ -96,7 +98,7 @@ const renderer = {
out += '"';

if (title) {
out += ` title="${title}"`;
out += ` title="${escape(title)}"`;
}
if (external_link) {
const target = ' target="_blank"';
Expand All @@ -118,7 +120,8 @@ const renderer = {
},

// Support Basic Description Lists
paragraph(text) {
paragraph({ tokens }) {
const text = this.parser.parseInline(tokens);
const { descriptionLists = true } = this.options;

if (descriptionLists) {
Expand All @@ -131,7 +134,7 @@ const renderer = {
},

// Prepend root to image path
image(href, title, text) {
image({ href, title, text }) {
const { options } = this;
const { hexo } = options;
const { relative_link } = hexo.config;
Expand All @@ -149,8 +152,8 @@ const renderer = {
}

let out = `<img src="${encodeURL(href)}"`;
if (text) out += ` alt="${text}"`;
if (title) out += ` title="${title}"`;
if (text) out += ` alt="${escape(text)}"`;
if (title) out += ` title="${escape(title)}"`;
if (lazyload) out += ' loading="lazy"';

out += '>';
Expand Down Expand Up @@ -185,7 +188,7 @@ const smartypants = (str, quotes) => {
};

const tokenizer = {
// Support AutoLink option
// Support autolink option
url(src) {
const { autolink } = this.options;

Expand Down Expand Up @@ -225,7 +228,7 @@ module.exports = function(data, options) {
// exec filter to extend marked
this.execFilterSync('marked:use', marked.use, { context: this });

// exec filter to extend renderer.
// exec filter to extend renderer
this.execFilterSync('marked:renderer', renderer, { context: this });

// exec filter to extend tokenizer
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"dompurify": "^3.0.3",
"hexo-util": "^3.1.0",
"jsdom": "^20.0.1",
"marked": "^12.0.1"
"marked": "^15.0.4"
},
"devDependencies": {
"c8": "^10.1.2",
Expand Down
8 changes: 5 additions & 3 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -901,12 +901,15 @@ describe('Marked renderer', () => {
});

describe('exec filter to extend', () => {
// Clear the cache, as the filter might permanently modify the tokenizer
// thereby affecting other test cases
delete require.cache[require.resolve('../lib/renderer')];
const hexo = new Hexo(__dirname, {silent: true});
hexo.config.marked = {};

it('should execute filter registered to marked:renderer', () => {
hexo.extend.filter.register('marked:renderer', renderer => {
renderer.image = function(href, title, text) {
renderer.image = function({ href }) {
return `<img data-src="${encodeURL(href)}">`;
};
});
Expand Down Expand Up @@ -949,7 +952,7 @@ describe('Marked renderer', () => {
const r = require('../lib/renderer').bind(hexo);

const result = r({text: body});
result.should.eql(`<p>${smartypants(body)}</p>\n`);
result.should.eql(`<p>${escapeHTML(smartypants(body))}</p>\n`);
});

it('should execute filter registered to marked:extensions', () => {
Expand Down Expand Up @@ -1042,6 +1045,5 @@ describe('Marked renderer', () => {
'<p><a href="http://hexo.io/">Hexo</a></p>\n'
].join(''));
});

});
});
Loading