Skip to content

Commit 9cbb9c5

Browse files
committed
Fix header spacing in Markdown, padding inside code tabs
1 parent 57b1f22 commit 9cbb9c5

7 files changed

Lines changed: 254 additions & 142 deletions

File tree

‎_TODO.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ COAK has two pricing tiers:
156156
- /search
157157
- /tags/[tag]
158158
- Bug reporter modal
159+
- Email templates
159160

160161
## Keyboard Navigation
161162

@@ -197,3 +198,19 @@ We have generated detailed outlines for each of the MDX proposed articles we hav
197198
Act as a principal software engineer. Your goal is to write a detailed technical article based on the provided outline. Context: The target audience is Senior DevOps and infrastructure Engineers. The tone should be authoritative, professional, and concise, avoiding fluff or filler words. Think step-by-step before writing to improve the accuracy of technical explanations. Use a friendly first-person voice. Anything that reads like generic marketing copy is not what we want but we still want the effect of being "real" and approachable - try not to sound like technical documentation. We want to show empathy for our readers.
198199

199200
Let's work through each article section by section based on the H2 headers in the outline. If the section looks good as-is, I'll just type "ok" so you know to continue to the next section.
201+
202+
## Stylings
203+
204+
- More space below headings
205+
- 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.
206+
- Better list styling and decoration markers
207+
- Remove dotted underline from abbr elements? Or some other way of indicating abbreviations?
208+
- [Link](url) [[color=pink target=_blank .centered]] is not picking up styles
209+
- 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
211+
- Make sure underline style in Core Markdown section is correct
212+
- Are we using breakpoints correctly - isn't iPhone wider than our `sm` breakpoint?
213+
- Mermaid theming, horizontal layout for desktop, vertical for mobile, using groups like in Code Tabs to add the media selectors e.g. `[g1:desktop]`
214+
215+
`graph TD`: Top-to-Bottom (Vertical).
216+
`graph LR`: Left-to-Right (Horizontal).

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

Lines changed: 126 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,78 @@ Nested blockquotes:
2929
>
3030
>> The Witch bade her clean the pots and kettles and sweep the floor and keep the fire fed with wood.
3131
32+
#### Blockquotes with internal remark-attribution plugin
33+
34+
The plugin allows to provide an attribution for a quotation:
35+
36+
```markdown
37+
> That's one small step for [a] man, one giant leap for mankind.
38+
> — Neil Armstrong (1969, July 21)
39+
```
40+
41+
> That's one small step for [a] man, one giant leap for mankind.
42+
> — Neil Armstrong (1969, July 21)
43+
44+
Compiles to the following HTML:
45+
46+
```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">
50+
<blockquote>
51+
<p>
52+
That's one small step for [a] man, one giant leap for mankind.
53+
</p>
54+
</blockquote>
55+
<figcaption class="c-blockquote__attribution">
56+
Neil Armstrong (1969, July 21)
57+
</figcaption>
58+
</figure>
59+
```
60+
61+
#### Blockquotes with remark-captions
62+
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.
64+
65+
**Blockquote caption**
66+
67+
```markdown
68+
> Some blockquote text that will have a caption
69+
> Source: The caption text that will appear under the blockquote
70+
```
71+
72+
> Some blockquote text that will have a caption
73+
> Source: The caption text that will appear under the blockquote
74+
75+
Compiles to the following HTML:
76+
77+
```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">
81+
Some blockquote text that will have a caption
82+
</p>
83+
</blockquote>
84+
<figcaption class="text-base italic pt-3">
85+
The caption text that will appear under the blockquote
86+
</figcaption>
87+
</figure>
88+
```
89+
90+
### Detail and Summary
91+
92+
```markdown
93+
<details>
94+
<summary>Details</summary>
95+
Something small enough to escape casual notice.
96+
</details>
97+
```
98+
99+
<details>
100+
<summary>Details</summary>
101+
Something small enough to escape casual notice.
102+
</details>
103+
32104
### Horizontal Rules
33105

