mod elements;
mod nodes;
mod utils;
use nodes::{node::root_node_md, utils::parse_html};
use utils::file::{read_from_filepath, write_to_filepath};
#[cfg(feature = "pyo3")]
pub mod python_bindings;
#[cfg(feature = "napi")]
pub mod nodejs_bindings;
pub fn from_html(html_text: &str) -> String {
let dom = parse_html(html_text);
root_node_md(&dom.document, None::<usize>)
}
pub fn from_file(html_filepath: &str) -> Result<String, String> {
let html_text = read_from_filepath(html_filepath)
.expect(format!("Failed to read: {}", html_filepath).as_str());
Ok(from_html(html_text.as_str()))
}
pub fn from_html_to_file(
html_text: &str,
markdown_filepath: &str,
overwrites: bool,
) -> Result<(), String> {
let md = from_html(html_text);
write_to_filepath(md.as_str(), markdown_filepath, overwrites)
}
pub fn from_file_to_file(
html_filepath: &str,
markdown_filepath: &str,
overwrites: bool,
) -> Result<(), String> {
let html = read_from_filepath(html_filepath)
.expect(format!("Failed to read: {}", html_filepath).as_str());
from_html_to_file(html.as_str(), markdown_filepath, overwrites)
}