From af966a34cd344fd4b963f0dbaeedb209b7d5bee7 Mon Sep 17 00:00:00 2001 From: tlylt Date: Tue, 28 Dec 2021 20:20:25 +0800 Subject: [PATCH 1/2] hr elements does not accept multiple classes Like other elements, hr elements should also allow multiple classes to be added. Currently, hr elements have a direct assignment of attributes in patterns.js. Thus, multiple class attributes are not combined into one. By using the `utils.addAttrs` method, the attribute values will be merged correctly. This bug fix helps with attributes on hr elements. Example:`--- {.a .b}` Before:`
` After: `
` --- patterns.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/patterns.js b/patterns.js index 0744a7b..1acec80 100644 --- a/patterns.js +++ b/patterns.js @@ -296,7 +296,8 @@ module.exports = options => { token.nesting = 0; let content = tokens[i + 1].content; let start = content.lastIndexOf(options.leftDelimiter); - token.attrs = utils.getAttrs(content, start, options); + let attrs = utils.getAttrs(content, start, options); + utils.addAttrs(attrs, token); token.markup = content; tokens.splice(i + 1, 2); } From 7043c29a79ec4957291f2eaa21bc0ad98d541c24 Mon Sep 17 00:00:00 2001 From: tlylt Date: Tue, 28 Dec 2021 21:12:34 +0800 Subject: [PATCH 2/2] add test for
multiple classes --- test.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test.js b/test.js index 5589436..bffdae9 100644 --- a/test.js +++ b/test.js @@ -389,6 +389,12 @@ function describeTestsWithOptions(options, postText) { expected = '

text

\n'; assert.equal(md.render(replaceDelimiters(src, options)), expected); }); + + it(replaceDelimiters('should support multiple classes for
', options), () => { + src = '--- {.a .b}'; + expected = '
\n'; + assert.equal(md.render(replaceDelimiters(src, options)), expected); + }); }); }