From 6ea6011ca66c3127ff42cd5d0d39b3bd40e56e76 Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Thu, 30 Aug 2018 17:10:46 +0300 Subject: Muse writer: use lightweight markup when possible --- test/Tests/Writers/Muse.hs | 50 ++++++++++++++++++++++++------- test/writer.muse | 75 ++++++++++++++++++++++------------------------ 2 files changed, 75 insertions(+), 50 deletions(-) (limited to 'test') diff --git a/test/Tests/Writers/Muse.hs b/test/Tests/Writers/Muse.hs index 50c0e78eb..f44097f9e 100644 --- a/test/Tests/Writers/Muse.hs +++ b/test/Tests/Writers/Muse.hs @@ -354,23 +354,51 @@ tests = [ testGroup "block elements" , "do not escape ; inside paragraph" =: text "foo ; bar" =?> "foo ; bar" ] , testGroup "emphasis" - [ "emph" =: emph (text "foo") =?> "foo" - , "strong" =: strong (text "foo") =?> "foo" + [ "emphasis" =: emph (text "foo") =?> "*foo*" + , "emphasis inside word" =: text "foo" <> emph (text "bar") <> text "baz" =?> "foobarbaz" + , "emphasis before comma" =: emph (text "foo") <> text ", bar" =?> "*foo*, bar" + , "emphasis before period" =: emph (text "foobar") <> text "." =?> "*foobar*." + , "empty emphasis" =: emph mempty =?> "" + , "empty strong" =: strong mempty =?> "" + , "empty strong emphasis" =: strong (emph mempty) =?> "****" + , "empty emphasized strong" =: emph (strong mempty) =?> "**" + , "strong" =: strong (text "foo") =?> "**foo**" + , "strong inside word" =: text "foo" <> strong (text "bar") <> text "baz" =?> "foobarbaz" + , "strong emphasis" =: strong (emph (text "foo")) =?> "***foo***" + , "strong after emphasis" =: emph (text "foo") <> strong (text "bar") =?> "*foo*bar" + , "strong emphasis after emphasis" =: emph (text "foo") <> strong (emph (text "bar")) =?> "*foo**bar*" + , "strong in the end of emphasis" =: emph (text "foo" <> strong (text "bar")) =?> "*foobar*" , "strikeout" =: strikeout (text "foo") =?> "foo" + , "space at the beginning of emphasis" =: emph (text " foo") =?> " foo" + , "space at the end of emphasis" =: emph (text "foo ") =?> "foo " + , "space at the beginning of strong" =: strong (text " foo") =?> " foo" + , "space at the end of strong" =: strong (text "foo ") =?> "foo " + , "space at the beginning of strong emphasis" =: strong (emph (text " foo")) =?> "** foo**" + , "space at the end of strong emphasis" =: strong (emph (text "foo ")) =?> "**foo **" + , "space at the beginning of emphasiszed strong" =: emph (strong (text " foo")) =?> "* foo*" + , "space at the end of emphasized strong" =: emph (strong (text "foo ")) =?> "*foo *" ] , "superscript" =: superscript (text "foo") =?> "foo" , "subscript" =: subscript (text "foo") =?> "foo" - , "smallcaps" =: smallcaps (text "foo") =?> "foo" - , "smallcaps near emphasis" =: emph (str "foo") <> smallcaps (str "bar") =?> "foobar" + , "smallcaps" =: smallcaps (text "foo") =?> "*foo*" + , "smallcaps near emphasis" =: emph (str "foo") <> smallcaps (str "bar") =?> "*foobar*" , "single quoted" =: singleQuoted (text "foo") =?> "‘foo’" , "double quoted" =: doubleQuoted (text "foo") =?> "“foo”" -- Cite is trivial , testGroup "code" - [ "simple" =: code "foo" =?> "foo" + [ "simple" =: code "foo" =?> "=foo=" + , "empty" =: code "" =?> "" + , "space" =: code " " =?> " " + , "space at the beginning" =: code " foo" =?> " foo" + , "space at the end" =: code "foo " =?> "foo " + , "use tags for =" =: code "foo = bar" =?> "foo = bar" , "escape tag" =: code "foo = bar baz" =?> "foo = bar</code> baz" - , "normalization with attributes" =: codeWith ("",["haskell"],[]) "foo" <> code "bar" =?> "foobar" - , "normalization" =: code " code "de>" =?> "</code>" - , "normalization with empty string" =: code " str "" <> code "de>" =?> "</code>" + , "normalization with attributes" =: codeWith ("",["haskell"],[]) "foo" <> code "bar" =?> "=foobar=" + , "code tag" =: code "foo" =?> "=foo=" + , "normalization" =: code " code "de>" <> code "=" =?> "</code>=" + , "normalization with empty string" =: code " str "" <> code "de>" <> code "=" =?> "</code>=" + , "emphasized code" =: emph (code "foo") =?> "*=foo=*" + , "strong code" =: strong (code "foo") =?> "**=foo=**" ] , testGroup "spaces" [ "space" =: text "a" <> space <> text "b" =?> "a b" @@ -385,7 +413,7 @@ tests = [ testGroup "block elements" , testGroup "math" [ "inline math" =: math "2^3" =?> "23" , "display math" =: displayMath "2^3" =?> "23" - , "multiple letters in inline math" =: math "abc" =?> "abc" + , "multiple letters in inline math" =: math "abc" =?> "*abc*" , "expand math before normalization" =: math "[" <> str "2]" =?> "[2]" , "multiple math expressions inside one inline list" =: math "5_4" <> text ", " <> displayMath "3^2" =?> "54, 32" ] @@ -461,7 +489,7 @@ tests = [ testGroup "block elements" "foobar" , "emph quoted" =: para (doubleQuoted (emph (text "foo"))) =?> - "“foo”" + "“*foo*”" , "strong word before" =: para (text "foo" <> strong (text "bar")) =?> "foobar" @@ -470,7 +498,7 @@ tests = [ testGroup "block elements" "foobar" , "strong quoted" =: para (singleQuoted (strong (text "foo"))) =?> - "‘foo’" + "‘**foo**’" ] ] ] diff --git a/test/writer.muse b/test/writer.muse index 5993ec357..35d43a751 100644 --- a/test/writer.muse +++ b/test/writer.muse @@ -11,7 +11,7 @@ markdown test suite. ** Level 2 with an [[/url][embedded link]] -*** Level 3 with emphasis +*** Level 3 with *emphasis* **** Level 4 @@ -19,7 +19,7 @@ markdown test suite. * Level 1 -** Level 2 with emphasis +** Level 2 with *emphasis* *** Level 3 @@ -271,18 +271,18 @@ Loose: Multiple blocks with italics: - apple :: red fruit + *apple* :: red fruit - contains seeds, crisp, pleasant to taste - orange :: orange fruit + contains seeds, crisp, pleasant to taste + *orange* :: orange fruit - - { orange code block } - + + { orange code block } + - - orange block quote - + + orange block quote + Multiple definitions, tight: @@ -331,7 +331,7 @@ Interpreted markdown in a table: -This is emphasized +This is *emphasized* @@ -341,7 +341,7 @@ This is emphasized -And this is strong +And this is **strong** @@ -461,27 +461,25 @@ Hr’s: * Inline Markup -This is emphasized, and so is this. +This is *emphasized*, and so *is this*. -This is strong, and so is this. +This is **strong**, and so **is this**. -An [[/url][emphasized link]]. +An *[[/url][emphasized link]]*. -This is strong and em. +***This is strong and em.*** -So is this word. +So is ***this*** word. -This is strong and em. +***This is strong and em.*** -So is this word. +So is ***this*** word. -This is code: >, $, \, \$, -. +This is code: =>=, =$=, =\=, =\$=, ==. -This is strikeout. +This is *strikeout*. -Superscripts: abcd ahello -ahello there. +Superscripts: abcd a*hello* ahello there. Subscripts: H2O, H23O, Hmany of themO. @@ -500,8 +498,8 @@ spaces: a^b c^d, a~b c~d. ‘He said, “I want to go.”’ Were you alive in the 70’s? -Here is some quoted ‘code’ and a -“[[http://example.com/?foo=1&bar=2][quoted link]]”. +Here is some quoted ‘=code=’ and a “[[http://example.com/?foo=1&bar=2][quoted +link]]”. Some dashes: one—two — three—four — five. @@ -515,22 +513,21 @@ Ellipses…and…and…. - \cite[22-23]{smith.1899} - 2 + 2 = 4 - - x ∈ y - - α ∧ ω + - *x* ∈ *y* + - *α* ∧ *ω* - 223 - - p-Tree + - *p*-Tree - Here’s some display math: $$\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}$$ - - Here’s one that has a line break in it: - α + ω × x2. + - Here’s one that has a line break in it: *α* + *ω* × *x*2. These shouldn’t be math: - To get the famous equation, write $e = mc^2$. - - $22,000 is a lot of money. So is $34,000. (It worked if “lot” is + - $22,000 is a *lot* of money. So is $34,000. (It worked if “lot” is emphasized.) - Shoes ($20) and socks ($5). - - Escaped $: $73 this should be emphasized 23$. + - Escaped =$=: $73 *this should be emphasized* 23$. Here’s a LaTeX table: @@ -669,7 +666,7 @@ An e-mail address: [[mailto:nobody@nowhere.net][nobody@nowhere.net]] Blockquoted: [[http://example.com/]] -Auto-links should not occur here: +Auto-links should not occur here: == or here: @@ -689,7 +686,7 @@ Here is a movie [[movie.jpg][movie]] icon. * Footnotes -Here is a footnote reference,[1] and another.[2] This should not be a +Here is a footnote reference,[1] and another.[2] This should *not* be a footnote reference, because it contains a space.[^my note] Here is an inline note.[3] @@ -716,9 +713,9 @@ This paragraph should not be part of the note, as it is not indented. If you want, you can indent every line, but you can also be lazy and just indent the first line of each block. -[3] This is easier to type. Inline notes may contain - [[http://google.com][links]] and ] verbatim characters, as - well as [bracketed text]. +[3] This is *easier* to type. Inline notes may contain + [[http://google.com][links]] and =]= verbatim characters, as well as + [bracketed text]. [4] In quote. -- cgit v1.2.3