haxiomic / console.hx

A haxe logging utility for easy rich output in both native and browser consoles
The Unlicense
48 stars 7 forks source link

Escaping does not seem to work #9

Closed claus-d3y closed 4 years ago

claus-d3y commented 4 years ago

When I try the following: Console.log('testing esc: \\<b>not\\<//> so <b>bold<//>') I get: testing esc: \not\ so bold

Yes, I have cheated to get this post to look right. It is a pain to discuss errors regarding formatting ;)

haxiomic commented 4 years ago

Thanks for reporting @cld-laerdal, just pushed a change – could you see if it works now?

claus-d3y commented 4 years ago

Thanks for the very prompt fix.

It opens, however, the annoying issue of escaping the escape character: Console.log('\\<red> not red\\\\<b>but bold\\\\\\<green>, yet no green'); yields: \not red \\but bold\\\, yet no green rather than probably: \not red \but bold*\\\, yet no green

The fix seems to be a bit complicated since you might easily detect the situation, but have to add a whole new category of changes to get the number of \'s right...

Perhaps a more viable solution would be to replace the \ with a literal flag, something like Console.log('<literal><red> not red\\<b>but bold\\\\<literal><green>, yet no green');

Just my early morning ramblings...

haxiomic commented 4 years ago

I see what you mean on escaping the escape character

I think that's a rare enough use case that I'll leave it be for now, maybe later I could go the html way and use &lt; for <