Skip to content

Commit

Permalink
feat: add content node to note
Browse files Browse the repository at this point in the history
  • Loading branch information
rusandorx committed Nov 10, 2023
1 parent 60058e9 commit 2ca35b7
Show file tree
Hide file tree
Showing 3 changed files with 234 additions and 195 deletions.
11 changes: 11 additions & 0 deletions src/transform/plugins/notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@ const notes: MarkdownItPluginCb = (md, {lang, path: optPath, log}) => {

titleInline.content = match[2] === undefined ? getTitle(type, lang) : match[2];
titleInline.children = [];

const contentOpen = new state.Token('yfm_note_content_open', 'div', 1);
contentOpen.attrSet('class', 'yfm-note-content');
const contentClose = new state.Token('yfm_note_content_close', 'div', -1);

if (newOpenToken.map) {
contentOpen.map = [newOpenToken.map[0] + 2, newOpenToken.map[1] + 2];
}

state.md.inline.parse(
titleInline.content,
state.md,
Expand All @@ -108,7 +117,9 @@ const notes: MarkdownItPluginCb = (md, {lang, path: optPath, log}) => {
titleOpen,
titleInline,
titleClose,
contentOpen,
...tokens.slice(i + 3, closeTokenIdx),
contentClose,
newCloseToken,
];
tokens.splice(i, closeTokenIdx - i + 3, ...insideTokens);
Expand Down
Loading

0 comments on commit 2ca35b7

Please sign in to comment.