1
0
mirror of https://github.com/lise-henry/crowbook synced 2024-09-21 20:41:33 +02:00

Add chapter struct

This commit is contained in:
Elisabeth Henry 2016-12-21 12:14:59 +01:00
parent 5a24016d75
commit 8947bc6e46
2 changed files with 48 additions and 1 deletions

46
src/lib/chapter.rs Normal file
View File

@ -0,0 +1,46 @@
// Copyright (C) 2016 Élisabeth HENRY.
//
// This file is part of Crowbook.
//
// Crowbook is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation, either version 2.1 of the License, or
// (at your option) any later version.
//
// Crowbook is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with Crowbook. If not, see <http://www.gnu.org/licenses/>.
use number::Number;
use token::Token;
/// Represents the content of a chapter.
#[derive(Debug)]
pub struct Chapter {
/// The numbering scheme of this chapter.
pub number: Number,
/// The filename of this chapter (used for inline links)
pub filename: String,
/// The (already parsed) content of this chapter
pub content: Vec<Token>,
}
impl Chapter {
/// Creates a new chapter
///
/// # Arguments
/// * `number`: the numbering scheme, to specify if this is a numbered chapter or not.
/// * `filename`: the path of the Markdown source file of the chapter.
/// * `content`: a vector of `Token`, as returned by `Parser`.
pub fn new<S: Into<String>>(number: Number, filename: S, content: Vec<Token>) -> Chapter {
Chapter {
number: number,
filename: filename.into(),
content: content,
}
}
}

View File

@ -140,6 +140,7 @@ pub use logger::{Logger, InfoLevel};
pub use renderer::Renderer;
pub use book_renderer::BookRenderer;
pub use crowbook_intl_runtime::__get_lang;
pub use chapter::Chapter;
#[macro_use]
#[doc(hidden)]
@ -155,7 +156,7 @@ mod odt;
mod parser;
mod token;
mod cleaner;
mod chapter;
mod number;
mod resource_handler;
mod logger;