Skip to content

Commit 6cfdf00

Browse files
committed
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. [^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 7007698 commit 6cfdf00

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
@@ -52,8 +52,6 @@ The latest released version is [`4.0.0`][latest].
5252
* [`Content`](#content)
5353
* [`ListContent`](#listcontent)
5454
* [`PhrasingContent`](#phrasingcontent)
55-
* [`StaticPhrasingContent`](#staticphrasingcontent)
56-
* [`TransparentContent`](#transparentcontent)
5755
* [Extensions](#extensions)
5856
* [GFM](#gfm)
5957
* [Frontmatter](#frontmatter)
@@ -517,7 +515,7 @@ Yields:
517515
```idl
518516
interface Emphasis <: Parent {
519517
type: 'emphasis'
520-
children: [TransparentContent]
518+
children: [PhrasingContent]
521519
}
522520
```
523521

@@ -526,7 +524,7 @@ contents.
526524

527525
**Emphasis** can be used where [**phrasing**][dfn-phrasing-content] content is
528526
expected.
529-
Its content model is [**transparent**][dfn-transparent-content] content.
527+
Its content model is [**phrasing**][dfn-phrasing-content] content.
530528

531529
For example, the following markdown:
532530

@@ -558,7 +556,7 @@ Yields:
558556
```idl
559557
interface Strong <: Parent {
560558
type: 'strong'
561-
children: [TransparentContent]
559+
children: [PhrasingContent]
562560
}
563561
```
564562

@@ -567,7 +565,7 @@ or urgency for its contents.
567565

568566
**Strong** can be used where [**phrasing**][dfn-phrasing-content] content is
569567
expected.
570-
Its content model is [**transparent**][dfn-transparent-content] content.
568+
Its content model is [**phrasing**][dfn-phrasing-content] content.
571569

572570
For example, the following markdown:
573571

@@ -664,7 +662,7 @@ Yields:
664662
```idl
665663
interface Link <: Parent {
666664
type: 'link'
667-
children: [StaticPhrasingContent]
665+
children: [PhrasingContent]
668666
}
669667
670668
Link includes Resource
@@ -674,7 +672,7 @@ Link includes Resource
674672

675673
**Link** can be used where [**phrasing**][dfn-phrasing-content] content is
676674
expected.
677-
Its content model is [**static phrasing**][dfn-static-phrasing-content] content.
675+
Its content model is also [**phrasing**][dfn-phrasing-content] content.
678676

679677
**Link** includes the mixin [**Resource**][dfn-mxn-resource].
680678

@@ -737,7 +735,7 @@ Yields:
737735
```idl
738736
interface LinkReference <: Parent {
739737
type: 'linkReference'
740-
children: [StaticPhrasingContent]
738+
children: [PhrasingContent]
741739
}
742740
743741
LinkReference includes Reference
@@ -748,7 +746,7 @@ association, or its original source if there is no association.
748746

749747
**LinkReference** can be used where [**phrasing**][dfn-phrasing-content] content
750748
is expected.
751-
Its content model is [**static phrasing**][dfn-static-phrasing-content] content.
749+
Its content model is also [**phrasing**][dfn-phrasing-content] content.
752750

753751
**LinkReference** includes the mixin [**Reference**][dfn-mxn-reference].
754752

@@ -951,27 +949,12 @@ type ListContent = ListItem
951949
### `PhrasingContent`
952950

953951
```idl
954-
type PhrasingContent = Link | LinkReference | StaticPhrasingContent
952+
type PhrasingContent = Break | Emphasis | HTML | Image | ImageReference
953+
| InlineCode | Link | LinkReference | Strong | Text
955954
```
956955

957956
**Phrasing** content represent the text in a document, and its markup.
958957

959-
### `StaticPhrasingContent`
960-
961-
```idl
962-
type StaticPhrasingContent =
963-
Break | Emphasis | HTML | Image | ImageReference | InlineCode | Strong | Text
964-
```
965-
966-
**StaticPhrasing** content represent the text in a document, and its
967-
markup, that is not intended for user interaction.
968-
969-
### `TransparentContent`
970-
971-
The **transparent** content model is derived from the content model of its
972-
[parent][dfn-parent].
973-
Effectively, this is used to prohibit nested links (and link references).
974-
975958
## Extensions
976959

977960
Markdown syntax is often extended.
@@ -1186,7 +1169,7 @@ or indeterminate or not applicable (when `null` or not present).
11861169
```idl
11871170
interface Delete <: Parent {
11881171
type: 'delete'
1189-
children: [TransparentContent]
1172+
children: [PhrasingContent]
11901173
}
11911174
```
11921175

@@ -1195,7 +1178,7 @@ accurate or no longer relevant.
11951178

11961179
**Delete** can be used where [**phrasing**][dfn-phrasing-content] content is
11971180
expected.
1198-
Its content model is [**transparent**][dfn-transparent-content] content.
1181+
Its content model is [**phrasing**][dfn-phrasing-content] content.
11991182

12001183
For example, the following markdown:
12011184

@@ -1259,11 +1242,10 @@ type RowContent = TableCell
12591242
type ListContentGfm = ListItemGfm
12601243
```
12611244

1262-
#### `StaticPhrasingContent` (GFM)
1245+
#### `PhrasingContent` (GFM)
12631246

12641247
```idl
1265-
type StaticPhrasingContentGfm =
1266-
FootnoteReference | Delete | StaticPhrasingContent
1248+
type PhrasingContentGfm = FootnoteReference | Delete | PhrasingContent
12671249
```
12681250

12691251
### Frontmatter
@@ -1355,10 +1337,10 @@ Yields:
13551337
}
13561338
```
13571339

1358-
#### `StaticPhrasingContent` (footnotes)
1340+
#### `PhrasingContent` (footnotes)
13591341

13601342
```idl
1361-
type StaticPhrasingContentFootnotes = Footnote | StaticPhrasingContent
1343+
type PhrasingContentFootnotes = Footnote | PhrasingContent
13621344
```
13631345

13641346
### MDX
@@ -1661,10 +1643,6 @@ projects!
16611643

16621644
[dfn-phrasing-content]: #phrasingcontent
16631645

1664-
[dfn-static-phrasing-content]: #staticphrasingcontent
1665-
1666-
[dfn-transparent-content]: #transparentcontent
1667-
16681646
[gfm-section]: #gfm
16691647

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

0 commit comments

Comments
 (0)