Skip to content

Commit f7df75f

Browse files
authored
Remove static phrasing content
Previously, there was a difference between static and dynamic phrasing content. There was also transparent content, to “inherit” the (static or dynamic) content model from a parent. This was used to prohibit links in links. However, while it is unwise to put links in links, it is possible with markdown to do so, by embedding autolinks in links with resources or references. Take for example: ```markdown [alpha <https://bravo> charlie](delta) ``` Yields, per CommonMark: ```html <p><a href="delta">alpha <a href="https://bravo">https://bravo</a> charlie</a></p> ``` See also: commonmark/commonmark-spec#719. There is also the case where while it is unwise to author such markdown, tools transforming mdast might inject links. It’s probably good to handle such cases in `mdast-util-to-markdown` and such? Not allowing links in links is also something imposed by HTML (particularly the parsing side[^1]): perhaps mdast could be used in places where this restriction doesn’t need to be imposed. Finally, it is hard to type such inherited content models. As in, transparent content is not used in `@types/mdast` (I don’t think it can be typed?): https://github.com/DefinitelyTyped/DefinitelyTyped/blob/3b052a3e5b59b0efaa22669d9bd8f268bd689835/types/mdast/index.d.ts#L286 So, this PR is a proposal to remove the difference and simplify the AST. Closes GH-42. [^1]: You can produce nested `a`s with the DOM: ```js let a1 = document.createElement('a'); a1.textContent = 'alpha'; let a2 = document.createElement('a'); a2.textContent = 'bravo'; a1.appendChild(a2) document.body.appendChild(a1) ```
1 parent eace3f0 commit f7df75f

File tree

1 file changed

+16
-38
lines changed

1 file changed

+16
-38
lines changed

readme.md

