A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/syntax-tree/mdast-util-heading-style below:

syntax-tree/mdast-util-heading-style: utility to get the style of an mdast heading

mdast utility to get the style of a heading.

This package is a tiny utility to figure out if a heading was written as ATX or as setext.

## ATX uses hashes

Setext uses an underline
------------------------

Probably not a lot! It’s used in remark-lint.

This package is ESM only. In Node.js (version 16+), install with npm:

npm install mdast-util-heading-style

In Deno with esm.sh:

import {headingStyle} from 'https://esm.sh/mdast-util-heading-style@3'

In browsers with esm.sh:

<script type="module">
  import {headingStyle} from 'https://esm.sh/mdast-util-heading-style@3?bundle'
</script>
import {unified} from 'unified'
import {fromMarkdown} from 'mdast-util-from-markdown'
import {headingStyle} from 'mdast-util-heading-style'

headingStyle(fromMarkdown('# ATX').children[0]) // => 'atx'
headingStyle(fromMarkdown('# ATX #\n').children[0]) // => 'atx-closed'
headingStyle(fromMarkdown('ATX\n===').children[0]) // => 'setext'

headingStyle(fromMarkdown('### ATX').children[0]) // => undefined
headingStyle(fromMarkdown('### ATX').children[0], 'setext') // => 'setext'

This package exports the identifier headingStyle. There is no default export.

headingStyle(node[, relative])

Get the heading style of a heading, optionally relative to a preferred style.

This is because ATX headings with a depth of three or more could be considered setext.

Style (Style) if it can be inferred, undefined otherwise.

Style of heading (TypeScript type).

type Style = 'atx' | 'atx-closed' | 'setext'

This package is fully typed with TypeScript. It exports the additional type Style.

Projects maintained by the unified collective are compatible with maintained versions of Node.js.

When we cut a new major release, we drop support for unmaintained versions of Node. This means we try to keep the current release line, mdast-util-heading-style@^3, compatible with Node.js 16.

Use of mdast-util-heading-style does not involve hast so there are no openings for cross-site scripting (XSS) attacks.

See contributing.md in syntax-tree/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

MIT © Titus Wormer


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4