Versi 8 menghadirkan dukungan penyeleksi untuk meningkatkan fleksibilitas tetapi itu juga mengubah beberapa hal yang diperkenalkan di versi 6. Pemilihan elemen dasar juga mendapat perubahan penting Show Versi 9 menghapus banyak opsi yang sebelumnya tidak digunakan lagi, memperkenalkan beberapa pemformat baru dan kemampuan baru untuk pemformat kustom. Sekarang paket mode ganda (cjs dan esm). CLI dipindahkan ke paket terpisah Instalasi
PenggunaanMengonversi satu dokumen const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World_ Konfigurasikan const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир! PilihanPilihan umumOptionDefaultDescriptionbaseElements Menjelaskan bagian mana dari dokumen masukan yang harus diubah dan ditampilkan dalam teks keluaran, dan dalam urutan apa. baseElements.selectors const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World0Elemen yang cocok dengan salah satu pemilih yang disediakan akan diproses dan disertakan dalam teks keluaran, dengan semua konten dalamnya Lihat bagian di bawah ini. const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World1 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World2 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World2 - mengatur elemen dasar dalam urutan yang sama seperti baseElements.selectors array;const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World5 - mengatur elemen dasar dalam urutan yang ditemukan dalam dokumen masukan. const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World6 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World7Konversi seluruh dokumen jika tidak ada pemilih yang cocok. const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World8 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World7Mendekode entitas HTML yang ditemukan di input HTML jika const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World7. Kalau tidak, pertahankan dalam teks keluaran. const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!1 const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!2Kamus dengan karakter yang harus diganti dalam teks keluaran dan escape sequence yang sesuai. const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!3 const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!2Objek dengan fungsi pemformatan khusus untuk elemen tertentu (lihat bagian di bawah). const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!5Menjelaskan cara membatasi teks keluaran jika dokumen HTML berukuran besar. const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!6 const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!7Sebuah string untuk disisipkan sebagai pengganti konten yang dilewati. const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!8 const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!9Berhenti mencari lebih banyak elemen dasar setelah mencapai jumlah ini. Tidak terbatas jika tidak ditentukan. const { convert } = require('html-to-text'); const html = '<a href="/page.html">Page</a><a href="!#" class="button">Action</a>'; const text = convert(html, { selectors: [ { selector: 'a', options: { baseUrl: 'https://example.com' } }, { selector: 'a.button', format: 'skip' } ] }); console.log(text); // Page [https://example.com/page.html]0 const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!9Jumlah maksimum node anak dari satu node yang akan ditambahkan ke output. Tidak terbatas jika tidak ditentukan. const { convert } = require('html-to-text'); const html = '<a href="/page.html">Page</a><a href="!#" class="button">Action</a>'; const text = convert(html, { selectors: [ { selector: 'a', options: { baseUrl: 'https://example.com' } }, { selector: 'a.button', format: 'skip' } ] }); console.log(text); // Page [https://example.com/page.html]2 const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!9Berhenti mencari node untuk ditambahkan ke output di bawah kedalaman ini di pohon DOM. Tidak terbatas jika tidak ditentukan. const { convert } = require('html-to-text'); const html = '<a href="/page.html">Page</a><a href="!#" class="button">Action</a>'; const text = convert(html, { selectors: [ { selector: 'a', options: { baseUrl: 'https://example.com' } }, { selector: 'a.button', format: 'skip' } ] }); console.log(text); // Page [https://example.com/page.html]4 const { convert } = require('html-to-text'); const html = '<a href="/page.html">Page</a><a href="!#" class="button">Action</a>'; const text = convert(html, { selectors: [ { selector: 'a', options: { baseUrl: 'https://example.com' } }, { selector: 'a.button', format: 'skip' } ] }); console.log(text); // Page [https://example.com/page.html]5Jika string input lebih panjang dari nilai ini - itu akan dipotong dan pesan akan dikirim ke const { convert } = require('html-to-text'); const html = '<a href="/page.html">Page</a><a href="!#" class="button">Action</a>'; const text = convert(html, { selectors: [ { selector: 'a', options: { baseUrl: 'https://example.com' } }, { selector: 'a.button', format: 'skip' } ] }); console.log(text); // Page [https://example.com/page.html]6. Ellipsis tidak digunakan dalam kasus ini. Tidak terbatas jika tidak ditentukan. const { convert } = require('html-to-text'); const html = '<a href="/page.html">Page</a><a href="!#" class="button">Action</a>'; const text = convert(html, { selectors: [ { selector: 'a', options: { baseUrl: 'https://example.com' } }, { selector: 'a.button', format: 'skip' } ] }); console.log(text); // Page [https://example.com/page.html]7Menjelaskan cara merangkai kata yang panjang. const { convert } = require('html-to-text'); const html = '<a href="/page.html">Page</a><a href="!#" class="button">Action</a>'; const text = convert(html, { selectors: [ { selector: 'a', options: { baseUrl: 'https://example.com' } }, { selector: 'a.button', format: 'skip' } ] }); console.log(text); // Page [https://example.com/page.html]8 const { convert } = require('html-to-text'); const html = '<a href="/page.html">Page</a><a href="!#" class="button">Action</a>'; const text = convert(html, { selectors: [ { selector: 'a', options: { baseUrl: 'https://example.com' } }, { selector: 'a.button', format: 'skip' } ] }); console.log(text); // Page [https://example.com/page.html]9Array yang berisi karakter yang dapat dibungkus. Diperiksa secara berurutan, pencarian berhenti setelah persyaratan panjang baris dapat dipenuhi. const { convert } = require('html-to-text'); const html = '<foo>Hello World</foo>'; const text = convert(html, { formatters: { // Create a formatter. 'fooBlockFormatter': function (elem, walk, builder, formatOptions) { builder.openBlock({ leadingLineBreaks: formatOptions.leadingLineBreaks || 1 }); walk(elem.children, builder); builder.addInline('!'); builder.closeBlock({ trailingLineBreaks: formatOptions.trailingLineBreaks || 1 }); } }, selectors: [ // Assign it to `foo` tags. { selector: 'foo', format: 'fooBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ] }); console.log(text); // Hello World!0 const { convert } = require('html-to-text'); const html = '<foo>Hello World</foo>'; const text = convert(html, { formatters: { // Create a formatter. 'fooBlockFormatter': function (elem, walk, builder, formatOptions) { builder.openBlock({ leadingLineBreaks: formatOptions.leadingLineBreaks || 1 }); walk(elem.children, builder); builder.addInline('!'); builder.closeBlock({ trailingLineBreaks: formatOptions.trailingLineBreaks || 1 }); } }, selectors: [ // Assign it to `foo` tags. { selector: 'foo', format: 'fooBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ] }); console.log(text); // Hello World!1Hilangkan kata-kata panjang pada batas panjang garis jika tidak ada peluang bungkus yang lebih baik ditemukan. const { convert } = require('html-to-text'); const html = '<foo>Hello World</foo>'; const text = convert(html, { formatters: { // Create a formatter. 'fooBlockFormatter': function (elem, walk, builder, formatOptions) { builder.openBlock({ leadingLineBreaks: formatOptions.leadingLineBreaks || 1 }); walk(elem.children, builder); builder.addInline('!'); builder.closeBlock({ trailingLineBreaks: formatOptions.trailingLineBreaks || 1 }); } }, selectors: [ // Assign it to `foo` tags. { selector: 'foo', format: 'fooBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ] }); console.log(text); // Hello World!2 const { convert } = require('html-to-text'); const html = '<foo>Hello World</foo>'; const text = convert(html, { formatters: { // Create a formatter. 'fooBlockFormatter': function (elem, walk, builder, formatOptions) { builder.openBlock({ leadingLineBreaks: formatOptions.leadingLineBreaks || 1 }); walk(elem.children, builder); builder.addInline('!'); builder.closeBlock({ trailingLineBreaks: formatOptions.trailingLineBreaks || 1 }); } }, selectors: [ // Assign it to `foo` tags. { selector: 'foo', format: 'fooBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ] }); console.log(text); // Hello World!1Secara default, setiap baris baru const { convert } = require('html-to-text'); const html = '<foo>Hello World</foo>'; const text = convert(html, { formatters: { // Create a formatter. 'fooBlockFormatter': function (elem, walk, builder, formatOptions) { builder.openBlock({ leadingLineBreaks: formatOptions.leadingLineBreaks || 1 }); walk(elem.children, builder); builder.addInline('!'); builder.closeBlock({ trailingLineBreaks: formatOptions.trailingLineBreaks || 1 }); } }, selectors: [ // Assign it to `foo` tags. { selector: 'foo', format: 'fooBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ] }); console.log(text); // Hello World!4 dari input HTML diciutkan menjadi spasi seperti karakter spasi putih HTML lainnya. Jika const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World_7, baris baru ini akan dipertahankan dalam output. Ini hanya berguna ketika input HTML membawa beberapa pemformatan teks biasa alih-alih tag yang tepat. const { convert } = require('html-to-text'); const html = '<foo>Hello World</foo>'; const text = convert(html, { formatters: { // Create a formatter. 'fooBlockFormatter': function (elem, walk, builder, formatOptions) { builder.openBlock({ leadingLineBreaks: formatOptions.leadingLineBreaks || 1 }); walk(elem.children, builder); builder.addInline('!'); builder.closeBlock({ trailingLineBreaks: formatOptions.trailingLineBreaks || 1 }); } }, selectors: [ // Assign it to `foo` tags. { selector: 'foo', format: 'fooBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ] }); console.log(text); // Hello World!6 const { convert } = require('html-to-text'); const html = '<a href="/page.html">Page</a><a href="!#" class="button">Action</a>'; const text = convert(html, { selectors: [ { selector: 'a', options: { baseUrl: 'https://example.com' } }, { selector: 'a.button', format: 'skip' } ] }); console.log(text); // Page [https://example.com/page.html]9Menjelaskan bagaimana elemen HTML yang berbeda harus diformat. Lihat bagian di bawah ini. ________32______8 const { convert } = require('html-to-text'); const html = '<foo>Hello World</foo>'; const text = convert(html, { formatters: { // Create a formatter. 'fooBlockFormatter': function (elem, walk, builder, formatOptions) { builder.openBlock({ leadingLineBreaks: formatOptions.leadingLineBreaks || 1 }); walk(elem.children, builder); builder.addInline('!'); builder.closeBlock({ trailingLineBreaks: formatOptions.trailingLineBreaks || 1 }); } }, selectors: [ // Assign it to `foo` tags. { selector: 'foo', format: 'fooBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ] }); console.log(text); // Hello World!9Serangkaian karakter yang dikenali sebagai spasi putih HTML. Nilai default menggunakan kumpulan karakter yang ditentukan di. (Ini termasuk ruang dengan lebar nol dibandingkan dengan. ) import { compile, convert } from 'html-to-text'; // for batch use: const compiledConvert = compile(options); let text = compiledConvert(html, metadata); // for single use: let text = convert(html, options, metadata);0 import { compile, convert } from 'html-to-text'; // for batch use: const compiledConvert = compile(options); let text = compiledConvert(html, metadata); // for single use: let text = convert(html, options, metadata);1Setelah berapa banyak karakter, jeda baris harus diikuti Setel ke import { compile, convert } from 'html-to-text'; // for batch use: const compiledConvert = compile(options); let text = compiledConvert(html, metadata); // for single use: let text = convert(html, options, metadata);2 atau const { convert } = require('html-to-text'); const html = '<foo>Hello World</foo>'; const text = convert(html, { formatters: { // Create a formatter. 'fooBlockFormatter': function (elem, walk, builder, formatOptions) { builder.openBlock({ leadingLineBreaks: formatOptions.leadingLineBreaks || 1 }); walk(elem.children, builder); builder.addInline('!'); builder.closeBlock({ trailingLineBreaks: formatOptions.trailingLineBreaks || 1 }); } }, selectors: [ // Assign it to `foo` tags. { selector: 'foo', format: 'fooBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ] }); console.log(text); // Hello World!1 untuk menonaktifkan pembungkusan kata Opsi yang tidak digunakan lagi atau dihapusOpsi lamaDepr. Rem. Sebagai gantinya, gunakanimport { compile, convert } from 'html-to-text'; // for batch use: const compiledConvert = compile(options); let text = compiledConvert(html, metadata); // for single use: let text = convert(html, options, metadata);_48. 0________42 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World_42_______69. Decoding 0Entitas sekarang ditangani oleh htmlparser2 sendiri dan entitas secara internal. Tidak ada bagian yang dapat dikonfigurasi pengguna dibandingkan dengan dia selain boolean const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World8. import { compile, convert } from 'html-to-text'; // for batch use: const compiledConvert = compile(options); let text = compiledConvert(html, metadata); // for single use: let text = convert(html, options, metadata);86. 0Cara formatter ditulis telah berubah total. Pemformat baru harus ditambahkan ke opsi const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!_3, yang lama tidak dapat digunakan kembali tanpa menulis ulang. Lihat di bawah. const options = { // ... formatters: { filterBlockFormatter: function (elem, walk, builder, formatOptions) { // all built-in and custom formatters available by name const blockFormatter = builder.options.formatters['block']; if (blockFormatter && elem.children.some(/* predicate */)) { blockFormatter(elem, walk, builder, formatOptions); } } }, selectors: [ { selector: 'div.questionable', format: 'filterBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ], // ... }_06. 09. 0 const options = { // ... formatters: { filterBlockFormatter: function (elem, walk, builder, formatOptions) { // all built-in and custom formatters available by name const blockFormatter = builder.options.formatters['block']; if (blockFormatter && elem.children.some(/* predicate */)) { blockFormatter(elem, walk, builder, formatOptions); } } }, selectors: [ { selector: 'div.questionable', format: 'filterBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ], // ... }1 const options = { // ... formatters: { filterBlockFormatter: function (elem, walk, builder, formatOptions) { // all built-in and custom formatters available by name const blockFormatter = builder.options.formatters['block']; if (blockFormatter && elem.children.some(/* predicate */)) { blockFormatter(elem, walk, builder, formatOptions); } } }, selectors: [ { selector: 'div.questionable', format: 'filterBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ], // ... }26. 09. 0 const options = { // ... formatters: { filterBlockFormatter: function (elem, walk, builder, formatOptions) { // all built-in and custom formatters available by name const blockFormatter = builder.options.formatters['block']; if (blockFormatter && elem.children.some(/* predicate */)) { blockFormatter(elem, walk, builder, formatOptions); } } }, selectors: [ { selector: 'div.questionable', format: 'filterBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ], // ... }3________52______46. 09. 0 const options = { // ... formatters: { filterBlockFormatter: function (elem, walk, builder, formatOptions) { // all built-in and custom formatters available by name const blockFormatter = builder.options.formatters['block']; if (blockFormatter && elem.children.some(/* predicate */)) { blockFormatter(elem, walk, builder, formatOptions); } } }, selectors: [ { selector: 'div.questionable', format: 'filterBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ], // ... }5 const options = { // ... formatters: { filterBlockFormatter: function (elem, walk, builder, formatOptions) { // all built-in and custom formatters available by name const blockFormatter = builder.options.formatters['block']; if (blockFormatter && elem.children.some(/* predicate */)) { blockFormatter(elem, walk, builder, formatOptions); } } }, selectors: [ { selector: 'div.questionable', format: 'filterBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ], // ... }66. 09. 0 const options = { // ... formatters: { filterBlockFormatter: function (elem, walk, builder, formatOptions) { // all built-in and custom formatters available by name const blockFormatter = builder.options.formatters['block']; if (blockFormatter && elem.children.some(/* predicate */)) { blockFormatter(elem, walk, builder, formatOptions); } } }, selectors: [ { selector: 'div.questionable', format: 'filterBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ], // ... }_7 const options = { // ... formatters: { filterBlockFormatter: function (elem, walk, builder, formatOptions) { // all built-in and custom formatters available by name const blockFormatter = builder.options.formatters['block']; if (blockFormatter && elem.children.some(/* predicate */)) { blockFormatter(elem, walk, builder, formatOptions); } } }, selectors: [ { selector: 'div.questionable', format: 'filterBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ], // ... }_8 const options = { // ... formatters: { filterBlockFormatter: function (elem, walk, builder, formatOptions) { // all built-in and custom formatters available by name const blockFormatter = builder.options.formatters['block']; if (blockFormatter && elem.children.some(/* predicate */)) { blockFormatter(elem, walk, builder, formatOptions); } } }, selectors: [ { selector: 'div.questionable', format: 'filterBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ], // ... }_9 html-to-text 0html-to-text 16. 09. 0html-to-text 2html-to-text 36. 09. 0html-to-text 4html-to-text 58. 0html-to-text 6html-to-text 76. 09. 0const options = { // ... formatters: { filterBlockFormatter: function (elem, walk, builder, formatOptions) { // all built-in and custom formatters available by name const blockFormatter = builder.options.formatters['block']; if (blockFormatter && elem.children.some(/* predicate */)) { blockFormatter(elem, walk, builder, formatOptions); } } }, selectors: [ { selector: 'div.questionable', format: 'filterBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ], // ... }_7 html-to-text _9baseElements _0html-to-text 0baseElements 28. 0baseElements 3baseElements 48. 0Lihat bagian di bawah ini. baseElements _56. 09. 0baseElements 6baseElements 76. 09. 0const options = { // ... formatters: { filterBlockFormatter: function (elem, walk, builder, formatOptions) { // all built-in and custom formatters available by name const blockFormatter = builder.options.formatters['block']; if (blockFormatter && elem.children.some(/* predicate */)) { blockFormatter(elem, walk, builder, formatOptions); } } }, selectors: [ { selector: 'div.questionable', format: 'filterBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ], // ... }_7 baseElements _9baseElements.selectors _0baseElements.selectors _1html-to-text 0Hal-hal lain dihapus
SelektorBeberapa contoh const { convert } = require('html-to-text'); const html = '<a href="/page.html">Page</a><a href="!#" class="button">Action</a>'; const text = convert(html, { selectors: [ { selector: 'a', options: { baseUrl: 'https://example.com' } }, { selector: 'a.button', format: 'skip' } ] }); console.log(text); // Page [https://example.com/page.html] Selectors array adalah perkiraan stylesheet kami yang longgar
Untuk mencapai performa terbaik saat memeriksa setiap elemen DOM terhadap pemilih yang disediakan, mereka dikompilasi ke dalam pohon keputusan. Tetapi juga penting bagaimana Anda memilih penyeleksi. Misalnya, Selektor yang didukung_____ 246 _____ bergantung pada paket peterseli dan selderee untuk dukungan penyeleksi Selektor berikut dapat digunakan dalam kombinasi apa pun
Anda dapat mencocokkan const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World09 dengan const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World10 misalnya Pemformat yang telah ditentukan sebelumnyaPemilih berikut memiliki pemformat yang ditentukan sebagai bagian dari konfigurasi default. Semuanya dapat ditimpa, tetapi Anda tidak perlu mengulangi import { compile, convert } from 'html-to-text'; // for batch use: const compiledConvert = compile(options); let text = compiledConvert(html, metadata); // for single use: let text = convert(html, options, metadata);8 atau opsi yang tidak ingin Anda timpa. (Namun perlu diingat ini hanya berlaku untuk pemilih yang sama. Tidak ada koneksi antara pemilih yang berbeda. ) const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World01 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World13Universal selector. const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World14 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World15 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World16 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World17 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World18 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World17 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World20 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World20 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World22 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World23 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World02 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World17 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World26 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World17 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World28 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World17 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World30 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World31 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World32 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World31 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World34 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World31 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World36 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World31 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World38 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World31 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World40 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World31 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World42 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World17 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World44 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World45 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World46 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World47 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World48 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World17 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World50 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World17 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World52 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World53 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World54 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World55 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World56 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World56 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World58 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World58Equivalent to const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World17. Gunakan const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World_61 sebagai gantinya untuk data tabular. const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World_62 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World63 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World64 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World64 Lebih banyak pemformat juga tersedia untuk digunakan FormatDescriptionconst { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World_61Untuk tabel yang akurat secara visual. Perhatikan bahwa ini mungkin tidak ramah pencarian (teks keluaran akan terlihat seperti omong kosong untuk mesin ketika ada konten sel yang dibungkus) dan juga sebaiknya dihindari untuk tabel yang digunakan sebagai alat tata letak halaman. const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World_67Lewati tag yang diberikan dengan isinya tanpa mencetak apa pun. const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World_68Sisipkan blok dengan string literal yang diberikan ( const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World69) alih-alih tag. const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World_70Render elemen sebagai tas blok HTML, ubah isinya menjadi teks. const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World71Render elemen dengan semua turunannya sebagai blok HTML. const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World_72Masukkan literal string yang diberikan ( const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World69) sebaris alih-alih tag. const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World_74Render elemen sebaris dibungkus dengan string yang diberikan ( const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World75 dan const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World76). const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World_77Render elemen sebagai tag HTML sebaris, ubah isinya menjadi teks. const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World78Render elemen dengan semua turunannya sebagai HTML sebaris Opsi formatOpsi berikut tersedia untuk pemformat bawaan OptionDefaultApplies toDescriptionconst { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World79 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World80, const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World81 atau const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World82semua pemformat tingkat blokJumlah jeda baris untuk memisahkan blok sebelumnya dari blok ini Perhatikan bahwa jeda baris N+1 diperlukan untuk membuat N baris kosong. const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World83 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World80 atau const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World81semua pemformat tingkat blokJumlah jeda baris untuk memisahkan blok ini dari yang berikutnya Perhatikan bahwa jeda baris N+1 diperlukan untuk membuat N baris kosong. const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World86 import { compile, convert } from 'html-to-text'; // for batch use: const compiledConvert = compile(options); let text = compiledConvert(html, metadata); // for single use: let text = convert(html, options, metadata);2 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World15, const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World47Host server untuk tautan const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World90 atribut dan gambar const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World91 atribut relatif terhadap root (yang dimulai dengan const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World92) Misalnya, dengan const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World93 dan const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World94 tautan dalam teks akan menjadi const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World95. const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World_96 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World97 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World15, const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World47Tautan keliling dengan tanda kurung ini Setel ke const { convert } = require('html-to-text'); const html = '<foo>Hello World</foo>'; const text = convert(html, { formatters: { // Create a formatter. 'fooBlockFormatter': function (elem, walk, builder, formatOptions) { builder.openBlock({ leadingLineBreaks: formatOptions.leadingLineBreaks || 1 }); walk(elem.children, builder); builder.addInline('!'); builder.closeBlock({ trailingLineBreaks: formatOptions.trailingLineBreaks || 1 }); } }, selectors: [ // Assign it to `foo` tags. { selector: 'foo', format: 'fooBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ] }); console.log(text); // Hello World!1 atau const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!01 untuk menonaktifkan. const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!02 const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!9 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World15, const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World47A berfungsi untuk menulis ulang tautan const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World90 atribut dan gambar const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World91 atribut. Argumen kedua opsional adalah objek metadata Diterapkan sebelum const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World_86. const options = { // ... formatters: { filterBlockFormatter: function (elem, walk, builder, formatOptions) { // all built-in and custom formatters available by name const blockFormatter = builder.options.formatters['block']; if (blockFormatter && elem.children.some(/* predicate */)) { blockFormatter(elem, walk, builder, formatOptions); } } }, selectors: [ { selector: 'div.questionable', format: 'filterBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ], // ... }0 const { convert } = require('html-to-text'); const html = '<foo>Hello World</foo>'; const text = convert(html, { formatters: { // Create a formatter. 'fooBlockFormatter': function (elem, walk, builder, formatOptions) { builder.openBlock({ leadingLineBreaks: formatOptions.leadingLineBreaks || 1 }); walk(elem.children, builder); builder.addInline('!'); builder.closeBlock({ trailingLineBreaks: formatOptions.trailingLineBreaks || 1 }); } }, selectors: [ // Assign it to `foo` tags. { selector: 'foo', format: 'fooBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ] }); console.log(text); // Hello World!1 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World15 Secara default tautan diterjemahkan dengan cara berikut const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!12 => menjadi => const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!13 Jika opsi ini disetel ke const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World_7 dan const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!15 dan const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!16 sama, const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!17 akan dihilangkan dan hanya const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!16 yang akan ada. const options = { // ... formatters: { filterBlockFormatter: function (elem, walk, builder, formatOptions) { // all built-in and custom formatters available by name const blockFormatter = builder.options.formatters['block']; if (blockFormatter && elem.children.some(/* predicate */)) { blockFormatter(elem, walk, builder, formatOptions); } } }, selectors: [ { selector: 'div.questionable', format: 'filterBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ], // ... }2 const { convert } = require('html-to-text'); const html = '<foo>Hello World</foo>'; const text = convert(html, { formatters: { // Create a formatter. 'fooBlockFormatter': function (elem, walk, builder, formatOptions) { builder.openBlock({ leadingLineBreaks: formatOptions.leadingLineBreaks || 1 }); walk(elem.children, builder); builder.addInline('!'); builder.closeBlock({ trailingLineBreaks: formatOptions.trailingLineBreaks || 1 }); } }, selectors: [ // Assign it to `foo` tags. { selector: 'foo', format: 'fooBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ] }); console.log(text); // Hello World!1 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World15Ignore all links. Hanya memproses teks internal tag jangkar. html-to-text 1const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World7 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World15Abaikan tautan jangkar (di mana const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!25). const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!26 const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!27 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World63Awalan string untuk setiap item daftar. const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!29 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World7 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World31Secara default, judul ( const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!32, const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!33, dll) menggunakan huruf besar Setel ini ke const { convert } = require('html-to-text'); const html = '<foo>Hello World</foo>'; const text = convert(html, { formatters: { // Create a formatter. 'fooBlockFormatter': function (elem, walk, builder, formatOptions) { builder.openBlock({ leadingLineBreaks: formatOptions.leadingLineBreaks || 1 }); walk(elem.children, builder); builder.addInline('!'); builder.closeBlock({ trailingLineBreaks: formatOptions.trailingLineBreaks || 1 }); } }, selectors: [ // Assign it to `foo` tags. { selector: 'foo', format: 'fooBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ] }); console.log(text); // Hello World!_1 untuk membiarkan heading apa adanya. const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!35 const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!9 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World45Length of the line. Jika tidak ditentukan maka nilai import { compile, convert } from 'html-to-text'; // for batch use: const compiledConvert = compile(options); let text = compiledConvert(html, metadata); // for single use: let text = convert(html, options, metadata);_0 digunakan. Jatuh kembali ke 40 jika itu juga dinonaktifkan. const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!39 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World7 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World20Potong baris kosong dari blockquote Sementara baris kosong harus dipertahankan dalam HTML, perilaku hemat ruang dipilih sebagai default untuk kenyamanan. const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!42 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World7 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World61Secara default, sel heading ( const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!45) menggunakan huruf besar Setel ini ke const { convert } = require('html-to-text'); const html = '<foo>Hello World</foo>'; const text = convert(html, { formatters: { // Create a formatter. 'fooBlockFormatter': function (elem, walk, builder, formatOptions) { builder.openBlock({ leadingLineBreaks: formatOptions.leadingLineBreaks || 1 }); walk(elem.children, builder); builder.addInline('!'); builder.closeBlock({ trailingLineBreaks: formatOptions.trailingLineBreaks || 1 }); } }, selectors: [ // Assign it to `foo` tags. { selector: 'foo', format: 'fooBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ] }); console.log(text); // Hello World!_1 untuk membiarkan sel judul sebagaimana adanya. const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!47 const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!48 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World61Konten sel tabel data akan dibungkus agar sesuai dengan lebar ini, bukan batas import { compile, convert } from 'html-to-text'; // for batch use: const compiledConvert = compile(options); let text = compiledConvert(html, metadata); // for single use: let text = convert(html, options, metadata);0 global Tetapkan ini ke const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!_9 untuk kembali ke batas import { compile, convert } from 'html-to-text'; // for batch use: const compiledConvert = compile(options); let text = compiledConvert(html, metadata); // for single use: let text = convert(html, options, metadata);0. const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!53 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World82 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World61Jumlah spasi antara kolom tabel data. const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!56 const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!57 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World61Jumlah baris kosong antara baris tabel data. const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!59 const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!60 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World68, const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World72Sebuah string yang akan dimasukkan sebagai pengganti tag. const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!63 const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!60 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World74String awalan untuk dimasukkan sebelum isi tag inline. const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!66 const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!60 const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World74Suffix string yang akan dimasukkan setelah isi tag inline Opsi format yang tidak digunakan lagiOpsi lamaBerlaku untukDepr. Rem. Sebagai gantinya gunakanhtml-to-text 3const { convert } = require('html-to-text'); // There is also an alias to `convert` called `htmlToText`. const html = '<h1>Hello World</h1>'; const text = convert(html, { wordwrap: 130 }); console.log(text); // Hello World158. 1 const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!_71 Ganti pemformatanconst { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!3 opsi adalah objek yang memiliki fungsi pemformatan. Mereka dapat ditugaskan untuk memformat elemen yang berbeda dalam larik const { convert } = require('html-to-text'); const html = '<foo>Hello World</foo>'; const text = convert(html, { formatters: { // Create a formatter. 'fooBlockFormatter': function (elem, walk, builder, formatOptions) { builder.openBlock({ leadingLineBreaks: formatOptions.leadingLineBreaks || 1 }); walk(elem.children, builder); builder.addInline('!'); builder.closeBlock({ trailingLineBreaks: formatOptions.trailingLineBreaks || 1 }); } }, selectors: [ // Assign it to `foo` tags. { selector: 'foo', format: 'fooBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ] }); console.log(text); // Hello World!6 Setiap pemformat adalah fungsi dari empat argumen yang tidak mengembalikan apa pun. Argumen adalah
Contoh pemformat kustom const { convert } = require('html-to-text'); const html = '<foo>Hello World</foo>'; const text = convert(html, { formatters: { // Create a formatter. 'fooBlockFormatter': function (elem, walk, builder, formatOptions) { builder.openBlock({ leadingLineBreaks: formatOptions.leadingLineBreaks || 1 }); walk(elem.children, builder); builder.addInline('!'); builder.closeBlock({ trailingLineBreaks: formatOptions.trailingLineBreaks || 1 }); } }, selectors: [ // Assign it to `foo` tags. { selector: 'foo', format: 'fooBlockFormatter', options: { leadingLineBreaks: 1, trailingLineBreaks: 1 } } ] }); console.log(text); // Hello World! Baru di versi 9. objek metadata dapat disediakan sebagai argumen opsional terakhir dari fungsi const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!81). Itu dapat diakses oleh pemformat sebagai const { compile } = require('html-to-text'); const convert = compile({ wordwrap: 130 }); const htmls = [ '<h1>Hello World!</h1>', '<h1>こんにちは世界!</h1>', '<h1>Привет, мир!</h1>' ]; const texts = htmls.map(convert); console.log(texts.join('\n')); // Hello World! // こんにちは世界! // Привет, мир!82 Lihat pemformat generik paket dasar dan pemformat teks paket ini untuk contoh lainnya. Cara termudah untuk menulis sendiri adalah memilih yang sudah ada dan menyesuaikannya Lihat BlockTextBuilder untuk fungsi dan argumen yang tersedia Metadata khususJika Anda perlu memberikan informasi tambahan tentang dokumen HTML Anda untuk digunakan dalam pemformat khusus - ini dapat dilakukan dengan bantuan objek metadata Bagaimana cara menulis teks dalam HTML?HTML berisi beberapa elemen untuk mendefinisikan teks dengan arti khusus. . - Teks tebal - Teks penting - Teks miring - Teks yang ditekankan - Teks yang disisipkan Tag HTML mana yang digunakan untuk teks?Grup Tag Teks adalah grup tag yang digunakan untuk membuat dokumen teks berformat baik. Tag teks mencakup
- |