{"id":1376,"date":"2012-08-21T10:52:48","date_gmt":"2012-08-21T15:52:48","guid":{"rendered":"https:\/\/blogs.mathworks.com\/community\/?p=1376"},"modified":"2016-04-01T20:56:58","modified_gmt":"2016-04-02T00:56:58","slug":"mastering-matlab-markup","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/community\/2012\/08\/21\/mastering-matlab-markup\/","title":{"rendered":"Mastering MATLAB Markup"},"content":{"rendered":"<p>In my completely biased opinion, one of the most useful features in <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/cody\/\">Cody<\/a>, <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/trendy\/\">Trendy<\/a>, and <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/answers\/\">MATLAB Answers<\/a> is the ability to use MATLAB Markup to format text. Formatted code blocks, embedded links, and emphasized text, as used in Matt&#8217;s <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/answers\/93-how-to-select-only-two-items-from-the-list-box#answer_217\">uicontrol answer<\/a> and @bmtran&#8217;s description of his popular <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/cody\/problems\/110-make-an-n-dimensional-multiplication-table\">n-dimensional multiplication problem<\/a>, really help readers understand what&#8217;s going on in the post.<\/p>\n<h3>MATLAB Mark-What?<\/h3>\n<p>If you haven&#8217;t used these applications, MATLAB Markup is an easy way to format plain text for conversion to HTML. For example, you might type:<\/p>\n<p><code style=\"margin-left: 2em;\">To *boldly* go...<\/code><\/p>\n<p>This is converted to HTML:<\/p>\n<p><code style=\"margin-left: 2em;\">To &lt;b&gt;boldly&lt;\/b&gt; go...<\/code><\/p>\n<p>and displayed looking nice and polished:<\/p>\n<div style=\"margin-left: 2em;\">To <strong>boldly<\/strong> go&#8230;<\/div>\n<h3>The Secret Identity of MATLAB Markup<\/h3>\n<p>Plain-text-to-HTML markup languages are nothing new. Wikipedia is <a href=\"http:\/\/en.wikipedia.org\/wiki\/Wiki_markup\">built with one<\/a>. I&#8217;ve been known to write my grocery lists in <a href=\"http:\/\/daringfireball.net\/projects\/markdown\/\">Markdown<\/a>. And MATLAB Markup has a well established ancestor: the text markup used in the MATLAB <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2012a\/techdoc\/ref\/publish.html\">publish<\/a> tool.<\/p>\n<p>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.<\/p>\n<p><a href=\"https:\/\/blogs.mathworks.com\/community\/files\/ndim_markup.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-1400\" title=\"ndim_markup\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/ndim_markup.png\" alt=\"An example of MATLAB Markup in the MATLAB editor\" width=\"679\" height=\"537\" \/><\/a><\/p>\n<h3>Tips and Tricks<\/h3>\n<h4>1. Remember to insert blank lines above and below paragraph markup<\/h4>\n<p>Blocks of code, images, and bulleted or numbered lists require a blank line above and below the markup. While this markup doesn&#8217;t work:<\/p>\n<p><code style=\"margin-left: 2em;\">A familiar plot:<br \/>\n&lt;&lt;http:\/\/mathworks.com\/matlabcentral\/images\/surf.gif&gt;&gt;<br \/>\n<\/code><\/p>\n<p>this markup does:<\/p>\n<pre class=\"code\" style=\"margin-left: 2em;\">A familiar plot:\r\n\r\n&lt;&lt;http:\/\/mathworks.com\/matlabcentral\/images\/surf.gif&gt;&gt;<\/pre>\n<h4>2. Nest markup as needed<\/h4>\n<p>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: <a href=\"https:\/\/www.mathworks.com\/help\/matlab\/ref\/publish.html\"><tt>publish<\/tt><\/a>. In MATLAB Markup, this looks like:<\/p>\n<p><code style=\"margin-left: 2em;\">&lt;https:\/\/www.mathworks.com\/help\/releases\/R2012a\/techdoc\/ref\/publish.html |publish|&gt;<\/code><\/p>\n<h4>3. Use HTML entities when you need to mark up the markup<\/h4>\n<p>Sometimes you&#8217;ll want to include markup characters while preventing their automatic conversion to HTML. If I typed:<\/p>\n<p><code style=\"margin-left: 2em;\">Absolute value is displayed as |abs_val|<\/code><\/p>\n<p>I&#8217;d get the following output:<\/p>\n<div style=\"margin-left: 2em;\">Absolute value is displayed as <tt>abs_val<\/tt><\/div>\n<p>Instead of using the pipe character (|), I use the <a href=\"http:\/\/en.wikipedia.org\/wiki\/List_of_XML_and_HTML_character_entity_references\">HTML entity<\/a> <tt>&amp;124;<\/tt>. A full list of relevant HTML entities appears on the <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/answers\/help\/markup\/\">MATLAB Markup help page<\/a>.<\/p>\n<p><code style=\"margin-left: 2em;\">Absolute value is displayed as &amp;#124;abs_val&amp;#124;<\/code><\/p>\n<p>and get the following output:<\/p>\n<div style=\"margin-left: 2em;\">Absolute value is displayed as |abs_val|<\/div>\n<h3>Resources<\/h3>\n<p>If you want to learn more about MATLAB Markup or publishing from MATLAB, here are some great resources:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/answers\/help\/markup\/\">MATLAB Markup help<\/a><\/li>\n<li><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/answers\/13205-tutorial-how-to-format-your-question-with-markup\">A great tutorial<\/a> by Oleg, complete with animated examples<\/li>\n<\/ul>\n<h3>What&#8217;s Next?<\/h3>\n<p>Help make MATLAB Markup more useful. Comment on this post with aspects that trip you up, enhancements you&#8217;d like to see, or tips for other users.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/community\/2012\/08\/21\/mastering-matlab-markup\/\">read more >><\/a><\/p>\n","protected":false},"author":75,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[51,36],"tags":[223,225],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/1376"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/users\/75"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/comments?post=1376"}],"version-history":[{"count":39,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/1376\/revisions"}],"predecessor-version":[{"id":3336,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/1376\/revisions\/3336"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/media?parent=1376"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/categories?post=1376"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/tags?post=1376"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}