git.iko.soy/typeable/pandoc
on master help sign in
RST writer: Use `.. code:: language` for code blocks with language.

Closes #721. Also fixed whitespace in lhs tests.

commit9d549ab683ba4d98a295dc156ea4b81f57f383a7 authorJohn MacFarlane <fiddlosopher@gmail.com> dateSat 26 Jan 2013, 16:09 (14 years ago) parent2f50406
11 files changed+25−20
src/Text/Pandoc/Writers/RST.hs+6−1 tests/lhs-test-markdown.native+1−1 tests/lhs-test.html+2−2 tests/lhs-test.html+lhs+2−2 tests/lhs-test.latex+2−2 tests/lhs-test.latex+lhs+2−2 tests/lhs-test.markdown+2−2 tests/lhs-test.markdown+lhs+2−2 tests/lhs-test.native+1−1 tests/lhs-test.rst+3−3 tests/lhs-test.rst+lhs+2−2
src/Text/Pandoc/Writers/RST.hs+6−1
@@ -177,7 +177,12 @@ blockToRST (CodeBlock (_,classes,_) str) = do
177177 if "haskell" `elem` classes && "literate" `elem` classes &&
178178 isEnabled Ext_literate_haskell opts
179179 then return $ prefixed "> " (text str) $$ blankline
180− else return $ "::" $+$ nest tabstop (text str) $$ blankline
180+ else return $
181+ (case [c | c <- classes,
182+ c `notElem` ["sourceCode","literate","numberLines"]] of
183+ [] -> "::"
184+ (lang:_) -> ".. code:: " <> text lang)
185+ $+$ nest tabstop (text str) $$ blankline
181186blockToRST (BlockQuote blocks) = do
182187 tabstop <- get >>= (return . writerTabStop . stOptions)
183188 contents <- blockListToRST blocks
tests/lhs-test-markdown.native+1−1
@@ -1,6 +1,6 @@
11[Header 1 ("lhs-test",[],[]) [Str "lhs",Space,Str "test"]
22,Para [Code ("",[],[]) "unsplit",Space,Str "is",Space,Str "an",Space,Str "arrow",Space,Str "that",Space,Str "takes",Space,Str "a",Space,Str "pair",Space,Str "of",Space,Str "values",Space,Str "and",Space,Str "combines",Space,Str "them",Space,Str "to",Space,Str "return",Space,Str "a",Space,Str "single",Space,Str "value:"]
3−,CodeBlock ("",["sourceCode","literate","haskell"],[]) "unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d\nunsplit = arr . uncurry \n -- arr (\\op (x,y) -> x `op` y) "
3+,CodeBlock ("",["sourceCode","literate","haskell"],[]) "unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d\nunsplit = arr . uncurry\n -- arr (\\op (x,y) -> x `op` y)"
44,Para [Code ("",[],[]) "(***)",Space,Str "combines",Space,Str "two",Space,Str "arrows",Space,Str "into",Space,Str "a",Space,Str "new",Space,Str "arrow",Space,Str "by",Space,Str "running",Space,Str "the",Space,Str "two",Space,Str "arrows",Space,Str "on",Space,Str "a",Space,Str "pair",Space,Str "of",Space,Str "values",Space,Str "(one",Space,Str "arrow",Space,Str "on",Space,Str "the",Space,Str "first",Space,Str "item",Space,Str "of",Space,Str "the",Space,Str "pair",Space,Str "and",Space,Str "one",Space,Str "arrow",Space,Str "on",Space,Str "the",Space,Str "second",Space,Str "item",Space,Str "of",Space,Str "the",Space,Str "pair)."]
55,CodeBlock ("",[],[]) "f *** g = first f >>> second g"
66,Para [Str "Block",Space,Str "quote:"]
tests/lhs-test.html+2−2
@@ -30,8 +30,8 @@ code > span.er { color: #ff0000; font-weight: bold; }
3030<h1>lhs test</h1>
3131<p><code>unsplit</code> is an arrow that takes a pair of values and combines them to return a single value:</p>
3232<pre class="sourceCode literate haskell"><code class="sourceCode haskell"><span class="ot">unsplit ::</span> (<span class="dt">Arrow</span> a) <span class="ot">=&gt;</span> (b <span class="ot">-&gt;</span> c <span class="ot">-&gt;</span> d) <span class="ot">-&gt;</span> a (b, c) d
33−unsplit <span class="fu">=</span> arr <span class="fu">.</span> <span class="fu">uncurry</span>
34− <span class="co">-- arr (\op (x,y) -&gt; x `op` y) </span></code></pre>
33+unsplit <span class="fu">=</span> arr <span class="fu">.</span> <span class="fu">uncurry</span>
34+ <span class="co">-- arr (\op (x,y) -&gt; x `op` y)</span></code></pre>
3535<p><code>(***)</code> combines two arrows into a new arrow by running the two arrows on a pair of values (one arrow on the first item of the pair and one arrow on the second item of the pair).</p>
3636<pre><code>f *** g = first f &gt;&gt;&gt; second g</code></pre>
3737<p>Block quote:</p>
tests/lhs-test.html+lhs+2−2
@@ -30,8 +30,8 @@ code > span.er { color: #ff0000; font-weight: bold; }
3030<h1>lhs test</h1>
3131<p><code>unsplit</code> is an arrow that takes a pair of values and combines them to return a single value:</p>
3232<pre class="sourceCode literate haskell"><code class="sourceCode haskell"><span class="fu">&gt;</span><span class="ot"> unsplit ::</span> (<span class="dt">Arrow</span> a) <span class="ot">=&gt;</span> (b <span class="ot">-&gt;</span> c <span class="ot">-&gt;</span> d) <span class="ot">-&gt;</span> a (b, c) d
33−<span class="fu">&gt;</span> unsplit <span class="fu">=</span> arr <span class="fu">.</span> <span class="fu">uncurry</span>
34−<span class="fu">&gt;</span> <span class="co">-- arr (\op (x,y) -&gt; x `op` y) </span></code></pre>
33+<span class="fu">&gt;</span> unsplit <span class="fu">=</span> arr <span class="fu">.</span> <span class="fu">uncurry</span>
34+<span class="fu">&gt;</span> <span class="co">-- arr (\op (x,y) -&gt; x `op` y)</span></code></pre>
3535<p><code>(***)</code> combines two arrows into a new arrow by running the two arrows on a pair of values (one arrow on the first item of the pair and one arrow on the second item of the pair).</p>
3636<pre><code>f *** g = first f &gt;&gt;&gt; second g</code></pre>
3737<p>Block quote:</p>
tests/lhs-test.latex+2−2
@@ -72,8 +72,8 @@ return a single value:
7272\begin{Shaded}
7373\begin{Highlighting}[]
7474\OtherTok{unsplit ::} \NormalTok{(}\DataTypeTok{Arrow} \NormalTok{a) }\OtherTok{=>} \NormalTok{(b }\OtherTok{->} \NormalTok{c }\OtherTok{->} \NormalTok{d) }\OtherTok{->} \NormalTok{a (b, c) d}
75−\NormalTok{unsplit }\FunctionTok{=} \NormalTok{arr }\FunctionTok{.} \FunctionTok{uncurry}
76− \CommentTok{-- arr (\textbackslash{}op (x,y) -> x `op` y) }
75+\NormalTok{unsplit }\FunctionTok{=} \NormalTok{arr }\FunctionTok{.} \FunctionTok{uncurry}
76+ \CommentTok{-- arr (\textbackslash{}op (x,y) -> x `op` y)}
7777\end{Highlighting}
7878\end{Shaded}
7979
tests/lhs-test.latex+lhs+2−2
@@ -53,8 +53,8 @@ return a single value:
5353
5454\begin{code}
5555unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
56−unsplit = arr . uncurry
57− -- arr (\op (x,y) -> x `op` y)
56+unsplit = arr . uncurry
57+ -- arr (\op (x,y) -> x `op` y)
5858\end{code}
5959
6060\texttt{(***)} combines two arrows into a new arrow by running the two arrows
tests/lhs-test.markdown+2−2
@@ -6,8 +6,8 @@ a single value:
66
77~~~~ {.sourceCode .literate .haskell}
88unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
9−unsplit = arr . uncurry
10− -- arr (\op (x,y) -> x `op` y)
9+unsplit = arr . uncurry
10+ -- arr (\op (x,y) -> x `op` y)
1111~~~~
1212
1313`(***)` combines two arrows into a new arrow by running the two arrows on a
tests/lhs-test.markdown+lhs+2−2
@@ -5,8 +5,8 @@ lhs test
55a single value:
66
77> unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
8−> unsplit = arr . uncurry
9−> -- arr (\op (x,y) -> x `op` y)
8+> unsplit = arr . uncurry
9+> -- arr (\op (x,y) -> x `op` y)
1010
1111`(***)` combines two arrows into a new arrow by running the two arrows on a
1212pair of values (one arrow on the first item of the pair and one arrow on the
tests/lhs-test.native+1−1
@@ -1,6 +1,6 @@
11[Header 1 ("",[],[]) [Str "lhs",Space,Str "test"]
22,Para [Code ("",[],[]) "unsplit",Space,Str "is",Space,Str "an",Space,Str "arrow",Space,Str "that",Space,Str "takes",Space,Str "a",Space,Str "pair",Space,Str "of",Space,Str "values",Space,Str "and",Space,Str "combines",Space,Str "them",Space,Str "to",Space,Str "return",Space,Str "a",Space,Str "single",Space,Str "value:"]
3−,CodeBlock ("",["sourceCode","literate","haskell"],[]) "unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d\nunsplit = arr . uncurry \n -- arr (\\op (x,y) -> x `op` y) "
3+,CodeBlock ("",["sourceCode","literate","haskell"],[]) "unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d\nunsplit = arr . uncurry\n -- arr (\\op (x,y) -> x `op` y)"
44,Para [Code ("",[],[]) "(***)",Space,Str "combines",Space,Str "two",Space,Str "arrows",Space,Str "into",Space,Str "a",Space,Str "new",Space,Str "arrow",Space,Str "by",Space,Str "running",Space,Str "the",Space,Str "two",Space,Str "arrows",Space,Str "on",Space,Str "a",Space,Str "pair",Space,Str "of",Space,Str "values",Space,Str "(one",Space,Str "arrow",Space,Str "on",Space,Str "the",Space,Str "first",Space,Str "item",Space,Str "of",Space,Str "the",Space,Str "pair",Space,Str "and",Space,Str "one",Space,Str "arrow",Space,Str "on",Space,Str "the",Space,Str "second",Space,Str "item",Space,Str "of",Space,Str "the",Space,Str "pair)."]
55,CodeBlock ("",[],[]) "f *** g = first f >>> second g"
66,Para [Str "Block",Space,Str "quote:"]
tests/lhs-test.rst+3−3
@@ -4,11 +4,11 @@ lhs test
44``unsplit`` is an arrow that takes a pair of values and combines them to
55return a single value:
66
7−::
7+.. code:: haskell
88
99 unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
10− unsplit = arr . uncurry
11− -- arr (\op (x,y) -> x `op` y)
10+ unsplit = arr . uncurry
11+ -- arr (\op (x,y) -> x `op` y)
1212
1313``(***)`` combines two arrows into a new arrow by running the two arrows on a
1414pair of values (one arrow on the first item of the pair and one arrow on the
tests/lhs-test.rst+lhs+2−2
@@ -5,8 +5,8 @@ lhs test
55return a single value:
66
77> unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
8−> unsplit = arr . uncurry
9−> -- arr (\op (x,y) -> x `op` y)
8+> unsplit = arr . uncurry
9+> -- arr (\op (x,y) -> x `op` y)
1010
1111``(***)`` combines two arrows into a new arrow by running the two arrows on a
1212pair of values (one arrow on the first item of the pair and one arrow on the