Tweak highlight name matching semantics, add doc comments

This commit is contained in:
Max Brunsfeld 2019-10-17 12:03:34 -07:00
parent b79295e1a0
commit 084406148b
3 changed files with 82 additions and 38 deletions

View file

@ -98,7 +98,7 @@ impl Serialize for Theme {
S: Serializer,
{
let mut map = serializer.serialize_map(Some(self.styles.len()))?;
for (name, style) in self.highlighter.highlight_names.iter().zip(&self.styles) {
for (name, style) in self.highlighter.names().iter().zip(&self.styles) {
let style = &style.ansi;
let color = style.foreground.map(|color| match color {
Color::Black => json!("black"),

View file

@ -46,7 +46,7 @@ lazy_static! {
.collect()
);
static ref HTML_ATTRS: Vec<String> = HIGHLIGHTER
.highlight_names
.names()
.iter()
.map(|s| format!("class={}", s))
.collect();
@ -598,9 +598,7 @@ fn to_token_vector<'a>(
)?;
for event in events {
match event? {
HighlightEvent::HighlightStart(s) => {
highlights.push(HIGHLIGHTER.highlight_names[s.0].as_str())
}
HighlightEvent::HighlightStart(s) => highlights.push(HIGHLIGHTER.names()[s.0].as_str()),
HighlightEvent::HighlightEnd => {
highlights.pop();
}