Skip to content

Fancy formatter removes backticks #380

Description

@stafyniaksacha

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions