mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
🤖 Merge PR #45375 html-to-text: Add format: blockquote support by @webstech
Add blockquote as a possible format attribute. Add all possible formatters to test case. Signed-off-by: Chris. Webster <chris@webstech.net>
This commit is contained in:
parent
9d17503404
commit
92aa7ed024
@ -22,3 +22,53 @@ console.log(fromString(htmlString));
|
||||
|
||||
console.log('Processing string with custom options');
|
||||
console.log(fromString(htmlString, htmlOptions));
|
||||
|
||||
const allElements = '<a>a</a>\
|
||||
<blockquote>b</blockquote>\
|
||||
<h1>h</h1>\
|
||||
<hr />\
|
||||
<img />\
|
||||
<br />\
|
||||
<ol></old>\
|
||||
<p>p</p>\
|
||||
<table></table>\
|
||||
<ul></ul>';
|
||||
|
||||
const fmtOptions: HtmlToTextOptions = {
|
||||
format: {
|
||||
anchor: (_el, _walk, _options) => {
|
||||
return "--anchor--\n";
|
||||
},
|
||||
blockquote: (_el, _walk, _options) => {
|
||||
return "--blockquote--\n";
|
||||
},
|
||||
heading: (_el, _walk, _options) => {
|
||||
return "--heading--\n";
|
||||
},
|
||||
horizontalLine: (_el, _walk, _options) => {
|
||||
return "--horizontalLine--\n";
|
||||
},
|
||||
image: (_el, _options) => {
|
||||
return "--image--\n";
|
||||
},
|
||||
lineBreak: (_el, _walk, _options) => {
|
||||
return "--lineBreak--\n";
|
||||
},
|
||||
orderedList: (_el, _walk, _options) => {
|
||||
return "--orderedList--\n";
|
||||
},
|
||||
paragraph: (_el, _walk, _options) => {
|
||||
return "--paragraph--\n";
|
||||
},
|
||||
table: (_el, _walk, _options) => {
|
||||
return "--table--\n";
|
||||
},
|
||||
text: (_el, _options) => {
|
||||
return "--text--\n";
|
||||
},
|
||||
unorderedList: (_el, _walk, _options) => {
|
||||
return "--unorderedList--\n";
|
||||
},
|
||||
},
|
||||
};
|
||||
console.log(fromString(allElements, fmtOptions));
|
||||
|
||||
1
types/html-to-text/index.d.ts
vendored
1
types/html-to-text/index.d.ts
vendored
@ -137,6 +137,7 @@ export interface Formatters {
|
||||
lineBreak?: Formatter;
|
||||
paragraph?: Formatter;
|
||||
anchor?: Formatter;
|
||||
blockquote?: Formatter;
|
||||
heading?: Formatter;
|
||||
table?: Formatter;
|
||||
orderedList?: Formatter;
|
||||
|
||||
1
types/html-to-text/lib/formatter.d.ts
vendored
1
types/html-to-text/lib/formatter.d.ts
vendored
@ -5,6 +5,7 @@ export const image: LeafFormatter;
|
||||
export const lineBreak: Formatter;
|
||||
export const paragraph: Formatter;
|
||||
export const anchor: Formatter;
|
||||
export const blockquote: Formatter;
|
||||
export const heading: Formatter;
|
||||
export const table: Formatter;
|
||||
export const orderedList: Formatter;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user