git.iko.soy/typeable/pandoc
on master help sign in
Muse writer: use lightweight markup when possible
commit6ea6011ca66c3127ff42cd5d0d39b3bd40e56e76 authorAlexander Krotov <ilabdsf@gmail.com> dateThu 30 Aug 2018, 17:10 (8 years ago) parent746c309
3 files changed+198−69
src/Text/Pandoc/Writers/Muse.hs+123−19 test/Tests/Writers/Muse.hs+39−11 test/writer.muse+36−39
src/Text/Pandoc/Writers/Muse.hs+123−19
@@ -46,7 +46,7 @@ module Text.Pandoc.Writers.Muse (writeMuse) where
4646import Prelude
4747import Control.Monad.Reader
4848import Control.Monad.State.Strict
49−import Data.Char (isSpace, isDigit, isAsciiUpper, isAsciiLower)
49+import Data.Char (isSpace, isAlphaNum, isDigit, isAsciiUpper, isAsciiLower)
5050import Data.Default
5151import Data.Text (Text)
5252import Data.List (intersperse, transpose, isInfixOf)
@@ -74,16 +74,20 @@ data WriterEnv =
7474 , envInsideLinkDescription :: Bool -- ^ Escape ] if True
7575 , envAfterSpace :: Bool -- ^ There is whitespace (not just newline) before
7676 , envOneLine :: Bool -- ^ True if newlines are not allowed
77+ , envInsideAsterisks :: Bool -- ^ True if outer element is emphasis with asterisks
78+ , envNearAsterisks :: Bool -- ^ Rendering inline near asterisks
7779 }
7880
7981data WriterState =
8082 WriterState { stNotes :: Notes
8183 , stIds :: Set.Set String
84+ , stUseTags :: Bool -- ^ Use tags for emphasis, for example because previous character is a letter
8285 }
8386
8487instance Default WriterState
8588 where def = WriterState { stNotes = []
8689 , stIds = Set.empty
90+ , stUseTags = False
8791 }
8892
8993evalMuse :: PandocMonad m => Muse m a -> WriterEnv -> WriterState -> m a
@@ -103,6 +107,8 @@ writeMuse opts document =
103107 , envInsideLinkDescription = False
104108 , envAfterSpace = False
105109 , envOneLine = False
110+ , envInsideAsterisks = False
111+ , envNearAsterisks = False
106112 }
107113
108114-- | Return Muse representation of document.
@@ -212,6 +218,7 @@ blockToMuse (BulletList items) = do
212218 => [Block]
213219 -> Muse m Doc
214220 bulletListItemToMuse item = do
221+ modify $ \st -> st { stUseTags = False }
215222 contents <- blockListToMuse item
216223 return $ hang 2 "- " contents
217224blockToMuse (DefinitionList items) = do
@@ -223,6 +230,7 @@ blockToMuse (DefinitionList items) = do
223230 => ([Inline], [[Block]])
224231 -> Muse m Doc
225232 definitionListItemToMuse (label, defs) = do
233+ modify $ \st -> st { stUseTags = False }
226234 label' <- local (\env -> env { envOneLine = True, envAfterSpace = True }) $ inlineListToMuse' label
227235 contents <- vcat <$> mapM descriptionToMuse defs
228236 let ind = offset label'
@@ -401,6 +409,17 @@ fixNotes (Space : n@Note{} : rest) = Str " " : n : fixNotes rest
401409fixNotes (SoftBreak : n@Note{} : rest) = Str " " : n : fixNotes rest
402410fixNotes (x:xs) = x : fixNotes xs
403411
412+startsWithSpace :: [Inline] -> Bool
413+startsWithSpace (Space:_) = True
414+startsWithSpace (SoftBreak:_) = True
415+startsWithSpace _ = False
416+
417+endsWithSpace :: [Inline] -> Bool
418+endsWithSpace [Space] = True
419+endsWithSpace [SoftBreak] = True
420+endsWithSpace (_:xs) = endsWithSpace xs
421+endsWithSpace [] = False
422+
404423urlEscapeBrackets :: String -> String
405424urlEscapeBrackets (']':xs) = '%':'5':'D':urlEscapeBrackets xs
406425urlEscapeBrackets (x:xs) = x:urlEscapeBrackets xs
@@ -409,9 +428,9 @@ urlEscapeBrackets [] = []
409428isHorizontalRule :: String -> Bool
410429isHorizontalRule s = length s >= 4 && all (== '-') s
411430
412−startsWithSpace :: String -> Bool
413−startsWithSpace (x:_) = isSpace x
414−startsWithSpace [] = False
431+stringStartsWithSpace :: String -> Bool
432+stringStartsWithSpace (x:_) = isSpace x
433+stringStartsWithSpace [] = False
415434
416435fixOrEscape :: Bool -> Inline -> Bool
417436fixOrEscape sp (Str "-") = sp
@@ -420,11 +439,19 @@ fixOrEscape _ (Str ">") = True
420439fixOrEscape sp (Str s) = (sp && (startsWithMarker isDigit s ||
421440 startsWithMarker isAsciiLower s ||
422441 startsWithMarker isAsciiUpper s))
423− || isHorizontalRule s || startsWithSpace s
442+ || isHorizontalRule s || stringStartsWithSpace s
424443fixOrEscape _ Space = True
425444fixOrEscape _ SoftBreak = True
426445fixOrEscape _ _ = False
427446
447+inlineListStartsWithAlnum :: PandocMonad m
448+ => [Inline]
449+ -> Muse m Bool
450+inlineListStartsWithAlnum (Str s:_) = do
451+ esc <- shouldEscapeString s
452+ return $ esc || isAlphaNum (head s)
453+inlineListStartsWithAlnum _ = return False
454+
428455-- | Convert list of Pandoc inline elements to Muse
429456renderInlineList :: PandocMonad m
430457 => [Inline]
@@ -436,11 +463,22 @@ renderInlineList (x:xs) = do
436463 start <- asks envInlineStart
437464 afterSpace <- asks envAfterSpace
438465 topLevel <- asks envTopLevel
439− r <- local (\env -> env { envInlineStart = False }) $ inlineToMuse x
466+ insideAsterisks <- asks envInsideAsterisks
467+ nearAsterisks <- asks envNearAsterisks
468+ useTags <- gets stUseTags
469+ alnumNext <- inlineListStartsWithAlnum xs
470+ let newUseTags = useTags || alnumNext
471+ modify $ \st -> st { stUseTags = newUseTags }
472+
473+ r <- local (\env -> env { envInlineStart = False
474+ , envInsideAsterisks = False
475+ , envNearAsterisks = nearAsterisks || (null xs && insideAsterisks)
476+ }) $ inlineToMuse x
440477 opts <- asks envOptions
441478 let isNewline = (x == SoftBreak && writerWrapText opts == WrapPreserve) || x == LineBreak
442479 lst' <- local (\env -> env { envInlineStart = isNewline
443480 , envAfterSpace = x == Space || (not topLevel && isNewline)
481+ , envNearAsterisks = False
444482 }) $ renderInlineList xs
445483 if start && fixOrEscape afterSpace x
446484 then pure (text "<verbatim></verbatim>" <> r <> lst')
@@ -452,7 +490,9 @@ inlineListToMuse :: PandocMonad m
452490 -> Muse m Doc
453491inlineListToMuse lst = do
454492 lst' <- (normalizeInlineList . fixNotes) <$> preprocessInlineList (map (removeKeyValues . replaceSmallCaps) lst)
455− renderInlineList lst'
493+ insideAsterisks <- asks envInsideAsterisks
494+ modify $ \st -> st { stUseTags = False } -- Previous character is likely a '>' or some other markup
495+ local (\env -> env { envNearAsterisks = insideAsterisks }) $ renderInlineList lst'
456496
457497inlineListToMuse' :: PandocMonad m => [Inline] -> Muse m Doc
458498inlineListToMuse' lst = do
@@ -466,52 +506,112 @@ inlineListToMuse' lst = do
466506inlineToMuse :: PandocMonad m
467507 => Inline
468508 -> Muse m Doc
469−inlineToMuse (Str str) =
470− text <$> conditionalEscapeString str
509+inlineToMuse (Str str) = do
510+ escapedStr <- conditionalEscapeString str
511+ let useTags = isAlphaNum $ last escapedStr -- escapedStr is never empty because empty strings are escaped
512+ modify $ \st -> st { stUseTags = useTags }
513+ return $ text escapedStr
514+inlineToMuse (Emph [Strong lst]) = do
515+ useTags <- gets stUseTags
516+ if useTags
517+ then do contents <- local (\env -> env { envInsideAsterisks = True }) $ inlineListToMuse lst
518+ modify $ \st -> st { stUseTags = False }
519+ return $ "<em>**" <> contents <> "**</em>"
520+ else if null lst || startsWithSpace lst || endsWithSpace lst
521+ then do
522+ contents <- local (\env -> env { envInsideAsterisks = False }) $ inlineListToMuse lst
523+ modify $ \st -> st { stUseTags = True }
524+ return $ "*<strong>" <> contents <> "</strong>*"
525+ else do
526+ contents <- local (\env -> env { envInsideAsterisks = True }) $ inlineListToMuse lst
527+ modify $ \st -> st { stUseTags = True }
528+ return $ "***" <> contents <> "***"
471529inlineToMuse (Emph lst) = do
472− contents <- inlineListToMuse lst
473− return $ "<em>" <> contents <> "</em>"
530+ useTags <- gets stUseTags
531+ if useTags || null lst || startsWithSpace lst || endsWithSpace lst
532+ then do contents <- inlineListToMuse lst
533+ return $ "<em>" <> contents <> "</em>"
534+ else do contents <- local (\env -> env { envInsideAsterisks = True }) $ inlineListToMuse lst
535+ modify $ \st -> st { stUseTags = True }
536+ return $ "*" <> contents <> "*"
537+inlineToMuse (Strong [Emph lst]) = do
538+ useTags <- gets stUseTags
539+ if useTags
540+ then do contents <- local (\env -> env { envInsideAsterisks = True }) $ inlineListToMuse lst
541+ modify $ \st -> st { stUseTags = False }
542+ return $ "<strong>*" <> contents <> "*</strong>"
543+ else if null lst || startsWithSpace lst || endsWithSpace lst
544+ then do
545+ contents <- local (\env -> env { envInsideAsterisks = False }) $ inlineListToMuse lst
546+ modify $ \st -> st { stUseTags = True }
547+ return $ "**<em>" <> contents <> "</em>**"
548+ else do
549+ contents <- local (\env -> env { envInsideAsterisks = True }) $ inlineListToMuse lst
550+ modify $ \st -> st { stUseTags = True }
551+ return $ "***" <> contents <> "***"
474552inlineToMuse (Strong lst) = do
475− contents <- inlineListToMuse lst
476− return $ "<strong>" <> contents <> "</strong>"
553+ useTags <- gets stUseTags
554+ if useTags || null lst || startsWithSpace lst || endsWithSpace lst
555+ then do contents <- inlineListToMuse lst
556+ modify $ \st -> st { stUseTags = False }
557+ return $ "<strong>" <> contents <> "</strong>"
558+ else do contents <- local (\env -> env { envInsideAsterisks = True }) $ inlineListToMuse lst
559+ modify $ \st -> st { stUseTags = True }
560+ return $ "**" <> contents <> "**"
477561inlineToMuse (Strikeout lst) = do
478562 contents <- inlineListToMuse lst
563+ modify $ \st -> st { stUseTags = False }
479564 return $ "<del>" <> contents <> "</del>"
480565inlineToMuse (Superscript lst) = do
481566 contents <- inlineListToMuse lst
567+ modify $ \st -> st { stUseTags = False }
482568 return $ "<sup>" <> contents <> "</sup>"
483569inlineToMuse (Subscript lst) = do
484570 contents <- inlineListToMuse lst
571+ modify $ \st -> st { stUseTags = False }
485572 return $ "<sub>" <> contents <> "</sub>"
486573inlineToMuse SmallCaps {} =
487574 fail "SmallCaps should be expanded before normalization"
488575inlineToMuse (Quoted SingleQuote lst) = do
489576 contents <- inlineListToMuse lst
577+ modify $ \st -> st { stUseTags = False }
490578 return $ "‘" <> contents <> "’"
491579inlineToMuse (Quoted DoubleQuote lst) = do
492580 contents <- inlineListToMuse lst
581+ modify $ \st -> st { stUseTags = False }
493582 return $ "“" <> contents <> "”"
494583inlineToMuse Cite {} =
495584 fail "Citations should be expanded before normalization"
496−inlineToMuse (Code _ str) = return $
497− "<code>" <> text (substitute "</code>" "<</code><code>/code>" str) <> "</code>"
585+inlineToMuse (Code _ str) = do
586+ useTags <- gets stUseTags
587+ modify $ \st -> st { stUseTags = False }
588+ return $ if useTags || null str || '=' `elem` str || isSpace (head str) || isSpace (last str)
589+ then "<code>" <> text (substitute "</code>" "<</code><code>/code>" str) <> "</code>"
590+ else "=" <> text str <> "="
498591inlineToMuse Math{} =
499592 fail "Math should be expanded before normalization"
500−inlineToMuse (RawInline (Format f) str) =
593+inlineToMuse (RawInline (Format f) str) = do
594+ modify $ \st -> st { stUseTags = False }
501595 return $ "<literal style=\"" <> text f <> "\">" <> text str <> "</literal>"
502596inlineToMuse LineBreak = do
503597 oneline <- asks envOneLine
598+ modify $ \st -> st { stUseTags = False }
504599 return $ if oneline then "<br>" else "<br>" <> cr
505−inlineToMuse Space = return space
600+inlineToMuse Space = do
601+ modify $ \st -> st { stUseTags = False }
602+ return space
506603inlineToMuse SoftBreak = do
507604 oneline <- asks envOneLine
508605 wrapText <- asks $ writerWrapText . envOptions
606+ modify $ \st -> st { stUseTags = False }
509607 return $ if not oneline && wrapText == WrapPreserve then cr else space
510608inlineToMuse (Link _ txt (src, _)) =
511609 case txt of
512− [Str x] | escapeURI x == src ->
610+ [Str x] | escapeURI x == src -> do
611+ modify $ \st -> st { stUseTags = False }
513612 return $ "[[" <> text (escapeLink x) <> "]]"
514613 _ -> do contents <- local (\env -> env { envInsideLinkDescription = True }) $ inlineListToMuse txt
614+ modify $ \st -> st { stUseTags = False }
515615 return $ "[[" <> text (escapeLink src) <> "][" <> contents <> "]]"
516616 where escapeLink lnk = if isImageUrl lnk then "URL:" ++ urlEscapeBrackets lnk else urlEscapeBrackets lnk
517617 -- Taken from muse-image-regexp defined in Emacs Muse file lisp/muse-regexps.el
@@ -537,11 +637,14 @@ inlineToMuse (Image attr@(_, classes, _) inlines (source, title)) = do
537637 let rightalign = if "align-right" `elem` classes
538638 then " r"
539639 else ""
640+ modify $ \st -> st { stUseTags = False }
540641 return $ "[[" <> text (urlEscapeBrackets source ++ width ++ leftalign ++ rightalign) <> "]" <> title' <> "]"
541642inlineToMuse (Note contents) = do
542643 -- add to notes in state
543644 notes <- gets stNotes
544− modify $ \st -> st { stNotes = contents:notes }
645+ modify $ \st -> st { stNotes = contents:notes
646+ , stUseTags = False
647+ }
545648 let ref = show $ length notes + 1
546649 return $ "[" <> text ref <> "]"
547650inlineToMuse (Span (anchor,names,_) inlines) = do
@@ -549,6 +652,7 @@ inlineToMuse (Span (anchor,names,_) inlines) = do
549652 let anchorDoc = if null anchor
550653 then mempty
551654 else text ('#':anchor) <> space
655+ modify $ \st -> st { stUseTags = False }
552656 return $ anchorDoc <> (if null inlines && not (null anchor)
553657 then mempty
554658 else (if null names
test/Tests/Writers/Muse.hs+39−11
@@ -354,23 +354,51 @@ tests = [ testGroup "block elements"
354354 , "do not escape ; inside paragraph" =: text "foo ; bar" =?> "foo ; bar"
355355 ]
356356 , testGroup "emphasis"
357− [ "emph" =: emph (text "foo") =?> "<em>foo</em>"
358− , "strong" =: strong (text "foo") =?> "<strong>foo</strong>"
357+ [ "emphasis" =: emph (text "foo") =?> "*foo*"
358+ , "emphasis inside word" =: text "foo" <> emph (text "bar") <> text "baz" =?> "foo<em>bar</em>baz"
359+ , "emphasis before comma" =: emph (text "foo") <> text ", bar" =?> "*foo*, bar"
360+ , "emphasis before period" =: emph (text "foobar") <> text "." =?> "*foobar*."
361+ , "empty emphasis" =: emph mempty =?> "<em></em>"
362+ , "empty strong" =: strong mempty =?> "<strong></strong>"
363+ , "empty strong emphasis" =: strong (emph mempty) =?> "**<em></em>**"
364+ , "empty emphasized strong" =: emph (strong mempty) =?> "*<strong></strong>*"
365+ , "strong" =: strong (text "foo") =?> "**foo**"
366+ , "strong inside word" =: text "foo" <> strong (text "bar") <> text "baz" =?> "foo<strong>bar</strong>baz"
367+ , "strong emphasis" =: strong (emph (text "foo")) =?> "***foo***"
368+ , "strong after emphasis" =: emph (text "foo") <> strong (text "bar") =?> "*foo*<strong>bar</strong>"
369+ , "strong emphasis after emphasis" =: emph (text "foo") <> strong (emph (text "bar")) =?> "*foo*<strong>*bar*</strong>"
370+ , "strong in the end of emphasis" =: emph (text "foo" <> strong (text "bar")) =?> "*foo<strong>bar</strong>*"
359371 , "strikeout" =: strikeout (text "foo") =?> "<del>foo</del>"
372+ , "space at the beginning of emphasis" =: emph (text " foo") =?> "<em> foo</em>"
373+ , "space at the end of emphasis" =: emph (text "foo ") =?> "<em>foo </em>"
374+ , "space at the beginning of strong" =: strong (text " foo") =?> "<strong> foo</strong>"
375+ , "space at the end of strong" =: strong (text "foo ") =?> "<strong>foo </strong>"
376+ , "space at the beginning of strong emphasis" =: strong (emph (text " foo")) =?> "**<em> foo</em>**"
377+ , "space at the end of strong emphasis" =: strong (emph (text "foo ")) =?> "**<em>foo </em>**"
378+ , "space at the beginning of emphasiszed strong" =: emph (strong (text " foo")) =?> "*<strong> foo</strong>*"
379+ , "space at the end of emphasized strong" =: emph (strong (text "foo ")) =?> "*<strong>foo </strong>*"
360380 ]
361381 , "superscript" =: superscript (text "foo") =?> "<sup>foo</sup>"
362382 , "subscript" =: subscript (text "foo") =?> "<sub>foo</sub>"
363− , "smallcaps" =: smallcaps (text "foo") =?> "<em>foo</em>"
364− , "smallcaps near emphasis" =: emph (str "foo") <> smallcaps (str "bar") =?> "<em>foobar</em>"
383+ , "smallcaps" =: smallcaps (text "foo") =?> "*foo*"
384+ , "smallcaps near emphasis" =: emph (str "foo") <> smallcaps (str "bar") =?> "*foobar*"
365385 , "single quoted" =: singleQuoted (text "foo") =?> "‘foo’"
366386 , "double quoted" =: doubleQuoted (text "foo") =?> "“foo”"
367387 -- Cite is trivial
368388 , testGroup "code"
369− [ "simple" =: code "foo" =?> "<code>foo</code>"
389+ [ "simple" =: code "foo" =?> "=foo="
390+ , "empty" =: code "" =?> "<code></code>"
391+ , "space" =: code " " =?> "<code> </code>"
392+ , "space at the beginning" =: code " foo" =?> "<code> foo</code>"
393+ , "space at the end" =: code "foo " =?> "<code>foo </code>"
394+ , "use tags for =" =: code "foo = bar" =?> "<code>foo = bar</code>"
370395 , "escape tag" =: code "<code>foo = bar</code> baz" =?> "<code><code>foo = bar<</code><code>/code> baz</code>"
371− , "normalization with attributes" =: codeWith ("",["haskell"],[]) "foo" <> code "bar" =?> "<code>foobar</code>"
372− , "normalization" =: code "</co" <> code "de>" =?> "<code><</code><code>/code></code>"
373− , "normalization with empty string" =: code "</co" <> str "" <> code "de>" =?> "<code><</code><code>/code></code>"
396+ , "normalization with attributes" =: codeWith ("",["haskell"],[]) "foo" <> code "bar" =?> "=foobar="
397+ , "code tag" =: code "<code>foo</code>" =?> "=<code>foo</code>="
398+ , "normalization" =: code "</co" <> code "de>" <> code "=" =?> "<code><</code><code>/code>=</code>"
399+ , "normalization with empty string" =: code "</co" <> str "" <> code "de>" <> code "=" =?> "<code><</code><code>/code>=</code>"
400+ , "emphasized code" =: emph (code "foo") =?> "*=foo=*"
401+ , "strong code" =: strong (code "foo") =?> "**=foo=**"
374402 ]
375403 , testGroup "spaces"
376404 [ "space" =: text "a" <> space <> text "b" =?> "a b"
@@ -385,7 +413,7 @@ tests = [ testGroup "block elements"
385413 , testGroup "math"
386414 [ "inline math" =: math "2^3" =?> "2<sup>3</sup>"
387415 , "display math" =: displayMath "2^3" =?> "2<sup>3</sup>"
388− , "multiple letters in inline math" =: math "abc" =?> "<em>abc</em>"
416+ , "multiple letters in inline math" =: math "abc" =?> "*abc*"
389417 , "expand math before normalization" =: math "[" <> str "2]" =?> "<verbatim>[2]</verbatim>"
390418 , "multiple math expressions inside one inline list" =: math "5_4" <> text ", " <> displayMath "3^2" =?> "5<sub>4</sub>, 3<sup>2</sup>"
391419 ]
@@ -461,7 +489,7 @@ tests = [ testGroup "block elements"
461489 "<em>foo</em>bar"
462490 , "emph quoted" =:
463491 para (doubleQuoted (emph (text "foo"))) =?>
464− "“<em>foo</em>”"
492+ "“*foo*”"
465493 , "strong word before" =:
466494 para (text "foo" <> strong (text "bar")) =?>
467495 "foo<strong>bar</strong>"
@@ -470,7 +498,7 @@ tests = [ testGroup "block elements"
470498 "<strong>foo</strong>bar"
471499 , "strong quoted" =:
472500 para (singleQuoted (strong (text "foo"))) =?>
473− "‘<strong>foo</strong>’"
501+ "‘**foo**’"
474502 ]
475503 ]
476504 ]
test/writer.muse+36−39
@@ -11,7 +11,7 @@ markdown test suite.
1111
1212** Level 2 with an [[/url][embedded link]]
1313
14−*** Level 3 with <em>emphasis</em>
14+*** Level 3 with *emphasis*
1515
1616**** Level 4
1717
@@ -19,7 +19,7 @@ markdown test suite.
1919
2020* Level 1
2121
22−** Level 2 with <em>emphasis</em>
22+** Level 2 with *emphasis*
2323
2424*** Level 3
2525
@@ -271,18 +271,18 @@ Loose:
271271
272272Multiple blocks with italics:
273273
274− <em>apple</em> :: red fruit
274+ *apple* :: red fruit
275275
276− contains seeds, crisp, pleasant to taste
277− <em>orange</em> :: orange fruit
276+ contains seeds, crisp, pleasant to taste
277+ *orange* :: orange fruit
278278
279− <example>
280− { orange code block }
281− </example>
279+ <example>
280+ { orange code block }
281+ </example>
282282
283− <quote>
284− orange block quote
285− </quote>
283+ <quote>
284+ orange block quote
285+ </quote>
286286
287287Multiple definitions, tight:
288288
@@ -331,7 +331,7 @@ Interpreted markdown in a table:
331331<td>
332332</literal>
333333
334−This is <em>emphasized</em>
334+This is *emphasized*
335335
336336<literal style="html">
337337</td>
@@ -341,7 +341,7 @@ This is <em>emphasized</em>
341341<td>
342342</literal>
343343
344−And this is <strong>strong</strong>
344+And this is **strong**
345345
346346<literal style="html">
347347</td>
@@ -461,27 +461,25 @@ Hr’s:
461461
462462* Inline Markup
463463
464−This is <em>emphasized</em>, and so <em>is this</em>.
464+This is *emphasized*, and so *is this*.
465465
466−This is <strong>strong</strong>, and so <strong>is this</strong>.
466+This is **strong**, and so **is this**.
467467
468−An <em>[[/url][emphasized link]]</em>.
468+An *[[/url][emphasized link]]*.
469469
470−<strong><em>This is strong and em.</em></strong>
470+***This is strong and em.***
471471
472−So is <strong><em>this</em></strong> word.
472+So is ***this*** word.
473473
474−<strong><em>This is strong and em.</em></strong>
474+***This is strong and em.***
475475
476−So is <strong><em>this</em></strong> word.
476+So is ***this*** word.
477477
478−This is code: <code>></code>, <code>$</code>, <code>\</code>, <code>\$</code>,
479−<code><html></code>.
478+This is code: =>=, =$=, =\=, =\$=, =<html>=.
480479
481−<del>This is <em>strikeout</em>.</del>
480+<del>This is *strikeout*.</del>
482481
483−Superscripts: a<sup>bc</sup>d a<sup><em>hello</em></sup>
484−a<sup>hello there</sup>.
482+Superscripts: a<sup>bc</sup>d a<sup>*hello*</sup> a<sup>hello there</sup>.
485483
486484Subscripts: H<sub>2</sub>O, H<sub>23</sub>O, H<sub>many of them</sub>O.
487485
@@ -500,8 +498,8 @@ spaces: a^b c^d, a~b c~d.
500498
501499‘He said, “I want to go.”’ Were you alive in the 70’s?
502500
503−Here is some quoted ‘<code>code</code>’ and a
504−“[[http://example.com/?foo=1&bar=2][quoted link]]”.
501+Here is some quoted ‘=code=’ and a “[[http://example.com/?foo=1&bar=2][quoted
502+link]]”.
505503
506504Some dashes: one—two — three—four — five.
507505
@@ -515,22 +513,21 @@ Ellipses…and…and….
515513
516514 - <literal style="tex">\cite[22-23]{smith.1899}</literal>
517515 - <verbatim>2 + 2 = 4</verbatim>
518− - <em>x</em> ∈ <em>y</em>
519− - <em>α</em> ∧ <em>ω</em>
516+ - *x* ∈ *y*
517+ - *α* ∧ *ω*
520518 - 223
521− - <em>p</em>-Tree
519+ - *p*-Tree
522520 - Here’s some display math:
523521 <verbatim>$$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$</verbatim>
524− - Here’s one that has a line break in it:
525− <em>α</em> + <em>ω</em> × <em>x</em><sup>2</sup>.
522+ - Here’s one that has a line break in it: *α* + *ω* × *x*<sup>2</sup>.
526523
527524These shouldn’t be math:
528525
529526 - To get the famous equation, write <code>$e = mc^2$</code>.
530− - $22,000 is a <em>lot</em> of money. So is $34,000. (It worked if “lot” is
527+ - $22,000 is a *lot* of money. So is $34,000. (It worked if “lot” is
531528 emphasized.)
532529 - Shoes ($20) and socks ($5).
533− - Escaped <code>$</code>: $73 <em>this should be emphasized</em> 23$.
530+ - Escaped =$=: $73 *this should be emphasized* 23$.
534531
535532Here’s a LaTeX table:
536533
@@ -669,7 +666,7 @@ An e-mail address: [[mailto:nobody@nowhere.net][nobody@nowhere.net]]
669666Blockquoted: [[http://example.com/]]
670667</quote>
671668
672−Auto-links should not occur here: <code><http://example.com/></code>
669+Auto-links should not occur here: =<http://example.com/>=
673670
674671<example>
675672or here: <http://example.com/>
@@ -689,7 +686,7 @@ Here is a movie [[movie.jpg][movie]] icon.
689686
690687* Footnotes
691688
692−Here is a footnote reference,[1] and another.[2] This should <em>not</em> be a
689+Here is a footnote reference,[1] and another.[2] This should *not* be a
693690footnote reference, because it contains a space.[^my note] Here is an inline
694691note.[3]
695692
@@ -716,9 +713,9 @@ This paragraph should not be part of the note, as it is not indented.
716713 If you want, you can indent every line, but you can also be lazy and just
717714 indent the first line of each block.
718715
719−[3] This is <em>easier</em> to type. Inline notes may contain
720− [[http://google.com][links]] and <code>]</code> verbatim characters, as
721− well as [bracketed text].
716+[3] This is *easier* to type. Inline notes may contain
717+ [[http://google.com][links]] and =]= verbatim characters, as well as
718+ [bracketed text].
722719
723720[4] In quote.
724721