Extracting Text With Highlights Operators

@eastgate, I have the following highlighted text from Medium, i.e., read a Medium article, highlight some text, and paste copied text into TBX.

The highlight color Medium uses appears to be #92F2FF, otherwise known as “light shade cyan” or “sky blue.” I’ve tried the highlights operators, e.g., $MyList=$Text.highlights(“#92F2FF”), or $MyList=$Text.highlights(“light shade cyan”), $MyList=$Text.highlights(“cyan”), etc. All this does is treat every line of text list an item for the list, it does not extract only the highlights. The highlighter operator is working fine; it picks up yellow and other TBX-known colors. Here is my question: is there a way I can have TBX capture the #92F2FF colored highlights?

Ah, I think the disconnect in String.highlights([aColor]), and missing this:

…have been highlighted in the $Text using Format ▸ Highlight.

That menu doesn’t allow any highlight colour, but only a choice from the Highlight sub-menu.

But. I’d agree the inference there isn’t obvious—bad writing by me. The article is now updated.

What you want is currently a feature request for someone <cough> to make. :slight_smile:

1 Like

Sounds good, makes sense. Thanks.

1 Like

I’ll look into this. At present, only the menu colors are recognized.

1 Like

Another use case is asking Tinderbox to recognize Markdown highlighting … e.g., text phrases delimited by “==.”

I have imported that text into a $Text attribute, and created a Highlighter that uses

$MyString = $Text.replace(/.==([^=]+)==./, “\1”); All good.

But when I try to use $MyList=$Text.highlights(“yellow”); to build a list of all highlighted phrases, I get nothing. If I use the menu option Format->Style->Highlight->yellow, it works.

Any way I can get Tinderbox to recognize $Text phrases delineated by “==”?

streamparse.tbx (189.6 KB)

1 Like

I’ll hook up the debugger and find out what’s ailing the .highlights() operator.