Skip to content

Commit

Permalink
remove obsidian header
Browse files Browse the repository at this point in the history
  • Loading branch information
Endle committed Sep 21, 2024
1 parent df6dbb9 commit 5952641
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions fire_seq_search_server/src/markdown_parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,39 @@ fn hack_specific_chars_cow(text: Cow<str>) -> String {
text.replace(bullet, " ")
}

use crate::query_engine::NotebookSoftware;
use std::borrow::Borrow;
use log::info;

fn remove_obsidian_header<'a>(content: Cow<'a, str>) -> Cow<'a, str> {
lazy_static! {
static ref RE: Regex = Regex::new(
r"---[\s\S]*?---"
).unwrap();
}
info!("from {:?}", &content);
let cr = content.borrow();
let ret: Cow<str> = RE.replace(cr, " ");
info!("into {:?}", &ret);
ret.into_owned().into()
}

pub fn parse_logseq_notebook(md: Cow<'_,str>, title: &str, server_info: &ServerInformation) -> String {
// Now we do some parsing for this file
let content = exclude_advanced_query(md);
let content = hack_specific_chars_cow(content);

let content = Cow::from(content);
let content = match &server_info.software {
NotebookSoftware::Obsidian => remove_obsidian_header(content),
_ => content,
};
let content: String = markdown_to_text::convert_from_logseq(
&content, title, server_info);

//let content = content.into_owned();
content

}


Expand Down

0 comments on commit 5952641

Please sign in to comment.