mirror of
https://github.com/cyborg42/epub2mdbook.git
synced 2026-02-11 00:34:50 -05:00
refactor
This commit is contained in:
parent
24a373c45a
commit
f8189b5d6d
4 changed files with 8 additions and 11 deletions
10
src/lib.rs
10
src/lib.rs
|
|
@ -25,8 +25,8 @@ pub fn convert_epub_to_mdbook(
|
|||
if !epub_path.is_file() {
|
||||
return Err(Error::NotAFile(epub_path.display().to_string()));
|
||||
}
|
||||
let book_name = epub_path.with_extension("");
|
||||
let book_name = book_name
|
||||
let book_name = epub_path
|
||||
.with_extension("")
|
||||
.file_name()
|
||||
.expect("unreachable")
|
||||
.to_string_lossy()
|
||||
|
|
@ -78,7 +78,7 @@ fn epub_nav_to_md(
|
|||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `doc` - The EPUB document
|
||||
/// * `epub_doc` - The EPUB document
|
||||
/// * `title` - The title of the book
|
||||
///
|
||||
/// # Returns
|
||||
|
|
@ -189,11 +189,11 @@ fn write_book_toml(
|
|||
creator: Option<String>,
|
||||
) -> io::Result<()> {
|
||||
let output_dir = output_dir.as_ref();
|
||||
let creator = match creator {
|
||||
let author = match creator {
|
||||
Some(creator) => format!("author = \"{creator}\"\n"),
|
||||
None => "".to_string(),
|
||||
};
|
||||
let toml_content = format!("[book]\ntitle = \"{title}\"\n{creator}",);
|
||||
let toml_content = format!("[book]\ntitle = \"{title}\"\n{author}",);
|
||||
fs::write(output_dir.join("book.toml"), toml_content)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue