Skip to content

Commit

Permalink
fix: Multiline asides
Browse files Browse the repository at this point in the history
  • Loading branch information
nzakas committed Mar 25, 2022
1 parent 4fa1c51 commit c48bc84
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 41 deletions.
13 changes: 8 additions & 5 deletions src/markua-aside.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,18 +249,21 @@ export function asidePlugin(md) {

let originalBMark = state.bMarks[startLine];
let originalEMark = state.eMarks[startLine];
let lineToTokenize = startLine + 1;
let fromLine = startTag.lineNumber;
let toLine = endTag.lineNumber;

if (!startTag.alone) {
if (startTag.alone) {
fromLine++;
} else {
state.bMarks[startTag.lineNumber] = startTag.end;
lineToTokenize = startLine;
}

if (!endTag.alone) {
toLine++;
state.eMarks[endTag.lineNumber] = endTag.start;
}

state.md.block.tokenize(state, lineToTokenize, lineToTokenize + 1);
state.md.block.tokenize(state, fromLine, toLine);

state.bMarks[startLine] = originalBMark;
state.eMarks[startLine] = originalEMark;
Expand All @@ -272,7 +275,7 @@ export function asidePlugin(md) {

state.parentType = originalParent;
state.lineMax = originalLineMax;
state.line = nextLine + 1;
state.line = endTag.lineNumber + 1;

return true;
}
Expand Down
36 changes: 0 additions & 36 deletions tests/fixtures/aside-block.txt

This file was deleted.

89 changes: 89 additions & 0 deletions tests/fixtures/aside-tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@

.
{aside}
Hello world!
{/aside}
.
<aside>
<p>Hello world!</p>
</aside>
.

.
{aside}Hello world!{/aside}
.
<aside>
<p>Hello world!</p>
</aside>
.

.
{aside}Hello world!
{/aside}
.
<aside>
<p>Hello world!</p>
</aside>
.

.
{aside}
Hello world!{/aside}
.
<aside>
<p>Hello world!</p>
</aside>
.

.
Lorem inspum sit dolor.

{aside}
Hello world!{/aside}

Lorem inspum sit dolor.
.
<p>Lorem inspum sit dolor.</p>
<aside>
<p>Hello world!</p>
</aside>
<p>Lorem inspum sit dolor.</p>
.

.
Lorem inspum sit dolor.

{aside}
Hello world!

Hello again!{/aside}

Lorem inspum sit dolor.
.
<p>Lorem inspum sit dolor.</p>
<aside>
<p>Hello world!</p>
<p>Hello again!</p>
</aside>
<p>Lorem inspum sit dolor.</p>
.


.
Lorem inspum sit dolor.

{aside}
Hello world!

Hello again!
{/aside}

Lorem inspum sit dolor.
.
<p>Lorem inspum sit dolor.</p>
<aside>
<p>Hello world!</p>
<p>Hello again!</p>
</aside>
<p>Lorem inspum sit dolor.</p>
.
File renamed without changes.

0 comments on commit c48bc84

Please sign in to comment.