Skip to content

Commit

Permalink
Refactor types
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Apr 4, 2023
1 parent e3075a5 commit 16e3fcb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
20 changes: 13 additions & 7 deletions dev/lib/html.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* @typedef {import('micromark-util-types').HtmlExtension} HtmlExtension
*
*/

/**
* @typedef Options
* Configuration (optional).
* @property {string} [clobberPrefix='user-content-']
Expand Down Expand Up @@ -31,22 +33,26 @@ import {sanitizeUri} from 'micromark-util-sanitize-uri'

const own = {}.hasOwnProperty

/** @type {Options} */
const defaultOptions = {}

/**
* Function that can be called to get an HTML extension for micromark (passed
* in `htmlExtensions`).
*
* @param {Options} [options={}]
* @param {Options | null | undefined} [options]
* Configuration (optional).
* @returns {HtmlExtension}
* HTML extension for micromark (passed in `htmlExtensions`).
*/
export function gfmFootnoteHtml(options = {}) {
const label = options.label || 'Footnotes'
const backLabel = options.backLabel || 'Back to content'
export function gfmFootnoteHtml(options) {
const config = options || defaultOptions
const label = config.label || 'Footnotes'
const backLabel = config.backLabel || 'Back to content'
const clobberPrefix =
options.clobberPrefix === undefined || options.clobberPrefix === null
config.clobberPrefix === undefined || config.clobberPrefix === null
? 'user-content-'
: options.clobberPrefix
: config.clobberPrefix
return {
enter: {
gfmFootnoteDefinition() {
Expand Down
10 changes: 5 additions & 5 deletions dev/lib/syntax.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* @typedef {import('micromark-util-types').Event} Event
* @typedef {import('micromark-util-types').Exiter} Exiter
* @typedef {import('micromark-util-types').Extension} Extension
* @typedef {import('micromark-util-types').Resolver} Resolver
* @typedef {import('micromark-util-types').State} State
* @typedef {import('micromark-util-types').Token} Token
* @typedef {import('micromark-util-types').TokenizeContext} TokenizeContext
* @typedef {import('micromark-util-types').Tokenizer} Tokenizer
* @typedef {import('micromark-util-types').Exiter} Exiter
* @typedef {import('micromark-util-types').State} State
* @typedef {import('micromark-util-types').Event} Event
*/

import {ok as assert} from 'uvu/assert'
Expand Down Expand Up @@ -113,7 +113,7 @@ function tokenizePotentialGfmFootnoteCall(effects, ok, nok) {
/** @type {Resolver} */
function resolveToPotentialGfmFootnoteCall(events, context) {
let index = events.length
/** @type {Token|undefined} */
/** @type {Token | undefined} */
let labelStart

// Find an opening.
Expand Down Expand Up @@ -298,7 +298,7 @@ function tokenizeDefinitionStart(effects, ok, nok) {
/** @type {string} */
let identifier
let size = 0
/** @type {boolean|undefined} */
/** @type {boolean | undefined} */
let data

return start
Expand Down

0 comments on commit 16e3fcb

Please sign in to comment.