Skip to content

Commit

Permalink
feat: add placeholder to note
Browse files Browse the repository at this point in the history
  • Loading branch information
rusandorx committed Nov 1, 2023
1 parent 60058e9 commit e5530e8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/transform/plugins/notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,18 @@ 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) {
const contentOpenStart = newOpenToken.map[0] + 1;
const contentOpenEnd = newOpenToken.map[0] + 2;

contentOpen.map = [contentOpenStart, contentOpenEnd];
}

state.md.inline.parse(
titleInline.content,
state.md,
Expand All @@ -108,7 +120,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

0 comments on commit e5530e8

Please sign in to comment.