@@ -20,19 +20,23 @@ import { getExecutablePath, validateUrl } from './utils.js'
2020 * @typedef LightpandaFetchOptions
2121 * @type {object }
2222 * @property {boolean } dump - Export fetched output as string
23+ * @property {boolean } dumpHtml - Export fetched output as HTML
24+ * @property {boolean } dumpMarkdown - Export fetched output as Markdown
2325 * @property {boolean } disableHostVerification - Disables host verification on all HTTP requests
2426 * @property {boolean } obeyRobots - Fetches and obeys the robots.txt (if available) of the web pages we make requests towards.
2527 * @property {string } httpProxy - The HTTP proxy to use for all HTTP requests
2628 */
2729export type LightpandaFetchOptions = {
28- dump ?: boolean
2930 disableHostVerification ?: boolean
3031 obeyRobots ?: boolean
3132 httpProxy ?: string
33+ dump ?: boolean
34+ dumpOptions ?: { type ?: 'html' | 'markdown' }
3235}
3336
3437const defaultOptions : LightpandaFetchOptions = {
3538 dump : true ,
39+ dumpOptions : { type : 'html' } ,
3640}
3741
3842/**
@@ -42,7 +46,7 @@ const defaultOptions: LightpandaFetchOptions = {
4246 * @returns {Promise<Buffer | string> }
4347 */
4448export const fetch = ( url : string , options : LightpandaFetchOptions = defaultOptions ) => {
45- const { dump, disableHostVerification, obeyRobots, httpProxy } = options
49+ const { dump, dumpOptions , disableHostVerification, obeyRobots, httpProxy } = options
4650 validateUrl ( url )
4751
4852 if ( httpProxy ) {
@@ -53,7 +57,7 @@ export const fetch = (url: string, options: LightpandaFetchOptions = defaultOpti
5357 try {
5458 const executablePath = getExecutablePath ( )
5559 const flags = [
56- { flag : ' --dump' , condition : dump } ,
60+ { flag : ` --dump ${ dumpOptions ?. type ?? 'html' } ` , condition : dump } ,
5761 { flag : '--insecure_disable_tls_host_verification' , condition : disableHostVerification } ,
5862 { flag : '--obey_robots' , condition : obeyRobots } ,
5963 { flag : `--http_proxy ${ httpProxy } ` , condition : httpProxy } ,
0 commit comments