34106
Asterisks (`***`):
@@ -53,6 +125,10 @@ _________________
53125

54126
Linked image:
55127

128+
```markdown
129+
[![An old rock in the desert](/assets/images/shiprock.svg "Shiprock placeholder")](https://www.flickr.com/photos/beaurogers/31833779864/in/photolist-Qv3rFw-34mt9F-a9Cmfy-5Ha3Zi-9msKdv-o3hgjr-hWpUte-4WMsJ1-KUQ8N-deshUb-vssBD-6CQci6-8AFCiD-zsJWT-nNfsgB-dPDwZJ-bn9JGn-5HtSXY-6CUhAL-a4UTXB-ugPum-KUPSo-fBLNm-6CUmpy-4WMsc9-8a7D3T-83KJev-6CQ2bK-nNusHJ-a78rQH-nw3NvT-7aq2qf-8wwBso-3nNceh-ugSKP-4mh4kh-bbeeqH-a7biME-q3PtTf-brFpgb-cg38zw-bXMZc-nJPELD-f58Lmo-bXMYG-bz8AAi-bxNtNT-bXMYi-bXMY6-bXMYv)
130+
```
131+
56132
[![An old rock in the desert](/assets/images/shiprock.svg "Shiprock placeholder")](https://www.flickr.com/photos/beaurogers/31833779864/in/photolist-Qv3rFw-34mt9F-a9Cmfy-5Ha3Zi-9msKdv-o3hgjr-hWpUte-4WMsJ1-KUQ8N-deshUb-vssBD-6CQci6-8AFCiD-zsJWT-nNfsgB-dPDwZJ-bn9JGn-5HtSXY-6CUhAL-a4UTXB-ugPum-KUPSo-fBLNm-6CUmpy-4WMsc9-8a7D3T-83KJev-6CQ2bK-nNusHJ-a78rQH-nw3NvT-7aq2qf-8wwBso-3nNceh-ugSKP-4mh4kh-bbeeqH-a7biME-q3PtTf-brFpgb-cg38zw-bXMZc-nJPELD-f58Lmo-bXMYG-bz8AAi-bxNtNT-bXMYi-bXMY6-bXMYv)
57133

58134
### `kbd`
@@ -200,6 +276,8 @@ Should compile to the following HTML:
200276
implemented by <a href="https://github.com/remarkjs/remark">remark</a></p>
201277
```
202278

279+
This plugin works on MDAST, a Markdown AST implemented by [remark](https://github.com/remarkjs/remark).
280+
203281
### rehype-accessible-emojis
204282

205283
There is a doc listing all available emojis in the /docs directory.
@@ -236,35 +314,71 @@ This custom plugin parses custom Markdown syntax to center- or right-align eleme
236314

237315
```markdown
238316
[center]paragraph[/center]
239-
240-
[right]paragraph[/right]
241317
```
242318

243319
[center]A centered paragraph[/center]
244320

245-
[right]A right-aligned paragraph[/right]
321+
```markdown
322+
[right]paragraph[/right]
323+
```
246324

247-
Block elements can be wrapped with their own tags to apply `flex flex-col items-end` or `flex flex-col items-center` classes:
325+
[right]A right-aligned paragraph[/right]
248326

249327
```markdown
250328
[center]
329+
251330
> My blockquote
331+
252332
[/center]
253333
```
254334

255335
[center]
256336

257337
> My blockquote
258338
339+
[/center]
340+
341+
```markdown
342+
[center]
343+
344+
- a
345+
- b
346+
347+
[/center]
348+
```
349+
350+
[center]
351+
259352
- a
260353
- b
261354

262355
[/center]
263356

357+
```markdown
264358
[right]
265359

266360
> My blockquote
267361
362+
[/right]
363+
```
364+
365+
[right]
366+
367+
> My blockquote
368+
369+
[/right]
370+
371+
```markdown
372+
[right]
373+
374+
- a
375+
- b
376+
377+
[/right]
378+
```
379+
380+
[right]
381+
268382
- a
269383
- b
270384

@@ -275,9 +389,9 @@ Block elements can be wrapped with their own tags to apply `flex flex-col items-
275389
Add HTML attributes to supported Markdown elements using a MDX-safe doubled-square-bracket postfix syntax:
276390

277391
```markdown
278-
### Heading [[.my-class #my-id]]
279392
![Image](/assets/images/shiprock.svg) [[width=300 .centered]]
280-
[Link](url) [[.btn target=_blank]]
393+
394+
[Link](url) [[color=pink target=_blank .centered]]
281395
```
282396

283397
![Image](/assets/images/shiprock.svg) [[width=300 .centered]]
@@ -316,15 +430,7 @@ The generated markup is not only accessible for screen readers but allows you to
316430

317431
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.
318432

319-
**Blockquote caption**
320-
321-
```markdown
322-
> Some blockquote text that will have a caption
323-
> Source: The caption text that will appear under the blockquote
324-
```
325-
326-
> Some blockquote text that will have a caption
327-
> Source: The caption text that will appear under the blockquote
433+
__Blockquote example is moved to the Blockquote section.__
328434

329435
**Code caption**
330436

@@ -415,20 +521,6 @@ The string `L = \frac{1}{2} \rho v^2 S C_L` within a fenced code black set to la
415521
L = \frac{1}{2} \rho v^2 S C_L
416522
```
417523

418-
### remark-supersub
419-
420-
Subscript and superscript text
421-
422-
```markdown
423-
~subscript~, e.g. a~i~
424-
425-
^superscript^, e.g. e^x^
426-
```
427-
428-
Subscript: a~i~
429-
430-
Superscript: e^x^
431-
432524
### remark-video
433525

434526
Embed videos in HTML5 markup that are in the `/public` folder
@@ -1258,13 +1350,15 @@ The references can be anywhere in the document, before or after their use:
12581350

12591351
## Core Markdown
12601352

1353+
Subscript and superscript text is from `remark-supersub`.
1354+
12611355
| Style | Syntax | Keyboard shortcut | Example | Output |
12621356
| --- | --- | --- | --- | --- |
12631357
| Bold | `** **` | Command+B (Mac) or Ctrl+B (Windows/Linux) | `**This is bold text**` | **This is bold text** |
12641358
| Italic | `_ _` | Command+I (Mac) or Ctrl+B (Windows/Linux) | `_This text is italicized_` | _This text is italicized_ |
12651359
| Strikethrough | `~~ ~~` or `~ ~` | None | `~~This was mistaken text~~` | ~~This was mistaken text~~ |
12661360
| Bold and nested italic | `** **` and `_ _` | None | `**This text is _extremely_ important**` | **This text is \*extremely\* important** |
12671361
| All bold and italic | `*** ***` | None | `**_All this text is important_**` | **_All this text is important_** |
1268-
| Subscript | `<sub> </sub>` | None | `This is a <sub>subscript</sub> text` | This is a <sub>subscript</sub> |
1269-
| Superscript | `<sup> </sup>` | None | `This is a <sup>superscript</sup> text` | This is a <sup>superscript</sup> text |
1270-
| Underline | `<ins> </ins>` | None | `This is an <ins>underlined</ins> text` | This is an <ins>underlined</ins> text |
1362+
| Subscript | `~subscript~` | None | `This is a ~subscript~ text` | This is a ~subscript~ |
1363+
| Superscript | `^superscript^` | None | `This is a ^superscript^ text` | This is a ^superscript^ text |
1364+
| Underline | `__ __` | None | `This is an __underlined__ text` | This is an __underlined__ text |

‎src/lib/config/markdown.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,16 @@ export const remarkCustomBlocksConfig = {
279279

280280
/** remark-captions plugin (explicit defaults from upstream README) */
281281
export const remarkCaptionsConfig = {
282+
/**
283+
* Caption is rendered outside the captioned element or inside its wrapping paragraph
284+
*/
282285
external: {
283286
table: 'Table:',
284287
code: 'Code:',
285288
},
289+
/**
290+
* Caption is rendered inside the captioned element or inside its wrapping paragraph
291+
*/
286292
internal: {
287293
blockquote: 'Source:',
288294
image: 'Figure:',

‎src/lib/markdown/plugins/rehype-tailwind/index.ts‎

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ export function rehypeTailwindClasses() {
6767
if (['h2', 'h3', 'h4'].includes(node.tagName)) {
6868
node.properties = node.properties || {}
6969
node.properties['className'] = ((node.properties['className'] as string[]) || []).concat([
70-
'mb-2',
71-
'mt-6',
7270
'relative',
71+
'my-6',
7372
/**
7473
* Remove top margin from first child element of headings since we're
7574
* controlling bottom margin here.
@@ -103,32 +102,18 @@ export function rehypeTailwindClasses() {
103102
])
104103
}
105104

106-
107-
/**
108-
* Code blocks (pre > code) stylings with responsive margins
109-
*/
110-
if (node.tagName === 'pre') {
111-
node.properties = node.properties || {}
112-
node.properties['className'] = ((node.properties['className'] as string[]) || []).concat([
113-
'block',
114-
'text-base',
115-
'px-4',
116-
'py-4',
117-
'bg-page-base-offset',
118-
'mb-6',
119-
])
120-
}
121-
122105
/**
123-
* Code blocks (pre > code.language-text) should wrap text instead of forcing horizontal scrolling.
124-
* This keeps the existing <pre> styles but allows future styling specifically for text blocks.
106+
* Non-Code Tabs Text Code blocks (pre > code.language-text) should wrap text
107+
* instead of forcing horizontal scrolling. This keeps the existing <pre>
108+
* styles but allows future styling specifically for text blocks.
125109
*/
126110
if (node.tagName === 'code' && hasClass(node, 'language-text')) {
127111
const parent = getParent(node)
128112

129113
if (isHastElement(parent) && parent.tagName === 'pre') {
130114
node.properties = node.properties || {}
131115
node.properties['className'] = ((node.properties['className'] as string[]) || []).concat([
116+
'my-2',
132117
'whitespace-pre-wrap',
133118
'break-words',
134119
])
@@ -146,10 +131,29 @@ export function rehypeTailwindClasses() {
146131
if (node.tagName === 'code-tabs') {
147132
node.properties = node.properties || {}
148133
node.properties['className'] = ((node.properties['className'] as string[]) || []).concat([
134+
'block',
135+
'border-page-base-offset',
149136
'border',
150-
'border-gray-200',
151-
'rounded-md',
137+
'max-w-full',
138+
'mb-4',
139+
'min-w-0',
152140
'overflow-hidden',
141+
'rounded-md',
142+
'w-full',
143+
])
144+
}
145+
146+
/**
147+
* Code blocks (pre > code) stylings with responsive margins
148+
*/
149+
if (node.tagName === 'pre') {
150+
node.properties = node.properties || {}
151+
node.properties['className'] = ((node.properties['className'] as string[]) || []).concat([
152+
'block',
153+
'bg-page-base-offset',
154+
'max-w-full',
155+
'pr-3',
156+
'py-3',
153157
])
154158
}
155159

@@ -231,13 +235,7 @@ export function rehypeTailwindClasses() {
231235
])
232236
}
233237

234-
/**
235-
* =============================================================================
236-
*
237-
* Attribution Blockquote Stylings
238-
*
239-
* =============================================================================
240-
*/
238+
/** Attribution Blockquote Stylings */
241239
if (node.tagName === 'figure' && hasClass(node, 'c-blockquote')) {
242240
node.properties = node.properties || {}
243241
node.properties['className'] = ((node.properties['className'] as string[]) || []).concat([

0 commit comments

Comments
 (0)