Code structure for fixed width area.
This commit is contained in:
parent
f97ca7a67d
commit
5ae8ac61e5
8
org_mode_samples/fixed_width_area/indented.org
Normal file
8
org_mode_samples/fixed_width_area/indented.org
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
: Fixed width area
|
||||||
|
: indented line
|
||||||
|
: At the top of the file
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
foo
|
||||||
|
: Another fixed width area
|
@ -12,6 +12,7 @@ use crate::parser::DynamicBlock;
|
|||||||
use crate::parser::Element;
|
use crate::parser::Element;
|
||||||
use crate::parser::ExampleBlock;
|
use crate::parser::ExampleBlock;
|
||||||
use crate::parser::ExportBlock;
|
use crate::parser::ExportBlock;
|
||||||
|
use crate::parser::FixedWidthArea;
|
||||||
use crate::parser::FootnoteDefinition;
|
use crate::parser::FootnoteDefinition;
|
||||||
use crate::parser::GreaterBlock;
|
use crate::parser::GreaterBlock;
|
||||||
use crate::parser::Heading;
|
use crate::parser::Heading;
|
||||||
@ -219,6 +220,7 @@ fn compare_element<'s>(
|
|||||||
Element::Clock(obj) => compare_clock(source, emacs, obj),
|
Element::Clock(obj) => compare_clock(source, emacs, obj),
|
||||||
Element::DiarySexp(obj) => compare_diary_sexp(source, emacs, obj),
|
Element::DiarySexp(obj) => compare_diary_sexp(source, emacs, obj),
|
||||||
Element::Planning(obj) => compare_planning(source, emacs, obj),
|
Element::Planning(obj) => compare_planning(source, emacs, obj),
|
||||||
|
Element::FixedWidthArea(obj) => compare_fixed_width_area(source, emacs, obj),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -752,3 +754,27 @@ fn compare_planning<'s>(
|
|||||||
children: Vec::new(),
|
children: Vec::new(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn compare_fixed_width_area<'s>(
|
||||||
|
source: &'s str,
|
||||||
|
emacs: &'s Token<'s>,
|
||||||
|
rust: &'s FixedWidthArea<'s>,
|
||||||
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
||||||
|
let child_status = Vec::new();
|
||||||
|
let mut this_status = DiffStatus::Good;
|
||||||
|
let emacs_name = "fixed-width";
|
||||||
|
if assert_name(emacs, emacs_name).is_err() {
|
||||||
|
this_status = DiffStatus::Bad;
|
||||||
|
}
|
||||||
|
|
||||||
|
if assert_bounds(source, emacs, rust).is_err() {
|
||||||
|
this_status = DiffStatus::Bad;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(DiffResult {
|
||||||
|
status: this_status,
|
||||||
|
name: emacs_name.to_owned(),
|
||||||
|
message: None,
|
||||||
|
children: child_status,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@ -10,6 +10,7 @@ use super::lesser_element::CommentBlock;
|
|||||||
use super::lesser_element::DiarySexp;
|
use super::lesser_element::DiarySexp;
|
||||||
use super::lesser_element::ExampleBlock;
|
use super::lesser_element::ExampleBlock;
|
||||||
use super::lesser_element::ExportBlock;
|
use super::lesser_element::ExportBlock;
|
||||||
|
use super::lesser_element::FixedWidthArea;
|
||||||
use super::lesser_element::Paragraph;
|
use super::lesser_element::Paragraph;
|
||||||
use super::lesser_element::Planning;
|
use super::lesser_element::Planning;
|
||||||
use super::lesser_element::SrcBlock;
|
use super::lesser_element::SrcBlock;
|
||||||
@ -36,6 +37,7 @@ pub enum Element<'s> {
|
|||||||
Clock(Clock<'s>),
|
Clock(Clock<'s>),
|
||||||
DiarySexp(DiarySexp<'s>),
|
DiarySexp(DiarySexp<'s>),
|
||||||
Planning(Planning<'s>),
|
Planning(Planning<'s>),
|
||||||
|
FixedWidthArea(FixedWidthArea<'s>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'s> Source<'s> for Element<'s> {
|
impl<'s> Source<'s> for Element<'s> {
|
||||||
@ -58,6 +60,7 @@ impl<'s> Source<'s> for Element<'s> {
|
|||||||
Element::Clock(obj) => obj.source,
|
Element::Clock(obj) => obj.source,
|
||||||
Element::DiarySexp(obj) => obj.source,
|
Element::DiarySexp(obj) => obj.source,
|
||||||
Element::Planning(obj) => obj.source,
|
Element::Planning(obj) => obj.source,
|
||||||
|
Element::FixedWidthArea(obj) => obj.source,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ use super::diary_sexp::diary_sexp;
|
|||||||
use super::drawer::drawer;
|
use super::drawer::drawer;
|
||||||
use super::dynamic_block::dynamic_block;
|
use super::dynamic_block::dynamic_block;
|
||||||
use super::element::Element;
|
use super::element::Element;
|
||||||
|
use super::fixed_width_area::fixed_width_area;
|
||||||
use super::footnote_definition::footnote_definition;
|
use super::footnote_definition::footnote_definition;
|
||||||
use super::greater_block::greater_block;
|
use super::greater_block::greater_block;
|
||||||
use super::lesser_block::comment_block;
|
use super::lesser_block::comment_block;
|
||||||
@ -49,6 +50,7 @@ pub fn non_paragraph_element<'r, 's>(
|
|||||||
let src_block_matcher = parser_with_context!(src_block)(context);
|
let src_block_matcher = parser_with_context!(src_block)(context);
|
||||||
let clock_matcher = parser_with_context!(clock)(context);
|
let clock_matcher = parser_with_context!(clock)(context);
|
||||||
let diary_sexp_matcher = parser_with_context!(diary_sexp)(context);
|
let diary_sexp_matcher = parser_with_context!(diary_sexp)(context);
|
||||||
|
let fixed_width_area_matcher = parser_with_context!(fixed_width_area)(context);
|
||||||
alt((
|
alt((
|
||||||
map(plain_list_matcher, Element::PlainList),
|
map(plain_list_matcher, Element::PlainList),
|
||||||
map(greater_block_matcher, Element::GreaterBlock),
|
map(greater_block_matcher, Element::GreaterBlock),
|
||||||
@ -64,5 +66,6 @@ pub fn non_paragraph_element<'r, 's>(
|
|||||||
map(src_block_matcher, Element::SrcBlock),
|
map(src_block_matcher, Element::SrcBlock),
|
||||||
map(clock_matcher, Element::Clock),
|
map(clock_matcher, Element::Clock),
|
||||||
map(diary_sexp_matcher, Element::DiarySexp),
|
map(diary_sexp_matcher, Element::DiarySexp),
|
||||||
|
map(fixed_width_area_matcher, Element::FixedWidthArea),
|
||||||
))(input)
|
))(input)
|
||||||
}
|
}
|
||||||
|
11
src/parser/fixed_width_area.rs
Normal file
11
src/parser/fixed_width_area.rs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
use super::Context;
|
||||||
|
use crate::error::Res;
|
||||||
|
use crate::parser::FixedWidthArea;
|
||||||
|
|
||||||
|
#[tracing::instrument(ret, level = "debug")]
|
||||||
|
pub fn fixed_width_area<'r, 's>(
|
||||||
|
context: Context<'r, 's>,
|
||||||
|
input: &'s str,
|
||||||
|
) -> Res<&'s str, FixedWidthArea<'s>> {
|
||||||
|
todo!()
|
||||||
|
}
|
@ -74,6 +74,11 @@ pub struct Planning<'s> {
|
|||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct FixedWidthArea<'s> {
|
||||||
|
pub source: &'s str,
|
||||||
|
}
|
||||||
|
|
||||||
impl<'s> Paragraph<'s> {
|
impl<'s> Paragraph<'s> {
|
||||||
pub fn of_text(input: &'s str) -> Self {
|
pub fn of_text(input: &'s str) -> Self {
|
||||||
let mut objects = Vec::with_capacity(1);
|
let mut objects = Vec::with_capacity(1);
|
||||||
@ -146,3 +151,9 @@ impl<'s> Source<'s> for Planning<'s> {
|
|||||||
self.source
|
self.source
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'s> Source<'s> for FixedWidthArea<'s> {
|
||||||
|
fn get_source(&'s self) -> &'s str {
|
||||||
|
self.source
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -7,6 +7,7 @@ mod dynamic_block;
|
|||||||
mod element;
|
mod element;
|
||||||
mod element_parser;
|
mod element_parser;
|
||||||
mod exiting;
|
mod exiting;
|
||||||
|
mod fixed_width_area;
|
||||||
mod footnote_definition;
|
mod footnote_definition;
|
||||||
mod greater_block;
|
mod greater_block;
|
||||||
mod greater_element;
|
mod greater_element;
|
||||||
@ -47,6 +48,7 @@ pub use lesser_element::CommentBlock;
|
|||||||
pub use lesser_element::DiarySexp;
|
pub use lesser_element::DiarySexp;
|
||||||
pub use lesser_element::ExampleBlock;
|
pub use lesser_element::ExampleBlock;
|
||||||
pub use lesser_element::ExportBlock;
|
pub use lesser_element::ExportBlock;
|
||||||
|
pub use lesser_element::FixedWidthArea;
|
||||||
pub use lesser_element::Paragraph;
|
pub use lesser_element::Paragraph;
|
||||||
pub use lesser_element::Planning;
|
pub use lesser_element::Planning;
|
||||||
pub use lesser_element::SrcBlock;
|
pub use lesser_element::SrcBlock;
|
||||||
|
Loading…
Reference in New Issue
Block a user