fn write_spans_for_tokens(&mut self, line: &str, ops: &[(usize, ScopeStackOp)]) {
        let mut cur_index = 0;

        // check and skip empty inner <span> tags
        let mut span_empty = false;
        let mut span_start = 0;

        for &(i, ref op) in ops {
            if i > cur_index {
                span_empty = false;
                self.write_escaped_html(&line[cur_index..i]);
                cur_index = i
            }
            let mut stack = self.stack.clone();
            stack.apply_with_hook(op, |basic_op, _| match basic_op {
                BasicScopeStackOp::Push(scope) => {
                    span_start = self.html.len();
                    span_empty = true;
                    self.open_scope(&scope);
                }
                BasicScopeStackOp::Pop => {
                    if span_empty {
                        self.html.truncate(span_start);
                    } else {
                        self.close_scope();
                    }
                    span_empty = false;
                }
            });
            self.stack = stack;
        }
        self.write_escaped_html(&line[cur_index..]);
    }
// write_spans_for_tokens creates spans for the list of tokens passed to it.
// It modifies the stack of the ClassedTableGenerator, adding any scopes
// that are unclosed at the end of the line.
//
// This is modified from highlight::tokens_to_classed_spans
write_spans_for_tokens creates spans for the list of tokens passed to it.
It modifies the stack of the ClassedTableGenerator, adding any scopes
that are unclosed at the end of the line.

This is modified from highlight::tokens_to_classed_spans
write_spans_for_tokens creates spans for the list of tokens passed to it . It modifies the stack of the ClassedTableGenerator adding any scopes that are unclosed at the end of the line . This is modified from highlight :: tokens_to_classed_spans
fn write_spans_for_tokens(&mut self, line: &str, ops: &[(usize, ScopeStackOp)]) {
        let mut cur_index = 0;
        // check and skip empty inner <span> tags
        let mut span_empty = false;
        let mut span_start = 0;
        for &(i, ref op) in ops {
            if i > cur_index {
                span_empty = false;
                self.write_escaped_html(&line[cur_index..i]);
                cur_index = i
            }
            let mut stack = self.stack.clone();
            stack.apply_with_hook(op, |basic_op, _| match basic_op {
                BasicScopeStackOp::Push(scope) => {
                    span_start = self.html.len();
                    span_empty = true;
                    self.open_scope(&scope);
                }
                BasicScopeStackOp::Pop => {
                    if span_empty {
                        self.html.truncate(span_start);
                    } else {
                        self.close_scope();
                    }
                    span_empty = false;
                }
            });
            self.stack = stack;
        }
        self.write_escaped_html(&line[cur_index..]);
    }
fn write_spans_for_tokens ( & mut self , line : & str , ops : & [ ( usize , ScopeStackOp ) ] ) { let mut cur_index = 0 ; // check and skip empty inner <span> tags let mut span_empty = false ; let mut span_start = 0 ; for & ( i , ref op ) in ops { if i > cur_index { span_empty = false ; self . write_escaped_html ( & line [ cur_index .. i ] ) ; cur_index = i } let mut stack = self . stack . clone ( ) ; stack . apply_with_hook ( op , | basic_op , _ | match basic_op { BasicScopeStackOp :: Push ( scope ) => { span_start = self . html . len ( ) ; span_empty = true ; self . open_scope ( & scope ) ; } BasicScopeStackOp :: Pop => { if span_empty { self . html . truncate ( span_start ) ; } else { self . close_scope ( ) ; } span_empty = false ; } } ) ; self . stack = stack ; } self . write_escaped_html ( & line [ cur_index .. ] ) ; }
write_spans_for_tokens creates spans for the list of tokens passed to it.
write_spans_for_tokens creates spans for the list of tokens passed to it .
&mut self
line
&str
ops
&[(usize, ScopeStackOp)]
&mut self
line
&str
ops
&[(usize, ScopeStackOp)]