Put back in needed pubs.

This commit is contained in:
Tom Alexander 2023-09-11 13:13:28 -04:00
parent 7650a9edff
commit 84953c1669
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
71 changed files with 522 additions and 515 deletions

View File

@ -69,13 +69,13 @@ use crate::types::Verbatim;
use crate::types::VerseBlock; use crate::types::VerseBlock;
#[derive(Debug)] #[derive(Debug)]
enum DiffEntry<'s> { pub enum DiffEntry<'s> {
DiffResult(DiffResult<'s>), DiffResult(DiffResult<'s>),
DiffLayer(DiffLayer<'s>), DiffLayer(DiffLayer<'s>),
} }
#[derive(Debug)] #[derive(Debug)]
struct DiffResult<'s> { pub struct DiffResult<'s> {
status: DiffStatus, status: DiffStatus,
name: String, name: String,
message: Option<String>, message: Option<String>,
@ -86,13 +86,13 @@ use crate::types::VerseBlock;
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
enum DiffStatus { enum DiffStatus {
Good, Good,
Bad, Bad,
} }
#[derive(Debug)] #[derive(Debug)]
struct DiffLayer<'s> { pub struct DiffLayer<'s> {
name: String, name: String,
children: Vec<DiffEntry<'s>>, children: Vec<DiffEntry<'s>>,
} }
@ -126,11 +126,11 @@ impl<'s> DiffEntry<'s> {
} }
} }
fn is_bad(&self) -> bool { pub fn is_bad(&self) -> bool {
self.is_immediately_bad() || self.has_bad_children() self.is_immediately_bad() || self.has_bad_children()
} }
fn print(&self, original_document: &str) -> Result<(), Box<dyn std::error::Error>> { pub fn print(&self, original_document: &str) -> Result<(), Box<dyn std::error::Error>> {
self.print_indented(0, original_document) self.print_indented(0, original_document)
} }
@ -374,7 +374,7 @@ fn compare_object<'s>(
} }
} }
fn compare_document<'s>( pub fn compare_document<'s>(
emacs: &'s Token<'s>, emacs: &'s Token<'s>,
rust: &'s Document<'s>, rust: &'s Document<'s>,
) -> Result<DiffEntry<'s>, Box<dyn std::error::Error>> { ) -> Result<DiffEntry<'s>, Box<dyn std::error::Error>> {

View File

@ -1,8 +1,8 @@
mod diff; mod diff;
mod parse; mod parse;
mod util; mod util;
use diff::compare_document; pub use diff::compare_document;
use parse::emacs_parse_anonymous_org_document; pub use parse::emacs_parse_anonymous_org_document;
use parse::emacs_parse_file_org_document; pub use parse::emacs_parse_file_org_document;
use parse::get_emacs_version; pub use parse::get_emacs_version;
use parse::get_org_mode_version; pub use parse::get_org_mode_version;

View File

@ -1,7 +1,7 @@
use std::path::Path; use std::path::Path;
use std::process::Command; use std::process::Command;
fn emacs_parse_anonymous_org_document<C>( pub fn emacs_parse_anonymous_org_document<C>(
file_contents: C, file_contents: C,
) -> Result<String, Box<dyn std::error::Error>> ) -> Result<String, Box<dyn std::error::Error>>
where where
@ -31,7 +31,7 @@ where
Ok(String::from_utf8(org_sexp)?) Ok(String::from_utf8(org_sexp)?)
} }
fn emacs_parse_file_org_document<P>(file_path: P) -> Result<String, Box<dyn std::error::Error>> pub fn emacs_parse_file_org_document<P>(file_path: P) -> Result<String, Box<dyn std::error::Error>>
where where
P: AsRef<Path>, P: AsRef<Path>,
{ {
@ -85,7 +85,7 @@ where
output output
} }
fn get_emacs_version() -> Result<String, Box<dyn std::error::Error>> { pub fn get_emacs_version() -> Result<String, Box<dyn std::error::Error>> {
let elisp_script = r#"(progn let elisp_script = r#"(progn
(message "%s" (version)) (message "%s" (version))
)"#; )"#;
@ -103,7 +103,7 @@ where
Ok(String::from_utf8(out.stderr)?) Ok(String::from_utf8(out.stderr)?)
} }
fn get_org_mode_version() -> Result<String, Box<dyn std::error::Error>> { pub fn get_org_mode_version() -> Result<String, Box<dyn std::error::Error>> {
let elisp_script = r#"(progn let elisp_script = r#"(progn
(org-mode) (org-mode)
(message "%s" (org-version nil t nil)) (message "%s" (org-version nil t nil))

View File

@ -21,7 +21,10 @@ fn get_offsets<'s, S: Source<'s>>(source: &'s str, rust_object: &'s S) -> (usize
(offset, end) (offset, end)
} }
fn assert_name<'s>(emacs: &'s Token<'s>, name: &str) -> Result<(), Box<dyn std::error::Error>> { pub(crate) fn assert_name<'s>(
emacs: &'s Token<'s>,
name: &str,
) -> Result<(), Box<dyn std::error::Error>> {
let children = emacs.as_list()?; let children = emacs.as_list()?;
let first_child = children let first_child = children
.first() .first()
@ -37,7 +40,7 @@ fn get_offsets<'s, S: Source<'s>>(source: &'s str, rust_object: &'s S) -> (usize
Ok(()) Ok(())
} }
fn assert_bounds<'s, S: Source<'s>>( pub(crate) fn assert_bounds<'s, S: Source<'s>>(
source: &'s str, source: &'s str,
emacs: &'s Token<'s>, emacs: &'s Token<'s>,
rust: &'s S, rust: &'s S,
@ -146,7 +149,7 @@ fn maybe_token_to_usize(
/// Returns Ok(None) if value is nil. /// Returns Ok(None) if value is nil.
/// ///
/// Returns error if the attribute is not specified on the token at all. /// Returns error if the attribute is not specified on the token at all.
fn get_property<'s, 'x>( pub(crate) fn get_property<'s, 'x>(
emacs: &'s Token<'s>, emacs: &'s Token<'s>,
key: &'x str, key: &'x str,
) -> Result<Option<&'s Token<'s>>, Box<dyn std::error::Error>> { ) -> Result<Option<&'s Token<'s>>, Box<dyn std::error::Error>> {

View File

@ -14,7 +14,7 @@ use crate::error::Res;
use crate::parser::OrgSource; use crate::parser::OrgSource;
#[derive(Debug)] #[derive(Debug)]
enum ContextElement<'r, 's> { pub(crate) enum ContextElement<'r, 's> {
/// Stores a parser that indicates that children should exit upon matching an exit matcher. /// Stores a parser that indicates that children should exit upon matching an exit matcher.
ExitMatcherNode(ExitMatcherNode<'r>), ExitMatcherNode(ExitMatcherNode<'r>),
@ -31,10 +31,10 @@ use crate::parser::OrgSource;
Placeholder(PhantomData<&'s str>), Placeholder(PhantomData<&'s str>),
} }
struct ExitMatcherNode<'r> { pub(crate) struct ExitMatcherNode<'r> {
// TODO: Should this be "&'r DynContextMatcher<'c>" ? // TODO: Should this be "&'r DynContextMatcher<'c>" ?
exit_matcher: &'r DynContextMatcher<'r>, pub(crate) exit_matcher: &'r DynContextMatcher<'r>,
class: ExitClass, pub(crate) class: ExitClass,
} }
impl<'r> std::fmt::Debug for ExitMatcherNode<'r> { impl<'r> std::fmt::Debug for ExitMatcherNode<'r> {
@ -46,13 +46,13 @@ impl<'r> std::fmt::Debug for ExitMatcherNode<'r> {
} }
#[derive(Debug)] #[derive(Debug)]
struct Context<'g, 'r, 's> { pub(crate) struct Context<'g, 'r, 's> {
global_settings: &'g GlobalSettings<'g, 's>, global_settings: &'g GlobalSettings<'g, 's>,
tree: List<'r, &'r ContextElement<'r, 's>>, tree: List<'r, &'r ContextElement<'r, 's>>,
} }
impl<'g, 'r, 's> Context<'g, 'r, 's> { impl<'g, 'r, 's> Context<'g, 'r, 's> {
fn new( pub(crate) fn new(
global_settings: &'g GlobalSettings<'g, 's>, global_settings: &'g GlobalSettings<'g, 's>,
tree: List<'r, &'r ContextElement<'r, 's>>, tree: List<'r, &'r ContextElement<'r, 's>>,
) -> Self { ) -> Self {
@ -62,12 +62,12 @@ impl<'g, 'r, 's> Context<'g, 'r, 's> {
} }
} }
fn with_additional_node(&'r self, new_element: &'r ContextElement<'r, 's>) -> Self { pub(crate) fn with_additional_node(&'r self, new_element: &'r ContextElement<'r, 's>) -> Self {
let new_tree = self.tree.push(new_element); let new_tree = self.tree.push(new_element);
Self::new(self.global_settings, new_tree) Self::new(self.global_settings, new_tree)
} }
fn iter(&'r self) -> super::list::Iter<'r, &'r ContextElement<'r, 's>> { pub(crate) fn iter(&'r self) -> super::list::Iter<'r, &'r ContextElement<'r, 's>> {
self.tree.iter() self.tree.iter()
} }
@ -78,7 +78,7 @@ impl<'g, 'r, 's> Context<'g, 'r, 's> {
} }
} }
fn get_parent(&'r self) -> Option<Self> { pub(crate) fn get_parent(&'r self) -> Option<Self> {
self.tree.get_parent().map(|parent_tree| Self { self.tree.get_parent().map(|parent_tree| Self {
global_settings: self.global_settings, global_settings: self.global_settings,
tree: parent_tree.clone(), tree: parent_tree.clone(),
@ -89,11 +89,11 @@ impl<'g, 'r, 's> Context<'g, 'r, 's> {
self.tree.get_data() self.tree.get_data()
} }
fn get_global_settings(&self) -> &'g GlobalSettings<'g, 's> { pub(crate) fn get_global_settings(&self) -> &'g GlobalSettings<'g, 's> {
self.global_settings self.global_settings
} }
fn with_global_settings<'gg>( pub(crate) fn with_global_settings<'gg>(
&self, &self,
new_settings: &'gg GlobalSettings<'gg, 's>, new_settings: &'gg GlobalSettings<'gg, 's>,
) -> Context<'gg, 'r, 's> { ) -> Context<'gg, 'r, 's> {
@ -104,7 +104,7 @@ impl<'g, 'r, 's> Context<'g, 'r, 's> {
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn check_exit_matcher( pub(crate) fn check_exit_matcher(
&'r self, &'r self,
i: OrgSource<'s>, i: OrgSource<'s>,
) -> IResult<OrgSource<'s>, OrgSource<'s>, CustomError<OrgSource<'s>>> { ) -> IResult<OrgSource<'s>, OrgSource<'s>, CustomError<OrgSource<'s>>> {
@ -133,7 +133,7 @@ impl<'g, 'r, 's> Context<'g, 'r, 's> {
/// Indicates if elements should consume the whitespace after them. /// Indicates if elements should consume the whitespace after them.
/// ///
/// Defaults to true. /// Defaults to true.
fn should_consume_trailing_whitespace(&self) -> bool { pub(crate) fn should_consume_trailing_whitespace(&self) -> bool {
self._should_consume_trailing_whitespace().unwrap_or(true) self._should_consume_trailing_whitespace().unwrap_or(true)
} }
@ -158,7 +158,7 @@ fn document_end<'b, 'g, 'r, 's>(
eof(input) eof(input)
} }
struct Iter<'g, 'r, 's> { struct Iter<'g, 'r, 's> {
global_settings: &'g GlobalSettings<'g, 's>, global_settings: &'g GlobalSettings<'g, 's>,
next: super::list::IterList<'r, &'r ContextElement<'r, 's>>, next: super::list::IterList<'r, &'r ContextElement<'r, 's>>,
} }
@ -175,7 +175,7 @@ impl<'g, 'r, 's> Iterator for Iter<'g, 'r, 's> {
} }
impl<'r, 's> ContextElement<'r, 's> { impl<'r, 's> ContextElement<'r, 's> {
fn document_context() -> Self { pub(crate) fn document_context() -> Self {
Self::ExitMatcherNode(ExitMatcherNode { Self::ExitMatcherNode(ExitMatcherNode {
exit_matcher: &document_end, exit_matcher: &document_end,
class: ExitClass::Document, class: ExitClass::Document,

View File

@ -1,5 +1,5 @@
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
enum ExitClass { pub(crate) enum ExitClass {
Document = 1, Document = 1,
Alpha = 2, Alpha = 2,
Beta = 3, Beta = 3,

View File

@ -1,13 +1,13 @@
use std::fmt::Debug; use std::fmt::Debug;
use std::path::PathBuf; use std::path::PathBuf;
trait FileAccessInterface: Debug { pub trait FileAccessInterface: Debug {
fn read_file(&self, path: &str) -> Result<String, std::io::Error>; fn read_file(&self, path: &str) -> Result<String, std::io::Error>;
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
struct LocalFileAccessInterface { pub struct LocalFileAccessInterface {
working_directory: Option<PathBuf>, pub working_directory: Option<PathBuf>,
} }
impl FileAccessInterface for LocalFileAccessInterface { impl FileAccessInterface for LocalFileAccessInterface {

View File

@ -7,11 +7,11 @@ use crate::types::Object;
// TODO: Ultimately, I think we'll need most of this: https://orgmode.org/manual/In_002dbuffer-Settings.html // TODO: Ultimately, I think we'll need most of this: https://orgmode.org/manual/In_002dbuffer-Settings.html
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
struct GlobalSettings<'g, 's> { pub struct GlobalSettings<'g, 's> {
radio_targets: Vec<&'g Vec<Object<'s>>>, pub radio_targets: Vec<&'g Vec<Object<'s>>>,
file_access: &'g dyn FileAccessInterface, pub file_access: &'g dyn FileAccessInterface,
in_progress_todo_keywords: BTreeSet<String>, pub in_progress_todo_keywords: BTreeSet<String>,
complete_todo_keywords: BTreeSet<String>, pub complete_todo_keywords: BTreeSet<String>,
} }
impl<'g, 's> GlobalSettings<'g, 's> { impl<'g, 's> GlobalSettings<'g, 's> {

View File

@ -1,7 +1,7 @@
use std::fmt::Debug; use std::fmt::Debug;
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
struct List<'parent, T> { pub(crate) struct List<'parent, T> {
data: T, data: T,
parent: Link<'parent, T>, parent: Link<'parent, T>,
} }
@ -9,30 +9,30 @@ use std::fmt::Debug;
type Link<'parent, T> = Option<&'parent List<'parent, T>>; type Link<'parent, T> = Option<&'parent List<'parent, T>>;
impl<'parent, T> List<'parent, T> { impl<'parent, T> List<'parent, T> {
fn new(first_item: T) -> Self { pub(crate) fn new(first_item: T) -> Self {
Self { Self {
data: first_item, data: first_item,
parent: None, parent: None,
} }
} }
fn get_data(&self) -> &T { pub(crate) fn get_data(&self) -> &T {
&self.data &self.data
} }
fn get_parent(&'parent self) -> Link<'parent, T> { pub(crate) fn get_parent(&'parent self) -> Link<'parent, T> {
self.parent self.parent
} }
fn iter(&self) -> Iter<'_, T> { pub(crate) fn iter(&self) -> Iter<'_, T> {
Iter { next: Some(self) } Iter { next: Some(self) }
} }
fn iter_list(&self) -> IterList<'_, T> { pub(crate) fn iter_list(&self) -> IterList<'_, T> {
IterList { next: Some(self) } IterList { next: Some(self) }
} }
fn push(&'parent self, item: T) -> Self { pub(crate) fn push(&'parent self, item: T) -> Self {
Self { Self {
data: item, data: item,
parent: Some(self), parent: Some(self),
@ -40,7 +40,7 @@ impl<'parent, T> List<'parent, T> {
} }
} }
struct Iter<'a, T> { pub(crate) struct Iter<'a, T> {
next: Link<'a, T>, next: Link<'a, T>,
} }
@ -54,7 +54,7 @@ impl<'a, T> Iterator for Iter<'a, T> {
} }
} }
struct IterList<'a, T> { pub(crate) struct IterList<'a, T> {
next: Link<'a, T>, next: Link<'a, T>,
} }

View File

@ -8,22 +8,22 @@ mod global_settings;
mod list; mod list;
mod parser_with_context; mod parser_with_context;
type RefContext<'b, 'g, 'r, 's> = &'b Context<'g, 'r, 's>; pub(crate) type RefContext<'b, 'g, 'r, 's> = &'b Context<'g, 'r, 's>;
trait ContextMatcher = for<'b, 'g, 'r, 's> Fn( pub(crate) trait ContextMatcher = for<'b, 'g, 'r, 's> Fn(
RefContext<'b, 'g, 'r, 's>, RefContext<'b, 'g, 'r, 's>,
OrgSource<'s>, OrgSource<'s>,
) -> Res<OrgSource<'s>, OrgSource<'s>>; ) -> Res<OrgSource<'s>, OrgSource<'s>>;
type DynContextMatcher<'c> = dyn ContextMatcher + 'c; type DynContextMatcher<'c> = dyn ContextMatcher + 'c;
trait Matcher = for<'s> Fn(OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>>; pub(crate) trait Matcher = for<'s> Fn(OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>>;
#[allow(dead_code)] #[allow(dead_code)]
type DynMatcher<'c> = dyn Matcher + 'c; type DynMatcher<'c> = dyn Matcher + 'c;
use context::Context; pub(crate) use context::Context;
use context::ContextElement; pub(crate) use context::ContextElement;
use context::ExitMatcherNode; pub(crate) use context::ExitMatcherNode;
use exiting::ExitClass; pub(crate) use exiting::ExitClass;
use file_access_interface::FileAccessInterface; pub use file_access_interface::FileAccessInterface;
use file_access_interface::LocalFileAccessInterface; pub use file_access_interface::LocalFileAccessInterface;
use global_settings::GlobalSettings; pub use global_settings::GlobalSettings;
use list::List; pub(crate) use list::List;
(crate) use parser_with_context::parser_with_context; pub(crate) use parser_with_context::parser_with_context;

View File

@ -3,4 +3,4 @@ macro_rules! parser_with_context {
move |context| move |i| $target(context, i) move |context| move |i| $target(context, i)
}; };
} }
(crate) use parser_with_context; pub(crate) use parser_with_context;

View File

@ -2,18 +2,18 @@ use nom::error::ErrorKind;
use nom::error::ParseError; use nom::error::ParseError;
use nom::IResult; use nom::IResult;
type Res<T, U> = IResult<T, U, CustomError<T>>; pub(crate) type Res<T, U> = IResult<T, U, CustomError<T>>;
// TODO: MyError probably shouldn't be based on the same type as the input type since it's used exclusively with static strings right now. // TODO: MyError probably shouldn't be based on the same type as the input type since it's used exclusively with static strings right now.
#[derive(Debug)] #[derive(Debug)]
enum CustomError<I> { pub enum CustomError<I> {
MyError(MyError<I>), MyError(MyError<I>),
Nom(I, ErrorKind), Nom(I, ErrorKind),
IO(std::io::Error), IO(std::io::Error),
} }
#[derive(Debug)] #[derive(Debug)]
struct MyError<I>( I); pub struct MyError<I>(pub(crate) I);
impl<I> ParseError<I> for CustomError<I> { impl<I> ParseError<I> for CustomError<I> {
fn from_error_kind(input: I, kind: ErrorKind) -> Self { fn from_error_kind(input: I, kind: ErrorKind) -> Self {

View File

@ -1,4 +1,4 @@
mod error; mod error;
use error::CustomError; pub(crate) use error::CustomError;
use error::MyError; pub(crate) use error::MyError;
use error::Res; pub(crate) use error::Res;

View File

@ -10,7 +10,7 @@ const SERVICE_NAME: &'static str = "organic";
// Despite the obvious verbosity that fully-qualifying everything causes, in these functions I am fully-qualifying everything relating to tracing. This is because the tracing feature involves multiple libraries working together and so I think it is beneficial to see which libraries contribute which bits. // Despite the obvious verbosity that fully-qualifying everything causes, in these functions I am fully-qualifying everything relating to tracing. This is because the tracing feature involves multiple libraries working together and so I think it is beneficial to see which libraries contribute which bits.
#[cfg(feature = "tracing")] #[cfg(feature = "tracing")]
fn init_telemetry() -> Result<(), Box<dyn std::error::Error>> { pub(crate) fn init_telemetry() -> Result<(), Box<dyn std::error::Error>> {
// by default it will hit http://localhost:4317 with a gRPC payload // by default it will hit http://localhost:4317 with a gRPC payload
// TODO: I think the endpoint can be controlled by the OTEL_EXPORTER_OTLP_TRACES_ENDPOINT env variable instead of hard-coded into this code base. Regardless, I am the only developer right now so I am not too concerned. // TODO: I think the endpoint can be controlled by the OTEL_EXPORTER_OTLP_TRACES_ENDPOINT env variable instead of hard-coded into this code base. Regardless, I am the only developer right now so I am not too concerned.
let exporter = opentelemetry_otlp::new_exporter() let exporter = opentelemetry_otlp::new_exporter()
@ -55,17 +55,17 @@ const SERVICE_NAME: &'static str = "organic";
} }
#[cfg(feature = "tracing")] #[cfg(feature = "tracing")]
fn shutdown_telemetry() -> Result<(), Box<dyn std::error::Error>> { pub(crate) fn shutdown_telemetry() -> Result<(), Box<dyn std::error::Error>> {
opentelemetry::global::shutdown_tracer_provider(); opentelemetry::global::shutdown_tracer_provider();
Ok(()) Ok(())
} }
#[cfg(not(feature = "tracing"))] #[cfg(not(feature = "tracing"))]
fn init_telemetry() -> Result<(), Box<dyn std::error::Error>> { pub(crate) fn init_telemetry() -> Result<(), Box<dyn std::error::Error>> {
Ok(()) Ok(())
} }
#[cfg(not(feature = "tracing"))] #[cfg(not(feature = "tracing"))]
fn shutdown_telemetry() -> Result<(), Box<dyn std::error::Error>> { pub(crate) fn shutdown_telemetry() -> Result<(), Box<dyn std::error::Error>> {
Ok(()) Ok(())
} }

View File

@ -6,20 +6,21 @@
#[cfg(feature = "compare")] #[cfg(feature = "compare")]
mod compare; mod compare;
#[cfg(feature = "compare")] #[cfg(feature = "compare")]
use compare::compare_document; pub use compare::compare_document;
#[cfg(feature = "compare")] #[cfg(feature = "compare")]
use compare::emacs_parse_anonymous_org_document; pub use compare::emacs_parse_anonymous_org_document;
#[cfg(feature = "compare")] #[cfg(feature = "compare")]
use compare::emacs_parse_file_org_document; pub use compare::emacs_parse_file_org_document;
#[cfg(feature = "compare")] #[cfg(feature = "compare")]
use compare::get_emacs_version; pub use compare::get_emacs_version;
#[cfg(feature = "compare")] #[cfg(feature = "compare")]
use compare::get_org_mode_version; pub use compare::get_org_mode_version;
mod context; mod context;
mod error; mod error;
mod parser; pub mod parser;
mod types; pub mod types;
use context::GlobalSettings; pub use context::FileAccessInterface;
use context::LocalFileAccessInterface; pub use context::GlobalSettings;
pub use context::LocalFileAccessInterface;

View File

@ -18,7 +18,7 @@ use crate::parser::util::get_consumed;
use crate::types::AngleLink; use crate::types::AngleLink;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn angle_link<'b, 'g, 'r, 's>( pub(crate) fn angle_link<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, AngleLink<'s>> { ) -> Res<OrgSource<'s>, AngleLink<'s>> {

View File

@ -31,7 +31,7 @@ use crate::types::Citation;
use crate::types::Object; use crate::types::Object;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn citation<'b, 'g, 'r, 's>( pub(crate) fn citation<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Citation<'s>> { ) -> Res<OrgSource<'s>, Citation<'s>> {

View File

@ -29,7 +29,7 @@ use crate::types::CitationReference;
use crate::types::Object; use crate::types::Object;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn citation_reference<'b, 'g, 'r, 's>( pub(crate) fn citation_reference<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, CitationReference<'s>> { ) -> Res<OrgSource<'s>, CitationReference<'s>> {
@ -49,7 +49,7 @@ use crate::types::Object;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn citation_reference_key<'b, 'g, 'r, 's>( pub(crate) fn citation_reference_key<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, OrgSource<'s>> { ) -> Res<OrgSource<'s>, OrgSource<'s>> {
@ -161,7 +161,7 @@ fn _key_suffix_end<'b, 'g, 'r, 's>(
tag(";")(input) tag(";")(input)
} }
fn must_balance_bracket<'s, F, O>( pub(crate) fn must_balance_bracket<'s, F, O>(
mut inner: F, mut inner: F,
) -> impl FnMut(OrgSource<'s>) -> Res<OrgSource<'s>, O> ) -> impl FnMut(OrgSource<'s>) -> Res<OrgSource<'s>, O>
where where

View File

@ -20,7 +20,7 @@ use crate::parser::util::start_of_line;
use crate::types::Clock; use crate::types::Clock;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn clock<'b, 'g, 'r, 's>( pub(crate) fn clock<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Clock<'s>> { ) -> Res<OrgSource<'s>, Clock<'s>> {

View File

@ -25,7 +25,7 @@ use crate::parser::util::start_of_line;
use crate::types::Comment; use crate::types::Comment;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn comment<'b, 'g, 'r, 's>( pub(crate) fn comment<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Comment<'s>> { ) -> Res<OrgSource<'s>, Comment<'s>> {
@ -68,7 +68,7 @@ fn comment_line<'b, 'g, 'r, 's>(
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn detect_comment<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> { pub(crate) fn detect_comment<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> {
tuple(( tuple((
start_of_line, start_of_line,
space0, space0,

View File

@ -13,7 +13,7 @@ use crate::parser::util::start_of_line;
use crate::types::DiarySexp; use crate::types::DiarySexp;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn diary_sexp<'b, 'g, 'r, 's>( pub(crate) fn diary_sexp<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, DiarySexp<'s>> { ) -> Res<OrgSource<'s>, DiarySexp<'s>> {
@ -32,7 +32,7 @@ use crate::types::DiarySexp;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn detect_diary_sexp<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> { pub(crate) fn detect_diary_sexp<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> {
tuple((start_of_line, tag("%%(")))(input)?; tuple((start_of_line, tag("%%(")))(input)?;
Ok((input, ())) Ok((input, ()))
} }

View File

@ -28,7 +28,7 @@ use crate::types::Object;
/// ///
/// 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.
#[allow(dead_code)] #[allow(dead_code)]
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())
} }
@ -38,7 +38,7 @@ use crate::types::Object;
/// ///
/// 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".
#[allow(dead_code)] #[allow(dead_code)]
fn parse_with_settings<'g, 's>( pub fn parse_with_settings<'g, 's>(
input: &'s str, input: &'s str,
global_settings: &'g GlobalSettings<'g, 's>, global_settings: &'g GlobalSettings<'g, 's>,
) -> Result<Document<'s>, String> { ) -> Result<Document<'s>, String> {
@ -58,7 +58,7 @@ use crate::types::Object;
/// ///
/// 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".
#[allow(dead_code)] #[allow(dead_code)]
fn document<'b, 'g, 'r, 's>( fn document<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: &'s str, input: &'s str,
) -> Res<&'s str, Document<'s>> { ) -> Res<&'s str, Document<'s>> {

View File

@ -32,7 +32,7 @@ use crate::types::Paragraph;
use crate::types::SetSource; use crate::types::SetSource;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn drawer<'b, 'g, 'r, 's>( pub(crate) fn drawer<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Drawer<'s>> { ) -> Res<OrgSource<'s>, Drawer<'s>> {

View File

@ -32,7 +32,7 @@ use crate::types::Paragraph;
use crate::types::SetSource; use crate::types::SetSource;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn dynamic_block<'b, 'g, 'r, 's>( pub(crate) fn dynamic_block<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, DynamicBlock<'s>> { ) -> Res<OrgSource<'s>, DynamicBlock<'s>> {

View File

@ -40,7 +40,7 @@ use crate::parser::table::org_mode_table;
use crate::types::Element; use crate::types::Element;
use crate::types::SetSource; use crate::types::SetSource;
const fn element( pub(crate) const fn element(
can_be_paragraph: bool, can_be_paragraph: bool,
) -> impl for<'b, 'g, 'r, 's> Fn( ) -> impl for<'b, 'g, 'r, 's> Fn(
RefContext<'b, 'g, 'r, 's>, RefContext<'b, 'g, 'r, 's>,
@ -127,7 +127,7 @@ fn _element<'b, 'g, 'r, 's>(
Ok((remaining, element)) Ok((remaining, element))
} }
const fn detect_element( pub(crate) const fn detect_element(
can_be_paragraph: bool, can_be_paragraph: bool,
) -> impl for<'b, 'g, 'r, 's> Fn(RefContext<'b, 'g, 'r, 's>, OrgSource<'s>) -> Res<OrgSource<'s>, ()> ) -> impl for<'b, 'g, 'r, 's> Fn(RefContext<'b, 'g, 'r, 's>, OrgSource<'s>) -> Res<OrgSource<'s>, ()>
{ {

View File

@ -433,7 +433,7 @@ const ORG_ENTITIES: [&'static str; 413] = [
]; ];
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn entity<'b, 'g, 'r, 's>( pub(crate) fn entity<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Entity<'s>> { ) -> Res<OrgSource<'s>, Entity<'s>> {

View File

@ -20,7 +20,7 @@ use crate::parser::util::get_consumed;
use crate::types::ExportSnippet; use crate::types::ExportSnippet;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn export_snippet<'b, 'g, 'r, 's>( pub(crate) fn export_snippet<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, ExportSnippet<'s>> { ) -> Res<OrgSource<'s>, ExportSnippet<'s>> {

View File

@ -21,7 +21,7 @@ use crate::parser::util::start_of_line;
use crate::types::FixedWidthArea; use crate::types::FixedWidthArea;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn fixed_width_area<'b, 'g, 'r, 's>( pub(crate) fn fixed_width_area<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, FixedWidthArea<'s>> { ) -> Res<OrgSource<'s>, FixedWidthArea<'s>> {
@ -57,7 +57,7 @@ fn fixed_width_area_line<'b, 'g, 'r, 's>(
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn detect_fixed_width_area<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> { pub(crate) fn detect_fixed_width_area<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> {
tuple(( tuple((
start_of_line, start_of_line,
space0, space0,

View File

@ -33,7 +33,7 @@ use crate::parser::util::start_of_line;
use crate::types::FootnoteDefinition; use crate::types::FootnoteDefinition;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn footnote_definition<'b, 'g, 'r, 's>( pub(crate) fn footnote_definition<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, FootnoteDefinition<'s>> { ) -> Res<OrgSource<'s>, FootnoteDefinition<'s>> {
@ -93,7 +93,7 @@ use crate::types::FootnoteDefinition;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn label<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> { pub(crate) fn label<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
alt(( alt((
digit1, digit1,
take_while(|c| WORD_CONSTITUENT_CHARACTERS.contains(c) || "-_".contains(c)), take_while(|c| WORD_CONSTITUENT_CHARACTERS.contains(c) || "-_".contains(c)),
@ -122,7 +122,7 @@ fn footnote_definition_end<'b, 'g, 'r, 's>(
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn detect_footnote_definition<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> { pub(crate) fn detect_footnote_definition<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> {
tuple((start_of_line, tag_no_case("[fn:"), label, tag("]")))(input)?; tuple((start_of_line, tag_no_case("[fn:"), label, tag("]")))(input)?;
Ok((input, ())) Ok((input, ()))
} }

View File

@ -23,7 +23,7 @@ use crate::parser::util::get_consumed;
use crate::types::FootnoteReference; use crate::types::FootnoteReference;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn footnote_reference<'b, 'g, 'r, 's>( pub(crate) fn footnote_reference<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, FootnoteReference<'s>> { ) -> Res<OrgSource<'s>, FootnoteReference<'s>> {

View File

@ -33,7 +33,7 @@ use crate::types::Paragraph;
use crate::types::SetSource; use crate::types::SetSource;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn greater_block<'b, 'g, 'r, 's>( pub(crate) fn greater_block<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, GreaterBlock<'s>> { ) -> Res<OrgSource<'s>, GreaterBlock<'s>> {

View File

@ -36,7 +36,7 @@ use crate::types::Object;
use crate::types::PriorityCookie; use crate::types::PriorityCookie;
use crate::types::TodoKeywordType; use crate::types::TodoKeywordType;
const fn heading( pub(crate) const fn heading(
parent_stars: usize, parent_stars: usize,
) -> impl for<'b, 'g, 'r, 's> Fn( ) -> impl for<'b, 'g, 'r, 's> Fn(
RefContext<'b, 'g, 'r, 's>, RefContext<'b, 'g, 'r, 's>,
@ -95,7 +95,7 @@ fn _heading<'b, 'g, 'r, 's>(
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn detect_headline<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> { pub(crate) fn detect_headline<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> {
tuple((start_of_line, many1(tag("*")), space1))(input)?; tuple((start_of_line, many1(tag("*")), space1))(input)?;
Ok((input, ())) Ok((input, ()))
} }

View File

@ -15,7 +15,7 @@ use crate::parser::util::start_of_line;
use crate::types::HorizontalRule; use crate::types::HorizontalRule;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn horizontal_rule<'b, 'g, 'r, 's>( pub(crate) fn horizontal_rule<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, HorizontalRule<'s>> { ) -> Res<OrgSource<'s>, HorizontalRule<'s>> {

View File

@ -13,7 +13,7 @@ use crate::types::Keyword;
use crate::GlobalSettings; use crate::GlobalSettings;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn scan_for_in_buffer_settings<'s>( pub(crate) 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>>> {
// TODO: Optimization idea: since this is slicing the OrgSource at each character, it might be more efficient to do a parser that uses a search function like take_until, and wrap it in a function similar to consumed but returning the input along with the normal output, then pass all of that into a verify that confirms we were at the start of a line using the input we just returned. // TODO: Optimization idea: since this is slicing the OrgSource at each character, it might be more efficient to do a parser that uses a search function like take_until, and wrap it in a function similar to consumed but returning the input along with the normal output, then pass all of that into a verify that confirms we were at the start of a line using the input we just returned.
@ -44,7 +44,7 @@ fn in_buffer_settings_key<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSou
))(input) ))(input)
} }
fn apply_in_buffer_settings<'g, 's, 'sf>( pub(crate) fn apply_in_buffer_settings<'g, 's, 'sf>(
keywords: Vec<Keyword<'sf>>, keywords: Vec<Keyword<'sf>>,
original_settings: &'g GlobalSettings<'g, 's>, original_settings: &'g GlobalSettings<'g, 's>,
) -> Result<GlobalSettings<'g, 's>, String> { ) -> Result<GlobalSettings<'g, 's>, String> {

View File

@ -26,7 +26,7 @@ use crate::parser::util::get_consumed;
use crate::types::InlineBabelCall; use crate::types::InlineBabelCall;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn inline_babel_call<'b, 'g, 'r, 's>( pub(crate) fn inline_babel_call<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, InlineBabelCall<'s>> { ) -> Res<OrgSource<'s>, InlineBabelCall<'s>> {

View File

@ -28,7 +28,7 @@ use crate::parser::util::get_consumed;
use crate::types::InlineSourceBlock; use crate::types::InlineSourceBlock;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn inline_source_block<'b, 'g, 'r, 's>( pub(crate) fn inline_source_block<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, InlineSourceBlock<'s>> { ) -> Res<OrgSource<'s>, InlineSourceBlock<'s>> {

View File

@ -31,7 +31,7 @@ const ORG_ELEMENT_AFFILIATED_KEYWORDS: [&'static str; 13] = [
]; ];
const ORG_ELEMENT_DUAL_KEYWORDS: [&'static str; 2] = ["caption", "results"]; const ORG_ELEMENT_DUAL_KEYWORDS: [&'static str; 2] = ["caption", "results"];
fn filtered_keyword<F: Matcher>( pub(crate) fn filtered_keyword<F: Matcher>(
key_parser: F, key_parser: F,
) -> impl for<'s> Fn(OrgSource<'s>) -> Res<OrgSource<'s>, Keyword<'s>> { ) -> impl for<'s> Fn(OrgSource<'s>) -> Res<OrgSource<'s>, Keyword<'s>> {
move |input| _filtered_keyword(&key_parser, input) move |input| _filtered_keyword(&key_parser, input)
@ -83,7 +83,7 @@ fn _filtered_keyword<'s, F: Matcher>(
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn keyword<'b, 'g, 'r, 's>( pub(crate) fn keyword<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Keyword<'s>> { ) -> Res<OrgSource<'s>, Keyword<'s>> {
@ -91,7 +91,7 @@ fn _filtered_keyword<'s, F: Matcher>(
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn affiliated_keyword<'b, 'g, 'r, 's>( pub(crate) fn affiliated_keyword<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Keyword<'s>> { ) -> Res<OrgSource<'s>, Keyword<'s>> {
@ -99,7 +99,7 @@ fn _filtered_keyword<'s, F: Matcher>(
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn babel_call_keyword<'b, 'g, 'r, 's>( pub(crate) fn babel_call_keyword<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Keyword<'s>> { ) -> Res<OrgSource<'s>, Keyword<'s>> {
@ -112,7 +112,7 @@ fn babel_call_key<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>>
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn table_formula_keyword<'b, 'g, 'r, 's>( pub(crate) fn table_formula_keyword<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Keyword<'s>> { ) -> Res<OrgSource<'s>, Keyword<'s>> {

View File

@ -19,7 +19,7 @@ use crate::error::Res;
/// Parses the text in the value of a #+TODO keyword. /// Parses the text in the value of a #+TODO keyword.
/// ///
/// Example input: "foo bar baz | lorem ipsum" /// Example input: "foo bar baz | lorem ipsum"
fn todo_keywords<'s>(input: &'s str) -> Res<&'s str, (Vec<&'s str>, Vec<&'s str>)> { pub(crate) fn todo_keywords<'s>(input: &'s str) -> Res<&'s str, (Vec<&'s str>, Vec<&'s str>)> {
let (remaining, mut before_pipe_words) = separated_list0(space1, todo_keyword_word)(input)?; let (remaining, mut before_pipe_words) = separated_list0(space1, todo_keyword_word)(input)?;
let (remaining, after_pipe_words) = opt(tuple(( let (remaining, after_pipe_words) = opt(tuple((
tuple((space0, tag("|"), space0)), tuple((space0, tag("|"), space0)),

View File

@ -25,7 +25,7 @@ use crate::parser::util::start_of_line;
use crate::types::LatexEnvironment; use crate::types::LatexEnvironment;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn latex_environment<'b, 'g, 'r, 's>( pub(crate) fn latex_environment<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, LatexEnvironment<'s>> { ) -> Res<OrgSource<'s>, LatexEnvironment<'s>> {

View File

@ -24,7 +24,7 @@ use crate::parser::util::get_consumed;
use crate::types::LatexFragment; use crate::types::LatexFragment;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn latex_fragment<'b, 'g, 'r, 's>( pub(crate) fn latex_fragment<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, LatexFragment<'s>> { ) -> Res<OrgSource<'s>, LatexFragment<'s>> {
@ -174,7 +174,7 @@ fn dollar_char_fragment<'b, 'g, 'r, 's>(
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn pre<'b, 'g, 'r, 's>( fn pre<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, ()> { ) -> Res<OrgSource<'s>, ()> {
@ -188,7 +188,7 @@ fn dollar_char_fragment<'b, 'g, 'r, 's>(
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn post<'b, 'g, 'r, 's>( fn post<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, ()> { ) -> Res<OrgSource<'s>, ()> {
@ -226,7 +226,7 @@ fn bordered_dollar_fragment<'b, 'g, 'r, 's>(
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn open_border<'b, 'g, 'r, 's>( fn open_border<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, OrgSource<'s>> { ) -> Res<OrgSource<'s>, OrgSource<'s>> {
@ -234,7 +234,7 @@ fn bordered_dollar_fragment<'b, 'g, 'r, 's>(
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn close_border<'b, 'g, 'r, 's>( fn close_border<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, ()> { ) -> Res<OrgSource<'s>, ()> {

View File

@ -35,7 +35,7 @@ use crate::types::SrcBlock;
use crate::types::VerseBlock; use crate::types::VerseBlock;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn verse_block<'b, 'g, 'r, 's>( pub(crate) fn verse_block<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, VerseBlock<'s>> { ) -> Res<OrgSource<'s>, VerseBlock<'s>> {
@ -90,7 +90,7 @@ use crate::types::VerseBlock;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn comment_block<'b, 'g, 'r, 's>( pub(crate) fn comment_block<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, CommentBlock<'s>> { ) -> Res<OrgSource<'s>, CommentBlock<'s>> {
@ -130,7 +130,7 @@ use crate::types::VerseBlock;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn example_block<'b, 'g, 'r, 's>( pub(crate) fn example_block<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, ExampleBlock<'s>> { ) -> Res<OrgSource<'s>, ExampleBlock<'s>> {
@ -170,7 +170,7 @@ use crate::types::VerseBlock;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn export_block<'b, 'g, 'r, 's>( pub(crate) fn export_block<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, ExportBlock<'s>> { ) -> Res<OrgSource<'s>, ExportBlock<'s>> {
@ -211,7 +211,7 @@ use crate::types::VerseBlock;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn src_block<'b, 'g, 'r, 's>( pub(crate) fn src_block<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, SrcBlock<'s>> { ) -> Res<OrgSource<'s>, SrcBlock<'s>> {

View File

@ -13,7 +13,7 @@ use crate::parser::util::get_consumed;
use crate::types::LineBreak; use crate::types::LineBreak;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn line_break<'b, 'g, 'r, 's>( pub(crate) fn line_break<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, LineBreak<'s>> { ) -> Res<OrgSource<'s>, LineBreak<'s>> {

View File

@ -37,7 +37,7 @@ mod property_drawer;
mod radio_link; mod radio_link;
mod regular_link; mod regular_link;
mod section; mod section;
mod sexp; pub mod sexp;
mod statistics_cookie; mod statistics_cookie;
mod subscript_and_superscript; mod subscript_and_superscript;
mod table; mod table;
@ -46,7 +46,6 @@ mod text_markup;
mod timestamp; mod timestamp;
mod token; mod token;
mod util; mod util;
use document::document; pub use document::parse;
use document::parse; pub use document::parse_with_settings;
use document::parse_with_settings; pub(crate) use org_source::OrgSource;
use org_source::OrgSource;

View File

@ -32,7 +32,7 @@ use crate::parser::timestamp::timestamp;
use crate::types::Object; use crate::types::Object;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn standard_set_object<'b, 'g, 'r, 's>( pub(crate) fn standard_set_object<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Object<'s>> { ) -> Res<OrgSource<'s>, Object<'s>> {
@ -47,7 +47,7 @@ use crate::types::Object;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn minimal_set_object<'b, 'g, 'r, 's>( pub(crate) fn minimal_set_object<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Object<'s>> { ) -> Res<OrgSource<'s>, Object<'s>> {
@ -140,7 +140,7 @@ fn minimal_set_object_sans_plain_text<'b, 'g, 'r, 's>(
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn detect_standard_set_object_sans_plain_text<'b, 'g, 'r, 's>( pub(crate) fn detect_standard_set_object_sans_plain_text<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, ()> { ) -> Res<OrgSource<'s>, ()> {
@ -174,7 +174,7 @@ fn detect_minimal_set_object_sans_plain_text<'b, 'g, 'r, 's>(
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn regular_link_description_set_object<'b, 'g, 'r, 's>( pub(crate) fn regular_link_description_set_object<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Object<'s>> { ) -> Res<OrgSource<'s>, Object<'s>> {
@ -221,7 +221,7 @@ fn regular_link_description_set_object_sans_plain_text<'b, 'g, 'r, 's>(
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn detect_regular_link_description_set_object_sans_plain_text<'b, 'g, 'r, 's>( fn detect_regular_link_description_set_object_sans_plain_text<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, ()> { ) -> Res<OrgSource<'s>, ()> {
@ -238,7 +238,7 @@ fn regular_link_description_set_object_sans_plain_text<'b, 'g, 'r, 's>(
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn table_cell_set_object<'b, 'g, 'r, 's>( pub(crate) fn table_cell_set_object<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Object<'s>> { ) -> Res<OrgSource<'s>, Object<'s>> {
@ -253,7 +253,7 @@ fn regular_link_description_set_object_sans_plain_text<'b, 'g, 'r, 's>(
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn table_cell_set_object_sans_plain_text<'b, 'g, 'r, 's>( fn table_cell_set_object_sans_plain_text<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Object<'s>> { ) -> Res<OrgSource<'s>, Object<'s>> {
@ -287,7 +287,7 @@ fn regular_link_description_set_object_sans_plain_text<'b, 'g, 'r, 's>(
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn detect_table_cell_set_object_sans_plain_text<'b, 'g, 'r, 's>( fn detect_table_cell_set_object_sans_plain_text<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, ()> { ) -> Res<OrgSource<'s>, ()> {

View File

@ -18,7 +18,7 @@ use crate::parser::util::get_consumed;
use crate::types::OrgMacro; use crate::types::OrgMacro;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn org_macro<'b, 'g, 'r, 's>( pub(crate) fn org_macro<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, OrgMacro<'s>> { ) -> Res<OrgSource<'s>, OrgMacro<'s>> {

View File

@ -11,10 +11,10 @@ use nom::Slice;
use crate::error::CustomError; use crate::error::CustomError;
use crate::error::MyError; use crate::error::MyError;
type BracketDepth = i16; pub(crate) type BracketDepth = i16;
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
struct OrgSource<'s> { pub(crate) struct OrgSource<'s> {
full_source: &'s str, full_source: &'s str,
start: usize, start: usize,
end: usize, // exclusive end: usize, // exclusive
@ -37,7 +37,7 @@ impl<'s> OrgSource<'s> {
/// Returns a wrapped string that keeps track of values we need for parsing org-mode. /// Returns a wrapped string that keeps track of values we need for parsing org-mode.
/// ///
/// Only call this on the full original string. Calling this on a substring can result in invalid values. /// Only call this on the full original string. Calling this on a substring can result in invalid values.
fn new(input: &'s str) -> Self { pub(crate) fn new(input: &'s str) -> Self {
OrgSource { OrgSource {
full_source: input, full_source: input,
start: 0, start: 0,
@ -51,37 +51,37 @@ impl<'s> OrgSource<'s> {
} }
/// Get the text since the line break preceding the start of this WrappedInput. /// Get the text since the line break preceding the start of this WrappedInput.
fn text_since_line_break(&self) -> &'s str { pub(crate) fn text_since_line_break(&self) -> &'s str {
&self.full_source[self.start_of_line..self.start] &self.full_source[self.start_of_line..self.start]
} }
fn len(&self) -> usize { pub(crate) fn len(&self) -> usize {
self.end - self.start self.end - self.start
} }
fn get_preceding_character(&self) -> Option<char> { pub(crate) fn get_preceding_character(&self) -> Option<char> {
self.preceding_character self.preceding_character
} }
fn is_at_start_of_line(&self) -> bool { pub(crate) fn is_at_start_of_line(&self) -> bool {
self.start == self.start_of_line self.start == self.start_of_line
} }
fn get_until(&self, other: OrgSource<'s>) -> OrgSource<'s> { pub(crate) fn get_until(&self, other: OrgSource<'s>) -> OrgSource<'s> {
assert!(other.start >= self.start); assert!(other.start >= self.start);
assert!(other.end <= self.end); assert!(other.end <= self.end);
self.slice(..(other.start - self.start)) self.slice(..(other.start - self.start))
} }
fn get_bracket_depth(&self) -> BracketDepth { pub(crate) fn get_bracket_depth(&self) -> BracketDepth {
self.bracket_depth self.bracket_depth
} }
fn get_brace_depth(&self) -> BracketDepth { pub(crate) fn get_brace_depth(&self) -> BracketDepth {
self.brace_depth self.brace_depth
} }
fn get_parenthesis_depth(&self) -> BracketDepth { pub(crate) fn get_parenthesis_depth(&self) -> BracketDepth {
self.parenthesis_depth self.parenthesis_depth
} }
} }
@ -306,7 +306,7 @@ impl<'s> InputTakeAtPosition for OrgSource<'s> {
} }
} }
fn convert_error<'a, I: Into<CustomError<&'a str>>>( pub(crate) fn convert_error<'a, I: Into<CustomError<&'a str>>>(
err: nom::Err<I>, err: nom::Err<I>,
) -> nom::Err<CustomError<&'a str>> { ) -> nom::Err<CustomError<&'a str>> {
match err { match err {

View File

@ -22,7 +22,7 @@ use crate::parser::util::start_of_line;
use crate::types::Paragraph; use crate::types::Paragraph;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn paragraph<'b, 'g, 'r, 's>( pub(crate) fn paragraph<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Paragraph<'s>> { ) -> Res<OrgSource<'s>, Paragraph<'s>> {

View File

@ -53,7 +53,7 @@ const ORG_LINK_PARAMETERS: [&'static str; 23] = [
]; ];
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn plain_link<'b, 'g, 'r, 's>( pub(crate) fn plain_link<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, PlainLink<'s>> { ) -> Res<OrgSource<'s>, PlainLink<'s>> {
@ -105,7 +105,7 @@ fn post<'b, 'g, 'r, 's>(
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn protocol<'b, 'g, 'r, 's>( pub(crate) fn protocol<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, OrgSource<'s>> { ) -> Res<OrgSource<'s>, OrgSource<'s>> {

View File

@ -41,7 +41,7 @@ use crate::types::PlainList;
use crate::types::PlainListItem; use crate::types::PlainListItem;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn detect_plain_list<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> { pub(crate) fn detect_plain_list<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> {
if verify( if verify(
tuple(( tuple((
start_of_line, start_of_line,
@ -63,7 +63,7 @@ use crate::types::PlainListItem;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn plain_list<'b, 'g, 'r, 's>( pub(crate) fn plain_list<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, PlainList<'s>> { ) -> Res<OrgSource<'s>, PlainList<'s>> {
@ -137,7 +137,7 @@ use crate::types::PlainListItem;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn plain_list_item<'b, 'g, 'r, 's>( fn plain_list_item<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, PlainListItem<'s>> { ) -> Res<OrgSource<'s>, PlainListItem<'s>> {

View File

@ -16,7 +16,7 @@ use crate::error::Res;
use crate::types::Object; use crate::types::Object;
use crate::types::PlainText; use crate::types::PlainText;
fn plain_text<F>( pub(crate) fn plain_text<F>(
end_condition: F, end_condition: F,
) -> impl for<'b, 'g, 'r, 's> Fn( ) -> impl for<'b, 'g, 'r, 's> Fn(
RefContext<'b, 'g, 'r, 's>, RefContext<'b, 'g, 'r, 's>,

View File

@ -18,7 +18,7 @@ use crate::parser::util::start_of_line;
use crate::types::Planning; use crate::types::Planning;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn planning<'b, 'g, 'r, 's>( pub(crate) fn planning<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Planning<'s>> { ) -> Res<OrgSource<'s>, Planning<'s>> {

View File

@ -31,7 +31,7 @@ use crate::types::NodeProperty;
use crate::types::PropertyDrawer; use crate::types::PropertyDrawer;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn property_drawer<'b, 'g, 'r, 's>( pub(crate) fn property_drawer<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, PropertyDrawer<'s>> { ) -> Res<OrgSource<'s>, PropertyDrawer<'s>> {

View File

@ -23,7 +23,7 @@ use crate::types::RadioLink;
use crate::types::RadioTarget; use crate::types::RadioTarget;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn radio_link<'b, 'g, 'r, 's>( pub(crate) fn radio_link<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, RadioLink<'s>> { ) -> Res<OrgSource<'s>, RadioLink<'s>> {
@ -47,7 +47,7 @@ use crate::types::RadioTarget;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn rematch_target<'x, 'b, 'g, 'r, 's>( pub(crate) fn rematch_target<'x, 'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
target: &'x Vec<Object<'x>>, target: &'x Vec<Object<'x>>,
input: OrgSource<'s>, input: OrgSource<'s>,
@ -78,7 +78,7 @@ use crate::types::RadioTarget;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn radio_target<'b, 'g, 'r, 's>( pub(crate) fn radio_target<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, RadioTarget<'s>> { ) -> Res<OrgSource<'s>, RadioTarget<'s>> {
@ -118,7 +118,7 @@ fn radio_target_end<'b, 'g, 'r, 's>(
alt((tag("<"), tag(">"), line_ending))(input) alt((tag("<"), tag(">"), line_ending))(input)
} }
trait RematchObject<'x> { pub(crate) trait RematchObject<'x> {
fn rematch_object<'b, 'g, 'r, 's>( fn rematch_object<'b, 'g, 'r, 's>(
&'x self, &'x self,
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,

View File

@ -21,7 +21,7 @@ use crate::types::Object;
use crate::types::RegularLink; use crate::types::RegularLink;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn regular_link<'b, 'g, 'r, 's>( pub(crate) fn regular_link<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, RegularLink<'s>> { ) -> Res<OrgSource<'s>, RegularLink<'s>> {
@ -32,7 +32,7 @@ use crate::types::RegularLink;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn regular_link_without_description<'b, 'g, 'r, 's>( fn regular_link_without_description<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, RegularLink<'s>> { ) -> Res<OrgSource<'s>, RegularLink<'s>> {
@ -51,7 +51,7 @@ use crate::types::RegularLink;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn regular_link_with_description<'b, 'g, 'r, 's>( fn regular_link_with_description<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, RegularLink<'s>> { ) -> Res<OrgSource<'s>, RegularLink<'s>> {
@ -72,7 +72,7 @@ use crate::types::RegularLink;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn pathreg<'b, 'g, 'r, 's>( fn pathreg<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, OrgSource<'s>> { ) -> Res<OrgSource<'s>, OrgSource<'s>> {
@ -88,7 +88,7 @@ use crate::types::RegularLink;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn description<'b, 'g, 'r, 's>( fn description<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Vec<Object<'s>>> { ) -> Res<OrgSource<'s>, Vec<Object<'s>>> {

View File

@ -25,7 +25,7 @@ use crate::types::Element;
use crate::types::Section; use crate::types::Section;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn zeroth_section<'b, 'g, 'r, 's>( pub(crate) fn zeroth_section<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Section<'s>> { ) -> Res<OrgSource<'s>, Section<'s>> {
@ -83,7 +83,7 @@ use crate::types::Section;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn section<'b, 'g, 'r, 's>( pub(crate) fn section<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
mut input: OrgSource<'s>, mut input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Section<'s>> { ) -> Res<OrgSource<'s>, Section<'s>> {

View File

@ -22,7 +22,7 @@ use super::util::get_consumed;
use crate::error::Res; use crate::error::Res;
#[derive(Debug)] #[derive(Debug)]
enum Token<'s> { pub enum Token<'s> {
Atom(&'s str), Atom(&'s str),
List(Vec<Token<'s>>), List(Vec<Token<'s>>),
TextWithProperties(TextWithProperties<'s>), TextWithProperties(TextWithProperties<'s>),
@ -30,9 +30,9 @@ use crate::error::Res;
} }
#[derive(Debug)] #[derive(Debug)]
struct TextWithProperties<'s> { pub struct TextWithProperties<'s> {
text: &'s str, pub(crate) text: &'s str,
properties: Vec<Token<'s>>, pub(crate) properties: Vec<Token<'s>>,
} }
enum ParseState { enum ParseState {
@ -41,35 +41,39 @@ enum ParseState {
} }
impl<'s> Token<'s> { impl<'s> Token<'s> {
fn as_vector<'p>(&'p self) -> Result<&'p Vec<Token<'s>>, Box<dyn std::error::Error>> { pub(crate) fn as_vector<'p>(
&'p self,
) -> Result<&'p Vec<Token<'s>>, Box<dyn std::error::Error>> {
Ok(match self { Ok(match self {
Token::Vector(children) => Ok(children), Token::Vector(children) => Ok(children),
_ => Err(format!("wrong token type, expected vector: {:?}", self)), _ => Err(format!("wrong token type, expected vector: {:?}", self)),
}?) }?)
} }
fn as_list<'p>(&'p self) -> Result<&'p Vec<Token<'s>>, Box<dyn std::error::Error>> { pub(crate) fn as_list<'p>(&'p self) -> Result<&'p Vec<Token<'s>>, Box<dyn std::error::Error>> {
Ok(match self { Ok(match self {
Token::List(children) => Ok(children), Token::List(children) => Ok(children),
_ => Err(format!("wrong token type, expected list: {:?}", self)), _ => Err(format!("wrong token type, expected list: {:?}", self)),
}?) }?)
} }
fn as_atom<'p>(&'p self) -> Result<&'s str, Box<dyn std::error::Error>> { pub(crate) fn as_atom<'p>(&'p self) -> Result<&'s str, Box<dyn std::error::Error>> {
Ok(match self { Ok(match self {
Token::Atom(body) => Ok(*body), Token::Atom(body) => Ok(*body),
_ => Err(format!("wrong token type, expected atom: {:?}", self)), _ => Err(format!("wrong token type, expected atom: {:?}", self)),
}?) }?)
} }
fn as_text<'p>(&'p self) -> Result<&'p TextWithProperties<'s>, Box<dyn std::error::Error>> { pub(crate) fn as_text<'p>(
&'p self,
) -> Result<&'p TextWithProperties<'s>, Box<dyn std::error::Error>> {
Ok(match self { Ok(match self {
Token::TextWithProperties(body) => Ok(body), Token::TextWithProperties(body) => Ok(body),
_ => Err(format!("wrong token type, expected text: {:?}", self)), _ => Err(format!("wrong token type, expected text: {:?}", self)),
}?) }?)
} }
fn as_map<'p>( pub(crate) fn as_map<'p>(
&'p self, &'p self,
) -> Result<HashMap<&'s str, &'p Token<'s>>, Box<dyn std::error::Error>> { ) -> Result<HashMap<&'s str, &'p Token<'s>>, Box<dyn std::error::Error>> {
let mut hashmap = HashMap::new(); let mut hashmap = HashMap::new();
@ -95,7 +99,7 @@ impl<'s> Token<'s> {
} }
} }
fn unquote(text: &str) -> Result<String, Box<dyn std::error::Error>> { pub(crate) fn unquote(text: &str) -> Result<String, Box<dyn std::error::Error>> {
let mut out = String::with_capacity(text.len()); let mut out = String::with_capacity(text.len());
if !text.starts_with(r#"""#) { if !text.starts_with(r#"""#) {
return Err("Quoted text does not start with quote.".into()); return Err("Quoted text does not start with quote.".into());
@ -132,7 +136,7 @@ impl<'s> Token<'s> {
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn sexp_with_padding<'s>(input: &'s str) -> Res<&'s str, Token<'s>> { pub fn sexp_with_padding<'s>(input: &'s str) -> Res<&'s str, Token<'s>> {
let (remaining, _) = multispace0(input)?; let (remaining, _) = multispace0(input)?;
let remaining = OrgSource::new(remaining); let remaining = OrgSource::new(remaining);
let (remaining, tkn) = token(remaining) let (remaining, tkn) = token(remaining)
@ -143,7 +147,7 @@ impl<'s> Token<'s> {
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn sexp<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, Token<'s>> { fn sexp<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, Token<'s>> {
let (remaining, tkn) = token(input)?; let (remaining, tkn) = token(input)?;
Ok((remaining, tkn)) Ok((remaining, tkn))
} }

View File

@ -13,7 +13,7 @@ use crate::error::Res;
use crate::types::StatisticsCookie; use crate::types::StatisticsCookie;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn statistics_cookie<'b, 'g, 'r, 's>( pub(crate) fn statistics_cookie<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, StatisticsCookie<'s>> { ) -> Res<OrgSource<'s>, StatisticsCookie<'s>> {
@ -24,7 +24,7 @@ use crate::types::StatisticsCookie;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn percent_statistics_cookie<'b, 'g, 'r, 's>( fn percent_statistics_cookie<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, StatisticsCookie<'s>> { ) -> Res<OrgSource<'s>, StatisticsCookie<'s>> {
@ -45,7 +45,7 @@ use crate::types::StatisticsCookie;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn fraction_statistics_cookie<'b, 'g, 'r, 's>( fn fraction_statistics_cookie<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, StatisticsCookie<'s>> { ) -> Res<OrgSource<'s>, StatisticsCookie<'s>> {

View File

@ -33,7 +33,7 @@ use crate::types::Subscript;
use crate::types::Superscript; use crate::types::Superscript;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn detect_subscript_or_superscript<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> { pub(crate) fn detect_subscript_or_superscript<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> {
// This does not have to detect all valid subscript/superscript but all that it detects must be valid. // This does not have to detect all valid subscript/superscript but all that it detects must be valid.
let (remaining, _) = one_of("_^")(input)?; let (remaining, _) = one_of("_^")(input)?;
pre(input)?; pre(input)?;
@ -46,7 +46,7 @@ use crate::types::Superscript;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn subscript<'b, 'g, 'r, 's>( pub(crate) fn subscript<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Subscript<'s>> { ) -> Res<OrgSource<'s>, Subscript<'s>> {
@ -66,7 +66,7 @@ use crate::types::Superscript;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn superscript<'b, 'g, 'r, 's>( pub(crate) fn superscript<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Superscript<'s>> { ) -> Res<OrgSource<'s>, Superscript<'s>> {

View File

@ -33,7 +33,7 @@ use crate::types::TableRow;
/// ///
/// This is not the table.el style. /// This is not the table.el style.
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn org_mode_table<'b, 'g, 'r, 's>( pub(crate) fn org_mode_table<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Table<'s>> { ) -> Res<OrgSource<'s>, Table<'s>> {
@ -74,7 +74,7 @@ use crate::types::TableRow;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn detect_table<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> { pub(crate) fn detect_table<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> {
tuple((start_of_line, space0, tag("|")))(input)?; tuple((start_of_line, space0, tag("|")))(input)?;
Ok((input, ())) Ok((input, ()))
} }
@ -89,7 +89,7 @@ fn table_end<'b, 'g, 'r, 's>(
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn org_mode_table_row<'b, 'g, 'r, 's>( fn org_mode_table_row<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, TableRow<'s>> { ) -> Res<OrgSource<'s>, TableRow<'s>> {
@ -100,7 +100,7 @@ fn table_end<'b, 'g, 'r, 's>(
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn org_mode_table_row_rule<'b, 'g, 'r, 's>( fn org_mode_table_row_rule<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, TableRow<'s>> { ) -> Res<OrgSource<'s>, TableRow<'s>> {
@ -117,7 +117,7 @@ fn table_end<'b, 'g, 'r, 's>(
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn org_mode_table_row_regular<'b, 'g, 'r, 's>( fn org_mode_table_row_regular<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, TableRow<'s>> { ) -> Res<OrgSource<'s>, TableRow<'s>> {
@ -137,7 +137,7 @@ fn table_end<'b, 'g, 'r, 's>(
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn org_mode_table_cell<'b, 'g, 'r, 's>( fn org_mode_table_cell<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, TableCell<'s>> { ) -> Res<OrgSource<'s>, TableCell<'s>> {

View File

@ -21,7 +21,7 @@ use crate::parser::util::get_consumed;
use crate::types::Target; use crate::types::Target;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn target<'b, 'g, 'r, 's>( pub(crate) fn target<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Target<'s>> { ) -> Res<OrgSource<'s>, Target<'s>> {

View File

@ -42,7 +42,7 @@ use crate::types::Underline;
use crate::types::Verbatim; use crate::types::Verbatim;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn text_markup<'b, 'g, 'r, 's>( pub(crate) fn text_markup<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Object<'s>> { ) -> Res<OrgSource<'s>, Object<'s>> {
@ -60,7 +60,7 @@ use crate::types::Verbatim;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn bold<'b, 'g, 'r, 's>( fn bold<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Bold<'s>> { ) -> Res<OrgSource<'s>, Bold<'s>> {
@ -77,7 +77,7 @@ use crate::types::Verbatim;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn italic<'b, 'g, 'r, 's>( fn italic<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Italic<'s>> { ) -> Res<OrgSource<'s>, Italic<'s>> {
@ -94,7 +94,7 @@ use crate::types::Verbatim;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn underline<'b, 'g, 'r, 's>( fn underline<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Underline<'s>> { ) -> Res<OrgSource<'s>, Underline<'s>> {
@ -111,7 +111,7 @@ use crate::types::Verbatim;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn strike_through<'b, 'g, 'r, 's>( fn strike_through<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, StrikeThrough<'s>> { ) -> Res<OrgSource<'s>, StrikeThrough<'s>> {
@ -128,7 +128,7 @@ use crate::types::Verbatim;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn verbatim<'b, 'g, 'r, 's>( fn verbatim<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Verbatim<'s>> { ) -> Res<OrgSource<'s>, Verbatim<'s>> {
@ -145,7 +145,7 @@ use crate::types::Verbatim;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn code<'b, 'g, 'r, 's>( fn code<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Code<'s>> { ) -> Res<OrgSource<'s>, Code<'s>> {
@ -288,7 +288,7 @@ fn _text_markup_string<'b, 'g, 'r, 's, 'c>(
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn pre<'b, 'g, 'r, 's>( fn pre<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, ()> { ) -> Res<OrgSource<'s>, ()> {
@ -307,7 +307,7 @@ fn _text_markup_string<'b, 'g, 'r, 's, 'c>(
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn post<'b, 'g, 'r, 's>( fn post<'b, 'g, 'r, 's>(
_context: RefContext<'b, 'g, 'r, 's>, _context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, ()> { ) -> Res<OrgSource<'s>, ()> {

View File

@ -23,7 +23,7 @@ use crate::parser::util::get_consumed;
use crate::types::Timestamp; use crate::types::Timestamp;
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn timestamp<'b, 'g, 'r, 's>( pub(crate) fn timestamp<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Timestamp<'s>> { ) -> Res<OrgSource<'s>, Timestamp<'s>> {

View File

@ -11,7 +11,7 @@ use crate::types::Section;
use crate::types::TableCell; use crate::types::TableCell;
use crate::types::TableRow; use crate::types::TableRow;
enum Token<'r, 's> { pub(crate) enum Token<'r, 's> {
Document(&'r Document<'s>), Document(&'r Document<'s>),
Heading(&'r Heading<'s>), Heading(&'r Heading<'s>),
Section(&'r Section<'s>), Section(&'r Section<'s>),
@ -109,12 +109,12 @@ impl<'r, 's> Token<'r, 's> {
} }
} }
struct AllTokensIterator<'r, 's> { pub(crate) struct AllTokensIterator<'r, 's> {
queued_tokens: VecDeque<Token<'r, 's>>, queued_tokens: VecDeque<Token<'r, 's>>,
} }
impl<'r, 's> AllTokensIterator<'r, 's> { impl<'r, 's> AllTokensIterator<'r, 's> {
fn new(tkn: Token<'r, 's>) -> Self { pub(crate) fn new(tkn: Token<'r, 's>) -> Self {
let mut queued_tokens = VecDeque::new(); let mut queued_tokens = VecDeque::new();
queued_tokens.push_back(tkn); queued_tokens.push_back(tkn);
AllTokensIterator { queued_tokens } AllTokensIterator { queued_tokens }

View File

@ -21,11 +21,11 @@ use crate::error::CustomError;
use crate::error::MyError; use crate::error::MyError;
use crate::error::Res; use crate::error::Res;
const WORD_CONSTITUENT_CHARACTERS: &str = pub(crate) const WORD_CONSTITUENT_CHARACTERS: &str =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
/// Check if we are below a section of the given section type regardless of depth /// Check if we are below a section of the given section type regardless of depth
fn in_section<'b, 'g, 'r, 's, 'x>( pub(crate) fn in_section<'b, 'g, 'r, 's, 'x>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
section_name: &'x str, section_name: &'x str,
) -> bool { ) -> bool {
@ -39,7 +39,7 @@ use crate::error::Res;
} }
/// Checks if we are currently an immediate child of the given section type /// Checks if we are currently an immediate child of the given section type
fn immediate_in_section<'b, 'g, 'r, 's, 'x>( pub(crate) fn immediate_in_section<'b, 'g, 'r, 's, 'x>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
section_name: &'x str, section_name: &'x str,
) -> bool { ) -> bool {
@ -54,7 +54,7 @@ use crate::error::Res;
} }
/// Check if we are below a section of the given section type regardless of depth /// Check if we are below a section of the given section type regardless of depth
fn in_object_section<'b, 'g, 'r, 's, 'x>( pub(crate) fn in_object_section<'b, 'g, 'r, 's, 'x>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
section_name: &'x str, section_name: &'x str,
) -> bool { ) -> bool {
@ -68,7 +68,7 @@ use crate::error::Res;
} }
/// Get a slice of the string that was consumed in a parser using the original input to the parser and the remaining input after the parser. /// Get a slice of the string that was consumed in a parser using the original input to the parser and the remaining input after the parser.
fn get_consumed<'s>(input: OrgSource<'s>, remaining: OrgSource<'s>) -> OrgSource<'s> { pub(crate) fn get_consumed<'s>(input: OrgSource<'s>, remaining: OrgSource<'s>) -> OrgSource<'s> {
input.get_until(remaining) input.get_until(remaining)
} }
@ -76,19 +76,19 @@ use crate::error::Res;
/// ///
/// It is up to the caller to ensure this is called at the start of a line. /// It is up to the caller to ensure this is called at the start of a line.
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn blank_line(input: OrgSource<'_>) -> Res<OrgSource<'_>, OrgSource<'_>> { pub(crate) fn blank_line(input: OrgSource<'_>) -> Res<OrgSource<'_>, OrgSource<'_>> {
not(eof)(input)?; not(eof)(input)?;
recognize(tuple((space0, alt((line_ending, eof)))))(input) recognize(tuple((space0, alt((line_ending, eof)))))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn element_trailing_whitespace<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> { fn element_trailing_whitespace<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, OrgSource<'s>> {
start_of_line(input)?; start_of_line(input)?;
alt((eof, recognize(many0(blank_line))))(input) alt((eof, recognize(many0(blank_line))))(input)
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn maybe_consume_object_trailing_whitespace_if_not_exiting<'b, 'g, 'r, 's>( pub(crate) fn maybe_consume_object_trailing_whitespace_if_not_exiting<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Option<OrgSource<'s>>> { ) -> Res<OrgSource<'s>, Option<OrgSource<'s>>> {
@ -104,7 +104,7 @@ use crate::error::Res;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn maybe_consume_trailing_whitespace_if_not_exiting<'b, 'g, 'r, 's>( pub(crate) fn maybe_consume_trailing_whitespace_if_not_exiting<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Option<OrgSource<'s>>> { ) -> Res<OrgSource<'s>, Option<OrgSource<'s>>> {
@ -117,7 +117,7 @@ use crate::error::Res;
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn maybe_consume_trailing_whitespace<'b, 'g, 'r, 's>( pub(crate) fn maybe_consume_trailing_whitespace<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, Option<OrgSource<'s>>> { ) -> Res<OrgSource<'s>, Option<OrgSource<'s>>> {
@ -130,7 +130,7 @@ use crate::error::Res;
/// Check that we are at the start of a line /// Check that we are at the start of a line
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn start_of_line<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> { pub(crate) fn start_of_line<'s>(input: OrgSource<'s>) -> Res<OrgSource<'s>, ()> {
if input.is_at_start_of_line() { if input.is_at_start_of_line() {
Ok((input, ())) Ok((input, ()))
} else { } else {
@ -140,7 +140,7 @@ use crate::error::Res;
} }
} }
fn preceded_by_whitespace( pub(crate) fn preceded_by_whitespace(
allow_start_of_file: bool, allow_start_of_file: bool,
) -> impl for<'s> Fn(OrgSource<'s>) -> Res<OrgSource<'s>, ()> { ) -> impl for<'s> Fn(OrgSource<'s>) -> Res<OrgSource<'s>, ()> {
move |input| _preceded_by_whitespace(allow_start_of_file, input) move |input| _preceded_by_whitespace(allow_start_of_file, input)
@ -168,13 +168,13 @@ fn _preceded_by_whitespace<'s>(
/// ///
/// This function only operates on spaces, tabs, carriage returns, and line feeds. It does not handle fancy unicode whitespace. /// This function only operates on spaces, tabs, carriage returns, and line feeds. It does not handle fancy unicode whitespace.
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn non_whitespace_character(input: OrgSource<'_>) -> Res<OrgSource<'_>, char> { pub(crate) fn non_whitespace_character(input: OrgSource<'_>) -> Res<OrgSource<'_>, char> {
none_of(" \t\r\n")(input) none_of(" \t\r\n")(input)
} }
/// Check that we are at the start of a line /// Check that we are at the start of a line
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn exit_matcher_parser<'b, 'g, 'r, 's>( pub(crate) fn exit_matcher_parser<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, OrgSource<'s>> { ) -> Res<OrgSource<'s>, OrgSource<'s>> {
@ -182,7 +182,7 @@ fn _preceded_by_whitespace<'s>(
} }
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn text_until_exit<'b, 'g, 'r, 's>( pub(crate) fn text_until_exit<'b, 'g, 'r, 's>(
context: RefContext<'b, 'g, 'r, 's>, context: RefContext<'b, 'g, 'r, 's>,
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Res<OrgSource<'s>, OrgSource<'s>> { ) -> Res<OrgSource<'s>, OrgSource<'s>> {
@ -193,7 +193,7 @@ fn _preceded_by_whitespace<'s>(
} }
#[allow(dead_code)] #[allow(dead_code)]
fn not_yet_implemented() -> Res<OrgSource<'static>, ()> { fn not_yet_implemented() -> Res<OrgSource<'static>, ()> {
return Err(nom::Err::Error(CustomError::MyError(MyError( return Err(nom::Err::Error(CustomError::MyError(MyError(
"Not implemented yet.".into(), "Not implemented yet.".into(),
)))); ))));
@ -204,7 +204,7 @@ fn _preceded_by_whitespace<'s>(
/// Text from the current point until the next line break or end of file /// Text from the current point until the next line break or end of file
/// ///
/// Useful for debugging. /// Useful for debugging.
fn text_until_eol<'r, 's>( fn text_until_eol<'r, 's>(
input: OrgSource<'s>, input: OrgSource<'s>,
) -> Result<&'s str, nom::Err<CustomError<OrgSource<'s>>>> { ) -> Result<&'s str, nom::Err<CustomError<OrgSource<'s>>>> {
let line = recognize(many_till(anychar, alt((line_ending, eof))))(input) let line = recognize(many_till(anychar, alt((line_ending, eof))))(input)
@ -212,7 +212,7 @@ fn _preceded_by_whitespace<'s>(
Ok(line.trim()) Ok(line.trim())
} }
fn include_input<'s, F, O>( pub(crate) fn include_input<'s, F, O>(
mut inner: F, mut inner: F,
) -> impl FnMut(OrgSource<'s>) -> Res<OrgSource<'s>, (OrgSource<'s>, O)> ) -> impl FnMut(OrgSource<'s>) -> Res<OrgSource<'s>, (OrgSource<'s>, O)>
where where

View File

@ -2,42 +2,42 @@ use super::Element;
use super::Object; use super::Object;
use super::Source; use super::Source;
type PriorityCookie = u8; pub type PriorityCookie = u8;
#[derive(Debug)] #[derive(Debug)]
struct Document<'s> { pub struct Document<'s> {
source: &'s str, pub source: &'s str,
zeroth_section: Option<Section<'s>>, pub zeroth_section: Option<Section<'s>>,
children: Vec<Heading<'s>>, pub children: Vec<Heading<'s>>,
} }
#[derive(Debug)] #[derive(Debug)]
struct Heading<'s> { pub struct Heading<'s> {
source: &'s str, pub source: &'s str,
stars: usize, pub stars: usize,
todo_keyword: Option<(TodoKeywordType, &'s str)>, pub todo_keyword: Option<(TodoKeywordType, &'s str)>,
priority_cookie: Option<PriorityCookie>, pub priority_cookie: Option<PriorityCookie>,
title: Vec<Object<'s>>, pub title: Vec<Object<'s>>,
tags: Vec<&'s str>, pub tags: Vec<&'s str>,
children: Vec<DocumentElement<'s>>, pub children: Vec<DocumentElement<'s>>,
is_comment: bool, pub is_comment: bool,
is_archived: bool, pub is_archived: bool,
} }
#[derive(Debug)] #[derive(Debug)]
struct Section<'s> { pub struct Section<'s> {
source: &'s str, pub source: &'s str,
children: Vec<Element<'s>>, pub children: Vec<Element<'s>>,
} }
#[derive(Debug)] #[derive(Debug)]
enum DocumentElement<'s> { pub enum DocumentElement<'s> {
Heading(Heading<'s>), Heading(Heading<'s>),
Section(Section<'s>), Section(Section<'s>),
} }
#[derive(Debug)] #[derive(Debug)]
enum TodoKeywordType { pub enum TodoKeywordType {
Todo, Todo,
Done, Done,
} }

View File

@ -23,7 +23,7 @@ use super::SetSource;
use super::Source; use super::Source;
#[derive(Debug)] #[derive(Debug)]
enum Element<'s> { pub enum Element<'s> {
Paragraph(Paragraph<'s>), Paragraph(Paragraph<'s>),
PlainList(PlainList<'s>), PlainList(PlainList<'s>),
GreaterBlock(GreaterBlock<'s>), GreaterBlock(GreaterBlock<'s>),
@ -51,28 +51,28 @@ use super::Source;
impl<'s> Source<'s> for Element<'s> { impl<'s> Source<'s> for Element<'s> {
fn get_source(&'s self) -> &'s str { fn get_source(&'s self) -> &'s str {
match self { match self {
Element::Paragraph(obj) => obj.source, Element::Paragraph(obj) => obj.get_source(),
Element::PlainList(obj) => obj.source, Element::PlainList(obj) => obj.get_source(),
Element::GreaterBlock(obj) => obj.source, Element::GreaterBlock(obj) => obj.get_source(),
Element::DynamicBlock(obj) => obj.source, Element::DynamicBlock(obj) => obj.get_source(),
Element::FootnoteDefinition(obj) => obj.source, Element::FootnoteDefinition(obj) => obj.get_source(),
Element::Comment(obj) => obj.source, Element::Comment(obj) => obj.get_source(),
Element::Drawer(obj) => obj.source, Element::Drawer(obj) => obj.get_source(),
Element::PropertyDrawer(obj) => obj.source, Element::PropertyDrawer(obj) => obj.get_source(),
Element::Table(obj) => obj.source, Element::Table(obj) => obj.get_source(),
Element::VerseBlock(obj) => obj.source, Element::VerseBlock(obj) => obj.get_source(),
Element::CommentBlock(obj) => obj.source, Element::CommentBlock(obj) => obj.get_source(),
Element::ExampleBlock(obj) => obj.source, Element::ExampleBlock(obj) => obj.get_source(),
Element::ExportBlock(obj) => obj.source, Element::ExportBlock(obj) => obj.get_source(),
Element::SrcBlock(obj) => obj.source, Element::SrcBlock(obj) => obj.get_source(),
Element::Clock(obj) => obj.source, Element::Clock(obj) => obj.get_source(),
Element::DiarySexp(obj) => obj.source, Element::DiarySexp(obj) => obj.get_source(),
Element::Planning(obj) => obj.source, Element::Planning(obj) => obj.get_source(),
Element::FixedWidthArea(obj) => obj.source, Element::FixedWidthArea(obj) => obj.get_source(),
Element::HorizontalRule(obj) => obj.source, Element::HorizontalRule(obj) => obj.get_source(),
Element::Keyword(obj) => obj.source, Element::Keyword(obj) => obj.get_source(),
Element::BabelCall(obj) => obj.source, Element::BabelCall(obj) => obj.get_source(),
Element::LatexEnvironment(obj) => obj.source, Element::LatexEnvironment(obj) => obj.get_source(),
} }
} }
} }

View File

@ -5,73 +5,73 @@ use super::Object;
use super::Source; use super::Source;
#[derive(Debug)] #[derive(Debug)]
struct PlainList<'s> { pub struct PlainList<'s> {
source: &'s str, pub source: &'s str,
children: Vec<PlainListItem<'s>>, pub children: Vec<PlainListItem<'s>>,
} }
#[derive(Debug)] #[derive(Debug)]
struct PlainListItem<'s> { pub struct PlainListItem<'s> {
source: &'s str, pub source: &'s str,
indentation: usize, pub indentation: usize,
bullet: &'s str, pub bullet: &'s str,
tag: Vec<Object<'s>>, pub tag: Vec<Object<'s>>,
children: Vec<Element<'s>>, pub children: Vec<Element<'s>>,
} }
#[derive(Debug)] #[derive(Debug)]
struct GreaterBlock<'s> { pub struct GreaterBlock<'s> {
source: &'s str, pub source: &'s str,
name: &'s str, pub name: &'s str,
parameters: Option<&'s str>, pub parameters: Option<&'s str>,
children: Vec<Element<'s>>, pub children: Vec<Element<'s>>,
} }
#[derive(Debug)] #[derive(Debug)]
struct DynamicBlock<'s> { pub struct DynamicBlock<'s> {
source: &'s str, pub source: &'s str,
name: &'s str, pub name: &'s str,
parameters: Option<&'s str>, pub parameters: Option<&'s str>,
children: Vec<Element<'s>>, pub children: Vec<Element<'s>>,
} }
#[derive(Debug)] #[derive(Debug)]
struct FootnoteDefinition<'s> { pub struct FootnoteDefinition<'s> {
source: &'s str, pub source: &'s str,
label: &'s str, pub label: &'s str,
children: Vec<Element<'s>>, pub children: Vec<Element<'s>>,
} }
#[derive(Debug)] #[derive(Debug)]
struct Drawer<'s> { pub struct Drawer<'s> {
source: &'s str, pub source: &'s str,
name: &'s str, pub name: &'s str,
children: Vec<Element<'s>>, pub children: Vec<Element<'s>>,
} }
#[derive(Debug)] #[derive(Debug)]
struct PropertyDrawer<'s> { pub struct PropertyDrawer<'s> {
source: &'s str, pub source: &'s str,
children: Vec<NodeProperty<'s>>, pub children: Vec<NodeProperty<'s>>,
} }
#[derive(Debug)] #[derive(Debug)]
struct NodeProperty<'s> { pub struct NodeProperty<'s> {
source: &'s str, pub source: &'s str,
value: Option<&'s str>, pub value: Option<&'s str>,
} }
#[derive(Debug)] #[derive(Debug)]
struct Table<'s> { pub struct Table<'s> {
source: &'s str, pub source: &'s str,
formulas: Vec<Keyword<'s>>, pub formulas: Vec<Keyword<'s>>,
children: Vec<TableRow<'s>>, pub children: Vec<TableRow<'s>>,
} }
#[derive(Debug)] #[derive(Debug)]
struct TableRow<'s> { pub struct TableRow<'s> {
source: &'s str, pub source: &'s str,
children: Vec<TableCell<'s>>, pub children: Vec<TableCell<'s>>,
} }
impl<'s> Source<'s> for PlainList<'s> { impl<'s> Source<'s> for PlainList<'s> {

View File

@ -3,101 +3,101 @@ use super::PlainText;
use super::Source; use super::Source;
#[derive(Debug)] #[derive(Debug)]
struct Paragraph<'s> { pub struct Paragraph<'s> {
source: &'s str, pub source: &'s str,
children: Vec<Object<'s>>, pub children: Vec<Object<'s>>,
} }
#[derive(Debug)] #[derive(Debug)]
struct Comment<'s> { pub struct Comment<'s> {
source: &'s str, pub source: &'s str,
} }
#[derive(Debug)] #[derive(Debug)]
struct TableCell<'s> { pub struct TableCell<'s> {
source: &'s str, pub source: &'s str,
children: Vec<Object<'s>>, pub children: Vec<Object<'s>>,
} }
#[derive(Debug)] #[derive(Debug)]
struct VerseBlock<'s> { pub struct VerseBlock<'s> {
source: &'s str, pub source: &'s str,
name: &'s str, pub name: &'s str,
data: Option<&'s str>, pub data: Option<&'s str>,
children: Vec<Object<'s>>, pub children: Vec<Object<'s>>,
} }
#[derive(Debug)] #[derive(Debug)]
struct CommentBlock<'s> { pub struct CommentBlock<'s> {
source: &'s str, pub source: &'s str,
name: &'s str, pub name: &'s str,
data: Option<&'s str>, pub data: Option<&'s str>,
contents: &'s str, pub contents: &'s str,
} }
#[derive(Debug)] #[derive(Debug)]
struct ExampleBlock<'s> { pub struct ExampleBlock<'s> {
source: &'s str, pub source: &'s str,
name: &'s str, pub name: &'s str,
data: Option<&'s str>, pub data: Option<&'s str>,
contents: &'s str, pub contents: &'s str,
} }
#[derive(Debug)] #[derive(Debug)]
struct ExportBlock<'s> { pub struct ExportBlock<'s> {
source: &'s str, pub source: &'s str,
name: &'s str, pub name: &'s str,
data: Option<&'s str>, pub data: Option<&'s str>,
contents: &'s str, pub contents: &'s str,
} }
#[derive(Debug)] #[derive(Debug)]
struct SrcBlock<'s> { pub struct SrcBlock<'s> {
source: &'s str, pub source: &'s str,
name: &'s str, pub name: &'s str,
data: Option<&'s str>, pub data: Option<&'s str>,
contents: &'s str, pub contents: &'s str,
} }
#[derive(Debug)] #[derive(Debug)]
struct Clock<'s> { pub struct Clock<'s> {
source: &'s str, pub source: &'s str,
} }
#[derive(Debug)] #[derive(Debug)]
struct DiarySexp<'s> { pub struct DiarySexp<'s> {
source: &'s str, pub source: &'s str,
} }
#[derive(Debug)] #[derive(Debug)]
struct Planning<'s> { pub struct Planning<'s> {
source: &'s str, pub source: &'s str,
} }
#[derive(Debug)] #[derive(Debug)]
struct FixedWidthArea<'s> { pub struct FixedWidthArea<'s> {
source: &'s str, pub source: &'s str,
} }
#[derive(Debug)] #[derive(Debug)]
struct HorizontalRule<'s> { pub struct HorizontalRule<'s> {
source: &'s str, pub source: &'s str,
} }
#[derive(Debug)] #[derive(Debug)]
struct Keyword<'s> { pub struct Keyword<'s> {
source: &'s str, pub source: &'s str,
key: &'s str, pub key: &'s str,
value: &'s str, pub value: &'s str,
} }
#[derive(Debug)] #[derive(Debug)]
struct LatexEnvironment<'s> { pub struct LatexEnvironment<'s> {
source: &'s str, pub source: &'s str,
} }
impl<'s> Paragraph<'s> { impl<'s> Paragraph<'s> {
fn of_text(input: &'s str) -> Self { pub(crate) fn of_text(input: &'s str) -> Self {
let mut objects = Vec::with_capacity(1); let mut objects = Vec::with_capacity(1);
objects.push(Object::PlainText(PlainText { source: input })); objects.push(Object::PlainText(PlainText { source: input }));
Paragraph { Paragraph {

View File

@ -4,65 +4,65 @@ mod greater_element;
mod lesser_element; mod lesser_element;
mod object; mod object;
mod source; mod source;
use document::Document; pub use document::Document;
use document::DocumentElement; pub use document::DocumentElement;
use document::Heading; pub use document::Heading;
use document::PriorityCookie; pub use document::PriorityCookie;
use document::Section; pub use document::Section;
use document::TodoKeywordType; pub use document::TodoKeywordType;
use element::Element; pub use element::Element;
use greater_element::Drawer; pub use greater_element::Drawer;
use greater_element::DynamicBlock; pub use greater_element::DynamicBlock;
use greater_element::FootnoteDefinition; pub use greater_element::FootnoteDefinition;
use greater_element::GreaterBlock; pub use greater_element::GreaterBlock;
use greater_element::NodeProperty; pub use greater_element::NodeProperty;
use greater_element::PlainList; pub use greater_element::PlainList;
use greater_element::PlainListItem; pub use greater_element::PlainListItem;
use greater_element::PropertyDrawer; pub use greater_element::PropertyDrawer;
use greater_element::Table; pub use greater_element::Table;
use greater_element::TableRow; pub use greater_element::TableRow;
use lesser_element::Clock; pub use lesser_element::Clock;
use lesser_element::Comment; pub use lesser_element::Comment;
use lesser_element::CommentBlock; pub use lesser_element::CommentBlock;
use lesser_element::DiarySexp; pub use lesser_element::DiarySexp;
use lesser_element::ExampleBlock; pub use lesser_element::ExampleBlock;
use lesser_element::ExportBlock; pub use lesser_element::ExportBlock;
use lesser_element::FixedWidthArea; pub use lesser_element::FixedWidthArea;
use lesser_element::HorizontalRule; pub use lesser_element::HorizontalRule;
use lesser_element::Keyword; pub use lesser_element::Keyword;
use lesser_element::LatexEnvironment; pub use lesser_element::LatexEnvironment;
use lesser_element::Paragraph; pub use lesser_element::Paragraph;
use lesser_element::Planning; pub use lesser_element::Planning;
use lesser_element::SrcBlock; pub use lesser_element::SrcBlock;
use lesser_element::TableCell; pub use lesser_element::TableCell;
use lesser_element::VerseBlock; pub use lesser_element::VerseBlock;
use object::AngleLink; pub use object::AngleLink;
use object::Bold; pub use object::Bold;
use object::Citation; pub use object::Citation;
use object::CitationReference; pub use object::CitationReference;
use object::Code; pub use object::Code;
use object::Entity; pub use object::Entity;
use object::ExportSnippet; pub use object::ExportSnippet;
use object::FootnoteReference; pub use object::FootnoteReference;
use object::InlineBabelCall; pub use object::InlineBabelCall;
use object::InlineSourceBlock; pub use object::InlineSourceBlock;
use object::Italic; pub use object::Italic;
use object::LatexFragment; pub use object::LatexFragment;
use object::LineBreak; pub use object::LineBreak;
use object::Object; pub use object::Object;
use object::OrgMacro; pub use object::OrgMacro;
use object::PlainLink; pub use object::PlainLink;
use object::PlainText; pub use object::PlainText;
use object::RadioLink; pub use object::RadioLink;
use object::RadioTarget; pub use object::RadioTarget;
use object::RegularLink; pub use object::RegularLink;
use object::StatisticsCookie; pub use object::StatisticsCookie;
use object::StrikeThrough; pub use object::StrikeThrough;
use object::Subscript; pub use object::Subscript;
use object::Superscript; pub use object::Superscript;
use object::Target; pub use object::Target;
use object::Timestamp; pub use object::Timestamp;
use object::Underline; pub use object::Underline;
use object::Verbatim; pub use object::Verbatim;
use source::SetSource; pub use source::SetSource;
use source::Source; pub use source::Source;

View File

@ -1,7 +1,7 @@
use super::Source; use super::Source;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
enum Object<'s> { pub enum Object<'s> {
Bold(Bold<'s>), Bold(Bold<'s>),
Italic(Italic<'s>), Italic(Italic<'s>),
Underline(Underline<'s>), Underline(Underline<'s>),
@ -32,157 +32,157 @@ use super::Source;
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct Bold<'s> { pub struct Bold<'s> {
source: &'s str, pub source: &'s str,
children: Vec<Object<'s>>, pub children: Vec<Object<'s>>,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct Italic<'s> { pub struct Italic<'s> {
source: &'s str, pub source: &'s str,
children: Vec<Object<'s>>, pub children: Vec<Object<'s>>,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct Underline<'s> { pub struct Underline<'s> {
source: &'s str, pub source: &'s str,
children: Vec<Object<'s>>, pub children: Vec<Object<'s>>,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct StrikeThrough<'s> { pub struct StrikeThrough<'s> {
source: &'s str, pub source: &'s str,
children: Vec<Object<'s>>, pub children: Vec<Object<'s>>,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct Code<'s> { pub struct Code<'s> {
source: &'s str, pub source: &'s str,
contents: &'s str, pub contents: &'s str,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct Verbatim<'s> { pub struct Verbatim<'s> {
source: &'s str, pub source: &'s str,
contents: &'s str, pub contents: &'s str,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct PlainText<'s> { pub struct PlainText<'s> {
source: &'s str, pub source: &'s str,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct RegularLink<'s> { pub struct RegularLink<'s> {
source: &'s str, pub source: &'s str,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct RadioTarget<'s> { pub struct RadioTarget<'s> {
source: &'s str, pub source: &'s str,
children: Vec<Object<'s>>, pub children: Vec<Object<'s>>,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct RadioLink<'s> { pub struct RadioLink<'s> {
source: &'s str, pub source: &'s str,
children: Vec<Object<'s>>, pub children: Vec<Object<'s>>,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct PlainLink<'s> { pub struct PlainLink<'s> {
source: &'s str, pub source: &'s str,
link_type: &'s str, pub link_type: &'s str,
path: &'s str, pub path: &'s str,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct AngleLink<'s> { pub struct AngleLink<'s> {
source: &'s str, pub source: &'s str,
link_type: &'s str, pub link_type: &'s str,
path: &'s str, pub path: &'s str,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct OrgMacro<'s> { pub struct OrgMacro<'s> {
source: &'s str, pub source: &'s str,
macro_name: &'s str, pub macro_name: &'s str,
macro_args: Vec<&'s str>, pub macro_args: Vec<&'s str>,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct Entity<'s> { pub struct Entity<'s> {
source: &'s str, pub source: &'s str,
entity_name: &'s str, pub entity_name: &'s str,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct LatexFragment<'s> { pub struct LatexFragment<'s> {
source: &'s str, pub source: &'s str,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct ExportSnippet<'s> { pub struct ExportSnippet<'s> {
source: &'s str, pub source: &'s str,
backend: &'s str, pub backend: &'s str,
contents: Option<&'s str>, pub contents: Option<&'s str>,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct FootnoteReference<'s> { pub struct FootnoteReference<'s> {
source: &'s str, pub source: &'s str,
label: Option<&'s str>, pub label: Option<&'s str>,
definition: Vec<Object<'s>>, pub definition: Vec<Object<'s>>,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct Citation<'s> { pub struct Citation<'s> {
source: &'s str, pub source: &'s str,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct CitationReference<'s> { pub struct CitationReference<'s> {
source: &'s str, pub source: &'s str,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct InlineBabelCall<'s> { pub struct InlineBabelCall<'s> {
source: &'s str, pub source: &'s str,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct InlineSourceBlock<'s> { pub struct InlineSourceBlock<'s> {
source: &'s str, pub source: &'s str,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct LineBreak<'s> { pub struct LineBreak<'s> {
source: &'s str, pub source: &'s str,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct Target<'s> { pub struct Target<'s> {
source: &'s str, pub source: &'s str,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct StatisticsCookie<'s> { pub struct StatisticsCookie<'s> {
source: &'s str, pub source: &'s str,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct Subscript<'s> { pub struct Subscript<'s> {
source: &'s str, pub source: &'s str,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct Superscript<'s> { pub struct Superscript<'s> {
source: &'s str, pub source: &'s str,
} }
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
struct Timestamp<'s> { pub struct Timestamp<'s> {
source: &'s str, pub source: &'s str,
} }
impl<'s> Source<'s> for Object<'s> { impl<'s> Source<'s> for Object<'s> {

View File

@ -1,6 +1,6 @@
trait Source<'s> { pub trait Source<'s> {
fn get_source(&'s self) -> &'s str; fn get_source(&'s self) -> &'s str;
} }
trait SetSource<'s> { pub trait SetSource<'s> {
fn set_source(&mut self, source: &'s str); fn set_source(&mut self, source: &'s str);
} }