Skip to main content

split_targets

Function split_targets 

Source
pub fn split_targets(text: &str) -> Vec<RefTargetText>
Expand description

The targets written in the text of a reference’s target argument: the text split at the commas, each part trimmed and parsed as a label.

The empty text is one target, not none, so that \ref{} has one target, which points at nothing, rather than no target at all.

§Examples

use flm_core::model::aspects::Label;
use flm_core::stdlib::features::refs::split_targets;

let targets = split_targets("sec:intro, eq:euler");
assert_eq!(targets.len(), 2);
assert_eq!(targets[0].label, Some(Label::new("sec", "intro")));
assert_eq!(targets[1].text, "eq:euler");

// A part that is not spelled `type:label` has no label.
assert_eq!(split_targets("nolabel")[0].label, None);