Skip to content

Commit

Permalink
try to get positions right
Browse files Browse the repository at this point in the history
  • Loading branch information
josh-heyer committed Feb 6, 2021
1 parent f7f1750 commit 14bacf0
Show file tree
Hide file tree
Showing 9 changed files with 2,334 additions and 2,320 deletions.
28 changes: 20 additions & 8 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,23 +280,35 @@ function attacher(options) {
const contentString = content.join(NEWLINE).replace(escapeTag, config.tag);
const add = eat(opening + food.join(NEWLINE));

// parse the content in block mode
const exit = ctx.enterBlock();
const contentNodes = {
type: "admonition-content",
children: ctx.tokenizeBlock(contentString, now)
};
exit();
let titleOffset = opening.indexOf(title);
if (titleOffset < 0)
titleOffset = indentSize + (quoted ? keyword.length+1 : 0);
const titleNow = Object.assign({}, now, {
column: now.column + titleOffset,
offset: now.offset + titleOffset,
});

// parse the title in inline mode
const titleNodes = {
type: "admonition-heading",
children: ctx.tokenizeInline(
title === "" ? "" : title || formatKeyword(keyword),
now
titleNow
)
};

++now.line;
now.column = 1;
now.offset += opening.length;

// parse the content in block mode
const exit = ctx.enterBlock();
const contentNodes = {
type: "admonition-content",
children: ctx.tokenizeBlock(contentString, now)
};
exit();

return add({
type: "admonition",
keyword,
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
"plugin"
],
"author": "Elvis Wolcott",
"contributors": ["Josh Heyer"],
"contributors": [
"Josh Heyer"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/elviswolcott/remark-admonitions/issues"
Expand Down
Loading

0 comments on commit 14bacf0

Please sign in to comment.