fix: verify use_sub_superscript
This commit is contained in:
parent
5bc15d80ff
commit
f150af7341
3 changed files with 12 additions and 16 deletions
|
|
@ -1,7 +1,7 @@
|
|||
#![doc = include_str!("../README.md")]
|
||||
|
||||
pub mod ast;
|
||||
mod config;
|
||||
pub mod config;
|
||||
mod entities;
|
||||
pub mod export;
|
||||
mod org;
|
||||
|
|
|
|||
|
|
@ -128,16 +128,8 @@ pub fn minimal_object_nodes(input: Input) -> Vec<GreenElement> {
|
|||
b'~' if emphasis::verify_pre(pre.s) => code_node(i),
|
||||
b'$' => latex_fragment_node(i),
|
||||
b'\\' => entity_node(i).or_else(|_| latex_fragment_node(i)),
|
||||
b'^' if !input.c.use_sub_superscript.is_nil()
|
||||
&& subscript_superscript::verify_pre(pre.s) =>
|
||||
{
|
||||
superscript_node(i)
|
||||
}
|
||||
b'_' if !input.c.use_sub_superscript.is_nil()
|
||||
&& subscript_superscript::verify_pre(pre.s) =>
|
||||
{
|
||||
subscript_node(i)
|
||||
}
|
||||
b'^' if subscript_superscript::verify_pre(&pre) => superscript_node(i),
|
||||
b'_' if subscript_superscript::verify_pre(&pre) => subscript_node(i),
|
||||
_ => Err(nom::Err::Error(())),
|
||||
},
|
||||
input,
|
||||
|
|
@ -199,8 +191,8 @@ pub fn standard_object_nodes(input: Input) -> Vec<GreenElement> {
|
|||
b'$' => latex_fragment_node(i),
|
||||
b'\\' if !pre.s.ends_with('\\') && i.as_bytes()[1] == b'\\' => line_break_node(i),
|
||||
b'\\' => entity_node(i).or_else(|_| latex_fragment_node(i)),
|
||||
b'^' if subscript_superscript::verify_pre(pre.s) => superscript_node(i),
|
||||
b'_' if subscript_superscript::verify_pre(pre.s) => subscript_node(i),
|
||||
b'^' if subscript_superscript::verify_pre(&pre) => superscript_node(i),
|
||||
b'_' if subscript_superscript::verify_pre(&pre) => subscript_node(i),
|
||||
_ => Err(nom::Err::Error(())),
|
||||
},
|
||||
input,
|
||||
|
|
@ -224,8 +216,8 @@ pub fn link_description_object_nodes(input: Input) -> Vec<GreenElement> {
|
|||
b'~' if emphasis::verify_pre(pre.s) => code_node(i),
|
||||
b'$' => latex_fragment_node(i),
|
||||
b'\\' => entity_node(i).or_else(|_| latex_fragment_node(i)),
|
||||
b'^' if subscript_superscript::verify_pre(pre.s) => superscript_node(i),
|
||||
b'_' if subscript_superscript::verify_pre(pre.s) => subscript_node(i),
|
||||
b'^' if subscript_superscript::verify_pre(&pre) => superscript_node(i),
|
||||
b'_' if subscript_superscript::verify_pre(&pre) => subscript_node(i),
|
||||
_ => Err(nom::Err::Error(())),
|
||||
},
|
||||
input,
|
||||
|
|
|
|||
|
|
@ -105,7 +105,11 @@ fn balanced_brackets(input: Input) -> IResult<Input, Input, ()> {
|
|||
Err(nom::Err::Error(()))
|
||||
}
|
||||
|
||||
pub fn verify_pre(s: &str) -> bool {
|
||||
pub fn verify_pre(i: &Input) -> bool {
|
||||
if i.c.use_sub_superscript.is_nil() {
|
||||
return false;
|
||||
}
|
||||
let s = i.s;
|
||||
if s.is_empty() {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue