Skip to content

Commit

Permalink
fix(fancy): style underscore with surrounding spaces (resolves #203)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jun 27, 2023
1 parent f09c758 commit bbed122
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion examples/special.ts
Expand Up @@ -18,7 +18,9 @@ consola.error(undefined, null, false, true, Number.NaN);

consola.log("We can `monospace` keyword using grave accent charachter!");

consola.log("We can also _underline_ words!");
consola.log(
"We can also _underline_ words but not_this or this should_not_be_underlined!"
);

// Nonstandard error
const { message, stack } = new Error("Custom Error!");
Expand Down
2 changes: 1 addition & 1 deletion src/reporters/fancy.ts
Expand Up @@ -129,7 +129,7 @@ function characterFormat(str: string) {
// highlight backticks
.replace(/`([^`]+)`/gm, (_, m) => colors.cyan(m))
// underline underscores
.replace(/_([^_]+)_/gm, (_, m) => colors.underline(m))
.replace(/\s+_([^_]+)_\s+/gm, (_, m) => ` ${colors.underline(m)} `)
);
}

Expand Down

0 comments on commit bbed122

Please sign in to comment.