+16-38
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ The latest released version is [`4.0.0`][latest].
5353
* [`Content`](#content)
5454
* [`ListContent`](#listcontent)
5555
* [`PhrasingContent`](#phrasingcontent)
56-
* [`StaticPhrasingContent`](#staticphrasingcontent)
57-
* [`TransparentContent`](#transparentcontent)
5856
* [Extensions](#extensions)
5957
* [GFM](#gfm)
6058
* [Frontmatter](#frontmatter)
@@ -527,7 +525,7 @@ Yields:
527525
```idl
528526
interface Emphasis <: Parent {
529527
type: 'emphasis'
530-
children: [TransparentContent]
528+
children: [PhrasingContent]
531529
}
532530
```
533531

@@ -536,7 +534,7 @@ contents.
536534

537535
**Emphasis** can be used where [**phrasing**][dfn-phrasing-content] content is
538536
expected.
539-
Its content model is [**transparent**][dfn-transparent-content] content.
537+
Its content model is [**phrasing**][dfn-phrasing-content] content.
540538

541539
For example, the following markdown:
542540

@@ -568,7 +566,7 @@ Yields:
568566
```idl
569567
interface Strong <: Parent {
570568
type: 'strong'
571-
children: [TransparentContent]
569+
children: [PhrasingContent]
572570
}
573571
```
574572

@@ -577,7 +575,7 @@ or urgency for its contents.
577575

578576
**Strong** can be used where [**phrasing**][dfn-phrasing-content] content is
579577
expected.
580-
Its content model is [**transparent**][dfn-transparent-content] content.
578+
Its content model is [**phrasing**][dfn-phrasing-content] content.
581579

582580
For example, the following markdown:
583581

@@ -674,7 +672,7 @@ Yields:
674672
```idl
675673
interface Link <: Parent {
676674
type: 'link'
677-
children: [StaticPhrasingContent]
675+
children: [PhrasingContent]
678676
}
679677
680678
Link includes Resource
@@ -684,7 +682,7 @@ Link includes Resource
684682

685683
**Link** can be used where [**phrasing**][dfn-phrasing-content] content is
686684
expected.
687-
Its content model is [**static phrasing**][dfn-static-phrasing-content] content.
685+
Its content model is also [**phrasing**][dfn-phrasing-content] content.
688686

689687
**Link** includes the mixin [**Resource**][dfn-mxn-resource].
690688

@@ -747,7 +745,7 @@ Yields:
747745
```idl
748746
interface LinkReference <: Parent {
749747
type: 'linkReference'
750-
children: [StaticPhrasingContent]
748+
children: [PhrasingContent]
751749
}
752750
753751
LinkReference includes Reference
@@ -758,7 +756,7 @@ association, or its original source if there is no association.
758756

759757
**LinkReference** can be used where [**phrasing**][dfn-phrasing-content] content
760758
is expected.
761-
Its content model is [**static phrasing**][dfn-static-phrasing-content] content.
759+
Its content model is also [**phrasing**][dfn-phrasing-content] content.
762760

763761
**LinkReference** includes the mixin [**Reference**][dfn-mxn-reference].
764762

@@ -961,27 +959,12 @@ type ListContent = ListItem
961959
### `PhrasingContent`
962960

963961
```idl
964-
type PhrasingContent = Link | LinkReference | StaticPhrasingContent
962+
type PhrasingContent = Break | Emphasis | HTML | Image | ImageReference
963+
| InlineCode | Link | LinkReference | Strong | Text
965964
```
966965

967966
**Phrasing** content represent the text in a document, and its markup.
968967

969-
### `StaticPhrasingContent`
970-
971-
```idl
972-
type StaticPhrasingContent =
973-
Break | Emphasis | HTML | Image | ImageReference | InlineCode | Strong | Text
974-
```
975-
976-
**StaticPhrasing** content represent the text in a document, and its
977-
markup, that is not intended for user interaction.
978-
979-
### `TransparentContent`
980-
981-
The **transparent** content model is derived from the content model of its
982-
[parent][dfn-parent].
983-
Effectively, this is used to prohibit nested links (and link references).
984-
985968
## Extensions
986969

987970
Markdown syntax is often extended.
@@ -1196,7 +1179,7 @@ or indeterminate or not applicable (when `null` or not present).
11961179
```idl
11971180
interface Delete <: Parent {
11981181
type: 'delete'
1199-
children: [TransparentContent]
1182+
children: [PhrasingContent]
12001183
}
12011184
```
12021185

@@ -1205,7 +1188,7 @@ accurate or no longer relevant.
12051188

12061189
**Delete** can be used where [**phrasing**][dfn-phrasing-content] content is
12071190
expected.
1208-
Its content model is [**transparent**][dfn-transparent-content] content.
1191+
Its content model is [**phrasing**][dfn-phrasing-content] content.
12091192

12101193
For example, the following markdown:
12111194

@@ -1269,11 +1252,10 @@ type RowContent = TableCell
12691252
type ListContentGfm = ListItemGfm
12701253
```
12711254

1272-
#### `StaticPhrasingContent` (GFM)
1255+
#### `PhrasingContent` (GFM)
12731256

12741257
```idl
1275-
type StaticPhrasingContentGfm =
1276-
FootnoteReference | Delete | StaticPhrasingContent
1258+
type PhrasingContentGfm = FootnoteReference | Delete | PhrasingContent
12771259
```
12781260

12791261
### Frontmatter
@@ -1365,10 +1347,10 @@ Yields:
13651347
}
13661348
```
13671349

1368-
#### `StaticPhrasingContent` (footnotes)
1350+
#### `PhrasingContent` (footnotes)
13691351

13701352
```idl
1371-
type StaticPhrasingContentFootnotes = Footnote | StaticPhrasingContent
1353+
type PhrasingContentFootnotes = Footnote | PhrasingContent
13721354
```
13731355

13741356
### MDX
@@ -1671,10 +1653,6 @@ projects!
16711653

16721654
[dfn-phrasing-content]: #phrasingcontent
16731655

1674-
[dfn-static-phrasing-content]: #staticphrasingcontent
1675-
1676-
[dfn-transparent-content]: #transparentcontent
1677-
16781656
[gfm-section]: #gfm
16791657

16801658
[gfm-footnote]: https://github.blog/changelog/2021-09-30-footnotes-now-supported-in-markdown-fields/

0 commit comments

Comments
 (0)