diff --git a/patterns.js b/patterns.js index 3f8f2e5..be68fe3 100644 --- a/patterns.js +++ b/patterns.js @@ -324,7 +324,7 @@ module.exports = options => { const content = token.content; const attrs = utils.getAttrs(content, content.lastIndexOf(options.leftDelimiter), options); let ii = i + 1; - while (tokens[ii + 1] && tokens[ii + 1].nesting === -1) { ii++; } + do if (tokens[ii] && tokens[ii].nesting === -1) { break; } while (ii++ < tokens.length); const openingToken = utils.getMatchingOpeningToken(tokens, ii); utils.addAttrs(attrs, openingToken); const trimmed = content.slice(0, content.lastIndexOf(options.leftDelimiter)); diff --git a/test.js b/test.js index da9e9a5..88d47f7 100644 --- a/test.js +++ b/test.js @@ -292,6 +292,34 @@ function describeTestsWithOptions(options, postText) { assert.equal(md.render(replaceDelimiters(src, options)), expected); }); + it(replaceDelimiters('should apply attributes to the last column of tables', options), () => { + src = '| title | title {.title-primar} |\n'; + src += '| :---: | :---: |\n'; + src += '| text | text {.text-primar} |\n'; + src += '| text {.text-primary} | text |\n'; + src += '\n'; + src += '{.c}'; + expected = '\n'; + expected += '\n'; + expected += '\n'; + expected += '\n'; + expected += '\n'; + expected += '\n'; + expected += '\n'; + expected += '\n'; + expected += '\n'; + expected += '\n'; + expected += '\n'; + expected += '\n'; + expected += '\n'; + expected += '\n'; + expected += '\n'; + expected += '\n'; + expected += '\n'; + expected += '
titletitle
texttext
texttext
\n'; + assert.equal(md.render(replaceDelimiters(src, options)), expected); + }); + it(replaceDelimiters('should support nested lists', options), () => { src = '- item\n'; src += ' - nested\n';