Skip to content

Commit

Permalink
Update comment for the reason
Browse files Browse the repository at this point in the history
  • Loading branch information
myl7 committed Feb 19, 2024
1 parent ce013a1 commit cc13db7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@ const handleNode =
// So we just need to addtionally check if the following one is a block.
// The legacy title variant is not affected since it checks an inline and does not case the newline.

// No addtional inlines can exist in this paragraph for the title
// No addtional inlines can exist in this paragraph for the title...
if (paragraph.children.length > 1) {
// Carriage returns are allowed by GitHub flavored Markdown.
// It makes a more coherent rendering in environments were admonitions aren't supported.
// When they are, we must strip the unnecessary `<br />` prepended in the first `<p>`.
// Unless it is an inline break, which can be transformed to from 2 spaces with a newline.
if (paragraph.children.at(1)?.type == 'break') {
// When it is, we actually have already found the line break required by GitHub.
// So we just strip the additional `<br>` element.
// The title element will be removed later.
paragraph.children.splice(1, 1)
} else {
return
Expand Down
1 change: 1 addition & 0 deletions test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ describe('GitHub beta blockquote-based admonitions with titles like [!NOTE]', fu
'# Admonitions\n' +
// So that the title isn't put inline with the forecoming text,
// when no GFM admonitions are available.
// These 2 spaces with the newline are transformed into an inline break.
// ----------vv
'> [!WARNING] \n' +
'> Critical content demanding immediate user attention due to potential risks.\n',
Expand Down

0 comments on commit cc13db7

Please sign in to comment.