{"id":465,"date":"2022-06-29T16:54:21","date_gmt":"2022-06-29T23:54:21","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/math-in-office\/?p=465"},"modified":"2022-10-31T11:30:29","modified_gmt":"2022-10-31T18:30:29","slug":"richedit-autoformatting","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/math-in-office\/richedit-autoformatting\/","title":{"rendered":"RichEdit Autoformatting"},"content":{"rendered":"<p>RichEdit and Word have had the most elaborate autoformatting ever since Office 2007, namely math formula auto-buildup. A <a href=\"https:\/\/www.unicode.org\/notes\/tn28\/UTN28-PlainTextMath-v3.1.pdf\">UnicodeMath<\/a> expression builds up into <a href=\"https:\/\/devblogs.microsoft.com\/math-in-office\/officemath\/\">OfficeMath<\/a> as soon as it is unambiguous. Word and other programs have also had less ambitious autoformatting since late in the last century. Such functionality includes auto conversion of some simple numeric fractions to composed Unicode numeric fractions, e.g., 1\/2 to \u00bd, ordinal superscripts, e.g., 1st to 1<sup>st<\/sup>, double dash to long dash, e.g., a<code><span style=\"color: #000000;\">--<\/span><\/code>b to a\u2014b, smart quotes, e.g., <code>\"<span style=\"color: #000000;\">word<\/span>\"<\/code> to \u201cword\u201d, and automatic bulleted\/numbered lists. Such autoformatting is available in recent builds of RichEdit since it\u2019s needed for the Office <a href=\"https:\/\/support.microsoft.com\/en-us\/office\/using-modern-comments-in-word-edc6ae71-0a2d-49fe-8faa-986f1e48136a#:~:text=Using%20modern%20comments%20in%20Word%201%20Two%20ways,...%204%20Assigning%20tasks.%20...%205%20FAQs.%20\">Modern Comments facility<\/a>. Word and RichEdit have also had <a href=\"https:\/\/devblogs.microsoft.com\/math-in-office\/richedit-hyperlinks\/\">autoURL<\/a> and <a href=\"https:\/\/docs.microsoft.com\/en-us\/archive\/blogs\/murrays\/inserting-tables-using-the-keyboard\">auto table<\/a> conversion for many years. The post <a href=\"https:\/\/devblogs.microsoft.com\/math-in-office\/richedit-emoticon-shortcuts\/\">RichEdit Emoticon Shortcuts &#8211; Math in Office (microsoft.com)<\/a> describes the RichEdit option to convert common emoticon shortcuts to emoji.<\/p>\n<p>Word also supports converting _&#8230;_ to italicize the text in the \u201c\u2026\u201d and *\u2026* to bold the text in the \u201c\u2026\u201d. These and some of the other autoformatting notations are reminiscent of <a href=\"https:\/\/www.markdownguide.org\/getting-started\/\">Markdown<\/a> which was invented to enter popular HTML constructs easily in a readable notation. That\u2019s the same rationale that\u2019s behind UnicodeMath for entering math equations and expressions. So, maybe RichEdit should have a Markdown editor option that includes UnicodeMath \ud83d\ude0a.<\/p>\n<p>RichEdit\u2019s conversion of simple numeric fractions to Unicode fractions is described in the post <a href=\"https:\/\/devblogs.microsoft.com\/math-in-office\/function-to-get-unicode-fractions\/\">Function to get Unicode Fractions &#8211; Math in Office (microsoft.com)<\/a>. It supports the whole Unicode fraction repertoire, \u2189 \u00bd \u2153 \u00bc \u2155 \u2159 \u2150 \u215b \u2151 \u2152 \u2154 \u2156 \u00be \u2157 \u215c \u2158 \u215a \u215e, whereas Word only handles \u00bd \u2153 \u00bc and \u00be. You can create arbitrary numeric fractions using the Unicode superscript and subscript digits along with the U+2044 fraction slash. For example, \u2074\u2075\u2076\u2044\u2087\u2088\u2089\u2080. Admittedly it\u2019s not great typography, but it works. To enter such characters, it\u2019s handy to have the <a href=\"https:\/\/devblogs.microsoft.com\/math-in-office\/richedit-hot-keys\/\">Alt+x hot key<\/a>. You can also enter \u215f\u2081\u2086, \u215f\u2083\u2082, \u215f\u2086\u2084, \u215f\u2081\u2082\u2088, and \u215f\u2082\u2085\u2086, where I use \u215f (U+215F) for the numerator and fraction slash.<\/p>\n<p>To enable RichEdit autoformatting options, send the message EM_SETAUTOFORMAT with wparam = acflgAutoFormat and lparam = 0. The acflgAutoFormat flag can be combined with other flags to disable autoformatting options. The flags and messages are defined by<\/p>\n<pre> \u00a0\u00a0\u00a0\u00a0acflgAutoFormat = 1\r\n\u00a0\u00a0\u00a0\u00a0\u00a0acflgNoSmartQuotes = 2\r\n\u00a0\u00a0\u00a0\u00a0\u00a0acflgNoSuperscript = 128\r\n\u00a0\u00a0\u00a0\u00a0\u00a0acflgNoEmDash = 256\r\n\u00a0\u00a0\u00a0\u00a0\u00a0acflgNoFraction = 1024\r\n\u00a0\u00a0\u00a0\u00a0\u00a0acflgNoBulletedLists = 8192\r\n\u00a0\u00a0\u00a0\u00a0\u00a0acflgNoNumberedLists = 16384\r\n \u00a0\u00a0\u00a0\u00a0EM_GETAUTOFORMAT = WM_USER + 392\r\n \u00a0\u00a0\u00a0\u00a0EM_SETAUTOFORMAT = WM_USER + 393\r\n<\/pre>\n<p>For the time being, also send EM_SETMSOAUTOCORRECT (WM_USER + 391) with wparam = 1 and lparam = 0. This message enables the RichEdit integration of the shared MSO autocorrect facility. As such, the current RichEdit autoformatting code requires MSO to be loaded, even though the autoformatting code doesn&#8217;t use it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>RichEdit and Word have had the most elaborate autoformatting ever since Office 2007, namely math formula auto-buildup. A UnicodeMath expression builds up into OfficeMath as soon as it is unambiguous. Word and other programs have also had less ambitious autoformatting since late in the last century. Such functionality includes auto conversion of some simple numeric [&hellip;]<\/p>\n","protected":false},"author":40611,"featured_media":55,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-465","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-math-in-office"],"acf":[],"blog_post_summary":"<p>RichEdit and Word have had the most elaborate autoformatting ever since Office 2007, namely math formula auto-buildup. A UnicodeMath expression builds up into OfficeMath as soon as it is unambiguous. Word and other programs have also had less ambitious autoformatting since late in the last century. Such functionality includes auto conversion of some simple numeric [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/posts\/465","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/users\/40611"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/comments?post=465"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/posts\/465\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/media\/55"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/media?parent=465"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/categories?post=465"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/math-in-office\/wp-json\/wp\/v2\/tags?post=465"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}