consola icon indicating copy to clipboard operation
consola copied to clipboard

Fancy formatter removes backticks

Open stafyniaksacha opened this issue 9 months ago • 1 comments

Environment

Node v22.x / Bun v1.1.x Tested on WSL / Win

Reproduction

import { consola } from 'consola'

consola.wrapAll() 

const template = [
  '```html',
  '<div>hello</div>',
  '```',

  '```html',
  '<div>hello</div>',
  '```',
].join('\n')

console.log(template)

Actual Output (tested bash / zsh / TERM=dumb sh):

```html
<div>hello</div>
``
`html
<div>hello</div>
``

Expected Output (minus ):

```html
<div>hello</div>
\```
```html
<div>hello</div>
\```

Describe the bug

Using console.log in context where consola.wrapConsole() // consola.wrapStd() was called may result in incorrect output.

I was trying to log two simple markdown code block in nuxt and realized that the output is wrong (I became mad because I did not knew console.log was wrapped)

The second html <div>hello</div> is written in blue, so I guess term caps are the cause, but node test.mjs > log && cat -e log doesn't show them.

Maybe related to backtick highlight ? https://github.com/unjs/consola/blob/main/src/reporters/fancy.ts#L141

stafyniaksacha avatar Apr 04 '25 16:04 stafyniaksacha

I’d like to work on this issue and open a PR to fix the backtick formatting in the fancy reporter.

olllayor avatar Sep 10 '25 08:09 olllayor