Skip to content

Commit e0fb7ce

Browse files
committed
Update stylings on blockquotes
1 parent 9cbb9c5 commit e0fb7ce

22 files changed

Lines changed: 1034 additions & 953 deletions

File tree

‎@types/mdast-extensions-figures-and-gridtables.d.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import type { Parent } from 'unist'
22

33
declare module 'mdast' {
4-
/** Custom node emitted by remark-captions / remark-attribution */
4+
/** Custom node emitted by remark-captions / remark-blockquote */
55
interface Figure extends Parent {
66
type: 'figure'
77
children: Array<RootContent>
88
}
99

10-
/** Custom node emitted by remark-captions / remark-attribution */
10+
/** Custom node emitted by remark-captions / remark-blockquote */
1111
interface Figcaption extends Parent {
1212
type: 'figcaption'
1313
children: Array<PhrasingContent>

‎_TODO.md‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,11 @@ Let's work through each article section by section based on the H2 headers in th
201201

202202
## Stylings
203203

204-
- More space below headings
205204
- Better appearance of details and summary elements. The styling in rehype-tailwind is applying to the detail and summary elements generated by remark-custom-blocks.
206205
- Better list styling and decoration markers
207206
- Remove dotted underline from abbr elements? Or some other way of indicating abbreviations?
208207
- [Link](url) [[color=pink target=_blank .centered]] is not picking up styles
209208
- We have remark-mark-plus to create marked text like ==mark me==. Is the Highlighter component our social highlighter?
210-
- Search icon is too large now
211209
- Make sure underline style in Core Markdown section is correct
212210
- Are we using breakpoints correctly - isn't iPhone wider than our `sm` breakpoint?
213211
- Mermaid theming, horizontal layout for desktop, vertical for mobile, using groups like in Code Tabs to add the media selectors e.g. `[g1:desktop]`

‎src/content/articles/demo/index.mdx‎

Lines changed: 60 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import Demo from '@components/Test/Demo.mdx'
1515

1616
### Blockquotes
1717

18+
Quotation marks are added by CSS, so should not be included on the blockquote text.
19+
1820
> This is a blockquote. Use it for quotes, citations, or to highlight important statements from external sources.
1921
2022
Nested blockquotes:
@@ -29,9 +31,9 @@ Nested blockquotes:
2931
>
3032
>> The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.
3133
32-
#### Blockquotes with internal remark-attribution plugin
34+
__Blockquotes with attribution__
3335

34-
The plugin allows to provide an attribution for a quotation:
36+
The pluginwill provide an attribution for a quotation if it is prefixed with an em dash. To include a date, put them in trailing parentheses:
3537

3638
```markdown
3739
> That's one small step for [a] man, one giant leap for mankind.
@@ -41,26 +43,32 @@ The plugin allows to provide an attribution for a quotation:
4143
> That's one small step for [a] man, one giant leap for mankind.
4244
> — Neil Armstrong (1969, July 21)
4345
46+
```markdown
47+
> That's one small step for [a] man, one giant leap for mankind.
48+
> — Neil Armstrong
49+
```
50+
51+
> Nothing inspires forgiveness quite like revenge.
52+
> — Scott Adams
53+
4454
Compiles to the following HTML:
4555

4656
```html
47-
The generated markup is not only accessible for screen readers but allows you to style the attribution line however you like:
48-
49-
<figure class="c-blockquote">
57+
<figure class="blockquote">
5058
<blockquote>
5159
<p>
5260
That's one small step for [a] man, one giant leap for mankind.
5361
</p>
5462
</blockquote>
55-
<figcaption class="c-blockquote__attribution">
63+
<figcaption class="blockquote-attribution">
5664
Neil Armstrong (1969, July 21)
5765
</figcaption>
5866
</figure>
5967
```
6068

61-
#### Blockquotes with remark-captions
69+
__Blockquotes with captions__
6270

63-
By default it wraps the elements code, image, table and blockquote in a `<figure>` element, and adds a `<figcaption>` block as the last child. You can configure it to work on other elements by changing the keywords.
71+
For blockquotes, captions are handled by the internal `remark-blockquote` plugin so they can be combined with an attribution.
6472

6573
**Blockquote caption**
6674

@@ -72,16 +80,46 @@ By default it wraps the elements code, image, table and blockquote in a `<figure
7280
> Some blockquote text that will have a caption
7381
> Source: The caption text that will appear under the blockquote
7482
75-
Compiles to the following HTML:
83+
Compiles to the following HTML (ignoring styles):
7684

7785
```html
78-
<figure class="my-8 mx-auto max-w-none text-center">
79-
<blockquote class="border-l-2 border-blue-600 my-8 pl-14 -ml-4 font-serif text-2xl italic">
80-
<p class="mb-8 leading-relaxed">
86+
<figure class="blockquote-figure">
87+
<blockquote>
88+
<p>
8189
Some blockquote text that will have a caption
8290
</p>
8391
</blockquote>
84-
<figcaption class="text-base italic pt-3">
92+
<figcaption class="blockquote-caption">
93+
The caption text that will appear under the blockquote
94+
</figcaption>
95+
</figure>
96+
```
97+
98+
__Blockquotes with both attribution and caption__
99+
100+
```markdown
101+
> That's one small step for [a] man, one giant leap for mankind.
102+
> — Neil Armstrong (1969, July 21)
103+
> Source: The caption text that will appear under the blockquote
104+
```
105+
106+
> That's one small step for [a] man, one giant leap for mankind.
107+
> — Neil Armstrong (1969, July 21)
108+
> Source: The caption text that will appear under the blockquote
109+
110+
Should compile to the following HTML:
111+
112+
```html
113+
<figure class="blockquote-figure">
114+
<blockquote>
115+
<p>
116+
That's one small step for [a] man, one giant leap for mankind.
117+
</p>
118+
</blockquote>
119+
<div class="blockquote-attribution">
120+
Neil Armstrong (1969, July 21)
121+
</div>
122+
<figcaption class="blockquote-caption">
85123
The caption text that will appear under the blockquote
86124
</figcaption>
87125
</figure>
@@ -397,9 +435,9 @@ Add HTML attributes to supported Markdown elements using a MDX-safe doubled-squa
397435
![Image](/assets/images/shiprock.svg) [[width=300 .centered]]
398436
[Link Example](/testing/markdown) [[.btn target=_blank]]
399437

400-
### remark-attribution
438+
### remark-blockquote
401439

402-
The plugin allows to provide an attribution for a quotation:
440+
The plugin allows you to provide an attribution for a quotation:
403441

404442
```markdown
405443
> That's one small step for [a] man, one giant leap for mankind.
@@ -412,36 +450,34 @@ The plugin allows to provide an attribution for a quotation:
412450
Should compile to the following HTML:
413451

414452
```html
415-
The generated markup is not only accessible for screen readers but allows you to style the attribution line however you like:
416-
417-
<figure class="c-blockquote">
453+
<figure class="blockquote">
418454
<blockquote>
419455
<p>
420456
That's one small step for [a] man, one giant leap for mankind.
421457
</p>
422458
</blockquote>
423-
<figcaption class="c-blockquote__attribution">
459+
<figcaption class="blockquote-attribution">
424460
Neil Armstrong (1969, July 21)
425461
</figcaption>
426462
</figure>
427463
```
428464

429465
### remark-captions
430466

431-
By default it wraps the elements code, image, table and blockquote in a `<figure>` element, and adds a `<figcaption>` block as the last child. You can configure it to work on other elements by changing the keywords.
432-
433-
__Blockquote example is moved to the Blockquote section.__
467+
By default it wraps the elements code, image, and table in a `<figure>` element, and adds a `<figcaption>` block as the last child. You can configure it to work on other elements by changing the keywords.
434468

435469
**Code caption**
436470

471+
The caption line is prefixed with `Code:` and added below the code block with no blank line:
472+
437473
```ts
438474
export const answer = 42
439475
```
440476
Code: This caption appears under the code block
441477

442478
**Table caption**
443479

444-
Note: a blank line is required before `Table:` so it parses as a paragraph after the table.
480+
Note: a blank line is required before tje `Table:` prefixed line so it parses as a paragraph after the table.
445481

446482
```markdown
447483
| a | b |
@@ -459,7 +495,7 @@ Table: This caption appears under the table
459495

460496
**Image caption**
461497

462-
Note: the `Figure:` caption must be in the same paragraph as the image (no blank line).
498+
Note: the `Figure:` prefixed line must be in the same paragraph as the image (no blank line).
463499

464500
```markdown
465501
![Wordmark](/assets/images/branding/wordmark.svg)

‎src/icons/search.svg‎

Lines changed: 1 addition & 4 deletions
Loading

‎src/lib/config/markdown.ts‎

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ Object.defineProperty(remarkAbbreviations, 'name', { value: 'remarkAbbreviations
112112
import remarkAttributes from '../markdown/plugins/remark-attributes'
113113
Object.defineProperty(remarkAttributes, 'name', { value: 'remarkAttributes' })
114114

115-
import remarkAttribution from '../markdown/plugins/remark-attribution'
116-
Object.defineProperty(remarkAttribution, 'name', { value: 'remarkAttribution' })
115+
import remarkBlockquote from '../markdown/plugins/remark-blockquote'
116+
Object.defineProperty(remarkBlockquote, 'name', { value: 'remarkBlockquote' })
117117

118118
import remarkAlign from '../markdown/plugins/remark-align'
119119
Object.defineProperty(remarkAlign, 'name', { value: 'remarkAlign' })
@@ -277,21 +277,23 @@ export const remarkCustomBlocksConfig = {
277277
},
278278
} as const
279279

280-
/** remark-captions plugin (explicit defaults from upstream README) */
280+
/**
281+
* remark-captions plugin
282+
*
283+
* NOTE: This plugin's options are `external` and `internal`.
284+
* We intentionally disable its built-in blockquote handling so our
285+
* `remarkBlockquote` plugin owns blockquote caption/attribution semantics.
286+
*/
281287
export const remarkCaptionsConfig = {
282-
/**
283-
* Caption is rendered outside the captioned element or inside its wrapping paragraph
284-
*/
285288
external: {
286-
table: 'Table:',
287289
code: 'Code:',
290+
table: 'Table:',
288291
},
289-
/**
290-
* Caption is rendered inside the captioned element or inside its wrapping paragraph
291-
*/
292292
internal: {
293-
blockquote: 'Source:',
294293
image: 'Figure:',
294+
// Prevent remark-captions from wrapping blockquotes (default is 'Source:').
295+
// Blockquotes are handled by `remarkBlockquote` instead.
296+
blockquote: '__BLOCKQUOTE_CAPTIONS_DISABLED__',
295297
},
296298
} as const
297299

@@ -319,7 +321,7 @@ export const remarkRehypeConfig: RemarkRehypeOptions = {
319321
/** Convert GridTables mdast nodes to standard HTML table output */
320322
handlers: {
321323
[TYPE_TABLE]: mdast2hastGridTablesHandler(),
322-
// remark-captions + remark-attribution emit mdast nodes with type "figure"/"figcaption".
324+
// remark-captions + remark-blockquote emit mdast nodes with type "figure"/"figcaption".
323325
// Without explicit handlers, mdast-util-to-hast may flatten block children (notably `code`) and drop captions.
324326
figure: (state: MdastToHastState, node: unknown) => {
325327
return {
@@ -374,7 +376,7 @@ export const markdownConfig: Partial<MdxOptions> = {
374376
remarkSupersub,
375377
/** Highlights via ==marked== */
376378
remarkMarkPlus,
377-
/** Captions for code, images, tables, and blockquotes */
379+
/** Captions for code, images, and tables */
378380
[remarkCaptions, remarkCaptionsConfig],
379381
/** Definition lists (PHP Markdown Extra style) */
380382
remarkDeflist,
@@ -390,8 +392,8 @@ export const markdownConfig: Partial<MdxOptions> = {
390392
* Example: [text content]{.class #id attr=value} creates <span> with attributes
391393
*/
392394
[remarkAttributes, remarkAttributesConfig],
393-
/** Wrap blockquotes with attribution in semantic figure/figcaption markup */
394-
remarkAttribution,
395+
/** Wrap blockquotes with caption/attribution in semantic figure markup */
396+
remarkBlockquote,
395397
/** Convert emoji syntax like :heart: to emoji images */
396398
remarkEmoji,
397399
/** Support generic directive syntax (required by remark-video) */

‎src/lib/markdown/__fixtures__/attribution.md‎

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: Blockquote Test
3+
---
4+
5+
<!-- markdownlint-disable -->
6+
7+
# Blockquote Feature Test
8+
9+
## Attribution
10+
11+
> That's one small step for man, one giant leap for mankind.
12+
> — Neil Armstrong
13+
14+
> The best way to predict the future is to invent it.
15+
> — Alan Kay
16+
17+
## Caption
18+
19+
> Some blockquote text that will have a caption
20+
> Source: The caption text that will appear under the blockquote
21+
22+
## Caption and attribution
23+
24+
> That's one small step for man, one giant leap for mankind.
25+
> — Neil Armstrong (1969, July 21)
26+
> Source: The caption text that will appear under the blockquote

‎src/lib/markdown/__tests__/e2e/full-pipeline.spec.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('Layer 4: E2E - Full Pipeline Integration', () => {
3333
// Verify all plugins contributed to the output
3434
expect(html).toContain('<abbr') // Abbreviations
3535
expect(html).toContain('class="custom-link"') // Attributes
36-
expect(html).toContain('class="c-blockquote') // Attribution
36+
expect(html).toContain('class="blockquote') // Blockquote attribution/caption
3737
expect(html).toContain('❤️') // Emoji
3838
expect(html).toContain('href="https://www.webstackbuilders.com"') // Auto-linking
3939
expect(html).toContain('class="anchor-link') // Anchor headings

0 commit comments

Comments
 (0)