Skip to content

Make properties of HastUtilToHtmlOptions type optional #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"html-void-elements": "^1.0.0",
"property-information": "^5.0.0",
"space-separated-tokens": "^1.0.0",
"stringify-entities": "^3.0.0",
"stringify-entities": "^3.0.1",
"unist-util-is": "^4.0.0",
"xtend": "^4.0.0"
},
Expand Down
43 changes: 22 additions & 21 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ declare namespace hastUtilToHtml {
*
* @defaultValue 'html'
*/
space: 'html' | 'svg'
space?: 'html' | 'svg'

/**
* Configuration for `stringify-entities`.
Expand All @@ -21,9 +21,10 @@ declare namespace hastUtilToHtml {
*
* @defaultValue {}
*/
entities: Partial<
/* eslint-disable-next-line @typescript-eslint/ban-types */
Omit<StringifyEntitiesOptions, 'escapeOnly' | 'attribute' | 'subset'>
/* eslint-disable-next-line @typescript-eslint/ban-types */
entities?: Omit<
StringifyEntitiesOptions,
'escapeOnly' | 'attribute' | 'subset'
>

/**
Expand All @@ -33,29 +34,29 @@ declare namespace hastUtilToHtml {
*
* @defaultValue `require('html-void-elements')`
*/
voids: string[]
voids?: string[]

/**
* Use a `<!DOCTYPE…` instead of `<!doctype…`.
* Useless except for XHTML.
*
* @defaultValue false
*/
upperDoctype: boolean
upperDoctype?: boolean

/**
* Preferred quote to use.
*
* @defaultValue '"'
*/
quote: '"' | "'"
quote?: '"' | "'"

/**
* Use the other quote if that results in less bytes.
*
* @defaultValue false
*/
quoteSmart: boolean
quoteSmart?: boolean

/**
* Leave attributes unquoted if that results in less bytes.
Expand All @@ -64,7 +65,7 @@ declare namespace hastUtilToHtml {
*
* @defaultValue false
*/
preferUnquoted: boolean
preferUnquoted?: boolean

/**
* Omit optional opening and closing tags.
Expand All @@ -75,7 +76,7 @@ declare namespace hastUtilToHtml {
*
* @defaultValue false
*/
omitOptionalTags: boolean
omitOptionalTags?: boolean

/**
* Collapse empty attributes: `class=""` is stringified as `class` instead.
Expand All @@ -85,7 +86,7 @@ declare namespace hastUtilToHtml {
*
* @defaultValue false
*/
collapseEmptyAttributes: boolean
collapseEmptyAttributes?: boolean

/**
* Close self-closing nodes with an extra slash (`/`): `<img />` instead of `<img>`.
Expand All @@ -95,7 +96,7 @@ declare namespace hastUtilToHtml {
*
* @defaultValue false
*/
closeSelfClosing: boolean
closeSelfClosing?: boolean

/**
* Close SVG elements without any content with slash (`/`) on the opening tag instead of an end tag: `<circle />` instead of `<circle></circle>`.
Expand All @@ -105,22 +106,22 @@ declare namespace hastUtilToHtml {
*
* @defaultValue false
*/
closeEmptyElements: boolean
closeEmptyElements?: boolean

/**
* Do not use an extra space when closing self-closing elements: `<img/>` instead of `<img />`.
* **Note**: Only used if `closeSelfClosing: true` or `closeEmptyElements: true`.
*
* @defaultValue false
*/
tightSelfClosing: boolean
tightSelfClosing?: boolean

/**
* Join known comma-separated attribute values with just a comma (`,`), instead of padding them on the right as well (`,·`, where `·` represents a space).
*
* @defaultValue false
*/
tightCommaSeparatedLists: boolean
tightCommaSeparatedLists?: boolean

/**
* Join attributes together, without white-space, if possible: `class="a b" title="c d"` is stringified as `class="a b"title="c d"` instead to save bytes.
Expand All @@ -130,15 +131,15 @@ declare namespace hastUtilToHtml {
*
* @defaultValue false
*/
tightAttributes: boolean
tightAttributes?: boolean

/**
* Drop unneeded spaces in doctypes: `<!doctypehtml>` instead of `<!doctype html>` to save bytes.
* **Note**: creates invalid (but working) markup.
*
* @defaultValue false
*/
tightDoctype: boolean
tightDoctype?: boolean

/**
* Do not encode characters which cause parse errors (even though they work), to save bytes.
Expand All @@ -148,15 +149,15 @@ declare namespace hastUtilToHtml {
*
* @defaultValue false
*/
allowParseErrors: boolean
allowParseErrors?: boolean

/**
* Do not encode some characters which cause XSS vulnerabilities in older browsers.
* **Note**: Only set this if you completely trust the content.
*
* @defaultValue false
*/
allowDangerousCharacters: boolean
allowDangerousCharacters?: boolean

/**
* Allow `raw` nodes and insert them as raw HTML.
Expand All @@ -165,7 +166,7 @@ declare namespace hastUtilToHtml {
*
* @defaultValue false
*/
allowDangerousHtml: boolean
allowDangerousHtml?: boolean
}
}

Expand All @@ -177,7 +178,7 @@ declare namespace hastUtilToHtml {
*/
declare function hastUtilToHtml(
tree: Node | Node[],
options?: Partial<hastUtilToHtml.HastUtilToHtmlOptions>
options?: hastUtilToHtml.HastUtilToHtmlOptions
): string

export = hastUtilToHtml