diff --git a/docs/vfm.md b/docs/vfm.md
index e1fa447..404ba37 100644
--- a/docs/vfm.md
+++ b/docs/vfm.md
@@ -193,12 +193,13 @@ ruby rt {
## Sectionization
-Level 2
+``` **CSS** @@ -255,6 +262,9 @@ section.title > h1:first-child { } .level2 { } + +blockquote > h1 { +} ``` ### Plain section diff --git a/src/plugins/section.ts b/src/plugins/section.ts index 80bc8b8..1532c05 100644 --- a/src/plugins/section.ts +++ b/src/plugins/section.ts @@ -31,7 +31,7 @@ const checkProperties = (node: any, depth: number) => { // {hidden} specifier if (Object.keys(hProperties).includes('hidden')) { - node.data.hProperties.hidden = "hidden"; + node.data.hProperties.hidden = 'hidden'; } // output section levels like Pandoc @@ -50,14 +50,23 @@ const checkProperties = (node: any, depth: number) => { /** * Wrap the header in sections. + * - Do not sectionize if parent is `blockquote`. + * - The attributes of the heading are basically copied to the section. + * - The `id` attribute is moved to the section. + * - The `hidden` attribute is not copied and only the heading applies. + * - Set the `levelN` class in the section to match the heading depth. * @param node Node of Markdown AST. * @param ancestors Parents. * @todo handle `@subtitle` properly. */ const sectionize = (node: any, ancestors: Parent[]) => { + const parent = ancestors[ancestors.length - 1]; + if (parent.type === 'blockquote') { + return; + } + const start = node; const depth = start.depth; - const parent = ancestors[ancestors.length - 1]; const isEnd = (node: any) => (node.type === 'heading' && node.depth <= depth) || node.type === 'export'; diff --git a/tests/section.test.ts b/tests/section.test.ts index 62e3e3e..61b2dc1 100644 --- a/tests/section.test.ts +++ b/tests/section.test.ts @@ -29,6 +29,17 @@ it('Heading with hidden attribute', () => { expect(received).toBe(expected); }); +it('Disable section with blockquote heading', () => { + const md = '> # Not Sectionize'; + const received = stringify(md, { partial: true }); + const expected = ` +Not Sectionize
+
++`; + expect(received).toBe(expected); +}); + it('Not Sectionize
+