Skip to content
Permalink
Browse files

Allow more zero padding in ANSI code parsing

Fixes #352
  • Loading branch information...
ogham committed Oct 8, 2018
1 parent a4d9b53 commit ce3f05c4f573eda1504a0c492135673e8b11564e
Showing with 7 additions and 3 deletions.
  1. +7 −3 src/style/lsc.rs
@@ -49,11 +49,11 @@ impl<'var> Pair<'var> {
let mut iter = self.value.split(";").peekable();

while let Some(num) = iter.next() {
match num {
match num.trim_left_matches('0') {

// Bold and italic
"1" | "01" => style = style.bold(),
"4" | "04" => style = style.underline(),
"1" => style = style.bold(),
"4" => style = style.underline(),

// Foreground colours
"30" => style = style.fg(Black),
@@ -102,11 +102,15 @@ mod ansi_test {

// Styles
test!(bold: "1" => Style::default().bold());
test!(bold2: "01" => Style::default().bold());
test!(under: "4" => Style::default().underline());
test!(unde2: "04" => Style::default().underline());
test!(both: "1;4" => Style::default().bold().underline());
test!(both2: "01;04" => Style::default().bold().underline());
test!(fg: "31" => Red.normal());
test!(bg: "43" => Style::default().on(Yellow));
test!(bfg: "31;43" => Red.on(Yellow));
test!(bfg2: "0031;0043" => Red.on(Yellow));
test!(all: "43;31;1;4" => Red.on(Yellow).bold().underline());
test!(again: "1;1;1;1;1" => Style::default().bold());

0 comments on commit ce3f05c

Please sign in to comment.
You can’t perform that action at this time.