-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
134 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ node_modules/ | |
/lib/ | ||
/index.js | ||
yarn.lock | ||
!dev/index.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
export {frontmatterHtml} from './lib/html.js' | ||
export {frontmatter} from './lib/syntax.js' | ||
export {toMatters} from './lib/to-matters.js' | ||
|
||
/** | ||
* Sequence. | ||
* | ||
* Depending on how this structure is used, it reflects a marker or a fence. | ||
*/ | ||
export interface Info { | ||
/** | ||
* Closing. | ||
*/ | ||
close: string | ||
/** | ||
* Opening. | ||
*/ | ||
open: string | ||
} | ||
|
||
/** | ||
* Fence configuration. | ||
*/ | ||
interface FenceFields { | ||
/** | ||
* Complete fences. | ||
* | ||
* This can be used when fences contain different characters or lengths | ||
* other than 3. | ||
* Pass `open` and `close` to interface to specify different characters for opening and | ||
* closing fences. | ||
*/ | ||
fence: Info | string | ||
/** | ||
* If `fence` is set, `marker` must not be set. | ||
*/ | ||
marker?: never | ||
} | ||
|
||
/** | ||
* Marker configuration. | ||
*/ | ||
interface MarkerFields { | ||
/** | ||
* Character repeated 3 times, used as complete fences. | ||
* | ||
* For example the character `'-'` will result in `'---'` being used as the | ||
* fence | ||
* Pass `open` and `close` to specify different characters for opening and | ||
* closing fences. | ||
*/ | ||
marker: Info | string | ||
/** | ||
* If `marker` is set, `fence` must not be set. | ||
*/ | ||
fence?: never | ||
} | ||
|
||
/** | ||
* Fields describing a kind of matter. | ||
*/ | ||
interface MatterFields { | ||
/** | ||
* Node type to tokenize as. | ||
*/ | ||
type: string | ||
/** | ||
* Whether matter can be found anywhere in the document, normally, only matter | ||
* at the start of the document is recognized. | ||
* | ||
* > 👉 **Note**: using this is a terrible idea. | ||
* > It’s called frontmatter, not matter-in-the-middle or so. | ||
* > This makes your markdown less portable. | ||
*/ | ||
anywhere?: boolean | null | undefined | ||
} | ||
|
||
/** | ||
* Fields describing a kind of matter. | ||
* | ||
* > 👉 **Note**: using `anywhere` is a terrible idea. | ||
* > It’s called frontmatter, not matter-in-the-middle or so. | ||
* > This makes your markdown less portable. | ||
* | ||
* > 👉 **Note**: `marker` and `fence` are mutually exclusive. | ||
* > If `marker` is set, `fence` must not be set, and vice versa. | ||
*/ | ||
export type Matter = | ||
| (MatterFields & FenceFields) | ||
| (MatterFields & MarkerFields) | ||
|
||
/** | ||
* Configuration. | ||
*/ | ||
export type Options = Matter | Preset | Array<Matter | Preset> | ||
|
||
/** | ||
* Known name of a frontmatter style. | ||
*/ | ||
export type Preset = 'toml' | 'yaml' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,4 @@ | ||
/** | ||
* @typedef {import('./lib/to-matters.js').Info} Info | ||
* @typedef {import('./lib/to-matters.js').Matter} Matter | ||
* @typedef {import('./lib/to-matters.js').Options} Options | ||
* @typedef {import('./lib/to-matters.js').Preset} Preset | ||
*/ | ||
|
||
// Note: types exposed from `index.d.ts`. | ||
export {frontmatter} from './lib/syntax.js' | ||
export {frontmatterHtml} from './lib/html.js' | ||
export {toMatters} from './lib/to-matters.js' | ||
|
||
// Note: we don’t have an `index.d.ts` in this extension because all token | ||
// types are dynamic in JS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters