From 29c2670da2a267094148f3edacaed5fc258bcdd1 Mon Sep 17 00:00:00 2001 From: Lucas Escot Date: Thu, 13 Feb 2020 19:27:34 +0100 Subject: Add highlight directive to the rST reader (#6140) --- test/rst-reader.native | 4 ++++ test/rst-reader.rst | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) (limited to 'test') diff --git a/test/rst-reader.native b/test/rst-reader.native index 70ed3cf60..d4322f9ae 100644 --- a/test/rst-reader.native +++ b/test/rst-reader.native @@ -39,6 +39,10 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa ,CodeBlock ("",[],[]) "this block is indented by two tabs\n\nThese should not be escaped: \\$ \\\\ \\> \\[ \\{" ,Para [Str "And:"] ,CodeBlock ("",["python"],[]) "def my_function(x):\n return x + 1" +,Para [Str "If",Space,Str "we",Space,Str "use",Space,Str "the",Space,Str "highlight",Space,Str "directive,",Space,Str "we",Space,Str "can",Space,Str "specify",Space,Str "a",Space,Str "default",Space,Str "language",SoftBreak,Str "for",Space,Str "literate",Space,Str "blocks."] +,CodeBlock ("",["haskell"],[]) "-- this code is in haskell\ndata Tree = Leaf | Node Tree Tree" +,CodeBlock ("",["haskell"],[]) "-- this code is in haskell too\ndata Nat = Zero | Succ Nat" +,CodeBlock ("",["javascript"],[]) "-- this code is in javascript\nlet f = (x, y) => x + y" ,Header 1 ("lists",[],[]) [Str "Lists"] ,Header 2 ("unordered",[],[]) [Str "Unordered"] ,Para [Str "Asterisks",Space,Str "tight:"] diff --git a/test/rst-reader.rst b/test/rst-reader.rst index a918c0e2c..d2d82d435 100644 --- a/test/rst-reader.rst +++ b/test/rst-reader.rst @@ -107,6 +107,30 @@ And: def my_function(x): return x + 1 +If we use the highlight directive, we can specify a default language +for literate blocks. + +.. highlight:: haskell + +:: + + -- this code is in haskell + data Tree = Leaf | Node Tree Tree + +:: + + -- this code is in haskell too + data Nat = Zero | Succ Nat + +.. highlight:: javascript + +:: + + -- this code is in javascript + let f = (x, y) => x + y + +.. highlight:: + Lists ===== -- cgit v1.2.3