Skip to content

Commit

Permalink
feat: Add notesAutotitle prop
Browse files Browse the repository at this point in the history
  • Loading branch information
3y3 committed Feb 1, 2024
1 parent e0320bf commit 9a89834
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/transform/plugins/notes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ function matchWrongNotes(tokens: Token[], i: number) {

const findCloseTokenIdx = closeTokenFactory('Note', matchOpenToken, matchCloseToken);

const notes: MarkdownItPluginCb = (md, {lang, path: optPath, log}) => {
// @ts-ignore
const notes: MarkdownItPluginCb = (md, {lang, notesAutotitle, path: optPath, log}) => {
notesAutotitle = typeof notesAutotitle === 'boolean' ? notesAutotitle : true;

const plugin = (state: StateCore) => {
const {tokens, env} = state;
const path = env.path || optPath;
Expand Down Expand Up @@ -99,7 +102,9 @@ const notes: MarkdownItPluginCb = (md, {lang, path: optPath, log}) => {
titleOpen.block = true;
titleClose.block = true;

titleInline.content = match[2] === undefined ? getTitle(type, lang) : match[2];
const autotitle = notesAutotitle ? getTitle(type, lang) : '';

titleInline.content = match[2] === undefined ? autotitle : match[2];
titleInline.children = [];

const contentOpen = new state.Token('yfm_note_content_open', 'div', 1);
Expand Down

0 comments on commit 9a89834

Please sign in to comment.