Skip to content

Commit

Permalink
🐛 Parse admonitions within lists
Browse files Browse the repository at this point in the history
Fixes: #26
  • Loading branch information
mterrel committed Jan 14, 2020
1 parent e817fb4 commit 5d70c74
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/parser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@ describe('parser', () => {
`);
});

test('should render a callout within a list', () => {
md.use(plugin());
expect(md.render(`- A list\n\n :::note\n Info\n ABC\n :::\n`)).toMatchInlineSnapshot(`
"<ul>
<li><p>A list</p>
<div class=\\"admonition admonition-note\\">
<div class=\\"admonition-heading\\">
<h5><div class=\\"admonition-icon\\">ℹ️</div> note</h5>
</div>
<div class=\\"admonition-content\\">
<p>Info</p>
<p>ABC</p>
</div></div></li>
</ul>
"
`);
});

test('should ignore content after callout', () => {
md.use(plugin());
expect(
Expand Down
2 changes: 1 addition & 1 deletion src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const parser: Remarkable.BlockParsingRule = (
endLine,
silent
) => {
let pos = state.bMarks[startLine] + state.blkIndent;
let pos = state.bMarks[startLine] + state.tShift[startLine];
const max = state.eMarks[startLine];

// Not enough chars or ending line with `:::`.
Expand Down

0 comments on commit 5d70c74

Please sign in to comment.