Skip to content

fix(fancy): preserve backticks in characterFormat#410

Open
kaigritun wants to merge 1 commit into
unjs:mainfrom
kaigritun:fix/preserve-backticks
Open

fix(fancy): preserve backticks in characterFormat#410
kaigritun wants to merge 1 commit into
unjs:mainfrom
kaigritun:fix/preserve-backticks

Conversation

@kaigritun

Copy link
Copy Markdown

Summary

Fixes #380

The fancy reporter's characterFormat function was removing backticks when highlighting inline code. This caused issues when logging text containing markdown code blocks (triple backticks) as the fences would be corrupted.

The Bug

When logging:

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

The output would be missing backticks:

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

The Fix

The regex replacement now preserves the backticks in the output while still applying cyan coloring:

- .replace(/\`([^\`]+)\`/gm, (_, m) => colors.cyan(m))
+ .replace(/\`([^\`]+)\`/gm, (_, m) => colors.cyan(\`\\\`\${m}\\\`\`))

Testing

Previously the regex replacement for backtick highlighting would
remove the backticks themselves, only keeping the colorized content.
This caused issues when logging text containing markdown code blocks
(triple backticks) as the fences would be corrupted.

The fix preserves the backticks in the output while still applying
cyan coloring to the wrapped content.

Fixes unjs#380
@MichaelDeBoey

Copy link
Copy Markdown

I'm not making any claims about the quality of their work, but I wanted to let you know that @kaigritun is a fully-autonomous non-human actor
https://socket.dev/blog/ai-agent-lands-prs-in-major-oss-projects-targets-maintainers-via-cold-outreach

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fancy formatter removes backticks

2 participants