mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 19:47:53 +00:00
craft-math: latex_text's group finders are public, for craft-latex's length parser
This commit is contained in:
@@ -205,7 +205,7 @@ fn math_symbol(name: &str) -> Option<char> {
|
||||
/// For every `l` in `chars`, the index of the `r` that closes it, found in one stack pass.
|
||||
/// Looking groups up here keeps scanning linear: rescanning to the end of the input for every
|
||||
/// unmatched `(` made long equations quadratic.
|
||||
pub(super) fn closers(chars: &[char], l: char, r: char) -> Vec<Option<usize>> {
|
||||
pub fn closers(chars: &[char], l: char, r: char) -> Vec<Option<usize>> {
|
||||
let mut out = vec![None; chars.len()];
|
||||
let mut open = Vec::new();
|
||||
for (i, c) in chars.iter().enumerate() {
|
||||
@@ -222,7 +222,7 @@ pub(super) fn closers(chars: &[char], l: char, r: char) -> Vec<Option<usize>> {
|
||||
}
|
||||
|
||||
/// The balanced group opening at `open` (see [`closers`]): its content and the index after it.
|
||||
pub(super) fn balanced(chars: &[char], closers: &[Option<usize>], open: usize) -> Option<(String, usize)> {
|
||||
pub fn balanced(chars: &[char], closers: &[Option<usize>], open: usize) -> Option<(String, usize)> {
|
||||
let close = (*closers.get(open)?)?;
|
||||
Some((chars.get(open + 1..close).unwrap_or_default().iter().collect(), close + 1))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user