@readme/markdown 14.4.0 → 14.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Callout/style.scss +7 -4
- package/components/Image/index.tsx +7 -2
- package/components/Image/style.scss +38 -3
- package/dist/index.d.ts +1 -1
- package/dist/lib/constants.d.ts +19 -0
- package/dist/lib/index.d.ts +1 -1
- package/dist/main.css +1 -1
- package/dist/main.css.map +1 -1
- package/dist/main.js +153 -39
- package/dist/main.node.js +153 -39
- package/dist/main.node.js.map +1 -1
- package/dist/processor/transform/mdxish/tables/repair-expression-escapes.d.ts +14 -0
- package/dist/processor/transform/mdxish/tables/tag-walker.d.ts +11 -1
- package/package.json +1 -1
- package/styles/gfm.scss +47 -21
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type RepairResult } from './utils';
|
|
2
|
+
/**
|
|
3
|
+
* mdxjs hands the contents of every `{…}` to acorn as a JavaScript expression.
|
|
4
|
+
* A bare backslash is only legal inside a string/template literal in JS, so a
|
|
5
|
+
* markdown-style escape such as `{customer\_id}` — common when authors escape an
|
|
6
|
+
* underscore out of habit — makes acorn throw "Could not parse expression with
|
|
7
|
+
* acorn", which drops parsing for the whole surrounding `<Table>`.
|
|
8
|
+
*
|
|
9
|
+
* This pass deletes backslashes that sit in JS *code* position inside a `{…}`
|
|
10
|
+
* expression. Backslashes within a '…', "…" or `…` literal are valid escapes
|
|
11
|
+
* and are left untouched. Scoped to the malformed-retry path; the happy path
|
|
12
|
+
* never runs it.
|
|
13
|
+
*/
|
|
14
|
+
export declare const repairExpressionEscapes: (html: string) => RepairResult;
|
|
@@ -7,12 +7,22 @@ interface TagEvent {
|
|
|
7
7
|
name: string;
|
|
8
8
|
start: number;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* `isSelfClosing` — source ends with `/>`.
|
|
12
|
+
* `isStrayCloser` — source starts with `</`. htmlparser2 follows the HTML5
|
|
13
|
+
* spec and rewrites stray void closers (`</br>`, `</p>`) into `onopentag`
|
|
14
|
+
* events; this flag lets consumers tell that apart from a real opener.
|
|
15
|
+
*/
|
|
16
|
+
interface OpenEvent extends TagEvent {
|
|
17
|
+
isSelfClosing: boolean;
|
|
18
|
+
isStrayCloser: boolean;
|
|
19
|
+
}
|
|
10
20
|
interface CloseEvent extends TagEvent {
|
|
11
21
|
implicit: boolean;
|
|
12
22
|
}
|
|
13
23
|
interface TagWalkHandlers {
|
|
14
24
|
onClose?: (event: CloseEvent) => void;
|
|
15
|
-
onOpen?: (event:
|
|
25
|
+
onOpen?: (event: OpenEvent) => void;
|
|
16
26
|
}
|
|
17
27
|
/**
|
|
18
28
|
* Drive htmlparser2 over `html` (after masking non-tag regions) and emit
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@readme/markdown",
|
|
3
3
|
"description": "ReadMe's React-based Markdown parser",
|
|
4
4
|
"author": "Rafe Goldberg <rafe@readme.io>",
|
|
5
|
-
"version": "14.
|
|
5
|
+
"version": "14.5.0",
|
|
6
6
|
"main": "dist/main.node.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"browser": "dist/main.js",
|
package/styles/gfm.scss
CHANGED
|
@@ -86,10 +86,24 @@
|
|
|
86
86
|
border-width: 0 0 1px;
|
|
87
87
|
box-sizing: content-box;
|
|
88
88
|
height: 0;
|
|
89
|
-
margin: 15px 0;
|
|
89
|
+
margin: var(--markdown-spacing, 15px) 0;
|
|
90
90
|
overflow: hidden;
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
// Direct-child only, top-level headings/hr act as section breaks that
|
|
94
|
+
// clear preceding floats (e.g. `<Image align="left|right">`). Nested
|
|
95
|
+
// headings (inside Callout, Cards, etc.) keep wrapping behavior so the
|
|
96
|
+
// component's own layout (e.g. callout icon float) isn't disrupted.
|
|
97
|
+
> h1,
|
|
98
|
+
> h2,
|
|
99
|
+
> h3,
|
|
100
|
+
> h4,
|
|
101
|
+
> h5,
|
|
102
|
+
> h6,
|
|
103
|
+
> hr {
|
|
104
|
+
clear: both;
|
|
105
|
+
}
|
|
106
|
+
|
|
93
107
|
input {
|
|
94
108
|
font: inherit;
|
|
95
109
|
margin: 0;
|
|
@@ -133,8 +147,19 @@
|
|
|
133
147
|
font-size: var(--markdown-title-size);
|
|
134
148
|
font-weight: var(--markdown-title-weight, 600);
|
|
135
149
|
line-height: 1.25;
|
|
136
|
-
margin-bottom: var(--markdown-title-marginBottom,
|
|
150
|
+
margin-bottom: var(--markdown-title-marginBottom, var(--markdown-spacing, 15px));
|
|
137
151
|
margin-top: var(--markdown-title-marginTop, 1em);
|
|
152
|
+
|
|
153
|
+
&:has(+ h1, + h2, + h3, + h4, + h5, + h6, + p) {
|
|
154
|
+
margin-bottom: calc(var(--markdown-spacing, 15px) / 2);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Tighten the gap when a heading immediately follows another heading
|
|
159
|
+
// (e.g. h1 + h2 as title/subtitle). Lets the preceding heading's margin-bottom
|
|
160
|
+
// define the gap instead of the following heading's larger margin-top.
|
|
161
|
+
:is(h1, h2, h3, h4, h5, h6) + :is(h1, h2, h3, h4, h5, h6) {
|
|
162
|
+
margin-top: 0;
|
|
138
163
|
}
|
|
139
164
|
|
|
140
165
|
h1 {
|
|
@@ -245,13 +270,23 @@
|
|
|
245
270
|
|
|
246
271
|
blockquote,
|
|
247
272
|
dl,
|
|
248
|
-
ol,
|
|
249
273
|
p,
|
|
250
274
|
pre,
|
|
251
|
-
table
|
|
275
|
+
table {
|
|
276
|
+
margin-bottom: var(--markdown-spacing, 15px);
|
|
277
|
+
margin-top: 0;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
ol,
|
|
252
281
|
ul {
|
|
253
|
-
margin-bottom: 15px
|
|
282
|
+
margin-bottom: round(1.3333em, 1px); // 20px at 15px base (condensed)
|
|
254
283
|
margin-top: 0;
|
|
284
|
+
|
|
285
|
+
ol,
|
|
286
|
+
ul {
|
|
287
|
+
margin-bottom: 0;
|
|
288
|
+
margin-top: round(0.5333em, 1px); // 8px at 15px base (condensed)
|
|
289
|
+
}
|
|
255
290
|
}
|
|
256
291
|
|
|
257
292
|
blockquote {
|
|
@@ -278,14 +313,6 @@
|
|
|
278
313
|
padding-left: 2em;
|
|
279
314
|
}
|
|
280
315
|
|
|
281
|
-
ol ol,
|
|
282
|
-
ol ul,
|
|
283
|
-
ul ol,
|
|
284
|
-
ul ul {
|
|
285
|
-
margin-bottom: 0;
|
|
286
|
-
margin-top: 0;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
316
|
li {
|
|
290
317
|
clear: both;
|
|
291
318
|
word-wrap: break-all;
|
|
@@ -296,7 +323,7 @@
|
|
|
296
323
|
}
|
|
297
324
|
|
|
298
325
|
li + li {
|
|
299
|
-
margin-top: 0.
|
|
326
|
+
margin-top: round(0.5333em, 1px); // 8px at 15px base (condensed)
|
|
300
327
|
}
|
|
301
328
|
|
|
302
329
|
dl {
|
|
@@ -316,6 +343,10 @@
|
|
|
316
343
|
padding: 0 1em;
|
|
317
344
|
}
|
|
318
345
|
|
|
346
|
+
.img {
|
|
347
|
+
margin: round(calc(var(--markdown-img-margin, var(--markdown-spacing, 15px)) * 1.33), 1px) 0;
|
|
348
|
+
}
|
|
349
|
+
|
|
319
350
|
:checked + .radio-label {
|
|
320
351
|
border-color: var(--project-color-primary);
|
|
321
352
|
position: relative;
|
|
@@ -341,19 +372,14 @@
|
|
|
341
372
|
}
|
|
342
373
|
|
|
343
374
|
@mixin markdown-overrides {
|
|
344
|
-
h5,
|
|
345
|
-
h6 {
|
|
346
|
-
font-size: 0.9em;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
375
|
blockquote h1:last-child,
|
|
350
376
|
blockquote h2:last-child {
|
|
351
377
|
border-bottom: 0;
|
|
352
378
|
}
|
|
353
379
|
|
|
354
380
|
> * {
|
|
355
|
-
margin-bottom: 15px
|
|
356
|
-
margin-top: 15px;
|
|
381
|
+
margin-bottom: var(--markdown-spacing, 15px);
|
|
382
|
+
margin-top: var(--markdown-spacing, 15px);
|
|
357
383
|
}
|
|
358
384
|
|
|
359
385
|
.task-list-item input {
|