mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
Add --dump-markdown flag
Add a new module to handle HTML-to-Markdown conversion and integrate it into the fetch command via a new CLI flag.
This commit is contained in:
@@ -28,6 +28,7 @@ pub const Notification = @import("Notification.zig");
|
||||
pub const log = @import("log.zig");
|
||||
pub const js = @import("browser/js/js.zig");
|
||||
pub const dump = @import("browser/dump.zig");
|
||||
pub const markdown = @import("browser/markdown.zig");
|
||||
pub const build_config = @import("build_config");
|
||||
pub const crash_handler = @import("crash_handler.zig");
|
||||
|
||||
@@ -36,6 +37,7 @@ const IS_DEBUG = @import("builtin").mode == .Debug;
|
||||
pub const FetchOpts = struct {
|
||||
wait_ms: u32 = 5000,
|
||||
dump: dump.RootOpts,
|
||||
dump_markdown: bool = false,
|
||||
writer: ?*std.Io.Writer = null,
|
||||
};
|
||||
pub fn fetch(app: *App, url: [:0]const u8, opts: FetchOpts) !void {
|
||||
@@ -94,7 +96,11 @@ pub fn fetch(app: *App, url: [:0]const u8, opts: FetchOpts) !void {
|
||||
_ = session.wait(opts.wait_ms);
|
||||
|
||||
const writer = opts.writer orelse return;
|
||||
try dump.root(page.window._document, opts.dump, writer, page);
|
||||
if (opts.dump_markdown) {
|
||||
try markdown.dump(page.window._document.asNode(), .{}, writer, page);
|
||||
} else {
|
||||
try dump.root(page.window._document, opts.dump, writer, page);
|
||||
}
|
||||
try writer.flush();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user