Jump to content

LVMark: Format markup for string controls


Recommended Posts

Inspired by this idea, these are just a few, one-day-of-coding functions that implement a simple, regex based markup for string controls.

For those not familiar with it, markup allows inline text to modify the displayed properties of the text. For instance, **bold** becomes bold, _italics_ becomes italics, etc.

The code currently supports:

  • Bold
  • Italic
  • Underline
  • Colors (in #XXXXXX format)
  • Text sizes (verysmall, small, large, verylarge)
  • Strikethrough
  • Some font setting

Of course, it's still limited by the string control capabilities (no hyperlinks, no superscripts, no embedded lists).

If people think it's worthwhile, I'll develop it into a somewhat more complete solution (or, of course, they can!). An X-control that supports it seems like an obvious extension, but I'm open to ideas.

Note: this was developed in LV2011, and back-ported to LV2009. If you spot a problem with it, please notify me.

Use: open and run LVMark_TestString.vi for a demonstration.

Thanks,

Joe Z.

LVMark2009.zip

  • Like 2
Link to comment

Based on the title, is this meant to be MarkDown compatible? That would be very nice!

Ton

I think it could be (and I would like it to be!), but there are some fundamental differences in how they work. For instance, Markdown doesn't support underlining, and focuses pretty heavily on linking.

I would like to end up closer to the Markdown spec than it is now, but there's a good bit of work yet to go.

Joe Z.

Link to comment

In LV2009 (Win7 SP1 32-bit), it seems that small and very small text do not work. I don't think your code is to blame, I manually cranked it down to 2pt Courier and it didn't change size whatsoever.

I think MarkDown support would be pretty cool too, and BBCode and CSS while you're at it! ;)

Link to comment

Hmmm I just checked it out. It looks good but I don't really like the codes... such as **bold** etc... rather would have

[b]bold[/b]

, with a clear opening and closing bracket but that can proberbly be changed easily. Also I would have implemented differently because now you loop threw the whole text each time for every style element and afterwards applying the style, you can do all of this in just 1 loop.

Edited by Wouter
Link to comment
  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.