Code structure for latex environment.
This commit is contained in:
parent
185f16d2cc
commit
4816a5dfc4
@ -18,6 +18,7 @@ use crate::parser::GreaterBlock;
|
|||||||
use crate::parser::Heading;
|
use crate::parser::Heading;
|
||||||
use crate::parser::HorizontalRule;
|
use crate::parser::HorizontalRule;
|
||||||
use crate::parser::Keyword;
|
use crate::parser::Keyword;
|
||||||
|
use crate::parser::LatexEnvironment;
|
||||||
use crate::parser::Paragraph;
|
use crate::parser::Paragraph;
|
||||||
use crate::parser::PlainList;
|
use crate::parser::PlainList;
|
||||||
use crate::parser::PlainListItem;
|
use crate::parser::PlainListItem;
|
||||||
@ -225,6 +226,7 @@ fn compare_element<'s>(
|
|||||||
Element::FixedWidthArea(obj) => compare_fixed_width_area(source, emacs, obj),
|
Element::FixedWidthArea(obj) => compare_fixed_width_area(source, emacs, obj),
|
||||||
Element::HorizontalRule(obj) => compare_horizontal_rule(source, emacs, obj),
|
Element::HorizontalRule(obj) => compare_horizontal_rule(source, emacs, obj),
|
||||||
Element::Keyword(obj) => compare_keyword(source, emacs, obj),
|
Element::Keyword(obj) => compare_keyword(source, emacs, obj),
|
||||||
|
Element::LatexEnvironment(obj) => compare_latex_environment(source, emacs, obj),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -830,3 +832,27 @@ fn compare_keyword<'s>(
|
|||||||
children: child_status,
|
children: child_status,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn compare_latex_environment<'s>(
|
||||||
|
source: &'s str,
|
||||||
|
emacs: &'s Token<'s>,
|
||||||
|
rust: &'s LatexEnvironment<'s>,
|
||||||
|
) -> Result<DiffResult, Box<dyn std::error::Error>> {
|
||||||
|
let child_status = Vec::new();
|
||||||
|
let mut this_status = DiffStatus::Good;
|
||||||
|
let emacs_name = "latex-environment";
|
||||||
|
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,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@ -13,6 +13,7 @@ use super::lesser_element::ExportBlock;
|
|||||||
use super::lesser_element::FixedWidthArea;
|
use super::lesser_element::FixedWidthArea;
|
||||||
use super::lesser_element::HorizontalRule;
|
use super::lesser_element::HorizontalRule;
|
||||||
use super::lesser_element::Keyword;
|
use super::lesser_element::Keyword;
|
||||||
|
use super::lesser_element::LatexEnvironment;
|
||||||
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;
|
||||||
@ -43,6 +44,7 @@ pub enum Element<'s> {
|
|||||||
FixedWidthArea(FixedWidthArea<'s>),
|
FixedWidthArea(FixedWidthArea<'s>),
|
||||||
HorizontalRule(HorizontalRule<'s>),
|
HorizontalRule(HorizontalRule<'s>),
|
||||||
Keyword(Keyword<'s>),
|
Keyword(Keyword<'s>),
|
||||||
|
LatexEnvironment(LatexEnvironment<'s>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'s> Source<'s> for Element<'s> {
|
impl<'s> Source<'s> for Element<'s> {
|
||||||
@ -68,6 +70,7 @@ impl<'s> Source<'s> for Element<'s> {
|
|||||||
Element::FixedWidthArea(obj) => obj.source,
|
Element::FixedWidthArea(obj) => obj.source,
|
||||||
Element::HorizontalRule(obj) => obj.source,
|
Element::HorizontalRule(obj) => obj.source,
|
||||||
Element::Keyword(obj) => obj.source,
|
Element::Keyword(obj) => obj.source,
|
||||||
|
Element::LatexEnvironment(obj) => obj.source,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -96,6 +99,7 @@ impl<'s> SetSource<'s> for Element<'s> {
|
|||||||
Element::FixedWidthArea(obj) => obj.source = source,
|
Element::FixedWidthArea(obj) => obj.source = source,
|
||||||
Element::HorizontalRule(obj) => obj.source = source,
|
Element::HorizontalRule(obj) => obj.source = source,
|
||||||
Element::Keyword(obj) => obj.source = source,
|
Element::Keyword(obj) => obj.source = source,
|
||||||
|
Element::LatexEnvironment(obj) => obj.source = source,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ use super::footnote_definition::footnote_definition;
|
|||||||
use super::greater_block::greater_block;
|
use super::greater_block::greater_block;
|
||||||
use super::horizontal_rule::horizontal_rule;
|
use super::horizontal_rule::horizontal_rule;
|
||||||
use super::keyword::keyword;
|
use super::keyword::keyword;
|
||||||
|
use super::latex_environment::latex_environment;
|
||||||
use super::lesser_block::comment_block;
|
use super::lesser_block::comment_block;
|
||||||
use super::lesser_block::example_block;
|
use super::lesser_block::example_block;
|
||||||
use super::lesser_block::export_block;
|
use super::lesser_block::export_block;
|
||||||
@ -51,6 +52,8 @@ pub fn element(
|
|||||||
let horizontal_rule_matcher = parser_with_context!(horizontal_rule)(context);
|
let horizontal_rule_matcher = parser_with_context!(horizontal_rule)(context);
|
||||||
let keyword_matcher = parser_with_context!(keyword)(context);
|
let keyword_matcher = parser_with_context!(keyword)(context);
|
||||||
let paragraph_matcher = parser_with_context!(paragraph)(context);
|
let paragraph_matcher = parser_with_context!(paragraph)(context);
|
||||||
|
let latex_environment_matcher = parser_with_context!(latex_environment)(context);
|
||||||
|
|
||||||
let (remaining, mut affiliated_keywords) = many0(keyword_matcher)(input)?;
|
let (remaining, mut affiliated_keywords) = many0(keyword_matcher)(input)?;
|
||||||
let (remaining, mut element) = match alt((
|
let (remaining, mut element) = match alt((
|
||||||
map(plain_list_matcher, Element::PlainList),
|
map(plain_list_matcher, Element::PlainList),
|
||||||
@ -69,6 +72,7 @@ pub fn element(
|
|||||||
map(diary_sexp_matcher, Element::DiarySexp),
|
map(diary_sexp_matcher, Element::DiarySexp),
|
||||||
map(fixed_width_area_matcher, Element::FixedWidthArea),
|
map(fixed_width_area_matcher, Element::FixedWidthArea),
|
||||||
map(horizontal_rule_matcher, Element::HorizontalRule),
|
map(horizontal_rule_matcher, Element::HorizontalRule),
|
||||||
|
map(latex_environment_matcher, Element::LatexEnvironment),
|
||||||
))(remaining)
|
))(remaining)
|
||||||
{
|
{
|
||||||
the_ok @ Ok(_) => the_ok,
|
the_ok @ Ok(_) => the_ok,
|
||||||
|
11
src/parser/latex_environment.rs
Normal file
11
src/parser/latex_environment.rs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
use super::Context;
|
||||||
|
use crate::error::Res;
|
||||||
|
use crate::parser::LatexEnvironment;
|
||||||
|
|
||||||
|
#[tracing::instrument(ret, level = "debug")]
|
||||||
|
pub fn latex_environment<'r, 's>(
|
||||||
|
context: Context<'r, 's>,
|
||||||
|
input: &'s str,
|
||||||
|
) -> Res<&'s str, LatexEnvironment<'s>> {
|
||||||
|
todo!()
|
||||||
|
}
|
@ -89,6 +89,11 @@ pub struct Keyword<'s> {
|
|||||||
pub source: &'s str,
|
pub source: &'s str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct LatexEnvironment<'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);
|
||||||
@ -179,3 +184,9 @@ impl<'s> Source<'s> for Keyword<'s> {
|
|||||||
self.source
|
self.source
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'s> Source<'s> for LatexEnvironment<'s> {
|
||||||
|
fn get_source(&'s self) -> &'s str {
|
||||||
|
self.source
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -13,6 +13,7 @@ mod greater_block;
|
|||||||
mod greater_element;
|
mod greater_element;
|
||||||
mod horizontal_rule;
|
mod horizontal_rule;
|
||||||
mod keyword;
|
mod keyword;
|
||||||
|
mod latex_environment;
|
||||||
mod lesser_block;
|
mod lesser_block;
|
||||||
mod lesser_element;
|
mod lesser_element;
|
||||||
mod list;
|
mod list;
|
||||||
@ -53,6 +54,7 @@ pub use lesser_element::ExportBlock;
|
|||||||
pub use lesser_element::FixedWidthArea;
|
pub use lesser_element::FixedWidthArea;
|
||||||
pub use lesser_element::HorizontalRule;
|
pub use lesser_element::HorizontalRule;
|
||||||
pub use lesser_element::Keyword;
|
pub use lesser_element::Keyword;
|
||||||
|
pub use lesser_element::LatexEnvironment;
|
||||||
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…
x
Reference in New Issue
Block a user