MATLAB Community

MATLAB, community & more

Mastering MATLAB Markup

In my completely biased opinion, one of the most useful features in Cody, Trendy, and MATLAB Answers is the ability to use MATLAB Markup to format text. Formatted code blocks, embedded links, and emphasized text, as used in Matt’s uicontrol answer and @bmtran’s description of his popular n-dimensional multiplication problem, really help readers understand what’s going on in the post.

MATLAB Mark-What?

If you haven’t used these applications, MATLAB Markup is an easy way to format plain text for conversion to HTML. For example, you might type:

To *boldly* go...

This is converted to HTML:

To <b>boldly</b> go...

and displayed looking nice and polished:

To boldly go…

The Secret Identity of MATLAB Markup

Plain-text-to-HTML markup languages are nothing new. Wikipedia is built with one. I’ve been known to write my grocery lists in Markdown. And MATLAB Markup has a well established ancestor: the text markup used in the MATLAB publish tool.

Check out the n-dimensional Cody question (linked to above), ready for MATLAB to publish as HTML. Note the asterisks for bold and underscores for italic.

An example of MATLAB Markup in the MATLAB editor

Tips and Tricks

1. Remember to insert blank lines above and below paragraph markup

Blocks of code, images, and bulleted or numbered lists require a blank line above and below the markup. While this markup doesn’t work:

A familiar plot:
<<http://mathworks.com/matlabcentral/images/surf.gif>>

this markup does:

A familiar plot:

<<http://mathworks.com/matlabcentral/images/surf.gif>>

2. Nest markup as needed

The convention on MATLAB Answers for linking to MathWorks documentation illustrates the usefulness of combining markup. Answerers are encouraged to format links with the name of the function in a monospaced font: publish. In MATLAB Markup, this looks like:

<https://www.mathworks.com/help/releases/R2012a/techdoc/ref/publish.html |publish|>

3. Use HTML entities when you need to mark up the markup

Sometimes you’ll want to include markup characters while preventing their automatic conversion to HTML. If I typed:

Absolute value is displayed as |abs_val|

I’d get the following output:

Absolute value is displayed as abs_val

Instead of using the pipe character (|), I use the HTML entity &124;. A full list of relevant HTML entities appears on the MATLAB Markup help page.

Absolute value is displayed as &#124;abs_val&#124;

and get the following output:

Absolute value is displayed as |abs_val|

Resources

If you want to learn more about MATLAB Markup or publishing from MATLAB, here are some great resources:

What’s Next?

Help make MATLAB Markup more useful. Comment on this post with aspects that trip you up, enhancements you’d like to see, or tips for other users.

|
  • print

コメント

コメントを残すには、ここ をクリックして MathWorks アカウントにサインインするか新しい MathWorks アカウントを作成します。