Skip to content

Commit

Permalink
fix markdown processor
Browse files Browse the repository at this point in the history
  • Loading branch information
akshayballal95 committed Dec 29, 2024
1 parent f483399 commit e452fe4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 98 deletions.
99 changes: 7 additions & 92 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "embed_anything"
version = "0.4.13"
version = "0.4.18"
edition.workspace = true
license.workspace = true
description.workspace = true
Expand Down Expand Up @@ -49,7 +49,6 @@ tokio = { version = "1.40.0", features = ["macros", "rt-multi-thread"] }


# Markdown Processing
markdown-parser = "0.1.2"
markdown_to_text = "1.0.0"

# Web Scraping
Expand Down
7 changes: 3 additions & 4 deletions rust/src/file_processor/markdown_processor.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use anyhow::Error;
use markdown_parser::read_file;

/// A struct that provides functionality to process Markdown files.
pub struct MarkdownProcessor;
Expand All @@ -16,9 +15,9 @@ impl MarkdownProcessor {
/// Returns a `Result` containing the extracted text content as a `String` if successful,
/// or an `Error` if an error occurred while reading the file or converting the Markdown.
pub fn extract_text<T: AsRef<std::path::Path>>(file_path: &T) -> Result<String, Error> {
let md = read_file(file_path)?;
let content = md.content();
let content = markdown_to_text::convert(content);
let bytes = std::fs::read(file_path)?;
let out = String::from_utf8_lossy(&bytes).to_string();
let content = markdown_to_text::convert(&out);
Ok(content)
}
}
Expand Down

0 comments on commit e452fe4

Please sign in to comment.