Skip to content

Commit ca3b2a1

Browse files
committed
Add remark-custom-blocks and set up an initial block for <details> and <summary> elements
1 parent ba61649 commit ca3b2a1

13 files changed

Lines changed: 573 additions & 37 deletions

File tree

‎.markdownlint.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"MD013": false,
44
"MD025": false,
55
"MD033": false,
6+
"MD035": false,
67
"MD036": false,
78
"MD041": false
89
}

‎@types/remark-custom-blocks.d.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Type definitions for remark-custom-blocks
3+
*
4+
* The package does not currently ship TypeScript types.
5+
*/
6+
7+
declare module 'remark-custom-blocks' {
8+
import type { Plugin } from 'unified'
9+
import type { Root } from 'mdast'
10+
11+
export type CustomBlockTitleRequirement = 'required' | 'optional' | 'none'
12+
13+
export type CustomBlockDefinition = {
14+
classes?: string
15+
title?: CustomBlockTitleRequirement
16+
containerElement?: string
17+
titleElement?: string
18+
contentsElement?: string
19+
details?: boolean
20+
}
21+
22+
export type RemarkCustomBlocksOptions = Record<string, CustomBlockDefinition>
23+
24+
const remarkCustomBlocks: Plugin<[RemarkCustomBlocksOptions?] | [], Root>
25+
26+
export default remarkCustomBlocks
27+
}

‎_TODO.md‎

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -249,51 +249,40 @@ Calculations: {Math.PI * 2}.
249249
Components: { <MyComponent /> }
250250
```
251251

252-
### THINGS TO WIRE INTO CUSTOM COMPONENTS IN STANDARD MARKDOWN OR ADD AS COMPONENTS
252+
### remark-supersub
253253

254-
### remark-text-decoration
255-
256-
This plugin lets you apply an element to text based on a marker defined in config. It could handle subscript, superscript, underline, and highlighting.
254+
Subscript and superscript text
257255

258256
```markdown
259257
~subscript~, e.g. a~i~
260258

261259
^superscript^, e.g. e^x^
262-
263-
!!underline!!
264-
265-
==marked== gives <mark>inserted</mark>
266260
```
267261

268-
### Youtube embedding
262+
Subscript: a~i~
269263

270-
- `rehype-video` for self-hosted videos, you have to pass the video filename into the unified `process()` pipeline along with the plugin
271-
- `@hongvanpc10/rehype-embed` works the same way - you have to pass the Youtube link into the config to be processed
264+
Superscript: e^x^
265+
266+
### remark-mark-plus
272267

268+
Inserts indicated text in a pair of `<mark>` elements
273269

274-
### remark-custom-blocks
270+
```markdown
271+
my ==marked== text
272+
```
275273

276-
This plugin parses custom Markdown syntax to create new custom blocks. It takes a config object with a name for the block, CSS classes to apply to it, and whether a title is required, optional, or the block does not have a title.
274+
my ==marked== text
277275

278-
These HTML elements aren't being processed by remarkGfm (they need to be raw HTML). Expandable and collapsible content using HTML <details> and <summary> elements.
276+
###
279277

280278
```markdown
281-
[[details | My summary]]
282-
| Some content for the detail
279+
!!underline!!
283280
```
284281

285-
```typescript
286-
{
287-
details: {
288-
classes: '',
289-
title: 'required',
290-
containerElement: 'details',
291-
titleElement: 'summary',
292-
contentsElement: 'div',
293-
details: true,
294-
},
295-
}
296-
```
282+
### Youtube embedding
283+
284+
- `rehype-video` for self-hosted videos, you have to pass the video filename into the unified `process()` pipeline along with the plugin
285+
- `@hongvanpc10/rehype-embed` works the same way - you have to pass the Youtube link into the config to be processed
297286

298287
### remark-captions
299288

0 commit comments

Comments
 (0)