mdast-util-to-hast
Advanced tools
Comparing version 12.1.2 to 12.2.0
/** | ||
* @param {H} h | ||
* @returns {Element|null} | ||
*/ | ||
export function footer(h: H): { | ||
type: string | ||
tagName: string | ||
properties: { | ||
dataFootnotes: boolean | ||
className: string[] | ||
} | ||
children: ( | ||
| { | ||
type: string | ||
tagName: string | ||
properties: { | ||
id: string | ||
className: string[] | ||
} | ||
children: { | ||
type: 'text' | ||
value: string | ||
}[] | ||
value?: undefined | ||
} | ||
| { | ||
type: string | ||
value: string | ||
tagName?: undefined | ||
properties?: undefined | ||
children?: undefined | ||
} | ||
| { | ||
type: string | ||
tagName: string | ||
properties: { | ||
id?: undefined | ||
className?: undefined | ||
} | ||
children: import('hast').ElementContent[] | ||
value?: undefined | ||
} | ||
)[] | ||
} | null | ||
export function footer(h: H): Element | null | ||
export type BlockContent = import('mdast').BlockContent | ||
@@ -45,0 +7,0 @@ export type FootnoteDefinition = import('mdast').FootnoteDefinition |
@@ -16,2 +16,3 @@ /** | ||
* @param {H} h | ||
* @returns {Element|null} | ||
*/ | ||
@@ -112,4 +113,4 @@ export function footer(h) { | ||
type: 'element', | ||
tagName: 'h2', | ||
properties: {id: 'footnote-label', className: ['sr-only']}, | ||
tagName: h.footnoteLabelTagName, | ||
properties: JSON.parse(JSON.stringify(h.footnoteLabelProperties)), | ||
children: [u('text', h.footnoteLabel)] | ||
@@ -116,0 +117,0 @@ }, |
@@ -83,2 +83,10 @@ /** | ||
/** | ||
* HTML used for the footnote label | ||
*/ | ||
footnoteLabelTagName: string | ||
/** | ||
* properties on the HTML tag used for the footnote label | ||
*/ | ||
footnoteLabelProperties: Properties | ||
/** | ||
* Label to use to go back to a footnote call from the footnote section | ||
@@ -149,2 +157,13 @@ */ | ||
/** | ||
* HTML tag to use for the footnote label. | ||
* Can be changed to match your document structure and play well with your choice of css. | ||
*/ | ||
footnoteLabelTagName?: string | undefined | ||
/** | ||
* Properties to use on the footnote label. | ||
* A 'sr-only' class is added by default to hide this from sighted users. | ||
* Change it to make the label visible, or add classes for other purposes. | ||
*/ | ||
footnoteLabelProperties?: import('hast').Properties | undefined | ||
/** | ||
* Label to use from backreferences back to their footnote call. | ||
@@ -151,0 +170,0 @@ * Affects screen reader users. |
@@ -47,2 +47,4 @@ /** | ||
* @property {string} footnoteLabel Label to use to introduce the footnote section | ||
* @property {string} footnoteLabelTagName HTML used for the footnote label | ||
* @property {Properties} footnoteLabelProperties properties on the HTML tag used for the footnote label | ||
* @property {string} footnoteBackLabel Label to use to go back to a footnote call from the footnote section | ||
@@ -77,2 +79,9 @@ * @property {(identifier: string) => Definition|null} definition Definition cache | ||
* Change it if you’re authoring in a different language. | ||
* @property {string} [footnoteLabelTagName='h2'] | ||
* HTML tag to use for the footnote label. | ||
* Can be changed to match your document structure and play well with your choice of css. | ||
* @property {Properties} [footnoteLabelProperties={id: 'footnote-label', className: ['sr-only']}] | ||
* Properties to use on the footnote label. | ||
* A 'sr-only' class is added by default to hide this from sighted users. | ||
* Change it to make the label visible, or add classes for other purposes. | ||
* @property {string} [footnoteBackLabel='Back to content'] | ||
@@ -124,2 +133,7 @@ * Label to use from backreferences back to their footnote call. | ||
h.footnoteLabel = settings.footnoteLabel || 'Footnotes' | ||
h.footnoteLabelTagName = settings.footnoteLabelTagName || 'h2' | ||
h.footnoteLabelProperties = settings.footnoteLabelProperties || { | ||
id: 'footnote-label', | ||
className: ['sr-only'] | ||
} | ||
h.footnoteBackLabel = settings.footnoteBackLabel || 'Back to content' | ||
@@ -126,0 +140,0 @@ h.definition = definitions(tree) |
{ | ||
"name": "mdast-util-to-hast", | ||
"version": "12.1.2", | ||
"version": "12.2.0", | ||
"description": "mdast utility to transform to hast", | ||
@@ -64,3 +64,3 @@ "license": "MIT", | ||
"typescript": "^4.0.0", | ||
"xo": "^0.50.0" | ||
"xo": "^0.51.0" | ||
}, | ||
@@ -67,0 +67,0 @@ "scripts": { |
@@ -96,12 +96,8 @@ # mdast-util-to-hast | ||
main() | ||
const markdown = String(await fs.readFile('example.md')) | ||
const mdast = fromMarkdown(markdown) | ||
const hast = toHast(mdast) | ||
const html = toHtml(hast) | ||
async function main() { | ||
const markdown = String(await fs.readFile('example.md')) | ||
const mdast = fromMarkdown(markdown) | ||
const hast = toHast(mdast) | ||
const html = toHtml(hast) | ||
console.log(html) | ||
} | ||
console.log(html) | ||
``` | ||
@@ -180,2 +176,27 @@ | ||
###### `options.footnoteLabelTagName` | ||
HTML tag to use for the footnote label (`string`, default: `h2`). | ||
Can be changed to match your document structure and play well with your | ||
choice of css. | ||
> 👉 **Note**: this option affects footnotes. | ||
> Footnotes are not specified by CommonMark. | ||
> They are supported by GitHub, so they can be enabled by using the utility | ||
> [`mdast-util-gfm`][mdast-util-gfm]. | ||
###### `options.footnoteLabelProperties` | ||
Properties to use on the footnote label (`object`, default: `{id: | ||
'footnote-label', className: ['sr-only']}`). | ||
A `sr-only` class is added by default to hide this from sighted users. | ||
Change it to make the label visible, or add classes for other purposes. | ||
Provide an object with no `className` or no `id` to have a footnote label with | ||
either no class or no id, or an empty object to have none. | ||
> 👉 **Note**: this option affects footnotes. | ||
> Footnotes are not specified by CommonMark. | ||
> They are supported by GitHub, so they can be enabled by using the utility | ||
> [`mdast-util-gfm`][mdast-util-gfm]. | ||
###### `options.footnoteBackLabel` | ||
@@ -182,0 +203,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
85748
1502
1740