This commit is contained in:
@ -3,7 +3,7 @@ use regex::Regex;
|
||||
use super::MarkdownSection;
|
||||
|
||||
pub struct MarkdownParser {
|
||||
code_block_regex: Regex,
|
||||
_code_block_regex: Regex,
|
||||
header_regex: Regex,
|
||||
link_regex: Regex,
|
||||
image_regex: Regex,
|
||||
@ -15,7 +15,7 @@ pub struct MarkdownParser {
|
||||
impl MarkdownParser {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
code_block_regex: Regex::new(r"```([a-zA-Z0-9]*)\n([\s\S]*?)\n```").unwrap(),
|
||||
_code_block_regex: Regex::new(r"```([a-zA-Z0-9]*)\n([\s\S]*?)\n```").unwrap(),
|
||||
header_regex: Regex::new(r"^(#{1,6})\s+(.+)$").unwrap(),
|
||||
link_regex: Regex::new(r"\[([^\]]+)\]\(([^)]+)\)").unwrap(),
|
||||
image_regex: Regex::new(r"!\[([^\]]*)\]\(([^)]+)\)").unwrap(),
|
||||
|
@ -41,11 +41,13 @@ pub enum MarkdownSection {
|
||||
}
|
||||
|
||||
pub trait Translator {
|
||||
#[allow(dead_code)]
|
||||
async fn translate(&self, content: &str, config: &TranslationConfig) -> Result<String>;
|
||||
async fn translate_markdown(&self, content: &str, config: &TranslationConfig) -> Result<String>;
|
||||
async fn translate_sections(&self, sections: Vec<MarkdownSection>, config: &TranslationConfig) -> Result<Vec<MarkdownSection>>;
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub struct TranslationResult {
|
||||
pub original: String,
|
||||
pub translated: String,
|
||||
@ -56,6 +58,7 @@ pub struct TranslationResult {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
#[allow(dead_code)]
|
||||
pub struct TranslationMetrics {
|
||||
pub character_count: usize,
|
||||
pub word_count: usize,
|
||||
@ -117,6 +120,7 @@ impl LanguageMapping {
|
||||
self.mappings.get(code)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn get_supported_languages(&self) -> Vec<String> {
|
||||
self.mappings.keys().cloned().collect()
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ impl Translator for OllamaTranslator {
|
||||
println!(" 🔤 Processing section {}", index + 1);
|
||||
|
||||
let translated_section = match §ion {
|
||||
MarkdownSection::Code(content, lang) => {
|
||||
MarkdownSection::Code(_content, _lang) => {
|
||||
if config.preserve_code {
|
||||
println!(" ⏭️ Preserving code block");
|
||||
section // Preserve code blocks
|
||||
@ -174,7 +174,7 @@ impl Translator for OllamaTranslator {
|
||||
MarkdownSection::Link(translated_text.trim().to_string(), url.clone())
|
||||
}
|
||||
}
|
||||
MarkdownSection::Image(alt, url) => {
|
||||
MarkdownSection::Image(_alt, _url) => {
|
||||
println!(" 🖼️ Preserving image");
|
||||
section // Preserve images
|
||||
}
|
||||
|
Reference in New Issue
Block a user