🤖 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:
Chris. Webster 2020-06-09 13:30:28 -07:00 committed by GitHub
parent 9d17503404
commit 92aa7ed024
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 52 additions and 0 deletions

View File

@ -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));

View File

@ -137,6 +137,7 @@ export interface Formatters {
lineBreak?: Formatter;
paragraph?: Formatter;
anchor?: Formatter;
blockquote?: Formatter;
heading?: Formatter;
table?: Formatter;
orderedList?: Formatter;

View File

@ -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;