Lisää pöytäkirja-/esityslistapohja

This commit is contained in:
Saku Laesvuori 2023-01-11 07:41:24 +02:00
commit 32765c3cee
3 changed files with 200 additions and 0 deletions

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# Pandoc-dokumenttipohja ja suodatin pöytäkirjoille
## Asennus

47
filters/allekirjoittajat.hs Executable file
View File

@ -0,0 +1,47 @@
#!/usr/bin/env runhaskell
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}
import Text.Pandoc.JSON
import Text.Pandoc.Writers (writeLaTeX)
import Data.Text (Text)
import qualified Data.Text as T
import Data.Default (def)
import Text.Pandoc.Class (runPure)
import Data.Either (fromRight)
import System.Environment (getArgs)
main :: IO ()
main = do
format <- getFormat
toJSONFilter $ case format of
"latex" -> allekirjoittajat latex
_ -> id
getFormat :: IO String
getFormat = head <$> getArgs
latex blocks = RawBlock (Format "latex") $ T.intercalate "\n"
[ "\\vspace{1cm}"
, "\\begin{table}[H]"
, "Pöytäkirjan vakuudeksi,"
, "\\vspace{8mm}"
, "\\begin{center}"
, "\\begin{tabular}{p{0.45\\textwidth} p{0.45\\textwidth}}"
, format names
, "\\end{tabular}"
, "\\end{center}"
, "\\end{table}"]
where names = fromRight (error "conversion failed!") $
runPure $ mapM (writeLaTeX def . Pandoc mempty) blocks
format (x:y:ys) = "\\dotfill & \\dotfill \\\\\n" <> x <> " & " <> y <>
"\\vspace{0.8cm}\\\\\n" <> format ys
format [x] = "\\dotfill & \\\\\n" <> x <> " & \\\\\n"
format [] = ""
allekirjoittajat :: ([[Block]] -> Block) -> Block -> Block
allekirjoittajat f (Div (_, (elem "allekirjoittajat" -> True), _) [(OrderedList _ blocks)])
= f blocks
allekirjoittajat f (Div (_, (elem "allekirjoittajat" -> True), _) [(BulletList blocks)])
= f blocks
allekirjoittajat _ x = x

150
templates/kokous.latex Normal file
View File

@ -0,0 +1,150 @@
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode$for(hyperrefoptions)$,$hyperrefoptions$$endfor$}{hyperref}
\PassOptionsToPackage{hyphens}{url}
\PassOptionsToPackage{dvipsnames,svgnames,x11names}{xcolor}
%
\documentclass[a4paper,finnish]{article}
\usepackage{amsmath,amssymb}
\usepackage{notomath}
\usepackage{iftex}
\usepackage{float}
\usepackage{geometry}
\ifPDFTeX
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provide euro and other symbols
\else % if luatex or xetex
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\defaultfontfeatures[\rmfamily]{Ligatures=TeX,Scale=1}
\fi
% 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
}{}
\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
\usepackage{xcolor}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{} % add URL line breaks if available
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
pdftitle={$otsikko$},
pdflang={fi},
colorlinks=true,
linkcolor={Maroon},
filecolor={Maroon},
citecolor={Blue},
urlcolor={Blue},
pdfcreator={LaTeX via pandoc}}
\urlstyle{tt}
\usepackage{graphicx}
\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
$if(highlighting-macros)$
$highlighting-macros$
$endif$
$if(tables)$
\usepackage{longtable,booktabs,array}
$if(multirow)$
\usepackage{multirow}
$endif$
\usepackage{calc} % for calculating minipage widths
% 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$
$if(strikeout)$
$-- also used for underline
\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}}
\setcounter{secnumdepth}{1}
\ifLuaTeX
\usepackage[bidi=basic]{babel}
\else
\usepackage[bidi=default]{babel}
\fi
\babelprovide[main,import]{finnish}
% get rid of language-specific shorthands (see #6817):
\let\LanguageShortHands\languageshorthands
\def\languageshorthands#1{}
$for(header-includes)$
$header-includes$
$endfor$
\ifLuaTeX
\usepackage{selnolig} % disable illegal ligatures
\fi
\usepackage{csquotes}
\renewcommand{\labelitemi}{--}
\renewcommand{\thesection}{§\arabic{section}}
\begin{document}
$if(otsikko)$
{\large\textbf{Datat \textsc{ry}}\\
$otsikko$\\
$paikka$, $aika$\\
$if(paikalla)$
Paikalla:
\begin{itemize}
\tightlist
$for(paikalla)$\item $paikalla$
$endfor$
\end{itemize}
$endif$
$if(poissa)$
Poissa:
\begin{itemize}
\tightlist
$for(poissa)$\item $poissa$
$endfor$
\end{itemize}
$endif$
\par
\huge \textbf{$alaotsikko$}
\par
\vskip1em
}
$endif$
$for(include-before)$
$include-before$
$endfor$
$body$
$for(include-after)$
$include-after$
$endfor$
\end{document}