Skip to content

Commit

Permalink
Refactor code-style
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jul 3, 2022
1 parent 5a6d4e2 commit 6343fed
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
1 change: 1 addition & 0 deletions dev/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/**
* @typedef {import('./matters.js').Options} Options
*/

export {frontmatterHtml} from './lib/html.js'
export {frontmatter} from './lib/syntax.js'
14 changes: 12 additions & 2 deletions dev/lib/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,20 @@
import {matters} from '../matters.js'

/**
* Create an extension to support frontmatter (YAML, TOML, and more).
* Add support for turning frontmatter in markdown to HTML.
*
* @param {Options} [options='yaml'] One preset or matter, or an array of them.
* Function that can be called to get an HTML extension for micromark (passed
* in `htmlExtensions`).
*
* This makes sure nothing is generated for frontmatter.
*
* Supports YAML by default.
* Can be configured to support other things.
*
* @param {Options} [options='yaml']
* Configuration (optional).
* @returns {HtmlExtension}
* HTML extension for micromark (passed in `htmlExtensions`).
*/
export function frontmatterHtml(options) {
const settings = matters(options)
Expand Down
12 changes: 10 additions & 2 deletions dev/lib/syntax.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,18 @@ import {types} from 'micromark-util-symbol/types.js'
import {matters} from '../matters.js'

/**
* Create an extension to support frontmatter (YAML, TOML, and more).
* Add support for parsing frontmatter in markdown.
*
* @param {Options} [options='yaml'] One preset or matter, or an array of them.
* Function that can be called to get a syntax extension for micromark (passed
* in `extensions`).
*
* Supports YAML by default.
* Can be configured to support TOML and more.
*
* @param {Options} [options='yaml']
* Configuration (optional).
* @returns {Extension}
* Syntax extension for micromark (passed in `extensions`).
*/
export function frontmatter(options) {
const settings = matters(options)
Expand Down
12 changes: 9 additions & 3 deletions dev/matters.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,46 @@
/**
* @typedef {'yaml'|'toml'} Preset
* Either `'yaml'` or `'toml'`
* Either `'yaml'` or `'toml'`.
*
* @typedef Info
* @property {string} open
* @property {string} close
*
* @typedef MatterProps
* @property {string} type
* Type to tokenize as
* Type to tokenize as.
* @property {boolean} [anywhere=false]
* If `true`, matter can be found anywhere in the document.
* If `false` (default), only matter at the start of the document is
* recognized.
*
* @typedef MarkerProps
* Marker configuration.
* @property {string|Info} marker
* Character used to construct fences.
* By providing an object with `open` and `close` different characters can be
* used for opening and closing fences.
* For example the character `'-'` will result in `'---'` being used as the
* fence
* @property {never} [fence]
* If `marker` is set, `fence` must not be set.
*
* @typedef FenceProps
* Fence configuration.
* @property {string|Info} fence
* String used as the complete fence.
* By providing an object with `open` and `close` different values can be used
* for opening and closing fences.
* This can be used too if fences contain different characters or lengths
* other than 3.
* @property {never} [marker]
* If `fence` is set, `marker` must not be set.
*
* @typedef {(MatterProps & FenceProps)|(MatterProps & MarkerProps)} Matter
* Matter object describing frontmatter.
*
* @typedef {Preset|Matter|Array.<Preset|Matter>} Options
* @typedef {Preset|Matter|Array<Preset|Matter>} Options
* Matter object or preset, or many.
*/

import {fault} from 'fault'
Expand Down

0 comments on commit 6343fed

Please sign in to comment.