Trim the trailing space off keywords with values.
This commit is contained in:
parent
1c142b68c6
commit
b0392ad6fb
@ -14,8 +14,11 @@ use organic::emacs_parse_file_org_document;
|
|||||||
use organic::get_emacs_version;
|
use organic::get_emacs_version;
|
||||||
#[cfg(feature = "compare")]
|
#[cfg(feature = "compare")]
|
||||||
use organic::get_org_mode_version;
|
use organic::get_org_mode_version;
|
||||||
|
use organic::parser::parse_with_settings;
|
||||||
#[cfg(feature = "compare")]
|
#[cfg(feature = "compare")]
|
||||||
use organic::parser::sexp::sexp_with_padding;
|
use organic::parser::sexp::sexp_with_padding;
|
||||||
|
use organic::GlobalSettings;
|
||||||
|
use organic::LocalFileAccessInterface;
|
||||||
|
|
||||||
#[cfg(feature = "tracing")]
|
#[cfg(feature = "tracing")]
|
||||||
use crate::init_tracing::init_telemetry;
|
use crate::init_tracing::init_telemetry;
|
||||||
@ -136,10 +139,6 @@ fn run_parse_on_file<P: AsRef<Path>>(org_path: P) -> Result<(), Box<dyn std::err
|
|||||||
|
|
||||||
#[cfg(not(feature = "compare"))]
|
#[cfg(not(feature = "compare"))]
|
||||||
fn run_parse_on_file<P: AsRef<Path>>(org_path: P) -> Result<(), Box<dyn std::error::Error>> {
|
fn run_parse_on_file<P: AsRef<Path>>(org_path: P) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
use organic::parser::parse_with_settings;
|
|
||||||
use organic::GlobalSettings;
|
|
||||||
use organic::LocalFileAccessInterface;
|
|
||||||
|
|
||||||
let org_path = org_path.as_ref();
|
let org_path = org_path.as_ref();
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"This program was built with compare disabled. Only parsing with organic, not comparing."
|
"This program was built with compare disabled. Only parsing with organic, not comparing."
|
||||||
|
@ -54,7 +54,6 @@ use crate::types::Section;
|
|||||||
/// Parse a full org-mode document.
|
/// Parse a full org-mode document.
|
||||||
///
|
///
|
||||||
/// This is the main entry point for Organic. It will parse the full contents of the input string as an org-mode document.
|
/// This is the main entry point for Organic. It will parse the full contents of the input string as an org-mode document.
|
||||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn parse<'s>(input: &'s str) -> Result<Document<'s>, String> {
|
pub fn parse<'s>(input: &'s str) -> Result<Document<'s>, String> {
|
||||||
parse_with_settings(input, &GlobalSettings::default())
|
parse_with_settings(input, &GlobalSettings::default())
|
||||||
@ -65,7 +64,6 @@ pub fn parse<'s>(input: &'s str) -> Result<Document<'s>, String> {
|
|||||||
/// This is the secondary entry point for Organic. It will parse the full contents of the input string as an org-mode document starting with the settings you supplied.
|
/// This is the secondary entry point for Organic. It will parse the full contents of the input string as an org-mode document starting with the settings you supplied.
|
||||||
///
|
///
|
||||||
/// This will not prevent additional settings from being learned during parsing, for example when encountering a "#+TODO".
|
/// This will not prevent additional settings from being learned during parsing, for example when encountering a "#+TODO".
|
||||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn parse_with_settings<'g, 's>(
|
pub fn parse_with_settings<'g, 's>(
|
||||||
input: &'s str,
|
input: &'s str,
|
||||||
@ -86,7 +84,6 @@ pub fn parse_with_settings<'g, 's>(
|
|||||||
/// Use this entry point when you want to have direct control over the starting context or if you want to use this integrated with other nom parsers. For general-purpose usage, the `parse` and `parse_with_settings` functions are a lot simpler.
|
/// Use this entry point when you want to have direct control over the starting context or if you want to use this integrated with other nom parsers. For general-purpose usage, the `parse` and `parse_with_settings` functions are a lot simpler.
|
||||||
///
|
///
|
||||||
/// This will not prevent additional settings from being learned during parsing, for example when encountering a "#+TODO".
|
/// This will not prevent additional settings from being learned during parsing, for example when encountering a "#+TODO".
|
||||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
pub fn document<'b, 'g, 'r, 's>(
|
pub fn document<'b, 'g, 'r, 's>(
|
||||||
context: RefContext<'b, 'g, 'r, 's>,
|
context: RefContext<'b, 'g, 'r, 's>,
|
||||||
|
@ -10,6 +10,7 @@ use super::OrgSource;
|
|||||||
use crate::error::Res;
|
use crate::error::Res;
|
||||||
use crate::types::Keyword;
|
use crate::types::Keyword;
|
||||||
|
|
||||||
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
pub fn scan_for_in_buffer_settings<'s>(
|
pub fn scan_for_in_buffer_settings<'s>(
|
||||||
input: OrgSource<'s>,
|
input: OrgSource<'s>,
|
||||||
) -> Res<OrgSource<'s>, Vec<Keyword<'s>>> {
|
) -> Res<OrgSource<'s>, Vec<Keyword<'s>>> {
|
||||||
|
@ -49,7 +49,11 @@ fn _filtered_keyword<'s, F: Matcher>(
|
|||||||
// TODO: When key is a member of org-element-parsed-keywords, value can contain the standard set objects, excluding footnote references.
|
// TODO: When key is a member of org-element-parsed-keywords, value can contain the standard set objects, excluding footnote references.
|
||||||
let (remaining, (consumed_input, (_, _, parsed_key, _))) =
|
let (remaining, (consumed_input, (_, _, parsed_key, _))) =
|
||||||
consumed(tuple((space0, tag("#+"), key_parser, tag(":"))))(input)?;
|
consumed(tuple((space0, tag("#+"), key_parser, tag(":"))))(input)?;
|
||||||
match tuple((space0, alt((line_ending, eof))))(remaining) {
|
match tuple((
|
||||||
|
space0::<OrgSource<'_>, CustomError<OrgSource<'_>>>,
|
||||||
|
alt((line_ending, eof)),
|
||||||
|
))(remaining)
|
||||||
|
{
|
||||||
Ok((remaining, _)) => {
|
Ok((remaining, _)) => {
|
||||||
return Ok((
|
return Ok((
|
||||||
remaining,
|
remaining,
|
||||||
@ -60,10 +64,13 @@ fn _filtered_keyword<'s, F: Matcher>(
|
|||||||
},
|
},
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
err @ Err(_) => err?,
|
Err(_) => {}
|
||||||
};
|
};
|
||||||
let (remaining, _ws) = space1(remaining)?;
|
let (remaining, _ws) = space1(remaining)?;
|
||||||
let (remaining, parsed_value) = is_not("\r\n")(remaining)?;
|
let (remaining, parsed_value) = recognize(many_till(
|
||||||
|
anychar,
|
||||||
|
peek(tuple((space0, alt((line_ending, eof))))),
|
||||||
|
))(remaining)?;
|
||||||
let (remaining, _ws) = tuple((space0, alt((line_ending, eof))))(remaining)?;
|
let (remaining, _ws) = tuple((space0, alt((line_ending, eof))))(remaining)?;
|
||||||
Ok((
|
Ok((
|
||||||
remaining,
|
remaining,
|
||||||
|
Loading…
Reference in New Issue
Block a user