diff --git a/docker/organic_test/Dockerfile b/docker/organic_test/Dockerfile index c2bef18..0100233 100644 --- a/docker/organic_test/Dockerfile +++ b/docker/organic_test/Dockerfile @@ -88,7 +88,7 @@ ARG DOOMEMACS_PATH=/foreign_documents/doomemacs ARG DOOMEMACS_REPO=https://github.com/doomemacs/doomemacs.git RUN mkdir -p $DOOMEMACS_PATH && git -C $DOOMEMACS_PATH init --initial-branch=main && git -C $DOOMEMACS_PATH remote add origin $DOOMEMACS_REPO && git -C $DOOMEMACS_PATH fetch origin $DOOMEMACS_VERSION && git -C $DOOMEMACS_PATH checkout FETCH_HEAD -ARG WORG_VERSION=74e80b0f7600801b1d1594542602394c085cc2f9 +ARG WORG_VERSION=0c8d5679b536af450b61812246a3e02b8103f4b8 ARG WORG_PATH=/foreign_documents/worg ARG WORG_REPO=https://git.sr.ht/~bzg/worg RUN mkdir -p $WORG_PATH && git -C $WORG_PATH init --initial-branch=main && git -C $WORG_PATH remote add origin $WORG_REPO && git -C $WORG_PATH fetch origin $WORG_VERSION && git -C $WORG_PATH checkout FETCH_HEAD diff --git a/org_mode_samples/lesser_element/fixed_width_area/tab_instead_of_space.org b/org_mode_samples/lesser_element/fixed_width_area/tab_instead_of_space.org new file mode 100644 index 0000000..eac5785 --- /dev/null +++ b/org_mode_samples/lesser_element/fixed_width_area/tab_instead_of_space.org @@ -0,0 +1,2 @@ +# Fixed width areas must begin with colon followed by a space, not a tab, so this is not a fixed width area. +: foo diff --git a/src/parser/fixed_width_area.rs b/src/parser/fixed_width_area.rs index 57a799c..f501591 100644 --- a/src/parser/fixed_width_area.rs +++ b/src/parser/fixed_width_area.rs @@ -3,7 +3,6 @@ use nom::bytes::complete::is_not; use nom::bytes::complete::tag; use nom::character::complete::line_ending; use nom::character::complete::space0; -use nom::character::complete::space1; use nom::combinator::eof; use nom::combinator::not; use nom::combinator::recognize; @@ -12,6 +11,7 @@ use nom::sequence::preceded; use nom::sequence::tuple; use super::org_source::OrgSource; +use super::util::only_space1; use super::util::org_line_ending; use crate::context::parser_with_context; use crate::context::RefContext; @@ -50,7 +50,7 @@ fn fixed_width_area_line<'b, 'g, 'r, 's>( let (remaining, _indent) = space0(input)?; let (remaining, _) = tuple(( tag(":"), - alt((recognize(tuple((space1, is_not("\r\n")))), space0)), + alt((recognize(tuple((only_space1, is_not("\r\n")))), space0)), org_line_ending, ))(remaining)?; let source = get_consumed(input, remaining); diff --git a/src/parser/util.rs b/src/parser/util.rs index 5faef14..7c5d733 100644 --- a/src/parser/util.rs +++ b/src/parser/util.rs @@ -1,4 +1,5 @@ use nom::branch::alt; +use nom::bytes::complete::is_a; use nom::character::complete::anychar; use nom::character::complete::line_ending; use nom::character::complete::none_of; @@ -228,9 +229,16 @@ where } } +/// Match at least one space character. +/// +/// This is similar to nom's space1 parser except space1 matches both spaces and tabs whereas this only matches spaces. +pub(crate) fn only_space1<'s>(input: OrgSource<'s>) -> Res, OrgSource<'s>> { + is_a(" ")(input) +} + /// Match single space or tab. /// -/// In org-mode syntax, spaces and tabs are interchangeable. +/// In org-mode syntax, spaces and tabs are often (but not always!) interchangeable. pub(crate) fn org_space<'s>(input: OrgSource<'s>) -> Res, char> { one_of(" \t")(input) }