knit-haskell 0.6.0.0 → 0.6.0.1
raw patch · 20 files changed
+869/−799 lines, 20 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ChangeLog.md +4/−1
- Readme.md +2/−3
- data/pandoc-data/data/templates/default.commonmark +21/−0
- data/pandoc-data/data/templates/default.haddock +1/−0
- data/pandoc-data/data/templates/default.html4 +69/−0
- data/pandoc-data/data/templates/default.html5 +72/−0
- data/pandoc-data/data/templates/default.latex +488/−0
- data/pandoc-data/data/templates/default.markdown +21/−0
- data/pandoc-data/templates/default.commonmark +0/−21
- data/pandoc-data/templates/default.haddock +0/−1
- data/pandoc-data/templates/default.html4 +0/−69
- data/pandoc-data/templates/default.html5 +0/−72
- data/pandoc-data/templates/default.latex +0/−488
- data/pandoc-data/templates/default.markdown +0/−21
- examples/ErrorExample.hs +24/−15
- examples/MtlExample.hs +32/−21
- examples/MultiDocExample.hs +18/−12
- examples/RandomExample.hs +65/−41
- examples/SimpleExample.hs +45/−26
- knit-haskell.cabal +7/−8
ChangeLog.md view
@@ -1,4 +1,7 @@-v 0.6.0.0+v 0.6.0.1 - (Released 2019-06-21)+* Moved the Pandoc default templates so they will be installed where Pandoc expects them. This is hard to test!++v 0.6.0.0 - (Released: 2019-06-19) * updated to use polysemy-zoo version of constraint absorbers in PandocMonad. * Hackage download should now include templates and associated css * Added mkPandocWriterConfig and addCss function in Knit.Report.Output to handle loading things in
Readme.md view
@@ -46,14 +46,13 @@ module. That has the main functions for "knitting" documents from fragments and re-exports all the required functions to input the supported fragment types and create/write Html. * This uses [polysemy](https://github.com/isovector/polysemy#readme) for its effect management rather than mtl. -Effects are provided for logging and generating [random-fu](http://hackage.haskell.org/package/random-fu) style random numbers. -Polysemy's inference and performance are improved greatly if you enable the [polysemy-plugin](https://hackage.haskell.org/package/polysemy-plugin),+Polysemy's inference and performance are greatly improved if you enable the [polysemy-plugin](https://hackage.haskell.org/package/polysemy-plugin), which involves: 1. adding "polysemy-plugin" in build-depends and 2. Add "ghc-options: -fplugin=Polysemy.Plugin" to your package configuration. Pandoc effects and writer effects for document building are also provided. * Polysemy is capable of "absorbing" some mtl-style monad constraints. This is demonstrated in-the [Random](https://github.com/adamConnerSax/knit-haskell/blob/master/examples/RandomExample.hs#L96) and+[RandomExample](https://github.com/adamConnerSax/knit-haskell/blob/master/examples/RandomExample.hs#L113) and composable absorbers for MonadReader, MonadWriter, MonadState and MonadError can be found in the [polysemy-zoo](https://github.com/isovector/polysemy-zoo). * Pandoc templates are included for HTML output. See the examples for how to access them
+ data/pandoc-data/data/templates/default.commonmark view
@@ -0,0 +1,21 @@+$if(titleblock)$+$titleblock$++$endif$+$for(header-includes)$+$header-includes$++$endfor$+$for(include-before)$+$include-before$++$endfor$+$if(toc)$+$table-of-contents$++$endif$+$body$+$for(include-after)$++$include-after$+$endfor$
+ data/pandoc-data/data/templates/default.haddock view
@@ -0,0 +1,1 @@+$body$
+ data/pandoc-data/data/templates/default.html4 view
@@ -0,0 +1,69 @@+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">+<html xmlns="http://www.w3.org/1999/xhtml"$if(lang)$ lang="$lang$" xml:lang="$lang$"$endif$$if(dir)$ dir="$dir$"$endif$>+<head>+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />+ <meta http-equiv="Content-Style-Type" content="text/css" />+ <meta name="generator" content="pandoc" />+$for(author-meta)$+ <meta name="author" content="$author-meta$" />+$endfor$+$if(date-meta)$+ <meta name="date" content="$date-meta$" />+$endif$+$if(keywords)$+ <meta name="keywords" content="$for(keywords)$$keywords$$sep$, $endfor$" />+$endif$+ <title>$if(title-prefix)$$title-prefix$ – $endif$$pagetitle$</title>+ <style type="text/css">+ code{white-space: pre-wrap;}+ span.smallcaps{font-variant: small-caps;}+ span.underline{text-decoration: underline;}+ div.column{display: inline-block; vertical-align: top; width: 50%;}+$if(quotes)$+ q { quotes: "“" "”" "‘" "’"; }+$endif$+ </style>+$if(highlighting-css)$+ <style type="text/css">+$highlighting-css$+ </style>+$endif$+$for(css)$+ <link rel="stylesheet" href="$css$" type="text/css" />+$endfor$+$if(math)$+ $math$+$endif$+$for(header-includes)$+ $header-includes$+$endfor$+</head>+<body>+$for(include-before)$+$include-before$+$endfor$+$if(title)$+<div id="$idprefix$header">+<h1 class="title">$title$</h1>+$if(subtitle)$+<h1 class="subtitle">$subtitle$</h1>+$endif$+$for(author)$+<h2 class="author">$author$</h2>+$endfor$+$if(date)$+<h3 class="date">$date$</h3>+$endif$+</div>+$endif$+$if(toc)$+<div id="$idprefix$TOC">+$table-of-contents$+</div>+$endif$+$body$+$for(include-after)$+$include-after$+$endfor$+</body>+</html>
+ data/pandoc-data/data/templates/default.html5 view
@@ -0,0 +1,72 @@+<!DOCTYPE html>+<html xmlns="http://www.w3.org/1999/xhtml" lang="$lang$" xml:lang="$lang$"$if(dir)$ dir="$dir$"$endif$>+<head>+ <meta charset="utf-8" />+ <meta name="generator" content="pandoc" />+ <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />+$for(author-meta)$+ <meta name="author" content="$author-meta$" />+$endfor$+$if(date-meta)$+ <meta name="dcterms.date" content="$date-meta$" />+$endif$+$if(keywords)$+ <meta name="keywords" content="$for(keywords)$$keywords$$sep$, $endfor$" />+$endif$+ <title>$if(title-prefix)$$title-prefix$ – $endif$$pagetitle$</title>+ <style>+ code{white-space: pre-wrap;}+ span.smallcaps{font-variant: small-caps;}+ span.underline{text-decoration: underline;}+ div.column{display: inline-block; vertical-align: top; width: 50%;}+$if(quotes)$+ q { quotes: "“" "”" "‘" "’"; }+$endif$+ </style>+$if(highlighting-css)$+ <style>+$highlighting-css$+ </style>+$endif$+$for(css)$+ <link rel="stylesheet" href="$css$" />+$endfor$+$if(math)$+ $math$+$endif$+ <!--[if lt IE 9]>+ <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>+ <![endif]-->+$for(header-includes)$+ $header-includes$+$endfor$+</head>+<body>+$for(include-before)$+$include-before$+$endfor$+$if(title)$+<header id="title-block-header">+<h1 class="title">$title$</h1>+$if(subtitle)$+<p class="subtitle">$subtitle$</p>+$endif$+$for(author)$+<p class="author">$author$</p>+$endfor$+$if(date)$+<p class="date">$date$</p>+$endif$+</header>+$endif$+$if(toc)$+<nav id="$idprefix$TOC" role="doc-toc">+$table-of-contents$+</nav>+$endif$+$body$+$for(include-after)$+$include-after$+$endfor$+</body>+</html>
+ data/pandoc-data/data/templates/default.latex view
@@ -0,0 +1,488 @@+% Options for packages loaded elsewhere+\PassOptionsToPackage{unicode$for(hyperrefoptions)$,$hyperrefoptions$$endfor$}{hyperref}+\PassOptionsToPackage{hyphens}{url}+$if(colorlinks)$+\PassOptionsToPackage{dvipsnames,svgnames*,x11names*}{xcolor}+$endif$+$if(dir)$+$if(latex-dir-rtl)$+\PassOptionsToPackage{RTLdocument}{bidi}+$endif$+$endif$+%+\documentclass[+$if(fontsize)$+ $fontsize$,+$endif$+$if(lang)$+ $babel-lang$,+$endif$+$if(papersize)$+ $papersize$paper,+$endif$+$if(beamer)$+ ignorenonframetext,+$if(handout)$+ handout,+$endif$+$if(aspectratio)$+ aspectratio=$aspectratio$,+$endif$+$endif$+$for(classoption)$+ $classoption$$sep$,+$endfor$+]{$documentclass$}+$if(beamer)$+$if(background-image)$+\usebackgroundtemplate{%+ \includegraphics[width=\paperwidth]{$background-image$}%+}+$endif$+\usepackage{pgfpages}+\setbeamertemplate{caption}[numbered]+\setbeamertemplate{caption label separator}{: }+\setbeamercolor{caption name}{fg=normal text.fg}+\beamertemplatenavigationsymbols$if(navigation)$$navigation$$else$empty$endif$+$for(beameroption)$+\setbeameroption{$beameroption$}+$endfor$+% Prevent slide breaks in the middle of a paragraph+\widowpenalties 1 10000+\raggedbottom+$if(section-titles)$+\setbeamertemplate{part page}{+ \centering+ \begin{beamercolorbox}[sep=16pt,center]{part title}+ \usebeamerfont{part title}\insertpart\par+ \end{beamercolorbox}+}+\setbeamertemplate{section page}{+ \centering+ \begin{beamercolorbox}[sep=12pt,center]{part title}+ \usebeamerfont{section title}\insertsection\par+ \end{beamercolorbox}+}+\setbeamertemplate{subsection page}{+ \centering+ \begin{beamercolorbox}[sep=8pt,center]{part title}+ \usebeamerfont{subsection title}\insertsubsection\par+ \end{beamercolorbox}+}+\AtBeginPart{+ \frame{\partpage}+}+\AtBeginSection{+ \ifbibliography+ \else+ \frame{\sectionpage}+ \fi+}+\AtBeginSubsection{+ \frame{\subsectionpage}+}+$endif$+$endif$+$if(beamerarticle)$+\usepackage{beamerarticle} % needs to be loaded first+$endif$+$if(fontfamily)$+\usepackage[$for(fontfamilyoptions)$$fontfamilyoptions$$sep$,$endfor$]{$fontfamily$}+$else$+\usepackage{lmodern}+$endif$+$if(linestretch)$+\usepackage{setspace}+$endif$+\usepackage{amssymb,amsmath}+\usepackage{ifxetex,ifluatex}+\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex+ \usepackage[$if(fontenc)$$fontenc$$else$T1$endif$]{fontenc}+ \usepackage[utf8]{inputenc}+ \usepackage{textcomp} % provide euro and other symbols+\else % if luatex or xetex+$if(mathspec)$+ \ifxetex+ \usepackage{mathspec}+ \else+ \usepackage{unicode-math}+ \fi+$else$+ \usepackage{unicode-math}+$endif$+ \defaultfontfeatures{Scale=MatchLowercase}+ \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}+$if(mainfont)$+ \setmainfont[$for(mainfontoptions)$$mainfontoptions$$sep$,$endfor$]{$mainfont$}+$endif$+$if(sansfont)$+ \setsansfont[$for(sansfontoptions)$$sansfontoptions$$sep$,$endfor$]{$sansfont$}+$endif$+$if(monofont)$+ \setmonofont[$for(monofontoptions)$$monofontoptions$$sep$,$endfor$]{$monofont$}+$endif$+$for(fontfamilies)$+ \newfontfamily{$fontfamilies.name$}[$for(fontfamilies.options)$$fontfamilies.options$$sep$,$endfor$]{$fontfamilies.font$}+$endfor$+$if(mathfont)$+$if(mathspec)$+ \ifxetex+ \setmathfont(Digits,Latin,Greek)[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}+ \else+ \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}+ \fi+$else$+ \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}+$endif$+$endif$+$if(CJKmainfont)$+ \ifxetex+ \usepackage{xeCJK}+ \setCJKmainfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$}+ \fi+$endif$+$if(luatexjapresetoptions)$+ \ifluatex+ \usepackage[$for(luatexjapresetoptions)$$luatexjapresetoptions$$sep$,$endfor$]{luatexja-preset}+ \fi+$endif$+$if(CJKmainfont)$+ \ifluatex+ \usepackage[$for(luatexjafontspecoptions)$$luatexjafontspecoptions$$sep$,$endfor$]{luatexja-fontspec}+ \setmainjfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$}+ \fi+$endif$+\fi+$if(beamer)$+$if(theme)$+\usetheme[$for(themeoptions)$$themeoptions$$sep$,$endfor$]{$theme$}+$endif$+$if(colortheme)$+\usecolortheme{$colortheme$}+$endif$+$if(fonttheme)$+\usefonttheme{$fonttheme$}+$endif$+$if(mainfont)$+\usefonttheme{serif} % use mainfont rather than sansfont for slide text+$endif$+$if(innertheme)$+\useinnertheme{$innertheme$}+$endif$+$if(outertheme)$+\useoutertheme{$outertheme$}+$endif$+$endif$+% Use upquote if available, for straight quotes in verbatim environments+\IfFileExists{upquote.sty}{\usepackage{upquote}}{}+\IfFileExists{microtype.sty}{% use microtype if available+ \usepackage[$for(microtypeoptions)$$microtypeoptions$$sep$,$endfor$]{microtype}+ \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts+}{}+$if(indent)$+$else$+\makeatletter+\@ifundefined{KOMAClassName}{% if non-KOMA class+ \IfFileExists{parskip.sty}{%+ \usepackage{parskip}+ }{% else+ \setlength{\parindent}{0pt}+ \setlength{\parskip}{6pt plus 2pt minus 1pt}}+}{% if KOMA class+ \KOMAoptions{parskip=half}}+\makeatother+$endif$+$if(verbatim-in-note)$+\usepackage{fancyvrb}+$endif$+\usepackage{xcolor}+\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available+\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}+\hypersetup{+$if(title-meta)$+ pdftitle={$title-meta$},+$endif$+$if(author-meta)$+ pdfauthor={$author-meta$},+$endif$+$if(lang)$+ pdflang={$lang$},+$endif$+$if(subject)$+ pdfsubject={$subject$},+$endif$+$if(keywords)$+ pdfkeywords={$for(keywords)$$keywords$$sep$, $endfor$},+$endif$+$if(colorlinks)$+ colorlinks=true,+ linkcolor=$if(linkcolor)$$linkcolor$$else$Maroon$endif$,+ filecolor=$if(filecolor)$$filecolor$$else$Maroon$endif$,+ citecolor=$if(citecolor)$$citecolor$$else$Blue$endif$,+ urlcolor=$if(urlcolor)$$urlcolor$$else$Blue$endif$,+$else$+ hidelinks,+$endif$+ pdfcreator={LaTeX via pandoc}}+\urlstyle{same} % disable monospaced font for URLs+$if(verbatim-in-note)$+\VerbatimFootnotes % allow verbatim text in footnotes+$endif$+$if(geometry)$+$if(beamer)$+\geometry{$for(geometry)$$geometry$$sep$,$endfor$}+$else$+\usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry}+$endif$+$endif$+$if(beamer)$+\newif\ifbibliography+$endif$+$if(listings)$+\usepackage{listings}+\newcommand{\passthrough}[1]{#1}+\lstset{defaultdialect=[5.3]Lua}+\lstset{defaultdialect=[x86masm]Assembler}+$endif$+$if(lhs)$+\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}+$endif$+$if(highlighting-macros)$+$highlighting-macros$+$endif$+$if(tables)$+\usepackage{longtable,booktabs}+$if(beamer)$+\usepackage{caption}+% Make caption package work with longtable+\makeatletter+\def\fnum@table{\tablename~\thetable}+\makeatother+$else$+% Correct order of tables after \paragraph or \subparagraph+\usepackage{etoolbox}+\makeatletter+\patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{}+\makeatother+% Allow footnotes in longtable head/foot+\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}+\makesavenoteenv{longtable}+$endif$+$endif$+$if(graphics)$+\usepackage{graphicx,grffile}+\makeatletter+\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}+\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}+\makeatother+% Scale images if necessary, so that they will not overflow the page+% margins by default, and it is still possible to overwrite the defaults+% using explicit options in \includegraphics[width, height, ...]{}+\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}+% Set default figure placement to htbp+\makeatletter+\def\fps@figure{htbp}+\makeatother+$endif$+$if(links-as-notes)$+% Make links footnotes instead of hotlinks:+\DeclareRobustCommand{\href}[2]{#2\footnote{\url{#1}}}+$endif$+$if(strikeout)$+\usepackage[normalem]{ulem}+% Avoid problems with \sout in headers with hyperref+\pdfstringdefDisableCommands{\renewcommand{\sout}{}}+$endif$+\setlength{\emergencystretch}{3em} % prevent overfull lines+\providecommand{\tightlist}{%+ \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}+$if(numbersections)$+\setcounter{secnumdepth}{$if(secnumdepth)$$secnumdepth$$else$5$endif$}+$else$+\setcounter{secnumdepth}{-\maxdimen} % remove section numbering+$endif$+$if(beamer)$+$else$+$if(block-headings)$+% Make \paragraph and \subparagraph free-standing+\ifx\paragraph\undefined\else+ \let\oldparagraph\paragraph+ \renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}+\fi+\ifx\subparagraph\undefined\else+ \let\oldsubparagraph\subparagraph+ \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}+\fi+$endif$+$endif$+$if(pagestyle)$+\pagestyle{$pagestyle$}+$endif$+$for(header-includes)$+$header-includes$+$endfor$+$if(lang)$+\ifxetex+ % Load polyglossia as late as possible: uses bidi with RTL langages (e.g. Hebrew, Arabic)+ \usepackage{polyglossia}+ \setmainlanguage[$polyglossia-lang.options$]{$polyglossia-lang.name$}+$for(polyglossia-otherlangs)$+ \setotherlanguage[$polyglossia-otherlangs.options$]{$polyglossia-otherlangs.name$}+$endfor$+\else+ \usepackage[shorthands=off,$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel}+$if(babel-newcommands)$+ $babel-newcommands$+$endif$+\fi+$endif$+$if(dir)$+\ifxetex+ % Load bidi as late as possible as it modifies e.g. graphicx+ \usepackage{bidi}+\fi+\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex+ \TeXXeTstate=1+ \newcommand{\RL}[1]{\beginR #1\endR}+ \newcommand{\LR}[1]{\beginL #1\endL}+ \newenvironment{RTL}{\beginR}{\endR}+ \newenvironment{LTR}{\beginL}{\endL}+\fi+$endif$+$if(natbib)$+\usepackage[$natbiboptions$]{natbib}+\bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$}+$endif$+$if(biblatex)$+\usepackage[$if(biblio-style)$style=$biblio-style$,$endif$$for(biblatexoptions)$$biblatexoptions$$sep$,$endfor$]{biblatex}+$for(bibliography)$+\addbibresource{$bibliography$}+$endfor$+$endif$++$if(title)$+\title{$title$$if(thanks)$\thanks{$thanks$}$endif$}+$endif$+$if(subtitle)$+$if(beamer)$+$else$+\usepackage{etoolbox}+\makeatletter+\providecommand{\subtitle}[1]{% add subtitle to \maketitle+ \apptocmd{\@title}{\par {\large #1 \par}}{}{}+}+\makeatother+$endif$+\subtitle{$subtitle$}+$endif$+$if(author)$+\author{$for(author)$$author$$sep$ \and $endfor$}+$endif$+\date{$date$}+$if(beamer)$+$if(institute)$+\institute{$for(institute)$$institute$$sep$ \and $endfor$}+$endif$+$if(titlegraphic)$+\titlegraphic{\includegraphics{$titlegraphic$}}+$endif$+$if(logo)$+\logo{\includegraphics{$logo$}}+$endif$+$endif$++\begin{document}+$if(has-frontmatter)$+\frontmatter+$endif$+$if(title)$+$if(beamer)$+\frame{\titlepage}+$else$+\maketitle+$endif$+$if(abstract)$+\begin{abstract}+$abstract$+\end{abstract}+$endif$+$endif$++$for(include-before)$+$include-before$++$endfor$+$if(toc)$+$if(toc-title)$+\renewcommand*\contentsname{$toc-title$}+$endif$+$if(beamer)$+\begin{frame}+$if(toc-title)$+ \frametitle{$toc-title$}+$endif$+ \tableofcontents[hideallsubsections]+\end{frame}+$else$+{+$if(colorlinks)$+\hypersetup{linkcolor=$if(toccolor)$$toccolor$$else$$endif$}+$endif$+\setcounter{tocdepth}{$toc-depth$}+\tableofcontents+}+$endif$+$endif$+$if(lot)$+\listoftables+$endif$+$if(lof)$+\listoffigures+$endif$+$if(linestretch)$+\setstretch{$linestretch$}+$endif$+$if(has-frontmatter)$+\mainmatter+$endif$+$body$++$if(has-frontmatter)$+\backmatter+$endif$+$if(natbib)$+$if(bibliography)$+$if(biblio-title)$+$if(has-chapters)$+\renewcommand\bibname{$biblio-title$}+$else$+\renewcommand\refname{$biblio-title$}+$endif$+$endif$+$if(beamer)$+\begin{frame}[allowframebreaks]{$biblio-title$}+ \bibliographytrue+$endif$+ \bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$}+$if(beamer)$+\end{frame}+$endif$++$endif$+$endif$+$if(biblatex)$+$if(beamer)$+\begin{frame}[allowframebreaks]{$biblio-title$}+ \bibliographytrue+ \printbibliography[heading=none]+\end{frame}+$else$+\printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$+$endif$++$endif$+$for(include-after)$+$include-after$++$endfor$+\end{document}
+ data/pandoc-data/data/templates/default.markdown view
@@ -0,0 +1,21 @@+$if(titleblock)$+$titleblock$++$endif$+$for(header-includes)$+$header-includes$++$endfor$+$for(include-before)$+$include-before$++$endfor$+$if(toc)$+$table-of-contents$++$endif$+$body$+$for(include-after)$++$include-after$+$endfor$
− data/pandoc-data/templates/default.commonmark
@@ -1,21 +0,0 @@-$if(titleblock)$-$titleblock$--$endif$-$for(header-includes)$-$header-includes$--$endfor$-$for(include-before)$-$include-before$--$endfor$-$if(toc)$-$table-of-contents$--$endif$-$body$-$for(include-after)$--$include-after$-$endfor$
− data/pandoc-data/templates/default.haddock
@@ -1,1 +0,0 @@-$body$
− data/pandoc-data/templates/default.html4
@@ -1,69 +0,0 @@-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">-<html xmlns="http://www.w3.org/1999/xhtml"$if(lang)$ lang="$lang$" xml:lang="$lang$"$endif$$if(dir)$ dir="$dir$"$endif$>-<head>- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />- <meta http-equiv="Content-Style-Type" content="text/css" />- <meta name="generator" content="pandoc" />-$for(author-meta)$- <meta name="author" content="$author-meta$" />-$endfor$-$if(date-meta)$- <meta name="date" content="$date-meta$" />-$endif$-$if(keywords)$- <meta name="keywords" content="$for(keywords)$$keywords$$sep$, $endfor$" />-$endif$- <title>$if(title-prefix)$$title-prefix$ – $endif$$pagetitle$</title>- <style type="text/css">- code{white-space: pre-wrap;}- span.smallcaps{font-variant: small-caps;}- span.underline{text-decoration: underline;}- div.column{display: inline-block; vertical-align: top; width: 50%;}-$if(quotes)$- q { quotes: "“" "”" "‘" "’"; }-$endif$- </style>-$if(highlighting-css)$- <style type="text/css">-$highlighting-css$- </style>-$endif$-$for(css)$- <link rel="stylesheet" href="$css$" type="text/css" />-$endfor$-$if(math)$- $math$-$endif$-$for(header-includes)$- $header-includes$-$endfor$-</head>-<body>-$for(include-before)$-$include-before$-$endfor$-$if(title)$-<div id="$idprefix$header">-<h1 class="title">$title$</h1>-$if(subtitle)$-<h1 class="subtitle">$subtitle$</h1>-$endif$-$for(author)$-<h2 class="author">$author$</h2>-$endfor$-$if(date)$-<h3 class="date">$date$</h3>-$endif$-</div>-$endif$-$if(toc)$-<div id="$idprefix$TOC">-$table-of-contents$-</div>-$endif$-$body$-$for(include-after)$-$include-after$-$endfor$-</body>-</html>
− data/pandoc-data/templates/default.html5
@@ -1,72 +0,0 @@-<!DOCTYPE html>-<html xmlns="http://www.w3.org/1999/xhtml" lang="$lang$" xml:lang="$lang$"$if(dir)$ dir="$dir$"$endif$>-<head>- <meta charset="utf-8" />- <meta name="generator" content="pandoc" />- <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />-$for(author-meta)$- <meta name="author" content="$author-meta$" />-$endfor$-$if(date-meta)$- <meta name="dcterms.date" content="$date-meta$" />-$endif$-$if(keywords)$- <meta name="keywords" content="$for(keywords)$$keywords$$sep$, $endfor$" />-$endif$- <title>$if(title-prefix)$$title-prefix$ – $endif$$pagetitle$</title>- <style>- code{white-space: pre-wrap;}- span.smallcaps{font-variant: small-caps;}- span.underline{text-decoration: underline;}- div.column{display: inline-block; vertical-align: top; width: 50%;}-$if(quotes)$- q { quotes: "“" "”" "‘" "’"; }-$endif$- </style>-$if(highlighting-css)$- <style>-$highlighting-css$- </style>-$endif$-$for(css)$- <link rel="stylesheet" href="$css$" />-$endfor$-$if(math)$- $math$-$endif$- <!--[if lt IE 9]>- <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>- <![endif]-->-$for(header-includes)$- $header-includes$-$endfor$-</head>-<body>-$for(include-before)$-$include-before$-$endfor$-$if(title)$-<header id="title-block-header">-<h1 class="title">$title$</h1>-$if(subtitle)$-<p class="subtitle">$subtitle$</p>-$endif$-$for(author)$-<p class="author">$author$</p>-$endfor$-$if(date)$-<p class="date">$date$</p>-$endif$-</header>-$endif$-$if(toc)$-<nav id="$idprefix$TOC" role="doc-toc">-$table-of-contents$-</nav>-$endif$-$body$-$for(include-after)$-$include-after$-$endfor$-</body>-</html>
− data/pandoc-data/templates/default.latex
@@ -1,488 +0,0 @@-% Options for packages loaded elsewhere-\PassOptionsToPackage{unicode$for(hyperrefoptions)$,$hyperrefoptions$$endfor$}{hyperref}-\PassOptionsToPackage{hyphens}{url}-$if(colorlinks)$-\PassOptionsToPackage{dvipsnames,svgnames*,x11names*}{xcolor}-$endif$-$if(dir)$-$if(latex-dir-rtl)$-\PassOptionsToPackage{RTLdocument}{bidi}-$endif$-$endif$-%-\documentclass[-$if(fontsize)$- $fontsize$,-$endif$-$if(lang)$- $babel-lang$,-$endif$-$if(papersize)$- $papersize$paper,-$endif$-$if(beamer)$- ignorenonframetext,-$if(handout)$- handout,-$endif$-$if(aspectratio)$- aspectratio=$aspectratio$,-$endif$-$endif$-$for(classoption)$- $classoption$$sep$,-$endfor$-]{$documentclass$}-$if(beamer)$-$if(background-image)$-\usebackgroundtemplate{%- \includegraphics[width=\paperwidth]{$background-image$}%-}-$endif$-\usepackage{pgfpages}-\setbeamertemplate{caption}[numbered]-\setbeamertemplate{caption label separator}{: }-\setbeamercolor{caption name}{fg=normal text.fg}-\beamertemplatenavigationsymbols$if(navigation)$$navigation$$else$empty$endif$-$for(beameroption)$-\setbeameroption{$beameroption$}-$endfor$-% Prevent slide breaks in the middle of a paragraph-\widowpenalties 1 10000-\raggedbottom-$if(section-titles)$-\setbeamertemplate{part page}{- \centering- \begin{beamercolorbox}[sep=16pt,center]{part title}- \usebeamerfont{part title}\insertpart\par- \end{beamercolorbox}-}-\setbeamertemplate{section page}{- \centering- \begin{beamercolorbox}[sep=12pt,center]{part title}- \usebeamerfont{section title}\insertsection\par- \end{beamercolorbox}-}-\setbeamertemplate{subsection page}{- \centering- \begin{beamercolorbox}[sep=8pt,center]{part title}- \usebeamerfont{subsection title}\insertsubsection\par- \end{beamercolorbox}-}-\AtBeginPart{- \frame{\partpage}-}-\AtBeginSection{- \ifbibliography- \else- \frame{\sectionpage}- \fi-}-\AtBeginSubsection{- \frame{\subsectionpage}-}-$endif$-$endif$-$if(beamerarticle)$-\usepackage{beamerarticle} % needs to be loaded first-$endif$-$if(fontfamily)$-\usepackage[$for(fontfamilyoptions)$$fontfamilyoptions$$sep$,$endfor$]{$fontfamily$}-$else$-\usepackage{lmodern}-$endif$-$if(linestretch)$-\usepackage{setspace}-$endif$-\usepackage{amssymb,amsmath}-\usepackage{ifxetex,ifluatex}-\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex- \usepackage[$if(fontenc)$$fontenc$$else$T1$endif$]{fontenc}- \usepackage[utf8]{inputenc}- \usepackage{textcomp} % provide euro and other symbols-\else % if luatex or xetex-$if(mathspec)$- \ifxetex- \usepackage{mathspec}- \else- \usepackage{unicode-math}- \fi-$else$- \usepackage{unicode-math}-$endif$- \defaultfontfeatures{Scale=MatchLowercase}- \defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}-$if(mainfont)$- \setmainfont[$for(mainfontoptions)$$mainfontoptions$$sep$,$endfor$]{$mainfont$}-$endif$-$if(sansfont)$- \setsansfont[$for(sansfontoptions)$$sansfontoptions$$sep$,$endfor$]{$sansfont$}-$endif$-$if(monofont)$- \setmonofont[$for(monofontoptions)$$monofontoptions$$sep$,$endfor$]{$monofont$}-$endif$-$for(fontfamilies)$- \newfontfamily{$fontfamilies.name$}[$for(fontfamilies.options)$$fontfamilies.options$$sep$,$endfor$]{$fontfamilies.font$}-$endfor$-$if(mathfont)$-$if(mathspec)$- \ifxetex- \setmathfont(Digits,Latin,Greek)[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}- \else- \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}- \fi-$else$- \setmathfont[$for(mathfontoptions)$$mathfontoptions$$sep$,$endfor$]{$mathfont$}-$endif$-$endif$-$if(CJKmainfont)$- \ifxetex- \usepackage{xeCJK}- \setCJKmainfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$}- \fi-$endif$-$if(luatexjapresetoptions)$- \ifluatex- \usepackage[$for(luatexjapresetoptions)$$luatexjapresetoptions$$sep$,$endfor$]{luatexja-preset}- \fi-$endif$-$if(CJKmainfont)$- \ifluatex- \usepackage[$for(luatexjafontspecoptions)$$luatexjafontspecoptions$$sep$,$endfor$]{luatexja-fontspec}- \setmainjfont[$for(CJKoptions)$$CJKoptions$$sep$,$endfor$]{$CJKmainfont$}- \fi-$endif$-\fi-$if(beamer)$-$if(theme)$-\usetheme[$for(themeoptions)$$themeoptions$$sep$,$endfor$]{$theme$}-$endif$-$if(colortheme)$-\usecolortheme{$colortheme$}-$endif$-$if(fonttheme)$-\usefonttheme{$fonttheme$}-$endif$-$if(mainfont)$-\usefonttheme{serif} % use mainfont rather than sansfont for slide text-$endif$-$if(innertheme)$-\useinnertheme{$innertheme$}-$endif$-$if(outertheme)$-\useoutertheme{$outertheme$}-$endif$-$endif$-% Use upquote if available, for straight quotes in verbatim environments-\IfFileExists{upquote.sty}{\usepackage{upquote}}{}-\IfFileExists{microtype.sty}{% use microtype if available- \usepackage[$for(microtypeoptions)$$microtypeoptions$$sep$,$endfor$]{microtype}- \UseMicrotypeSet[protrusion]{basicmath} % disable protrusion for tt fonts-}{}-$if(indent)$-$else$-\makeatletter-\@ifundefined{KOMAClassName}{% if non-KOMA class- \IfFileExists{parskip.sty}{%- \usepackage{parskip}- }{% else- \setlength{\parindent}{0pt}- \setlength{\parskip}{6pt plus 2pt minus 1pt}}-}{% if KOMA class- \KOMAoptions{parskip=half}}-\makeatother-$endif$-$if(verbatim-in-note)$-\usepackage{fancyvrb}-$endif$-\usepackage{xcolor}-\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available-\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}-\hypersetup{-$if(title-meta)$- pdftitle={$title-meta$},-$endif$-$if(author-meta)$- pdfauthor={$author-meta$},-$endif$-$if(lang)$- pdflang={$lang$},-$endif$-$if(subject)$- pdfsubject={$subject$},-$endif$-$if(keywords)$- pdfkeywords={$for(keywords)$$keywords$$sep$, $endfor$},-$endif$-$if(colorlinks)$- colorlinks=true,- linkcolor=$if(linkcolor)$$linkcolor$$else$Maroon$endif$,- filecolor=$if(filecolor)$$filecolor$$else$Maroon$endif$,- citecolor=$if(citecolor)$$citecolor$$else$Blue$endif$,- urlcolor=$if(urlcolor)$$urlcolor$$else$Blue$endif$,-$else$- hidelinks,-$endif$- pdfcreator={LaTeX via pandoc}}-\urlstyle{same} % disable monospaced font for URLs-$if(verbatim-in-note)$-\VerbatimFootnotes % allow verbatim text in footnotes-$endif$-$if(geometry)$-$if(beamer)$-\geometry{$for(geometry)$$geometry$$sep$,$endfor$}-$else$-\usepackage[$for(geometry)$$geometry$$sep$,$endfor$]{geometry}-$endif$-$endif$-$if(beamer)$-\newif\ifbibliography-$endif$-$if(listings)$-\usepackage{listings}-\newcommand{\passthrough}[1]{#1}-\lstset{defaultdialect=[5.3]Lua}-\lstset{defaultdialect=[x86masm]Assembler}-$endif$-$if(lhs)$-\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{}-$endif$-$if(highlighting-macros)$-$highlighting-macros$-$endif$-$if(tables)$-\usepackage{longtable,booktabs}-$if(beamer)$-\usepackage{caption}-% Make caption package work with longtable-\makeatletter-\def\fnum@table{\tablename~\thetable}-\makeatother-$else$-% Correct order of tables after \paragraph or \subparagraph-\usepackage{etoolbox}-\makeatletter-\patchcmd\longtable{\par}{\if@noskipsec\mbox{}\fi\par}{}{}-\makeatother-% Allow footnotes in longtable head/foot-\IfFileExists{footnotehyper.sty}{\usepackage{footnotehyper}}{\usepackage{footnote}}-\makesavenoteenv{longtable}-$endif$-$endif$-$if(graphics)$-\usepackage{graphicx,grffile}-\makeatletter-\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi}-\def\maxheight{\ifdim\Gin@nat@height>\textheight\textheight\else\Gin@nat@height\fi}-\makeatother-% Scale images if necessary, so that they will not overflow the page-% margins by default, and it is still possible to overwrite the defaults-% using explicit options in \includegraphics[width, height, ...]{}-\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio}-% Set default figure placement to htbp-\makeatletter-\def\fps@figure{htbp}-\makeatother-$endif$-$if(links-as-notes)$-% Make links footnotes instead of hotlinks:-\DeclareRobustCommand{\href}[2]{#2\footnote{\url{#1}}}-$endif$-$if(strikeout)$-\usepackage[normalem]{ulem}-% Avoid problems with \sout in headers with hyperref-\pdfstringdefDisableCommands{\renewcommand{\sout}{}}-$endif$-\setlength{\emergencystretch}{3em} % prevent overfull lines-\providecommand{\tightlist}{%- \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}-$if(numbersections)$-\setcounter{secnumdepth}{$if(secnumdepth)$$secnumdepth$$else$5$endif$}-$else$-\setcounter{secnumdepth}{-\maxdimen} % remove section numbering-$endif$-$if(beamer)$-$else$-$if(block-headings)$-% Make \paragraph and \subparagraph free-standing-\ifx\paragraph\undefined\else- \let\oldparagraph\paragraph- \renewcommand{\paragraph}[1]{\oldparagraph{#1}\mbox{}}-\fi-\ifx\subparagraph\undefined\else- \let\oldsubparagraph\subparagraph- \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}-\fi-$endif$-$endif$-$if(pagestyle)$-\pagestyle{$pagestyle$}-$endif$-$for(header-includes)$-$header-includes$-$endfor$-$if(lang)$-\ifxetex- % Load polyglossia as late as possible: uses bidi with RTL langages (e.g. Hebrew, Arabic)- \usepackage{polyglossia}- \setmainlanguage[$polyglossia-lang.options$]{$polyglossia-lang.name$}-$for(polyglossia-otherlangs)$- \setotherlanguage[$polyglossia-otherlangs.options$]{$polyglossia-otherlangs.name$}-$endfor$-\else- \usepackage[shorthands=off,$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel}-$if(babel-newcommands)$- $babel-newcommands$-$endif$-\fi-$endif$-$if(dir)$-\ifxetex- % Load bidi as late as possible as it modifies e.g. graphicx- \usepackage{bidi}-\fi-\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex- \TeXXeTstate=1- \newcommand{\RL}[1]{\beginR #1\endR}- \newcommand{\LR}[1]{\beginL #1\endL}- \newenvironment{RTL}{\beginR}{\endR}- \newenvironment{LTR}{\beginL}{\endL}-\fi-$endif$-$if(natbib)$-\usepackage[$natbiboptions$]{natbib}-\bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$}-$endif$-$if(biblatex)$-\usepackage[$if(biblio-style)$style=$biblio-style$,$endif$$for(biblatexoptions)$$biblatexoptions$$sep$,$endfor$]{biblatex}-$for(bibliography)$-\addbibresource{$bibliography$}-$endfor$-$endif$--$if(title)$-\title{$title$$if(thanks)$\thanks{$thanks$}$endif$}-$endif$-$if(subtitle)$-$if(beamer)$-$else$-\usepackage{etoolbox}-\makeatletter-\providecommand{\subtitle}[1]{% add subtitle to \maketitle- \apptocmd{\@title}{\par {\large #1 \par}}{}{}-}-\makeatother-$endif$-\subtitle{$subtitle$}-$endif$-$if(author)$-\author{$for(author)$$author$$sep$ \and $endfor$}-$endif$-\date{$date$}-$if(beamer)$-$if(institute)$-\institute{$for(institute)$$institute$$sep$ \and $endfor$}-$endif$-$if(titlegraphic)$-\titlegraphic{\includegraphics{$titlegraphic$}}-$endif$-$if(logo)$-\logo{\includegraphics{$logo$}}-$endif$-$endif$--\begin{document}-$if(has-frontmatter)$-\frontmatter-$endif$-$if(title)$-$if(beamer)$-\frame{\titlepage}-$else$-\maketitle-$endif$-$if(abstract)$-\begin{abstract}-$abstract$-\end{abstract}-$endif$-$endif$--$for(include-before)$-$include-before$--$endfor$-$if(toc)$-$if(toc-title)$-\renewcommand*\contentsname{$toc-title$}-$endif$-$if(beamer)$-\begin{frame}-$if(toc-title)$- \frametitle{$toc-title$}-$endif$- \tableofcontents[hideallsubsections]-\end{frame}-$else$-{-$if(colorlinks)$-\hypersetup{linkcolor=$if(toccolor)$$toccolor$$else$$endif$}-$endif$-\setcounter{tocdepth}{$toc-depth$}-\tableofcontents-}-$endif$-$endif$-$if(lot)$-\listoftables-$endif$-$if(lof)$-\listoffigures-$endif$-$if(linestretch)$-\setstretch{$linestretch$}-$endif$-$if(has-frontmatter)$-\mainmatter-$endif$-$body$--$if(has-frontmatter)$-\backmatter-$endif$-$if(natbib)$-$if(bibliography)$-$if(biblio-title)$-$if(has-chapters)$-\renewcommand\bibname{$biblio-title$}-$else$-\renewcommand\refname{$biblio-title$}-$endif$-$endif$-$if(beamer)$-\begin{frame}[allowframebreaks]{$biblio-title$}- \bibliographytrue-$endif$- \bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$}-$if(beamer)$-\end{frame}-$endif$--$endif$-$endif$-$if(biblatex)$-$if(beamer)$-\begin{frame}[allowframebreaks]{$biblio-title$}- \bibliographytrue- \printbibliography[heading=none]-\end{frame}-$else$-\printbibliography$if(biblio-title)$[title=$biblio-title$]$endif$-$endif$--$endif$-$for(include-after)$-$include-after$--$endfor$-\end{document}
− data/pandoc-data/templates/default.markdown
@@ -1,21 +0,0 @@-$if(titleblock)$-$titleblock$--$endif$-$for(header-includes)$-$header-includes$--$endfor$-$for(include-before)$-$include-before$--$endfor$-$if(toc)$-$table-of-contents$--$endif$-$body$-$for(include-after)$--$include-after$-$endfor$
examples/ErrorExample.hs view
@@ -5,11 +5,11 @@ {-# LANGUAGE GADTs #-} module Main where -import qualified Knit.Report as K +import qualified Knit.Report as K import qualified Data.Map as M-import qualified Data.Text as T-import Data.String.Here (here)+import qualified Data.Text as T+import Data.String.Here ( here ) import qualified Graphics.Vega.VegaLite as V templateVars :: M.Map String String@@ -22,13 +22,19 @@ main :: IO () main = do- let template = K.FromIncludedTemplateDir "pandoc-bootstrap-KH.html"- pandocWriterConfig <- K.mkPandocWriterConfig template templateVars K.mindocOptionsF- resSimpleE <- K.knitHtml (Just "ErrorExample.Main") K.logAll pandocWriterConfig makeDocWithKnitError+ let template = K.FromIncludedTemplateDir "pandoc-bootstrap-KH.html"+ pandocWriterConfig <- K.mkPandocWriterConfig template+ templateVars+ K.mindocOptionsF+ resSimpleE <- K.knitHtml (Just "ErrorExample.Main")+ K.logAll+ pandocWriterConfig+ makeDocWithKnitError case resSimpleE of- Right htmlAsText -> K.writeAndMakePathLT "examples/html/error_example.html" htmlAsText+ Right htmlAsText ->+ K.writeAndMakePathLT "examples/html/error_example.html" htmlAsText Left err -> putStrLn $ "Pandoc Error: " ++ show err- + md1 :: T.Text md1 = [here| ## Some example markdown@@ -46,7 +52,8 @@ K.addMarkDown "## Some example latex" K.addLatex "Overused favorite equation: $e^{i\\pi} + 1 = 0$" K.logLE K.Info "adding a visualization..."- K.knitError "Uh oh! Something went wrong which I am explaining with this message."+ K.knitError+ "Uh oh! Something went wrong which I am explaining with this message." K.addMarkDown "## An example hvega visualization" _ <- K.addHvega Nothing Nothing exampleVis return ()@@ -54,10 +61,12 @@ exampleVis :: V.VegaLite exampleVis =- let cars = V.dataFromUrl "https://vega.github.io/vega-datasets/data/cars.json" []- enc = V.encoding- . V.position V.X [ V.PName "Horsepower", V.PmType V.Quantitative ]- . V.position V.Y [ V.PName "Miles_per_Gallon", V.PmType V.Quantitative ]- . V.color [ V.MName "Origin", V.MmType V.Nominal ]+ let cars =+ V.dataFromUrl "https://vega.github.io/vega-datasets/data/cars.json" []+ enc =+ V.encoding+ . V.position V.X [V.PName "Horsepower", V.PmType V.Quantitative]+ . V.position V.Y [V.PName "Miles_per_Gallon", V.PmType V.Quantitative]+ . V.color [V.MName "Origin", V.MmType V.Nominal] bkg = V.background "rgba(0, 0, 0, 0.05)"- in V.toVegaLite [ bkg, cars, V.mark V.Circle [], enc [] ] + in V.toVegaLite [bkg, cars, V.mark V.Circle [], enc []]
examples/MtlExample.hs view
@@ -6,17 +6,20 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} module Main where -import qualified Knit.Report as K +import qualified Knit.Report as K -import Control.Monad.IO.Class (MonadIO)+import Control.Monad.IO.Class ( MonadIO ) import qualified Data.Map as M import qualified Data.Text.IO as T import qualified Data.Text.Lazy as TL-import qualified Data.Text as T-import Data.String.Here (here)+import qualified Data.Text as T+import Data.String.Here ( here ) import qualified Graphics.Vega.VegaLite as V -import Control.Monad.Reader (ReaderT, ask, runReaderT)+import Control.Monad.Reader ( ReaderT+ , ask+ , runReaderT+ ) templateVars :: M.Map String String templateVars = M.fromList@@ -27,7 +30,7 @@ ] -- A demo application stack -newtype MyApp env a = MyStack { unMyApp :: ReaderT env IO a } deriving (Functor, Applicative, Monad, MonadIO) +newtype MyApp env a = MyStack { unMyApp :: ReaderT env IO a } deriving (Functor, Applicative, Monad, MonadIO) type ExampleApp = MyApp T.Text @@ -39,13 +42,18 @@ main :: IO () main = do- let template = K.FromIncludedTemplateDir "pandoc-bootstrap-KH.html"- templateVarsWithCss <- K.addCss (K.FromIncludedCssDir "pandoc-bootstrap.css") templateVars- pandocWriterConfig <- K.mkPandocWriterConfig template templateVarsWithCss K.mindocOptionsF+ let template = K.FromIncludedTemplateDir "pandoc-bootstrap-KH.html"+ templateVarsWithCss <- K.addCss+ (K.FromIncludedCssDir "pandoc-bootstrap.css")+ templateVars+ pandocWriterConfig <- K.mkPandocWriterConfig template+ templateVarsWithCss+ K.mindocOptionsF resE <- runExampleApp "This is from the MyApp environment." $ K.knitHtml (Just "MtlExample.Main") K.logAll pandocWriterConfig makeDoc case resE of- Right htmlAsText -> K.writeAndMakePathLT "examples/html/mtl_example.html" htmlAsText+ Right htmlAsText ->+ K.writeAndMakePathLT "examples/html/mtl_example.html" htmlAsText Left err -> putStrLn $ "Pandoc error: " ++ show err md1 :: T.Text@@ -57,8 +65,7 @@ [MarkDownLink]:<https://pandoc.org/MANUAL.html#pandocs-markdown> |] -makeDoc :: ( K.KnitOne effs- , K.KnitBase ExampleApp effs) => K.Sem effs ()+makeDoc :: (K.KnitOne effs, K.KnitBase ExampleApp effs) => K.Sem effs () makeDoc = K.wrapPrefix "makeDoc" $ do K.logLE K.Info "adding some markdown..." K.addMarkDown md1@@ -71,18 +78,22 @@ K.addMarkDown "## An example hvega visualization" _ <- K.addHvega Nothing Nothing exampleVis - K.logLE K.Info "Retrieving some text from the base monad and current date-time."+ K.logLE K.Info+ "Retrieving some text from the base monad and current date-time." envText <- K.liftKnit @ExampleApp getEnv- curTime <- K.getCurrentTime - K.addMarkDown "## An example of getting env from a base monad, and time from the Pandoc Effects."+ curTime <- K.getCurrentTime+ K.addMarkDown+ "## An example of getting env from a base monad, and time from the Pandoc Effects." K.addMarkDown $ envText <> "\n\n" <> (T.pack $ show curTime) exampleVis :: V.VegaLite exampleVis =- let cars = V.dataFromUrl "https://vega.github.io/vega-datasets/data/cars.json" []- enc = V.encoding- . V.position V.X [ V.PName "Horsepower", V.PmType V.Quantitative ]- . V.position V.Y [ V.PName "Miles_per_Gallon", V.PmType V.Quantitative ]- . V.color [ V.MName "Origin", V.MmType V.Nominal ]+ let cars =+ V.dataFromUrl "https://vega.github.io/vega-datasets/data/cars.json" []+ enc =+ V.encoding+ . V.position V.X [V.PName "Horsepower", V.PmType V.Quantitative]+ . V.position V.Y [V.PName "Miles_per_Gallon", V.PmType V.Quantitative]+ . V.color [V.MName "Origin", V.MmType V.Nominal] bkg = V.background "rgba(0, 0, 0, 0.05)"- in V.toVegaLite [ bkg, cars, V.mark V.Circle [], enc [] ] + in V.toVegaLite [bkg, cars, V.mark V.Circle [], enc []]
examples/MultiDocExample.hs view
@@ -5,13 +5,13 @@ {-# LANGUAGE GADTs #-} module Main where -import qualified Knit.Report as K +import qualified Knit.Report as K import qualified Data.Map as M import qualified Data.Text.IO as T import qualified Data.Text.Lazy as TL import qualified Data.Text as T-import Data.String.Here (here)+import Data.String.Here ( here ) import qualified Graphics.Vega.VegaLite as V templateVars :: M.Map String String@@ -25,15 +25,19 @@ main :: IO () main = do let template = K.FromIncludedTemplateDir "pandoc-adaptive-bootstrap-KH.html"- tvWithCss <- K.addCss (K.FromIncludedCssDir "pandoc-bootstrap.css") templateVars- pandocWriterConfig <- K.mkPandocWriterConfig template tvWithCss K.mindocOptionsF+ tvWithCss <- K.addCss (K.FromIncludedCssDir "pandoc-bootstrap.css")+ templateVars+ pandocWriterConfig <- K.mkPandocWriterConfig template+ tvWithCss+ K.mindocOptionsF resE <- K.knitHtmls (Just "MTLExample.Main") K.logAll pandocWriterConfig $ do K.newPandoc (K.PandocInfo "multi_doc1" M.empty) makeDoc1 K.newPandoc (K.PandocInfo "multi_doc2" M.empty) makeDoc2 case resE of- Right namedDocs -> K.writeAllPandocResultsWithInfoAsHtml "examples/html" namedDocs+ Right namedDocs ->+ K.writeAllPandocResultsWithInfoAsHtml "examples/html" namedDocs Left err -> putStrLn $ "pandoc error: " ++ show err- + md1 :: T.Text md1 = [here| ## Some example markdown@@ -78,11 +82,13 @@ exampleVis :: V.VegaLite exampleVis =- let cars = V.dataFromUrl "https://vega.github.io/vega-datasets/data/cars.json" []- enc = V.encoding- . V.position V.X [ V.PName "Horsepower", V.PmType V.Quantitative ]- . V.position V.Y [ V.PName "Miles_per_Gallon", V.PmType V.Quantitative ]- . V.color [ V.MName "Origin", V.MmType V.Nominal ]+ let cars =+ V.dataFromUrl "https://vega.github.io/vega-datasets/data/cars.json" []+ enc =+ V.encoding+ . V.position V.X [V.PName "Horsepower", V.PmType V.Quantitative]+ . V.position V.Y [V.PName "Miles_per_Gallon", V.PmType V.Quantitative]+ . V.color [V.MName "Origin", V.MmType V.Nominal] bkg = V.background "rgba(0, 0, 0, 0.05)"- in V.toVegaLite [ bkg, cars, V.mark V.Circle [], enc [] ] + in V.toVegaLite [bkg, cars, V.mark V.Circle [], enc []]
examples/RandomExample.hs view
@@ -6,25 +6,29 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} module Main where -import qualified Knit.Report as K-import qualified Polysemy.RandomFu as PR-import qualified Polysemy.ConstraintAbsorber.MonadRandom as PR-import qualified Colonnade as C+import qualified Knit.Report as K+import qualified Polysemy.RandomFu as PR+import qualified Polysemy.ConstraintAbsorber.MonadRandom+ as PR+import qualified Colonnade as C -import Control.Monad (replicateM)-import Control.Monad.IO.Class (MonadIO)-import qualified Data.Map as M-import qualified Data.Text as T-import Data.String.Here (here)-import qualified Graphics.Vega.VegaLite as V+import Control.Monad ( replicateM )+import Control.Monad.IO.Class ( MonadIO )+import qualified Data.Map as M+import qualified Data.Text as T+import Data.String.Here ( here )+import qualified Graphics.Vega.VegaLite as V -import Data.Random (MonadRandom, sample, stdNormal)-import Data.Random.Source.PureMT (newPureMT)+import Data.Random ( MonadRandom+ , sample+ , stdNormal+ )+import Data.Random.Source.PureMT ( newPureMT ) -import Control.Monad.Reader (ReaderT- , ask- , runReaderT- )+import Control.Monad.Reader ( ReaderT+ , ask+ , runReaderT+ ) templateVars :: M.Map String String templateVars = M.fromList@@ -47,14 +51,19 @@ main :: IO () main = do- let template = K.FromIncludedTemplateDir "mindoc-pandoc-KH.html"- pandocWriterConfig <- K.mkPandocWriterConfig template templateVars K.mindocOptionsF- pureMTSource <- newPureMT - resE <- runExampleApp "This is from the MyApp environment."- $ K.knitHtml (Just "RandomExample.Main") K.logAll pandocWriterConfig- $ PR.runRandomIOPureMT pureMTSource $ makeDoc- case resE of - Right htmlAsText -> K.writeAndMakePathLT "examples/html/random_example.html" htmlAsText+ let template = K.FromIncludedTemplateDir "mindoc-pandoc-KH.html"+ pandocWriterConfig <- K.mkPandocWriterConfig template+ templateVars+ K.mindocOptionsF+ pureMTSource <- newPureMT+ resE <-+ runExampleApp "This is from the MyApp environment."+ $ K.knitHtml (Just "RandomExample.Main") K.logAll pandocWriterConfig+ $ PR.runRandomIOPureMT pureMTSource+ $ makeDoc+ case resE of+ Right htmlAsText ->+ K.writeAndMakePathLT "examples/html/random_example.html" htmlAsText Left err -> putStrLn $ "Pandoc error: " ++ show err md1 :: T.Text@@ -66,9 +75,10 @@ [MarkDownLink]:<https://pandoc.org/MANUAL.html#pandocs-markdown> |] -makeDoc :: ( K.KnitOne effs- , K.Member PR.RandomFu effs -- this one needs to be handled before knitting- , K.KnitBase ExampleApp effs) => K.Sem effs ()+makeDoc+ :: (K.KnitOne effs, K.Member PR.RandomFu effs -- this one needs to be handled before knitting+ , K.KnitBase ExampleApp effs)+ => K.Sem effs () makeDoc = K.wrapPrefix "makeDoc" $ do K.logLE K.Info "adding some markdown..." K.addMarkDown md1@@ -81,33 +91,47 @@ K.addMarkDown "## An example hvega visualization" _ <- K.addHvega Nothing Nothing exampleVis - K.logLE K.Info "Retrieving some text from the base monad and current date-time."+ K.logLE K.Info+ "Retrieving some text from the base monad and current date-time." envText <- K.liftKnit @ExampleApp getEnv- curTime <- K.getCurrentTime - K.addMarkDown "## An example of getting env from a base monad, and time from the Pandoc Effects." + curTime <- K.getCurrentTime+ K.addMarkDown+ "## An example of getting env from a base monad, and time from the Pandoc Effects." K.addMarkDown $ envText <> "\n\n" <> (T.pack $ show curTime) K.logLE K.Info "Using another polysemy effect, here RandomFu" let nDraws = 20 someNormalDoubles <- PR.sampleRVar $ replicateM nDraws (stdNormal @Double)- K.addMarkDown "## An example of using the RandomFu effect to get random numbers and using Colonnade to make tables."+ K.addMarkDown+ "## An example of using the RandomFu effect to get random numbers and using Colonnade to make tables." K.addMarkDown $ "some std normal draws: "- K.addColonnadeTextTable (C.headed "#" (T.pack . show . fst) <> C.headed "Draw" (T.pack . show . snd)) $ zip [1..nDraws] someNormalDoubles+ K.addColonnadeTextTable+ ( C.headed "#" (T.pack . show . fst)+ <> C.headed "Draw" (T.pack . show . snd)+ )+ $ zip [1 .. nDraws] someNormalDoubles moreNormalDoubles <- PR.absorbMonadRandom (monadRandomFunction nDraws)- K.addMarkDown "## This time, using absorbMonadRandom to interoperate with a function using the MonadRandom constraint."+ K.addMarkDown+ "## This time, using absorbMonadRandom to interoperate with a function using the MonadRandom constraint." K.addMarkDown $ "some std normal draws: "- K.addColonnadeTextTable (C.headed "#" (T.pack . show . fst) <> C.headed "Draw" (T.pack . show . snd)) $ zip [1..nDraws] moreNormalDoubles+ K.addColonnadeTextTable+ ( C.headed "#" (T.pack . show . fst)+ <> C.headed "Draw" (T.pack . show . snd)+ )+ $ zip [1 .. nDraws] moreNormalDoubles monadRandomFunction :: MonadRandom m => Int -> m [Double] monadRandomFunction = sample . flip replicateM (stdNormal @Double)- + exampleVis :: V.VegaLite exampleVis =- let cars = V.dataFromUrl "https://vega.github.io/vega-datasets/data/cars.json" []- enc = V.encoding- . V.position V.X [ V.PName "Horsepower", V.PmType V.Quantitative ]- . V.position V.Y [ V.PName "Miles_per_Gallon", V.PmType V.Quantitative ]- . V.color [ V.MName "Origin", V.MmType V.Nominal ]+ let cars =+ V.dataFromUrl "https://vega.github.io/vega-datasets/data/cars.json" []+ enc =+ V.encoding+ . V.position V.X [V.PName "Horsepower", V.PmType V.Quantitative]+ . V.position V.Y [V.PName "Miles_per_Gallon", V.PmType V.Quantitative]+ . V.color [V.MName "Origin", V.MmType V.Nominal] bkg = V.background "rgba(0, 0, 0, 0.05)"- in V.toVegaLite [ bkg, cars, V.mark V.Circle [], enc [] ] + in V.toVegaLite [bkg, cars, V.mark V.Circle [], enc []]
examples/SimpleExample.hs view
@@ -5,14 +5,14 @@ {-# LANGUAGE GADTs #-} module Main where -import qualified Knit.Report as K +import qualified Knit.Report as K -import qualified Data.Map as M-import qualified Data.Text as T-import Data.String.Here (here)-import qualified Graphics.Vega.VegaLite as V+import qualified Data.Map as M+import qualified Data.Text as T+import Data.String.Here ( here )+import qualified Graphics.Vega.VegaLite as V -import qualified Plots as P+import qualified Plots as P templateVars :: M.Map String String templateVars = M.fromList@@ -25,10 +25,16 @@ main :: IO () main = do let template = K.FromIncludedTemplateDir "mindoc-pandoc-KH.html"- pandocWriterConfig <- K.mkPandocWriterConfig template templateVars K.mindocOptionsF- resE <- K.knitHtml (Just "SimpleExample.Main") K.logAll pandocWriterConfig makeDoc+ pandocWriterConfig <- K.mkPandocWriterConfig template+ templateVars+ K.mindocOptionsF+ resE <- K.knitHtml (Just "SimpleExample.Main")+ K.logAll+ pandocWriterConfig+ makeDoc case resE of- Right htmlAsText -> K.writeAndMakePathLT "examples/html/simple_example.html" htmlAsText+ Right htmlAsText ->+ K.writeAndMakePathLT "examples/html/simple_example.html" htmlAsText Left err -> putStrLn $ "Pandoc Error: " ++ show err md1 :: T.Text@@ -50,38 +56,51 @@ K.logLE K.Info "adding a visualization..." K.addMarkDown "## An example hvega visualization" _ <- K.addHvega Nothing (Just "From the cars data-set") exampleVis- K.addMarkDown "## Example Diagrams visualizations, the lsecond using the plots library."+ K.addMarkDown+ "## Example Diagrams visualizations, the lsecond using the plots library." K.logLE K.Info "adding a Diagrams example and plots example..." _ <- K.addDiagramAsSVG Nothing (Just "Example diagram") 300 300 exampleDiagram- _ <- K.addDiagramAsSVG Nothing (Just "Example diagrams visualization using the Plots library") 300 300 samplePlot+ _ <- K.addDiagramAsSVG+ Nothing+ (Just "Example diagrams visualization using the Plots library")+ 300+ 300+ samplePlot return () -- example using HVega exampleVis :: V.VegaLite exampleVis =- let cars = V.dataFromUrl "https://vega.github.io/vega-datasets/data/cars.json" []- enc = V.encoding- . V.position V.X [ V.PName "Horsepower", V.PmType V.Quantitative ]- . V.position V.Y [ V.PName "Miles_per_Gallon", V.PmType V.Quantitative ]- . V.color [ V.MName "Origin", V.MmType V.Nominal ]+ let cars =+ V.dataFromUrl "https://vega.github.io/vega-datasets/data/cars.json" []+ enc =+ V.encoding+ . V.position V.X [V.PName "Horsepower", V.PmType V.Quantitative]+ . V.position V.Y [V.PName "Miles_per_Gallon", V.PmType V.Quantitative]+ . V.color [V.MName "Origin", V.MmType V.Nominal] bkg = V.background "rgba(0, 0, 0, 0.05)"- in V.toVegaLite [ bkg, cars, V.mark V.Circle [], enc [] ] + in V.toVegaLite [bkg, cars, V.mark V.Circle [], enc []] -- sampleDiagram -- from <https://archives.haskell.org/projects.haskell.org/diagrams/gallery/Hilbert.html> hilbert 0 = mempty-hilbert n = hilbert' (n-1) K.# K.reflectY <> K.vrule 1- <> hilbert (n-1) <> K.hrule 1- <> hilbert (n-1) <> K.vrule (-1)- <> hilbert' (n-1) K.# K.reflectX- where- hilbert' m = hilbert m K.# K.rotateBy (1/4)+hilbert n =+ hilbert' (n - 1)+ K.# K.reflectY+ <> K.vrule 1+ <> hilbert (n - 1)+ <> K.hrule 1+ <> hilbert (n - 1)+ <> K.vrule (-1)+ <> hilbert' (n - 1)+ K.# K.reflectX+ where hilbert' m = hilbert m K.# K.rotateBy (1 / 4) -exampleDiagram :: K.Diagram K.SVG -exampleDiagram = K.frame 1 . K.lw K.medium . K.lc K.darkred- . K.strokeT $ hilbert 5+exampleDiagram :: K.Diagram K.SVG+exampleDiagram =+ K.frame 1 . K.lw K.medium . K.lc K.darkred . K.strokeT $ hilbert 5 -- example using Plots (as an example of using Diagrams)
knit-haskell.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.4 name: knit-haskell-version: 0.6.0.0+version: 0.6.0.1 synopsis: a minimal Rmarkdown sort-of-thing for haskell, by way of Pandoc description: knit-haskell is a beginning attempt at bringing some of the benefits of Rmarkdown to Haskell.@@ -32,14 +32,13 @@ data-files: knit-haskell-templates/*.html knit-haskell-css/*.css- pandoc-data/templates/*.html4- pandoc-data/templates/*.html5- pandoc-data/templates/default.latex- pandoc-data/templates/default.markdown- pandoc-data/templates/default.commonmark- pandoc-data/templates/default.haddock+ pandoc-data/data/templates/*.html4+ pandoc-data/data/templates/*.html5+ pandoc-data/data/templates/default.latex+ pandoc-data/data/templates/default.markdown+ pandoc-data/data/templates/default.commonmark+ pandoc-data/data/templates/default.haddock -tested-with: GHC ==8.6.4 Build-type: Simple source-repository head