Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/transform/plugins/code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {generateID} from './utils';

const wrapInClipboard = (element: string | undefined, id: number) => {
return `
<div class="yfm-clipboard">
<div class="code-block-container yfm-clipboard">
${element}
<button class="yfm-clipboard-button" aria-label="Copy">
<svg width="16" height="16" viewBox="0 0 24 24" class="yfm-clipboard-icon" data-animation="${id}">
Expand Down
17 changes: 17 additions & 0 deletions src/transform/plugins/notes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,23 @@ const index: MarkdownItPluginCb = (md, {lang, notesAutotitle, path: optPath, log
} catch (e) {
md.core.ruler.push('notes', plugin);
}

md.renderer.rules['yfm_note_open'] = (tokens, idx, _opts, _env, self) => {
const token = tokens[idx];

const containerClassName = 'yfm-note-container';

return [
`<div class="${containerClassName}">`,
`<${token.tag}${self.renderAttrs(token)}>`,
].join('\n');
};

md.renderer.rules['yfm_note_close'] = (tokens, idx) => {
const token = tokens[idx];

return [`</${token.tag}>`, '</div>'].join('\n');
};
};

export = index;
17 changes: 17 additions & 0 deletions src/transform/plugins/table/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,23 @@ const yfmTable: MarkdownItPluginCb = (md) => {
return true;
},
);

md.renderer.rules['yfm_table_open'] = (tokens, idx, _opts, _env, self) => {
const token = tokens[idx];

const containerClassName = 'yfm-table-container';

return [
`<div class="${containerClassName}">`,
`<${token.tag}${self.renderAttrs(token)}>\n`,
].join('\n');
};

md.renderer.rules['yfm_table_close'] = (tokens, idx) => {
const token = tokens[idx];

return [`</${token.tag}>`, '</div>\n'].join('\n');
};
};

export = yfmTable;
176 changes: 97 additions & 79 deletions test/__snapshots__/notes.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,126 +1,144 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Alerts should render nested notes 1`] = `
<div class="yfm-note yfm-accent-info"
note-type="info"
>
<p class="yfm-note-title">
Outer title
</p>
<div class="yfm-note-content">
<p>
Outer content
<div class="yfm-note-container">
<div class="yfm-note yfm-accent-info"
note-type="info"
>
<p class="yfm-note-title">
Outer title
</p>
<div class="yfm-note yfm-accent-info"
note-type="info"
>
<p class="yfm-note-title">
Inner title
<div class="yfm-note-content">
<p>
Outer content
</p>
<div class="yfm-note-content">
<p>
Inner content
</p>
<div class="yfm-note-container">
<div class="yfm-note yfm-accent-info"
note-type="info"
>
<p class="yfm-note-title">
Inner title
</p>
<div class="yfm-note-content">
<p>
Inner content
</p>
</div>
</div>
</div>
</div>
</div>
</div>
`;

exports[`Alerts should render note with empty string title 1`] = `
<div class="yfm-note yfm-accent-info"
note-type="info"
>
<div class="yfm-note-content">
<p>
Note content with empty string title
</p>
<div class="yfm-note-container">
<div class="yfm-note yfm-accent-info"
note-type="info"
>
<div class="yfm-note-content">
<p>
Note content with empty string title
</p>
</div>
</div>
</div>
`;

exports[`Alerts should render note without title (notesAutotitle: false) 1`] = `
<div class="yfm-note yfm-accent-info"
note-type="info"
>
<div class="yfm-note-content">
<p>
Note content without title
</p>
<div class="yfm-note-container">
<div class="yfm-note yfm-accent-info"
note-type="info"
>
<div class="yfm-note-content">
<p>
Note content without title
</p>
</div>
</div>
</div>
`;

exports[`Alerts should render note without title (notesAutotitle: true) 1`] = `
<div class="yfm-note yfm-accent-info"
note-type="info"
>
<p class="yfm-note-title">
Примечание
</p>
<div class="yfm-note-content">
<p>
Note content without title
<div class="yfm-note-container">
<div class="yfm-note yfm-accent-info"
note-type="info"
>
<p class="yfm-note-title">
Примечание
</p>
<div class="yfm-note-content">
<p>
Note content without title
</p>
</div>
</div>
</div>
`;

exports[`Alerts should render siblings notes 1`] = `
<div class="yfm-note yfm-accent-info"
note-type="info"
>
<p class="yfm-note-title">
Note title 1
</p>
<div class="yfm-note-content">
<p>
Note content 1
<div class="yfm-note-container">
<div class="yfm-note yfm-accent-info"
note-type="info"
>
<p class="yfm-note-title">
Note title 1
</p>
<div class="yfm-note-content">
<p>
Note content 1
</p>
</div>
</div>
</div>
<div class="yfm-note yfm-accent-info"
note-type="info"
>
<p class="yfm-note-title">
Note title 2
</p>
<div class="yfm-note-content">
<p>
Note content 2
<div class="yfm-note-container">
<div class="yfm-note yfm-accent-info"
note-type="info"
>
<p class="yfm-note-title">
Note title 2
</p>
<div class="yfm-note-content">
<p>
Note content 2
</p>
</div>
</div>
</div>
`;

exports[`Alerts should render simple note 1`] = `
<div class="yfm-note yfm-accent-info"
note-type="info"
>
<p class="yfm-note-title">
Note title
</p>
<div class="yfm-note-content">
<p>
Note content
<div class="yfm-note-container">
<div class="yfm-note yfm-accent-info"
note-type="info"
>
<p class="yfm-note-title">
Note title
</p>
<div class="yfm-note-content">
<p>
Note content
</p>
</div>
</div>
</div>
`;

exports[`Alerts should render title with format 1`] = `
<div class="yfm-note yfm-accent-info"
note-type="info"
>
<p class="yfm-note-title">
<em>
Italic note title
</em>
</p>
<div class="yfm-note-content">
<p>
Content
<div class="yfm-note-container">
<div class="yfm-note yfm-accent-info"
note-type="info"
>
<p class="yfm-note-title">
<em>
Italic note title
</em>
</p>
<div class="yfm-note-content">
<p>
Content
</p>
</div>
</div>
</div>
`;
2 changes: 1 addition & 1 deletion test/__snapshots__/term.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exports[`Terms Should create term in code with definition template 1`] = `
<h1>
Web
</h1>
<div class="yfm-clipboard">
<div class="code-block-container yfm-clipboard">
<pre>
<code class="hljs">
<i class="yfm yfm-term_title"
Expand Down
58 changes: 30 additions & 28 deletions test/table/__snapshots__/table.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Table plugin parses table with liquid variables inside 1`] = `
<table>
<tbody>
<tr>
<td>
<p>
{{variable | length}} column 1, row 1
</p>
</td>
<td>
<p>
Cell in column 2, row 1
</p>
</td>
</tr>
<tr>
<td>
<p>
Cell in column 1, row 2
</p>
</td>
<td>
<p>
Cell in column 2, row 2
</p>
</td>
</tr>
</tbody>
</table>
<div class="yfm-table-container">
<table>
<tbody>
<tr>
<td>
<p>
{{variable | length}} column 1, row 1
</p>
</td>
<td>
<p>
Cell in column 2, row 1
</p>
</td>
</tr>
<tr>
<td>
<p>
Cell in column 1, row 2
</p>
</td>
<td>
<p>
Cell in column 2, row 2
</p>
</td>
</tr>
</tbody>
</table>
</div>
`;
Loading