Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reference field to LinkReference, ImageReference #23

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 35 additions & 8 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,17 @@ Yields:
### `Code`

`Code` ([`Text`][text]) occurs at block level (see
[`InlineCode`][inlinecode] for code spans). `Code` sports a language
tag (when using GitHub Flavoured Markdown fences with a flag, `null`
otherwise).
[`InlineCode`][inlinecode] for code spans). `Code` supports an
info string and a language tag (when the line with the opening fence
contains some text, it is stored as the info string, the first word
following the fence is stored as the language tag, the rest of the
line is stored as the info string, both are null if missing)

```idl
interface Code <: Text {
type: "code";
lang: string | null;
info: string | null;
}
```

Expand All @@ -180,6 +183,7 @@ Yields:
{
"type": "code",
"lang": null,
"info": null,
"value": "foo()"
}
```
Expand Down Expand Up @@ -719,10 +723,15 @@ its `url` and `title` defined somewhere else in the document by a
`referenceType` is needed to detect if a reference was meant as a
reference (`[foo][]`) or just unescaped brackets (`[foo]`).

wooorm marked this conversation as resolved.
Show resolved Hide resolved
`reference` provides the original raw reference, if the `reference` differs
from the `identifier`. This enables compilers, transformers, and linters to
accurately reconstruct the original input.

```idl
interface LinkReference <: Parent {
type: "linkReference";
identifier: string;
reference: string;
referenceType: referenceType;
}
```
Expand All @@ -736,7 +745,7 @@ enum referenceType {
For example, the following markdown:

```md
[alpha][bravo]
[alpha][Bravo]
```

Yields:
Expand All @@ -745,6 +754,7 @@ Yields:
{
"type": "linkReference",
"identifier": "bravo",
"reference": "Bravo",
"referenceType": "full",
"children": [{
"type": "text",
Expand All @@ -763,10 +773,14 @@ its `url` and `title` defined somewhere else in the document by a
reference (`![foo][]`) or just unescaped brackets (`![foo]`).
See [`LinkReference`][linkreference] for the definition of `referenceType`.

`reference` provides the original raw reference.
See [`LinkReference`][linkreference] for the definition of `reference`.

```idl
interface ImageReference <: Node {
type: "imageReference";
identifier: string;
reference: string;
referenceType: referenceType;
alt: string | null;
}
Expand All @@ -775,7 +789,7 @@ interface ImageReference <: Node {
For example, the following markdown:

```md
![alpha][bravo]
![alpha][Bravo]
```

Yields:
Expand All @@ -784,6 +798,7 @@ Yields:
{
"type": "imageReference",
"identifier": "bravo",
"reference": "Bravo",
"referenceType": "full",
"alt": "alpha"
}
Expand All @@ -799,21 +814,23 @@ but its content is already outside the documents flow: placed in a
interface FootnoteReference <: Node {
type: "footnoteReference";
identifier: string;
reference: string;
}
```

For example, the following markdown:

```md
[^alpha]
[^Alpha]
```

Yields:

```json
{
"type": "footnoteReference",
"identifier": "alpha"
"identifier": "Alpha"
wooorm marked this conversation as resolved.
Show resolved Hide resolved
"reference": "alpha"
}
```

Expand All @@ -823,10 +840,15 @@ Yields:
and title) of a [`LinkReference`][linkreference] or an
[`ImageReference`][imagereference].

`definition` provides the original raw definition, if the `definition` differs
from the `identifier`. This enables compilers, transformers, and linters to
accurately reconstruct the original input.

```idl
interface Definition <: Node {
type: "definition";
identifier: string;
definition: string;
title: string | null;
url: string;
}
Expand All @@ -835,7 +857,7 @@ interface Definition <: Node {
For example, the following markdown:

```md
[alpha]: http://example.com
[Alpha]: http://example.com
```

Yields:
Expand All @@ -844,6 +866,7 @@ Yields:
{
"type": "definition",
"identifier": "alpha",
"definition": "Alpha",
wooorm marked this conversation as resolved.
Show resolved Hide resolved
"title": null,
"url": "http://example.com"
}
Expand All @@ -854,6 +877,10 @@ Yields:
`FootnoteDefinition` ([`Parent`][parent]) represents the definition
(i.e., content) of a [`FootnoteReference`][footnotereference].

`definition` provides the original raw definition.
See [`Definition`][definition] for the definition of `definition`.


```idl
interface FootnoteDefinition <: Parent {
type: "footnoteDefinition";
Expand Down