Populate entity fields.
This commit is contained in:
parent
c150aa4dea
commit
ef591556fe
@ -51,7 +51,7 @@ pub struct GlobalSettings<'g, 's> {
|
||||
/// The special characters that can be written in org-mode like \infin for the infinity symbol.
|
||||
///
|
||||
/// Corresponds to org-entities elisp variable.
|
||||
pub entities: &'g [EntityDefinition<'g>],
|
||||
pub entities: &'g [EntityDefinition<'s>],
|
||||
}
|
||||
|
||||
pub const DEFAULT_TAB_WIDTH: IndentationLevel = 8;
|
||||
|
@ -26,6 +26,7 @@ pub(crate) use context::HasAffiliatedKeywordInner;
|
||||
pub(crate) use exiting::ExitClass;
|
||||
pub use file_access_interface::FileAccessInterface;
|
||||
pub use file_access_interface::LocalFileAccessInterface;
|
||||
pub use global_settings::EntityDefinition;
|
||||
pub use global_settings::GlobalSettings;
|
||||
pub use global_settings::HeadlineLevelFilter;
|
||||
pub use global_settings::DEFAULT_TAB_WIDTH;
|
||||
|
@ -8,6 +8,7 @@ use nom::sequence::tuple;
|
||||
|
||||
use super::org_source::OrgSource;
|
||||
use super::util::maybe_consume_object_trailing_whitespace_if_not_exiting;
|
||||
use crate::context::EntityDefinition;
|
||||
use crate::context::RefContext;
|
||||
use crate::error::CustomError;
|
||||
use crate::error::MyError;
|
||||
@ -21,7 +22,7 @@ pub(crate) fn entity<'b, 'g, 'r, 's>(
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, Entity<'s>> {
|
||||
let (remaining, _) = tag("\\")(input)?;
|
||||
let (remaining, entity_name) = name(context, remaining)?;
|
||||
let (remaining, (entity_definition, entity_name)) = name(context, remaining)?;
|
||||
|
||||
let (remaining, _trailing_whitespace) =
|
||||
maybe_consume_object_trailing_whitespace_if_not_exiting(context, remaining)?;
|
||||
@ -32,6 +33,11 @@ pub(crate) fn entity<'b, 'g, 'r, 's>(
|
||||
Entity {
|
||||
source: source.into(),
|
||||
name: entity_name.into(),
|
||||
latex_math_mode: entity_definition.latex_math_mode,
|
||||
latex: entity_definition.latex,
|
||||
html: entity_definition.html,
|
||||
ascii: entity_definition.ascii,
|
||||
utf8: entity_definition.utf8,
|
||||
},
|
||||
))
|
||||
}
|
||||
@ -40,7 +46,7 @@ pub(crate) fn entity<'b, 'g, 'r, 's>(
|
||||
fn name<'b, 'g, 'r, 's>(
|
||||
context: RefContext<'b, 'g, 'r, 's>,
|
||||
input: OrgSource<'s>,
|
||||
) -> Res<OrgSource<'s>, OrgSource<'s>> {
|
||||
) -> Res<OrgSource<'s>, (&'g EntityDefinition<'s>, OrgSource<'s>)> {
|
||||
for entity in context.get_global_settings().entities {
|
||||
let result = tuple((
|
||||
tag::<_, _, CustomError<_>>(entity.name),
|
||||
@ -48,7 +54,7 @@ fn name<'b, 'g, 'r, 's>(
|
||||
))(input);
|
||||
match result {
|
||||
Ok((remaining, (ent, _))) => {
|
||||
return Ok((remaining, ent));
|
||||
return Ok((remaining, (entity, ent)));
|
||||
}
|
||||
Err(_) => {}
|
||||
}
|
||||
|
@ -168,6 +168,12 @@ pub struct OrgMacro<'s> {
|
||||
pub struct Entity<'s> {
|
||||
pub source: &'s str,
|
||||
pub name: &'s str,
|
||||
pub latex_math_mode: bool,
|
||||
pub latex: &'s str,
|
||||
pub html: &'s str,
|
||||
pub ascii: &'s str,
|
||||
// Skipping latin1 because it is detrimental to the future. If anyone out there is using latin1, take a long look in the mirror and change your ways.
|
||||
pub utf8: &'s str,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
|
Loading…
x
Reference in New Issue
Block a user