When using the C or C++ parser, the '%' character in a string is misinterpreted as a "placeholder".
This can be observed by trying to format "% + 10px". Syntect outputs <span class="constant other placeholder c">% + 10p</span>x instead of the expected % + 10px.
Complete example:
extern crate syntect;
use syntect::util::{LinesWithEndings};
use syntect::html::{ClassedHTMLGenerator, ClassStyle};
fn main() {
let syntax_set = syntect::parsing::SyntaxSet::load_defaults_newlines();
let syntax = syntax_set.find_syntax_by_extension("c++").unwrap();
let mut h = ClassedHTMLGenerator::new_with_class_style(syntax, &syntax_set, ClassStyle::Spaced);
for line in LinesWithEndings::from(r#""% + 10px""#) {
h.parse_html_for_line_which_includes_newline(line).unwrap();
}
assert_eq!(h.finalize(), r#"<span class="source c++"><span class="string quoted double c"><span class="punctuation definition string begin c">"</span>% + 10px<span class="punctuation definition string end c">"</span></span></span>"#);
}
When using the C or C++ parser, the '%' character in a string is misinterpreted as a "placeholder".
This can be observed by trying to format
"% + 10px"
. Syntect outputs<span class="constant other placeholder c">% + 10p</span>x
instead of the expected% + 10px
.Complete example: