docs(elements): some doc comment for struct and fields
This commit is contained in:
parent
94360097a8
commit
f235354046
|
@ -4,11 +4,14 @@ use nom::{bytes::complete::tag_no_case, character::complete::alpha1, sequence::p
|
||||||
|
|
||||||
use crate::parsers::{line, take_lines_while};
|
use crate::parsers::{line, take_lines_while};
|
||||||
|
|
||||||
|
/// Special Block Element
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
pub struct SpecialBlock<'a> {
|
pub struct SpecialBlock<'a> {
|
||||||
|
/// Optional block parameters
|
||||||
pub parameters: Option<Cow<'a, str>>,
|
pub parameters: Option<Cow<'a, str>>,
|
||||||
|
/// Block name
|
||||||
pub name: Cow<'a, str>,
|
pub name: Cow<'a, str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,10 +24,12 @@ impl SpecialBlock<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Quote Block Element
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
pub struct QuoteBlock<'a> {
|
pub struct QuoteBlock<'a> {
|
||||||
|
/// Optional block parameters
|
||||||
pub parameters: Option<Cow<'a, str>>,
|
pub parameters: Option<Cow<'a, str>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,10 +41,12 @@ impl QuoteBlock<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Center Block Element
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
pub struct CenterBlock<'a> {
|
pub struct CenterBlock<'a> {
|
||||||
|
/// Optional block parameters
|
||||||
pub parameters: Option<Cow<'a, str>>,
|
pub parameters: Option<Cow<'a, str>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,10 +58,12 @@ impl CenterBlock<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Verse Block Element
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
pub struct VerseBlock<'a> {
|
pub struct VerseBlock<'a> {
|
||||||
|
/// Optional block parameters
|
||||||
pub parameters: Option<Cow<'a, str>>,
|
pub parameters: Option<Cow<'a, str>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,11 +75,13 @@ impl VerseBlock<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Comment Block Element
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
pub struct CommentBlock<'a> {
|
pub struct CommentBlock<'a> {
|
||||||
pub data: Option<Cow<'a, str>>,
|
pub data: Option<Cow<'a, str>>,
|
||||||
|
/// Comment, without block's boundaries
|
||||||
pub contents: Cow<'a, str>,
|
pub contents: Cow<'a, str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,11 +94,13 @@ impl CommentBlock<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Example Block Element
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
pub struct ExampleBlock<'a> {
|
pub struct ExampleBlock<'a> {
|
||||||
pub data: Option<Cow<'a, str>>,
|
pub data: Option<Cow<'a, str>>,
|
||||||
|
/// Block contents
|
||||||
pub contents: Cow<'a, str>,
|
pub contents: Cow<'a, str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,11 +113,13 @@ impl ExampleBlock<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Export Block Element
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
pub struct ExportBlock<'a> {
|
pub struct ExportBlock<'a> {
|
||||||
pub data: Cow<'a, str>,
|
pub data: Cow<'a, str>,
|
||||||
|
/// Block contents
|
||||||
pub contents: Cow<'a, str>,
|
pub contents: Cow<'a, str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,11 +132,14 @@ impl ExportBlock<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Src Block Element
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
pub struct SourceBlock<'a> {
|
pub struct SourceBlock<'a> {
|
||||||
|
/// Block contents
|
||||||
pub contents: Cow<'a, str>,
|
pub contents: Cow<'a, str>,
|
||||||
|
/// Language of the code in the block
|
||||||
pub language: Cow<'a, str>,
|
pub language: Cow<'a, str>,
|
||||||
pub arguments: Cow<'a, str>,
|
pub arguments: Cow<'a, str>,
|
||||||
}
|
}
|
||||||
|
@ -134,6 +152,12 @@ impl SourceBlock<'_> {
|
||||||
contents: self.contents.into_owned().into(),
|
contents: self.contents.into_owned().into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: fn number_lines() -> Some(New) | Some(Continued) | None { }
|
||||||
|
// TODO: fn preserve_indent() -> bool { }
|
||||||
|
// TODO: fn use_labels() -> bool { }
|
||||||
|
// TODO: fn label_fmt() -> Option<String> { }
|
||||||
|
// TODO: fn retain_labels() -> bool { }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn parse_block_element(input: &str) -> IResult<&str, (&str, Option<&str>, &str)> {
|
pub(crate) fn parse_block_element(input: &str) -> IResult<&str, (&str, Option<&str>, &str)> {
|
||||||
|
|
|
@ -11,26 +11,28 @@ use nom::{
|
||||||
use crate::elements::{Datetime, Timestamp};
|
use crate::elements::{Datetime, Timestamp};
|
||||||
use crate::parsers::eol;
|
use crate::parsers::eol;
|
||||||
|
|
||||||
/// clock elements
|
/// Clock Element
|
||||||
///
|
|
||||||
/// there are two types of clock: *closed* clock and *running* clock.
|
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
#[cfg_attr(feature = "ser", serde(untagged))]
|
#[cfg_attr(feature = "ser", serde(untagged))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Clock<'a> {
|
pub enum Clock<'a> {
|
||||||
/// closed Clock
|
/// Closed Clock
|
||||||
Closed {
|
Closed {
|
||||||
|
/// Time start
|
||||||
start: Datetime<'a>,
|
start: Datetime<'a>,
|
||||||
|
/// Time end
|
||||||
end: Datetime<'a>,
|
end: Datetime<'a>,
|
||||||
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
||||||
repeater: Option<Cow<'a, str>>,
|
repeater: Option<Cow<'a, str>>,
|
||||||
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
||||||
delay: Option<Cow<'a, str>>,
|
delay: Option<Cow<'a, str>>,
|
||||||
|
/// Clock duration
|
||||||
duration: Cow<'a, str>,
|
duration: Cow<'a, str>,
|
||||||
},
|
},
|
||||||
/// running Clock
|
/// Running Clock
|
||||||
Running {
|
Running {
|
||||||
|
/// Time start
|
||||||
start: Datetime<'a>,
|
start: Datetime<'a>,
|
||||||
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
||||||
repeater: Option<Cow<'a, str>>,
|
repeater: Option<Cow<'a, str>>,
|
||||||
|
@ -117,7 +119,7 @@ impl Clock<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// returns `true` if the clock is running
|
/// Returns `true` if the clock is running.
|
||||||
pub fn is_running(&self) -> bool {
|
pub fn is_running(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Clock::Closed { .. } => false,
|
Clock::Closed { .. } => false,
|
||||||
|
@ -125,7 +127,7 @@ impl Clock<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// returns `true` if the clock is closed
|
/// Returns `true` if the clock is closed.
|
||||||
pub fn is_closed(&self) -> bool {
|
pub fn is_closed(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Clock::Closed { .. } => true,
|
Clock::Closed { .. } => true,
|
||||||
|
@ -133,7 +135,7 @@ impl Clock<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// returns `Some` if the clock is closed, `None` if running
|
/// Returns clock duration, or `None` if it's running.
|
||||||
pub fn duration(&self) -> Option<&str> {
|
pub fn duration(&self) -> Option<&str> {
|
||||||
match self {
|
match self {
|
||||||
Clock::Closed { duration, .. } => Some(duration),
|
Clock::Closed { duration, .. } => Some(duration),
|
||||||
|
@ -141,7 +143,7 @@ impl Clock<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// constructs a new timestamp object from the clock
|
/// Constructs a timestamp from the clock.
|
||||||
pub fn value(&self) -> Timestamp<'_> {
|
pub fn value(&self) -> Timestamp<'_> {
|
||||||
match &*self {
|
match &*self {
|
||||||
Clock::Closed {
|
Clock::Closed {
|
||||||
|
|
|
@ -9,10 +9,12 @@ use nom::{
|
||||||
IResult,
|
IResult,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Statistics Cookie Object
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Cookie<'a> {
|
pub struct Cookie<'a> {
|
||||||
|
/// Full cookie value
|
||||||
pub value: Cow<'a, str>,
|
pub value: Cow<'a, str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,12 @@ use nom::{
|
||||||
|
|
||||||
use crate::parsers::{eol, line, take_lines_while};
|
use crate::parsers::{eol, line, take_lines_while};
|
||||||
|
|
||||||
|
/// Drawer Element
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Drawer<'a> {
|
pub struct Drawer<'a> {
|
||||||
|
/// Drawer name
|
||||||
pub name: Cow<'a, str>,
|
pub name: Cow<'a, str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,14 @@ use nom::{
|
||||||
|
|
||||||
use crate::parsers::{line, take_lines_while};
|
use crate::parsers::{line, take_lines_while};
|
||||||
|
|
||||||
|
/// Dynamic Block Element
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct DynBlock<'a> {
|
pub struct DynBlock<'a> {
|
||||||
|
/// Block name
|
||||||
pub block_name: Cow<'a, str>,
|
pub block_name: Cow<'a, str>,
|
||||||
|
/// Block argument
|
||||||
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
||||||
pub arguments: Option<Cow<'a, str>>,
|
pub arguments: Option<Cow<'a, str>>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,12 @@ use nom::{
|
||||||
|
|
||||||
use crate::parsers::line;
|
use crate::parsers::line;
|
||||||
|
|
||||||
|
/// Footnote Definition Element
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct FnDef<'a> {
|
pub struct FnDef<'a> {
|
||||||
|
/// Footnote label, used for refrence
|
||||||
pub label: Cow<'a, str>,
|
pub label: Cow<'a, str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,10 +10,12 @@ use nom::{
|
||||||
Err, IResult,
|
Err, IResult,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Footnote Reference Element
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct FnRef<'a> {
|
pub struct FnRef<'a> {
|
||||||
|
/// Footnote label
|
||||||
pub label: Cow<'a, str>,
|
pub label: Cow<'a, str>,
|
||||||
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
||||||
pub definition: Option<Cow<'a, str>>,
|
pub definition: Option<Cow<'a, str>>,
|
||||||
|
|
|
@ -7,14 +7,19 @@ use nom::{
|
||||||
IResult,
|
IResult,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Inline Babel Call Object
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct InlineCall<'a> {
|
pub struct InlineCall<'a> {
|
||||||
|
/// Called code block name
|
||||||
pub name: Cow<'a, str>,
|
pub name: Cow<'a, str>,
|
||||||
|
/// Header arguments applied to the code block
|
||||||
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
||||||
pub inside_header: Option<Cow<'a, str>>,
|
pub inside_header: Option<Cow<'a, str>>,
|
||||||
|
/// Arugment passed to the code block
|
||||||
pub arguments: Cow<'a, str>,
|
pub arguments: Cow<'a, str>,
|
||||||
|
/// Header arguments applied to the calling instance
|
||||||
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
||||||
pub end_header: Option<Cow<'a, str>>,
|
pub end_header: Option<Cow<'a, str>>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,13 +7,17 @@ use nom::{
|
||||||
IResult,
|
IResult,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Inline Src Block Object
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct InlineSrc<'a> {
|
pub struct InlineSrc<'a> {
|
||||||
|
/// Language of the code
|
||||||
pub lang: Cow<'a, str>,
|
pub lang: Cow<'a, str>,
|
||||||
|
/// Optional header arguments
|
||||||
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
||||||
pub options: Option<Cow<'a, str>>,
|
pub options: Option<Cow<'a, str>>,
|
||||||
|
/// Source code
|
||||||
pub body: Cow<'a, str>,
|
pub body: Cow<'a, str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,16 @@ use nom::{
|
||||||
|
|
||||||
use crate::parsers::line;
|
use crate::parsers::line;
|
||||||
|
|
||||||
|
/// Keyword Elemenet
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Keyword<'a> {
|
pub struct Keyword<'a> {
|
||||||
|
/// Keyword name
|
||||||
pub key: Cow<'a, str>,
|
pub key: Cow<'a, str>,
|
||||||
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
||||||
pub optional: Option<Cow<'a, str>>,
|
pub optional: Option<Cow<'a, str>>,
|
||||||
|
/// Keyword value
|
||||||
pub value: Cow<'a, str>,
|
pub value: Cow<'a, str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +32,7 @@ impl Keyword<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Babel Call Elemenet
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
@ -7,10 +7,12 @@ use nom::{
|
||||||
IResult,
|
IResult,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Link Object
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Link<'a> {
|
pub struct Link<'a> {
|
||||||
|
/// Link destination
|
||||||
pub path: Cow<'a, str>,
|
pub path: Cow<'a, str>,
|
||||||
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
||||||
pub desc: Option<Cow<'a, str>>,
|
pub desc: Option<Cow<'a, str>>,
|
||||||
|
|
|
@ -3,6 +3,7 @@ use std::iter::once;
|
||||||
|
|
||||||
use memchr::memchr_iter;
|
use memchr::memchr_iter;
|
||||||
|
|
||||||
|
/// Plain List Element
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -63,10 +64,12 @@ impl List {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// List Item Elemenet
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ListItem<'a> {
|
pub struct ListItem<'a> {
|
||||||
|
/// List item bullet
|
||||||
pub bullet: Cow<'a, str>,
|
pub bullet: Cow<'a, str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,14 @@ use nom::{
|
||||||
IResult,
|
IResult,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Macro Object
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Macros<'a> {
|
pub struct Macros<'a> {
|
||||||
|
/// Macro name
|
||||||
pub name: Cow<'a, str>,
|
pub name: Cow<'a, str>,
|
||||||
|
/// Arguments passed to the macro
|
||||||
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
||||||
pub arguments: Option<Cow<'a, str>>,
|
pub arguments: Option<Cow<'a, str>>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ pub use self::{
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
/// Org-mode element enum
|
/// Orgize Element Enum
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
|
|
|
@ -2,18 +2,18 @@ use memchr::memchr;
|
||||||
|
|
||||||
use crate::elements::Timestamp;
|
use crate::elements::Timestamp;
|
||||||
|
|
||||||
/// palnning elements
|
/// Palnning element
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Planning<'a> {
|
pub struct Planning<'a> {
|
||||||
/// the date when the task should be done
|
/// Timestamp associated to deadline keyword
|
||||||
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
||||||
pub deadline: Option<Timestamp<'a>>,
|
pub deadline: Option<Timestamp<'a>>,
|
||||||
/// the date when you should start working on the task
|
/// Timestamp associated to scheduled keyword
|
||||||
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
||||||
pub scheduled: Option<Timestamp<'a>>,
|
pub scheduled: Option<Timestamp<'a>>,
|
||||||
/// the date when the task is closed
|
/// Timestamp associated to closed keyword
|
||||||
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
||||||
pub closed: Option<Timestamp<'a>>,
|
pub closed: Option<Timestamp<'a>>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,19 @@
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use nom::{
|
use nom::{
|
||||||
bytes::complete::{tag, take_until, take_while1},
|
bytes::complete::{tag, take, take_until, take_while1},
|
||||||
sequence::{delimited, separated_pair},
|
sequence::{delimited, separated_pair},
|
||||||
IResult,
|
IResult,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Export Snippet Object
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Snippet<'a> {
|
pub struct Snippet<'a> {
|
||||||
|
/// Back-end name
|
||||||
pub name: Cow<'a, str>,
|
pub name: Cow<'a, str>,
|
||||||
|
/// Export code
|
||||||
pub value: Cow<'a, str>,
|
pub value: Cow<'a, str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +27,7 @@ impl Snippet<'_> {
|
||||||
tag(":"),
|
tag(":"),
|
||||||
take_until("@@"),
|
take_until("@@"),
|
||||||
),
|
),
|
||||||
tag("@@"),
|
take(2usize),
|
||||||
)(input)?;
|
)(input)?;
|
||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
|
|
|
@ -7,13 +7,16 @@ use nom::{
|
||||||
|
|
||||||
use crate::parsers::{line, take_lines_while};
|
use crate::parsers::{line, take_lines_while};
|
||||||
|
|
||||||
|
/// Table Elemenet
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
#[cfg_attr(feature = "ser", serde(tag = "table_type"))]
|
#[cfg_attr(feature = "ser", serde(tag = "table_type"))]
|
||||||
pub enum Table<'a> {
|
pub enum Table<'a> {
|
||||||
|
/// "org" type table
|
||||||
#[cfg_attr(feature = "ser", serde(rename = "org"))]
|
#[cfg_attr(feature = "ser", serde(rename = "org"))]
|
||||||
Org { tblfm: Option<Cow<'a, str>> },
|
Org { tblfm: Option<Cow<'a, str>> },
|
||||||
|
/// "table.el" type table
|
||||||
#[cfg_attr(feature = "ser", serde(rename = "table.el"))]
|
#[cfg_attr(feature = "ser", serde(rename = "table.el"))]
|
||||||
TableEl { value: Cow<'a, str> },
|
TableEl { value: Cow<'a, str> },
|
||||||
}
|
}
|
||||||
|
@ -31,13 +34,12 @@ impl Table<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Table Row Elemenet
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
#[cfg_attr(
|
#[cfg_attr(feature = "ser", serde(tag = "table_row_type"))]
|
||||||
feature = "ser",
|
#[cfg_attr(feature = "ser", serde(rename_all = "kebab-case"))]
|
||||||
serde(tag = "table_row_type", rename_all = "kebab-case")
|
|
||||||
)]
|
|
||||||
pub enum TableRow {
|
pub enum TableRow {
|
||||||
Standard,
|
Standard,
|
||||||
Rule,
|
Rule,
|
||||||
|
|
|
@ -7,10 +7,12 @@ use nom::{
|
||||||
IResult,
|
IResult,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Target Object
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Target<'a> {
|
pub struct Target<'a> {
|
||||||
|
/// Target ID
|
||||||
pub target: Cow<'a, str>,
|
pub target: Cow<'a, str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,14 +8,7 @@ use nom::{
|
||||||
IResult,
|
IResult,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Datetime
|
/// Orgize Datetime Struct
|
||||||
///
|
|
||||||
/// # Syntax
|
|
||||||
///
|
|
||||||
/// ```text
|
|
||||||
/// YYYY-MM-DD DAYNAME
|
|
||||||
/// ```
|
|
||||||
///
|
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
@ -101,12 +94,11 @@ mod chrono {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Timestamp Object
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
#[cfg_attr(
|
#[cfg_attr(feature = "ser", serde(rename_all = "kebab-case"))]
|
||||||
feature = "ser",
|
#[cfg_attr(feature = "ser", serde(tag = "timestamp_type"))]
|
||||||
serde(tag = "timestamp_type", rename_all = "kebab-case")
|
|
||||||
)]
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Timestamp<'a> {
|
pub enum Timestamp<'a> {
|
||||||
Active {
|
Active {
|
||||||
|
|
|
@ -19,24 +19,28 @@ use crate::config::ParseConfig;
|
||||||
use crate::elements::{Drawer, Planning, Timestamp};
|
use crate::elements::{Drawer, Planning, Timestamp};
|
||||||
use crate::parsers::{line, skip_empty_lines, take_one_word};
|
use crate::parsers::{line, skip_empty_lines, take_one_word};
|
||||||
|
|
||||||
|
/// Title Elemenet
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq))]
|
||||||
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
#[cfg_attr(feature = "ser", derive(serde::Serialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Title<'a> {
|
pub struct Title<'a> {
|
||||||
/// headline level, number of stars
|
/// Headline level, number of stars
|
||||||
pub level: usize,
|
pub level: usize,
|
||||||
/// priority cookie
|
/// Headline priority cookie
|
||||||
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
||||||
pub priority: Option<char>,
|
pub priority: Option<char>,
|
||||||
/// headline tags, including the sparated colons
|
/// Headline title tags, including the sparated colons
|
||||||
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Vec::is_empty"))]
|
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Vec::is_empty"))]
|
||||||
pub tags: Vec<Cow<'a, str>>,
|
pub tags: Vec<Cow<'a, str>>,
|
||||||
/// headline keyword
|
/// Headline title keyword
|
||||||
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
||||||
pub keyword: Option<Cow<'a, str>>,
|
pub keyword: Option<Cow<'a, str>>,
|
||||||
|
/// Raw headline's text, without the stars and the tags
|
||||||
pub raw: Cow<'a, str>,
|
pub raw: Cow<'a, str>,
|
||||||
|
/// Planning elemenet associated to this headline
|
||||||
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "Option::is_none"))]
|
||||||
pub planning: Option<Box<Planning<'a>>>,
|
pub planning: Option<Box<Planning<'a>>>,
|
||||||
|
/// Property drawer associated to this headline
|
||||||
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "HashMap::is_empty"))]
|
#[cfg_attr(feature = "ser", serde(skip_serializing_if = "HashMap::is_empty"))]
|
||||||
pub properties: HashMap<Cow<'a, str>, Cow<'a, str>>,
|
pub properties: HashMap<Cow<'a, str>, Cow<'a, str>>,
|
||||||
}
|
}
|
||||||
|
@ -106,18 +110,26 @@ impl Title<'_> {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: fn is_archived(&self) -> bool { }
|
||||||
|
// TODO: fn is_commented(&self) -> bool { }
|
||||||
|
// TODO: fn is_quoted(&self) -> bool { }
|
||||||
|
// TODO: fn is_footnote_section(&self) -> bool { }
|
||||||
|
|
||||||
|
/// Returns this headline's closed timestamp, or `None` if not set.
|
||||||
pub fn closed(&self) -> Option<&Timestamp> {
|
pub fn closed(&self) -> Option<&Timestamp> {
|
||||||
self.planning
|
self.planning
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|planning| planning.closed.as_ref())
|
.and_then(|planning| planning.closed.as_ref())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns this headline's scheduled timestamp, or `None` if not set.
|
||||||
pub fn scheduled(&self) -> Option<&Timestamp> {
|
pub fn scheduled(&self) -> Option<&Timestamp> {
|
||||||
self.planning
|
self.planning
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|planning| planning.scheduled.as_ref())
|
.and_then(|planning| planning.scheduled.as_ref())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns this headline's deadline timestamp, or `None` if not set.
|
||||||
pub fn deadline(&self) -> Option<&Timestamp> {
|
pub fn deadline(&self) -> Option<&Timestamp> {
|
||||||
self.planning
|
self.planning
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
|
Loading…
Reference in a new issue