diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nodes/Callouts.js | 12 | ||||
-rw-r--r-- | src/tests/markdown.spec.js | 8 |
2 files changed, 18 insertions, 2 deletions
diff --git a/src/nodes/Callouts.js b/src/nodes/Callouts.js index f1ffe8482..0f2b2e8de 100644 --- a/src/nodes/Callouts.js +++ b/src/nodes/Callouts.js @@ -47,7 +47,11 @@ export default Node.create({ type: { default: 'info', rendered: false, - parseHTML: element => element.getAttribute('data-callout'), + parseHTML: element => { + return element.getAttribute('data-callout') + || typesAvailable.find((type) => element.classList.contains(type)) + || (element.classList.contains('warning') && 'warn') + }, renderHTML: attributes => { return { 'data-callout': attributes.type, @@ -61,7 +65,11 @@ export default Node.create({ parseHTML() { return [ { - tag: 'div', + tag: 'div.callout', + }, + { + tag: 'p.callout', + priority: 1001, }, ] }, diff --git a/src/tests/markdown.spec.js b/src/tests/markdown.spec.js index 1bb86ac39..2e862c13b 100644 --- a/src/tests/markdown.spec.js +++ b/src/tests/markdown.spec.js @@ -150,6 +150,14 @@ describe('Markdown serializer from html', () => { expect(markdownThroughEditorHtml( `<div data-callout="${type}" class="callout callout-${type}"><p>!${type}!</p>just do it<p></p></div>` )).toBe(`::: ${type}\n!${type}!\n\njust do it\n\n:::`) + expect(markdownThroughEditorHtml( + `<p class="callout ${type}">!${type}!</p>` + )).toBe(`::: ${type}\n!${type}!\n\n:::`) }) }) + test('callouts with handbook classes', () => { + expect(markdownThroughEditorHtml( + `<p class="callout warning">!warning!</p>` + )).toBe(`::: warn\n!warning!\n\n:::`) + }) }) |