git.iko.soy/typeable/pandoc
on master help sign in
RST writer: Use `.. code:: language` for code blocks with language.
9d549abJohn MacFarlane
src/Text/Pandoc/Writers/RST.hs+6−1
@@ -177,7 +177,12 @@ blockToRST (CodeBlock (_,classes,_) str) = do
177 if "haskell" `elem` classes && "literate" `elem` classes &&
177 if "haskell" `elem` classes && "literate" `elem` classes &&
178 isEnabled Ext_literate_haskell opts
178 isEnabled Ext_literate_haskell opts
179 then return $ prefixed "> " (text str) $$ blankline
179 then return $ prefixed "> " (text str) $$ blankline
180+ else return $
181+ (case [c | c <- classes,
182+ c `notElem` ["sourceCode","literate","numberLines"]] of
183+ [] -> "::"
184+ (lang:_) -> ".. code:: " <> text lang)
180− else return $ "::" $+$ nest tabstop (text str) $$ blankline
185+ $+$ nest tabstop (text str) $$ blankline
181blockToRST (BlockQuote blocks) = do
186blockToRST (BlockQuote blocks) = do
182 tabstop <- get >>= (return . writerTabStop . stOptions)
187 tabstop <- get >>= (return . writerTabStop . stOptions)
183 contents <- blockListToRST blocks
188 contents <- blockListToRST blocks
tests/lhs-test-markdown.native+1−1
@@ -1,6 +1,6 @@
1[Header 1 ("lhs-test",[],[]) [Str "lhs",Space,Str "test"]
1[Header 1 ("lhs-test",[],[]) [Str "lhs",Space,Str "test"]
2,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:"]
2,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)"
4,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)."]
4,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)."]
5,CodeBlock ("",[],[]) "f *** g = first f >>> second g"
5,CodeBlock ("",[],[]) "f *** g = first f >>> second g"
6,Para [Str "Block",Space,Str "quote:"]
6,Para [Str "Block",Space,Str "quote:"]
tests/lhs-test.html+2−2
@@ -30,8 +30,8 @@ code > span.er { color: #ff0000; font-weight: bold; }
30<h1>lhs test</h1>
30<h1>lhs test</h1>
31<p><code>unsplit</code> is an arrow that takes a pair of values and combines them to return a single value:</p>
31<p><code>unsplit</code> is an arrow that takes a pair of values and combines them to return a single value:</p>
32<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
32<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>
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>
34+ <span class="co">-- arr (\op (x,y) -&gt; x `op` y)</span></code></pre>
35<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>
35<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>
36<pre><code>f *** g = first f &gt;&gt;&gt; second g</code></pre>
36<pre><code>f *** g = first f &gt;&gt;&gt; second g</code></pre>
37<p>Block quote:</p>
37<p>Block quote:</p>
tests/lhs-test.html+lhs+2−2
@@ -30,8 +30,8 @@ code > span.er { color: #ff0000; font-weight: bold; }
30<h1>lhs test</h1>
30<h1>lhs test</h1>
31<p><code>unsplit</code> is an arrow that takes a pair of values and combines them to return a single value:</p>
31<p><code>unsplit</code> is an arrow that takes a pair of values and combines them to return a single value:</p>
32<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
32<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>
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>
34+<span class="fu">&gt;</span> <span class="co">-- arr (\op (x,y) -&gt; x `op` y)</span></code></pre>
35<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>
35<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>
36<pre><code>f *** g = first f &gt;&gt;&gt; second g</code></pre>
36<pre><code>f *** g = first f &gt;&gt;&gt; second g</code></pre>
37<p>Block quote:</p>
37<p>Block quote:</p>
tests/lhs-test.latex+2−2
@@ -72,8 +72,8 @@ return a single value:
72\begin{Shaded}
72\begin{Shaded}
73\begin{Highlighting}[]
73\begin{Highlighting}[]
74\OtherTok{unsplit ::} \NormalTok{(}\DataTypeTok{Arrow} \NormalTok{a) }\OtherTok{=>} \NormalTok{(b }\OtherTok{->} \NormalTok{c }\OtherTok{->} \NormalTok{d) }\OtherTok{->} \NormalTok{a (b, c) d}
74\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}
75+\NormalTok{unsplit }\FunctionTok{=} \NormalTok{arr }\FunctionTok{.} \FunctionTok{uncurry}
76− \CommentTok{-- arr (\textbackslash{}op (x,y) -> x `op` y) }
76+ \CommentTok{-- arr (\textbackslash{}op (x,y) -> x `op` y)}
77\end{Highlighting}
77\end{Highlighting}
78\end{Shaded}
78\end{Shaded}
79
79
tests/lhs-test.latex+lhs+2−2
@@ -53,8 +53,8 @@ return a single value:
53
53
54\begin{code}
54\begin{code}
55unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
55unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
56−unsplit = arr . uncurry
56+unsplit = arr . uncurry
57− -- arr (\op (x,y) -> x `op` y)
57+ -- arr (\op (x,y) -> x `op` y)
58\end{code}
58\end{code}
59
59
60\texttt{(***)} combines two arrows into a new arrow by running the two arrows
60\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:
6
6
7~~~~ {.sourceCode .literate .haskell}
7~~~~ {.sourceCode .literate .haskell}
8unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
8unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
9−unsplit = arr . uncurry
9+unsplit = arr . uncurry
10− -- arr (\op (x,y) -> x `op` y)
10+ -- arr (\op (x,y) -> x `op` y)
11~~~~
11~~~~
12
12
13`(***)` combines two arrows into a new arrow by running the two arrows on a
13`(***)` 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
5a single value:
5a single value:
6
6
7> unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
7> unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
8−> unsplit = arr . uncurry
8+> unsplit = arr . uncurry
9−> -- arr (\op (x,y) -> x `op` y)
9+> -- arr (\op (x,y) -> x `op` y)
10
10
11`(***)` combines two arrows into a new arrow by running the two arrows on a
11`(***)` combines two arrows into a new arrow by running the two arrows on a
12pair of values (one arrow on the first item of the pair and one arrow on the
12pair 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 @@
1[Header 1 ("",[],[]) [Str "lhs",Space,Str "test"]
1[Header 1 ("",[],[]) [Str "lhs",Space,Str "test"]
2,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:"]
2,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)"
4,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)."]
4,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)."]
5,CodeBlock ("",[],[]) "f *** g = first f >>> second g"
5,CodeBlock ("",[],[]) "f *** g = first f >>> second g"
6,Para [Str "Block",Space,Str "quote:"]
6,Para [Str "Block",Space,Str "quote:"]
tests/lhs-test.rst+3−3
@@ -4,11 +4,11 @@ lhs test
4``unsplit`` is an arrow that takes a pair of values and combines them to
4``unsplit`` is an arrow that takes a pair of values and combines them to
5return a single value:
5return a single value:
6
6
7−::
7+.. code:: haskell
8
8
9 unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
9 unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
10− unsplit = arr . uncurry
10+ unsplit = arr . uncurry
11− -- arr (\op (x,y) -> x `op` y)
11+ -- arr (\op (x,y) -> x `op` y)
12
12
13``(***)`` combines two arrows into a new arrow by running the two arrows on a
13``(***)`` combines two arrows into a new arrow by running the two arrows on a
14pair of values (one arrow on the first item of the pair and one arrow on the
14pair 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
5return a single value:
5return a single value:
6
6
7> unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
7> unsplit :: (Arrow a) => (b -> c -> d) -> a (b, c) d
8−> unsplit = arr . uncurry
8+> unsplit = arr . uncurry
9−> -- arr (\op (x,y) -> x `op` y)
9+> -- arr (\op (x,y) -> x `op` y)
10
10
11``(***)`` combines two arrows into a new arrow by running the two arrows on a
11``(***)`` combines two arrows into a new arrow by running the two arrows on a
12pair of values (one arrow on the first item of the pair and one arrow on the
12pair of values (one arrow on the first item of the pair and one arrow on the