Coder Social home page Coder Social logo

Comments (5)

raine avatar raine commented on July 21, 2024

Just after opening this issue, I realized that flipping the order in which color styles are applied to the header texts fixes the issue. It appears that doing cyan before bold is causing the problem here. Not sure if there still is a bug in ansi-to-html, though.

raine/ramda-cli@487010e

from ansi-to-html.

rburns avatar rburns commented on July 21, 2024

It appears to me that the 22 escaped code may be ignored as the previous opening bold tag is not on the top of the stack. https://github.com/rburns/ansi-to-html/blob/master/src/ansi_to_html.js#L149 https://github.com/rburns/ansi-to-html/blob/master/src/ansi_to_html.js#L299

the trailing close bold tag is on account of closing the remaining tags in the stack.

I've been trying to come up with a small test case which demonstrates that's what's happening. no luck yet.

In general, interpreting 22 as <span style="font-weight: normal"> instead of </b> might be a better approach.

from ansi-to-html.

rburns avatar rburns commented on July 21, 2024

this looks about right.

with the current release

convert.toHtml('\x1b[1m\x1b[36mname\x1b[22m|')

will produce

<b><span style="color:#0AA">name|</span></b>

which leaves the '|' erroneously bold.

Can you test the code on this branch, and see if it gives better results: https://github.com/rburns/ansi-to-html/pull/50/files

from ansi-to-html.

raine avatar raine commented on July 21, 2024

Thanks @rburns.

Those changes appear to work as well.

With this, I wonder if it would make sense to change the starting <b> to a span element with a bold style.

from ansi-to-html.

rburns avatar rburns commented on July 21, 2024

for consistencies sake, it would probably make sense to use a style attribute instead of a bold tag. But, in the interest of not changing something that works, I'd probably lean towards leaving it as it is.

The relevance of the using the style attribute for 'normal' text is that there isn't a <normal> tag, in the way that there is a <bold> tag. The previous solution used a </bold> tag to emulate <normal>, which is context sensitive, and led to the bug.

Similarly, these https://github.com/rburns/ansi-to-html/blob/master/src/ansi_to_html.js#L150-L151 might better be implemented with font-style and text-decoration css properties.

But, this appears to fix this issue, so I'll merge it before making more changes.

from ansi-to-html.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.