Compare commits
No commits in common. "c420ccd029676b1ca14228afd5259e3e0ee1e57b" and "f47d688be4ed1c1688d065074b1f3cee457d7129" have entirely different histories.
c420ccd029
...
f47d688be4
4
Makefile
4
Makefile
@ -45,6 +45,10 @@ dockerclippy:
|
|||||||
clippy:
|
clippy:
|
||||||
> cargo clippy --no-deps --all-targets --all-features -- -D warnings
|
> cargo clippy --no-deps --all-targets --all-features -- -D warnings
|
||||||
|
|
||||||
|
.PHONY: clippyfix
|
||||||
|
clippyfix:
|
||||||
|
> cargo clippy --fix --lib -p organic --all-features
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test:
|
test:
|
||||||
> cargo test --no-default-features --features compare --no-fail-fast --lib --test test_loader -- --test-threads $(TESTJOBS)
|
> cargo test --no-default-features --features compare --no-fail-fast --lib --test test_loader -- --test-threads $(TESTJOBS)
|
||||||
|
@ -25,13 +25,13 @@ ifdef REMOTE_REPO
|
|||||||
else
|
else
|
||||||
@echo "REMOTE_REPO not defined, not removing from remote repo."
|
@echo "REMOTE_REPO not defined, not removing from remote repo."
|
||||||
endif
|
endif
|
||||||
docker volume rm rust-cache cargo-cache
|
docker volume rm cargo-cache
|
||||||
|
|
||||||
# NOTE: This target will write to folders underneath the git-root
|
# NOTE: This target will write to folders underneath the git-root
|
||||||
.PHONY: run
|
.PHONY: run
|
||||||
run: build
|
run: build
|
||||||
docker run --rm --init --read-only --mount type=tmpfs,destination=/tmp -v "$$(readlink -f ../../):/source:ro" --workdir=/source --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target $(IMAGE_NAME)
|
docker run --rm --init --read-only --mount type=tmpfs,destination=/tmp -v "$$(readlink -f ../../):/source" --workdir=/source --mount source=cargo-cache,target=/usr/local/cargo/registry $(IMAGE_NAME)
|
||||||
|
|
||||||
.PHONY: shell
|
.PHONY: shell
|
||||||
shell: build
|
shell: build
|
||||||
docker run --rm -i -t --entrypoint /bin/sh --mount type=tmpfs,destination=/tmp -v "$$(readlink -f ../../):/source:ro" --workdir=/source --mount source=cargo-cache,target=/usr/local/cargo/registry --mount source=rust-cache,target=/target --env CARGO_TARGET_DIR=/target $(IMAGE_NAME)
|
docker run --rm -i -t --entrypoint /bin/sh --mount type=tmpfs,destination=/tmp -v "$$(readlink -f ../../):/source" --workdir=/source --mount source=cargo-cache,target=/usr/local/cargo/registry $(IMAGE_NAME)
|
||||||
|
@ -655,7 +655,7 @@ pub(crate) fn compare_property_number_lines<
|
|||||||
(Some(number_lines), Some(rust_number_lines)) => {
|
(Some(number_lines), Some(rust_number_lines)) => {
|
||||||
let token_list = number_lines.as_list()?;
|
let token_list = number_lines.as_list()?;
|
||||||
let number_type = token_list
|
let number_type = token_list
|
||||||
.first()
|
.get(0)
|
||||||
.map(Token::as_atom)
|
.map(Token::as_atom)
|
||||||
.map_or(Ok(None), |r| r.map(Some))?
|
.map_or(Ok(None), |r| r.map(Some))?
|
||||||
.ok_or(":number-lines should have a type.")?;
|
.ok_or(":number-lines should have a type.")?;
|
||||||
|
@ -2153,7 +2153,7 @@ fn compare_plain_text<'b, 's>(
|
|||||||
let text = emacs.as_text()?;
|
let text = emacs.as_text()?;
|
||||||
let start_ind: usize = text
|
let start_ind: usize = text
|
||||||
.properties
|
.properties
|
||||||
.first()
|
.get(0)
|
||||||
.expect("Should have start index.")
|
.expect("Should have start index.")
|
||||||
.as_atom()?
|
.as_atom()?
|
||||||
.parse()?;
|
.parse()?;
|
||||||
|
@ -15,8 +15,10 @@ use crate::context::RefContext;
|
|||||||
use crate::error::CustomError;
|
use crate::error::CustomError;
|
||||||
use crate::error::Res;
|
use crate::error::Res;
|
||||||
use crate::parser::macros::element;
|
use crate::parser::macros::element;
|
||||||
|
use crate::types::AffiliatedKeywords;
|
||||||
use crate::types::Object;
|
use crate::types::Object;
|
||||||
use crate::types::Paragraph;
|
use crate::types::Paragraph;
|
||||||
|
use crate::types::PlainText;
|
||||||
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
@ -78,10 +80,13 @@ pub(crate) fn broken_end<'b, 'g, 'r, 's>(
|
|||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
remaining,
|
remaining,
|
||||||
Paragraph::of_text(
|
Paragraph {
|
||||||
input.get_until(remaining).into(),
|
source: input.get_until(remaining).into(),
|
||||||
input.get_until(lead_in_remaining).into(),
|
affiliated_keywords: AffiliatedKeywords::default(),
|
||||||
),
|
children: vec![Object::PlainText(PlainText {
|
||||||
|
source: input.get_until(lead_in_remaining).into(),
|
||||||
|
})],
|
||||||
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -134,10 +139,13 @@ pub(crate) fn broken_dynamic_block<'b, 'g, 'r, 's>(
|
|||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
remaining,
|
remaining,
|
||||||
Paragraph::of_text(
|
Paragraph {
|
||||||
input.get_until(remaining).into(),
|
source: input.get_until(remaining).into(),
|
||||||
input.get_until(lead_in_remaining).into(),
|
affiliated_keywords: AffiliatedKeywords::default(),
|
||||||
),
|
children: vec![Object::PlainText(PlainText {
|
||||||
|
source: input.get_until(lead_in_remaining).into(),
|
||||||
|
})],
|
||||||
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,7 @@ mod tests {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
first_paragraph
|
first_paragraph
|
||||||
.children
|
.children
|
||||||
.first()
|
.get(0)
|
||||||
.expect("Len already asserted to be 1"),
|
.expect("Len already asserted to be 1"),
|
||||||
&Object::Citation(Citation {
|
&Object::Citation(Citation {
|
||||||
source: "[cite:@foo]",
|
source: "[cite:@foo]",
|
||||||
|
@ -31,6 +31,7 @@ use crate::types::Drawer;
|
|||||||
use crate::types::Element;
|
use crate::types::Element;
|
||||||
use crate::types::Keyword;
|
use crate::types::Keyword;
|
||||||
use crate::types::Paragraph;
|
use crate::types::Paragraph;
|
||||||
|
use crate::types::SetSource;
|
||||||
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
@ -80,8 +81,9 @@ where
|
|||||||
))(remaining)
|
))(remaining)
|
||||||
{
|
{
|
||||||
Ok((remain, (_not_immediate_exit, first_line, (_trailing_whitespace, _exit_contents)))) => {
|
Ok((remain, (_not_immediate_exit, first_line, (_trailing_whitespace, _exit_contents)))) => {
|
||||||
|
let mut element = Element::Paragraph(Paragraph::of_text(first_line.into()));
|
||||||
let source = get_consumed(remaining, remain);
|
let source = get_consumed(remaining, remain);
|
||||||
let element = Element::Paragraph(Paragraph::of_text(source.into(), first_line.into()));
|
element.set_source(source.into());
|
||||||
(remain, vec![element])
|
(remain, vec![element])
|
||||||
}
|
}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
|
@ -37,6 +37,7 @@ use crate::types::DynamicBlock;
|
|||||||
use crate::types::Element;
|
use crate::types::Element;
|
||||||
use crate::types::Keyword;
|
use crate::types::Keyword;
|
||||||
use crate::types::Paragraph;
|
use crate::types::Paragraph;
|
||||||
|
use crate::types::SetSource;
|
||||||
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "tracing",
|
feature = "tracing",
|
||||||
@ -87,7 +88,9 @@ where
|
|||||||
))))(remaining)?;
|
))))(remaining)?;
|
||||||
let leading_blank_lines =
|
let leading_blank_lines =
|
||||||
leading_blank_lines.map(|(source, (first_line, _remaining_lines))| {
|
leading_blank_lines.map(|(source, (first_line, _remaining_lines))| {
|
||||||
Element::Paragraph(Paragraph::of_text(source.into(), first_line.into()))
|
let mut element = Element::Paragraph(Paragraph::of_text(first_line.into()));
|
||||||
|
element.set_source(source.into());
|
||||||
|
element
|
||||||
});
|
});
|
||||||
let (remaining, (mut children, _exit_contents)) =
|
let (remaining, (mut children, _exit_contents)) =
|
||||||
many_till(element_matcher, exit_matcher)(remaining)?;
|
many_till(element_matcher, exit_matcher)(remaining)?;
|
||||||
|
@ -39,6 +39,7 @@ use crate::types::Element;
|
|||||||
use crate::types::Keyword;
|
use crate::types::Keyword;
|
||||||
use crate::types::Paragraph;
|
use crate::types::Paragraph;
|
||||||
use crate::types::QuoteBlock;
|
use crate::types::QuoteBlock;
|
||||||
|
use crate::types::SetSource;
|
||||||
use crate::types::SpecialBlock;
|
use crate::types::SpecialBlock;
|
||||||
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
@ -256,7 +257,9 @@ fn greater_block_body<'c, 'b, 'g, 'r, 's>(
|
|||||||
))))(remaining)?;
|
))))(remaining)?;
|
||||||
let leading_blank_lines =
|
let leading_blank_lines =
|
||||||
leading_blank_lines.map(|(source, (first_line, _remaining_lines))| {
|
leading_blank_lines.map(|(source, (first_line, _remaining_lines))| {
|
||||||
Element::Paragraph(Paragraph::of_text(source.into(), first_line.into()))
|
let mut element = Element::Paragraph(Paragraph::of_text(first_line.into()));
|
||||||
|
element.set_source(source.into());
|
||||||
|
element
|
||||||
});
|
});
|
||||||
let (remaining, (mut children, _exit_contents)) =
|
let (remaining, (mut children, _exit_contents)) =
|
||||||
many_till(element_matcher, exit_matcher)(remaining)?;
|
many_till(element_matcher, exit_matcher)(remaining)?;
|
||||||
|
@ -22,6 +22,7 @@ use super::CenterBlock;
|
|||||||
use super::Drawer;
|
use super::Drawer;
|
||||||
use super::GetStandardProperties;
|
use super::GetStandardProperties;
|
||||||
use super::QuoteBlock;
|
use super::QuoteBlock;
|
||||||
|
use super::SetSource;
|
||||||
use super::SpecialBlock;
|
use super::SpecialBlock;
|
||||||
use super::StandardProperties;
|
use super::StandardProperties;
|
||||||
|
|
||||||
@ -54,6 +55,38 @@ pub enum Element<'s> {
|
|||||||
LatexEnvironment(LatexEnvironment<'s>),
|
LatexEnvironment(LatexEnvironment<'s>),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'s> SetSource<'s> for Element<'s> {
|
||||||
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
|
fn set_source(&mut self, source: &'s str) {
|
||||||
|
match self {
|
||||||
|
Element::Paragraph(obj) => obj.source = source,
|
||||||
|
Element::PlainList(obj) => obj.source = source,
|
||||||
|
Element::CenterBlock(obj) => obj.source = source,
|
||||||
|
Element::QuoteBlock(obj) => obj.source = source,
|
||||||
|
Element::SpecialBlock(obj) => obj.source = source,
|
||||||
|
Element::DynamicBlock(obj) => obj.source = source,
|
||||||
|
Element::FootnoteDefinition(obj) => obj.source = source,
|
||||||
|
Element::Comment(obj) => obj.source = source,
|
||||||
|
Element::Drawer(obj) => obj.source = source,
|
||||||
|
Element::PropertyDrawer(obj) => obj.source = source,
|
||||||
|
Element::Table(obj) => obj.source = source,
|
||||||
|
Element::VerseBlock(obj) => obj.source = source,
|
||||||
|
Element::CommentBlock(obj) => obj.source = source,
|
||||||
|
Element::ExampleBlock(obj) => obj.source = source,
|
||||||
|
Element::ExportBlock(obj) => obj.source = source,
|
||||||
|
Element::SrcBlock(obj) => obj.source = source,
|
||||||
|
Element::Clock(obj) => obj.source = source,
|
||||||
|
Element::DiarySexp(obj) => obj.source = source,
|
||||||
|
Element::Planning(obj) => obj.source = source,
|
||||||
|
Element::FixedWidthArea(obj) => obj.source = source,
|
||||||
|
Element::HorizontalRule(obj) => obj.source = source,
|
||||||
|
Element::Keyword(obj) => obj.source = source,
|
||||||
|
Element::BabelCall(obj) => obj.source = source,
|
||||||
|
Element::LatexEnvironment(obj) => obj.source = source,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'s> GetStandardProperties<'s> for Element<'s> {
|
impl<'s> GetStandardProperties<'s> for Element<'s> {
|
||||||
fn get_standard_properties<'b>(&'b self) -> &'b dyn StandardProperties<'s> {
|
fn get_standard_properties<'b>(&'b self) -> &'b dyn StandardProperties<'s> {
|
||||||
match self {
|
match self {
|
||||||
|
@ -169,11 +169,11 @@ impl<'s> Paragraph<'s> {
|
|||||||
/// Generate a paragraph of the passed in text with no additional properties.
|
/// Generate a paragraph of the passed in text with no additional properties.
|
||||||
///
|
///
|
||||||
/// This is used for elements that support an "empty" content like greater blocks.
|
/// This is used for elements that support an "empty" content like greater blocks.
|
||||||
pub(crate) fn of_text(source: &'s str, body: &'s str) -> Self {
|
pub(crate) fn of_text(input: &'s str) -> Self {
|
||||||
Paragraph {
|
Paragraph {
|
||||||
source,
|
source: input,
|
||||||
affiliated_keywords: AffiliatedKeywords::default(),
|
affiliated_keywords: AffiliatedKeywords::default(),
|
||||||
children: vec![Object::PlainText(PlainText { source: body })],
|
children: vec![Object::PlainText(PlainText { source: input })],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ mod greater_element;
|
|||||||
mod lesser_element;
|
mod lesser_element;
|
||||||
mod macros;
|
mod macros;
|
||||||
mod object;
|
mod object;
|
||||||
|
mod source;
|
||||||
mod standard_properties;
|
mod standard_properties;
|
||||||
mod util;
|
mod util;
|
||||||
pub use affiliated_keyword::AffiliatedKeyword;
|
pub use affiliated_keyword::AffiliatedKeyword;
|
||||||
@ -112,4 +113,5 @@ pub use object::WarningDelay;
|
|||||||
pub use object::WarningDelayType;
|
pub use object::WarningDelayType;
|
||||||
pub use object::Year;
|
pub use object::Year;
|
||||||
pub use object::YearInner;
|
pub use object::YearInner;
|
||||||
|
pub(crate) use source::SetSource;
|
||||||
pub use standard_properties::StandardProperties;
|
pub use standard_properties::StandardProperties;
|
||||||
|
3
src/types/source.rs
Normal file
3
src/types/source.rs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
pub(crate) trait SetSource<'s> {
|
||||||
|
fn set_source(&mut self, source: &'s str);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user