Skip to content

Instantly share code, notes, and snippets.

View mpickering's full-sized avatar

Matthew Pickering mpickering

  • Well Typed LLP
  • Sheffield, UK
View GitHub Profile
all:
pandoc --filter pandoc-citeproc --variable="linestretch=2" --template=afterbody.tex -o minimal.pdf minimal.md
@mpickering
mpickering / extrafile.md
Created August 19, 2014 10:00
Transclusion

This is the extra file.

Sat Dec 6 21:21 2014 Time and Allocation Profiling Report (Final)
pandoc +RTS -K16m -p -K4000M -RTS -f html -t plain -o plain.txt 76d21fc1321880f48eb6/bad.html
total time = 71.03 secs (71031 ticks @ 1000 us, 1 processor)
total alloc = 148,899,219,400 bytes (excludes profiling overheads)
COST CENTRE MODULE %time %alloc
realLength Text.Pandoc.Pretty 30.3 27.6
@mpickering
mpickering / gist:b9fceb4cf9f11e116b49
Created December 8, 2014 17:41
Pandoc filter to remove comments
module Main where
import Text.Pandoc.JSON
import Data.List
main = toJSONFilter removeComments
removeComments :: Block -> [Block]
removeComments e@(RawBlock (Format "html") s) = if isComment s then [] else [e]
removeComments e = [e]
@mpickering
mpickering / gist:0fce7cf3124fee8b38a1
Created December 8, 2014 17:43
Pandoc filter to remove footnotes
module Main where
import Text.Pandoc.JSON
main = toJSONFilter removeFootnote
removeFootnote :: Inline -> [Inline]
removeFootnote (Note _) = []
removeFootnote e = [e]
@mpickering
mpickering / gist:fdc747b9c8306659cb43
Created December 17, 2014 22:32
Pandoc filter to insert non-breaking spaces.
module Main where
import Text.Pandoc.JSON
import Data.List (isPrefixOf)
import Data.Char (isAlphaNum)
main = toJSONFilter insertSpaces
insertSpaces :: Inline -> Inline
insertSpaces l@(Link [Str x] (url, tit))
@mpickering
mpickering / HTML.hs
Created December 31, 2014 01:32
Servant HTML Combinator
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeFamilies #-}
import Data.ByteString.Lazy ()
import Text.Blaze.Html (Html)
import Text.Blaze.Renderer.Utf8 (renderMarkup)
import Control.Monad.Trans.Either (EitherT, runEitherT)
import Data.Proxy (Proxy (Proxy))
import Servant.Server.Internal (HasServer (..), RouteMismatch (WrongMethod, NotFound),
@mpickering
mpickering / gist:c518863fa193ac075042
Created January 4, 2015 01:52
Pandoc filter to render frames around content
{-# LANGUAGE OverloadedStrings #-}
module Main where
-- https://groups.google.com/d/msgid/pandoc-discuss/45a32eb9-23b9-4df1-8c6e-2e08073df166%40googlegroups.com?utm_medium=email&utm_source=footer
import Text.Pandoc.JSON
import Text.Pandoc.Definition
import Text.Printf
import Data.Maybe
@mpickering
mpickering / gist:fe079e41a9f30f9e683f
Created January 4, 2015 21:59
Simple servant example
{-# LANGUAGE DataKinds, TypeFamilies, TypeOperators, OverloadedStrings #-}
module M where
import Servant.Server
import Servant
import Data.Text (Text)
import Network.Wai.Handler.Warp
import Data.Proxy
myApi :: Proxy MyApi
module RepListMin where
repListMin :: [Int] -> [Int]
repListMin xs = res
where
(m, res) = repListMin' m xs
repListMin' :: Int -> [Int] -> (Int, [Int])
repListMin' m [x] = (x, [m])