question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Document TextBox with markdown does not function as expected

See original GitHub issue

When using markdown within a TextBox it is not rendered as expected.

Consider a TextBox with the following options:

// ...
contentHasMarkup : true,
wordWrap : true,

Then call the following:

const s = '^GRangers ^-^gare masters of the hunt, often living very independent lives or even occasionally as hermits. Skilled with ^Yranged weapons^-^g, ^GRangers ^-^gprefer to keep their enemies at a distance during combat.';
textbox.setContent(s, true);

Results look something like this: image

Expected: ", " and “prefer…” text should be “dim” Green.

Another oddity that I’m not sure is expected: “^Gfoo ^gbar” I would expect to be bright Green “Foo” and dim “bar”, but I seem to have to insert ^- between since the bright toggles on?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
cronvelcommented, Jan 21, 2021

@NuSkooler Great PoC 😉

On your ansi-bbs.js termconfig, you need to turn off deltaEscapeSequence: false (at the end of the file). It should greatly improve the support. It tells the ScreenBuffer to fully reset color/attribute anytime a cell has different style that the previous one during a blit (this only affect the blit, not how markup is interpreted).

It sounds like I can explicitly set one or more properties on parent elements (document or screen buffer) to bgBlack to counter this?

Yes, you can add an attr option to almost all widgets. Set it to attr: { bgColor: 'black' }. When attr is not set on a widget, it used the lib’s default one, usually the terminal default color like CSI 49 for background. It could use some other decent default when it make more sense (e.g. highlighting a button).

1reaction
cronvelcommented, Jan 20, 2021

@NuSkooler I’m saying you that that blink is coming from your termconfig, the bgBrightRed was the first line containing such reference to blink, I just copied the first occurrence.

It really works fine on my end.

Also everything is backed by a ScreenBuffer, that’s why you got some extra ESC seq. When a particular widget is drawn, it doesn’t know what happened before, so it set everything that should be. Also each cell in the ScreenBuffer has some properties: defaultColor and the bgDefaultColor are, well, the default color of a cell. Everytime a ScreenBuffer surface is blitted it ensures each cell will be drawn with the correct color/attributes. It remembers color/attributes during that process so it only send necessary code between cell, but not between surface blit (everything can happen between 2 blits, including userland codes messing with attributes).

Also the markup was never meant to be a way of writing ESC seq, instead it is meant to convey features of Terminal Kit. You express what you want (color/attributes), the lib try its best to make it work across all supported platforms. E.g. bold in Terminal Kit is meant to write something using bold font. If the platform doesn’t support bold font, the termconfig should fallback to what is as close as possible of bold (in a User eXperience sense), eventually just disable it if no clean fallback is possible, but not wildly send “\x1b[1m” because “hey, it’s the bold code”. The lib is supposed to abstract that away, the userland code may not even know how terminals work (and how messy they are).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bootstrap markdown not working as expected - Stack Overflow
It is a pretty basic fiddle with just a text area and the markdown code, but as you can see, it does not...
Read more >
15 Common Problems with rmarkdown (and some solutions)
15.1 Avoiding problems · restart R · run all chunks below · find the chunk that did not work, fix until it does...
Read more >
Markdown User Guide - Skillable
Some key codes may not function as expected when using vSphere. It is highly recommended to test each key combo before publishing the...
Read more >
Handbook Markdown Guide - GitLab
This method works for YouTube videos and any other embed video within an <iframe> tag. Copy the code below and paste it into...
Read more >
Formatting text with Markdown - Zendesk help
Markdown is a simple markup language you can use to easily add formatting, links, and images to plain text. You can use it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found