Skip to content

Commit

Permalink
Merge pull request #20 from gabyx/feature/pandoc-update-2.14
Browse files Browse the repository at this point in the history
Pandoc update 2.14.0.1
  • Loading branch information
gabyx authored Jun 5, 2021
2 parents a7e2a72 + 95b3bd2 commit b37eaa8
Show file tree
Hide file tree
Showing 7 changed files with 253 additions and 179 deletions.
26 changes: 21 additions & 5 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,32 @@
"label": "🛠️ Convert Markdown ⇉ HTML",
"type": "shell",
"command": "${workspaceFolder}/gradlew",
"args": ["-t", "build-html", "-Ppython=${config:python.pythonPath}"],
"args": ["-t", "build-html", "-Ppython=${config:python.pythonPath}", "--warning-mode", "all"],
"problemMatcher": [],
"presentation": {
"panel": "dedicated",
"group": "converter"
}
},
{
"label": "🛠️ Convert Markdown ⇉ PDF",
"type": "shell",
"command": "${workspaceFolder}/gradlew",
"args": ["-t", "build-pdf-tex", "-Ppython=${config:python.pythonPath}"],
"args": ["-t", "build-pdf-tex", "-Ppython=${config:python.pythonPath}", "--warning-mode", "all"],
"problemMatcher": [],
"presentation": {
"panel": "dedicated",
"group": "converter"
}
},
{
"label": "🛠️ Convert Markdown ⇉ Jira",
"type": "shell",
"command": "${workspaceFolder}/gradlew",
"args": ["-t", "build-jira", "-Ppython=${config:python.pythonPath}"],
"args": ["-t", "build-jira", "-Ppython=${config:python.pythonPath}", "--warning-mode", "all"],
"problemMatcher": [],
"presentation": {
"panel": "dedicated",
"group": "converter"
}
},
Expand All @@ -51,22 +54,35 @@
"label": "📄 View HTML",
"type": "shell",
"command": "${workspaceFolder}/gradlew",
"args": ["-t", "view-html", "-Ppython=${config:python.pythonPath}"],
"args": ["-t", "view-html", "-Ppython=${config:python.pythonPath}", "--warning-mode", "all"],
"problemMatcher": [],
"presentation": {
"group": "converter"
}
},
{
"label": "🛠️ Convert Markdown ⇉ HTML, PDF",
"type": "shell",
"command": "${workspaceFolder}/gradlew",
"args": ["-parallel", "-t", "build-html", "build-pdf", "-Ppython=${config:python.pythonPath}", "--warning-mode", "all"],
"problemMatcher": [],
"isBackground": true,
"presentation": {
"panel": "dedicated",
"group": "converter"
}
},
{
"label": "🛠️ Convert Markdown ⇉ HTML, PDF + 📄 View HTML",
"dependsOn": ["🛠️ Convert Markdown ⇉ HTML", "🛠️ Convert Markdown ⇉ PDF", "📄 View HTML"],
"dependsOn": ["🛠️ Convert Markdown ⇉ HTML, PDF", "📄 View HTML"],
"problemMatcher": [],
"presentation": {
"group": "converter"
}
},
{
"label": "🛠️ Convert Markdown ⇉ HTML + 📄 View HTML",
"type": "shell",
"dependsOn": ["🛠️ Convert Markdown ⇉ HTML", "📄 View HTML"],
"problemMatcher": [],
"presentation": {
Expand Down
4 changes: 2 additions & 2 deletions Content.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<meta name="author" content="Gabriel Nützi" />
<meta name="author" content="The Community" />
<title>Technical Documents</title>
<title>Technical Documents</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
Expand Down Expand Up @@ -524,7 +524,7 @@ <h3 data-number="2.3.2" id="sec:multi-line-table"><span class="header-section-nu
<h1 class="unnumbered" id="references">References</h1>
<div id="refs" class="references csl-bib-body" role="doc-bibliography">
<div id="ref-nuetzig_thesis_2016" class="csl-entry" role="doc-biblioentry">
<div class="csl-left-margin">[1] </div><div class="csl-right-inline">G. Nützi, <span>‘Non-smooth granular rigid body dynamics with applications to chute flows,</span> PhD thesis, ETH Zurich; ETH Zürich, Zürich, 2016. </div>
<div class="csl-left-margin">[1] </div><div class="csl-right-inline">G. Nützi, <span>‘Non-smooth granular rigid body dynamics with applications to chute flows’</span>, PhD thesis, ETH Zurich; ETH Zürich, Zürich, 2016. </div>
</div>
<div id="ref-rockafellar_convex_2015" class="csl-entry" role="doc-biblioentry">
<div class="csl-left-margin">[2] </div><div class="csl-right-inline">R. T. Rockafellar, <em>Convex analysis</em>. Princeton: Princeton University Press, 2015 [Online]. Available: <a href="https://www.degruyter.com/view/title/516543">https://www.degruyter.com/view/title/516543</a></div>
Expand Down
Binary file modified Content.pdf
Binary file not shown.
47 changes: 44 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import java.lang.module.ModuleDescriptor.Version

plugins {
//id "com.liferay.yarn" version "7.2.6"
id("org.siouan.frontend-jdk11") version "5.1.0"
Expand All @@ -6,6 +8,8 @@ plugins {
@Suppress("unchecked_cast", "nothing_to_inline")
inline fun <T> uncheckedCast(target: Any?): T = target as T


apply(plugin = "java")
apply(from = "gradle/runCommand.gradle.kts")
val checkCmd = project.extensions.getByName("checkCommand")
as (Array<String>, String?) -> Void
Expand All @@ -30,6 +34,7 @@ val globalEnv = System.getenv()
val pathSep = System.getProperty("path.separator")
val binDir = file("${project.buildDir}/node_modules/.bin")

val pandocVersionMin = Version.parse("2.14")
val pandocExe: String = project.properties.getOrDefault("pandoc", "pandoc") as String
val pythonExe: String = project.properties.getOrDefault("python", "python") as String

Expand All @@ -47,6 +52,39 @@ fun MutableMap<String, String>.addExecutableDirToPath(exe: String) {
}
}

fun List<String>.runCommand(
workingDir: File = File(".")
): String? = runCatching {
ProcessBuilder(this)
.directory(workingDir)
.start().also { it.waitFor() }
.inputStream.bufferedReader().readText()
}.getOrNull()


fun checkPandocInstall(pandocExe: String){
var pandocAvailable = false
var version : String? = listOf<String>(pandocExe, "--version").runCommand()

if(version != null){
var m = Regex("""pandoc\s*(.*)""").find(version)
if(m != null) {
var v = Version.parse(m.groupValues[1])
if(v.compareTo(pandocVersionMin) >= 0){
pandocAvailable = true
}
}
}

if(!pandocAvailable) {
throw RuntimeException(
"Pandoc version should be >= ${pandocVersionMin.toString()}")
} else {
logger.quiet("Pandoc exectuable found.")
}
}


val initBuild by tasks.register<Task>("initBuild") {
group = "TechnicalMarkdown"
description = "Setups node/yarn and modules."
Expand Down Expand Up @@ -76,7 +114,7 @@ val defineEnvironment by tasks.register<Task>("defineEnvironment") {

logger.quiet("Checking executables ...")
checkCmd(arrayOf(pythonExe, "--version"), null)
checkCmd(arrayOf(pandocExe, "--version"), null)
checkPandocInstall(pandocExe)

logger.quiet("Pandoc Exe: $pandocExe")
logger.quiet("Python Exe: $pythonExe")
Expand Down Expand Up @@ -179,7 +217,10 @@ abstract class PandocTask @Inject constructor() : Exec() {
additionalArgs.convention(arrayOf())
markdownFiles.convention(project.fileTree("${project.rootDir}/chapters/"){include("**/*.md", "**/*.html")})
assetFiles.convention(project.fileTree("${project.rootDir}/files/"){ include("**/*") })
convertFiles.convention(project.fileTree("${project.rootDir}/convert/"){ include("**/*") })
convertFiles.convention(project.fileTree("${project.rootDir}/convert/"){
include("pandoc/**/*")
include("scripts/**/*")
})

inputs.files(inputFile, markdownFiles, assetFiles, convertFiles)
outputs.file(outputFile)
Expand Down Expand Up @@ -255,7 +296,7 @@ val transformMath = project.task<Copy>("transform-math") {
}

val buildHTML = tasks.register<PandocTask>("build-html") {
dependsOn(initBuild, defineEnvironment, compileLess)
dependsOn(initBuild, defineEnvironment, convertTables, compileLess)
inputFile.set(mainFileMarkdown)
exportType.set("html")
verbose.set(true)
Expand Down
124 changes: 53 additions & 71 deletions build/output-tex/input.tex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
% Options for packages loaded elsewhere
\PassOptionsToPackage{unicode,linktoc=all,hidelinks}{hyperref}
\PassOptionsToPackage{hyphens}{url}
\PassOptionsToPackage{dvipsnames,svgnames*,x11names*}{xcolor}
\PassOptionsToPackage{dvipsnames,svgnames,x11names}{xcolor}
%
\documentclass[
12pt,
Expand All @@ -17,13 +17,24 @@
headings=optiontohead,
svgnames,
dvipsnames]{scrreprt}
\usepackage{amsmath}
\usepackage{ifxetex,ifluatex}
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
\title{Technical Documents}
\usepackage{etoolbox}
\makeatletter
\providecommand{\subtitle}[1]{% add subtitle to \maketitle
\apptocmd{\@title}{\par {\large #1 \par}}{}{}
}
\makeatother
\subtitle{Demonstrating the Power of Markdown with Pandoc}
\author{Gabriel Nützi \and The Community}
\date{2. December 2020}

\usepackage{amsmath,amssymb}
\usepackage{lmodern}
\usepackage{iftex}
\ifPDFTeX
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{textcomp} % provide euro and other symbols
\usepackage{amssymb}
\else % if luatex or xetex
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
Expand All @@ -33,6 +44,7 @@
\setmonofont[]{Latin Modern Mono}
\setmathfont[]{Latin Modern Math}
\fi
% Use upquote if available, for straight quotes in verbatim environments
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\IfFileExists{microtype.sty}{% use microtype if available
\usepackage[]{microtype}
Expand All @@ -56,10 +68,10 @@
pdfauthor={Gabriel Nützi; The Community},
pdflang={en-GB},
colorlinks=true,
linkcolor=DarkBlue,
filecolor=DarkBlue,
citecolor=DarkBlue,
urlcolor=MediumBlue,
linkcolor={DarkBlue},
filecolor={DarkBlue},
citecolor={DarkBlue},
urlcolor={MediumBlue},
pdfcreator={LaTeX via pandoc}}
\urlstyle{same} % disable monospaced font for URLs
\usepackage{color}
Expand Down Expand Up @@ -100,7 +112,7 @@
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.10,0.09,0.49}{#1}}
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{#1}}
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{#1}}}}
\usepackage{longtable,booktabs}
\usepackage{longtable,booktabs,array}
\usepackage{calc} % for calculating minipage widths
% Correct order of tables after \paragraph or \subparagraph
\usepackage{etoolbox}
Expand All @@ -114,6 +126,29 @@
\providecommand{\tightlist}{%
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
\setcounter{secnumdepth}{3}
\newlength{\cslhangindent}
\setlength{\cslhangindent}{1.5em}
\newlength{\csllabelwidth}
\setlength{\csllabelwidth}{3em}
\newlength{\cslentryspacingunit} % times entry-spacing
\setlength{\cslentryspacingunit}{\parskip}
\newenvironment{CSLReferences}[2] % #1 hanging-ident, #2 entry spacing
{% don't indent paragraphs
\setlength{\parindent}{0pt}
% turn on hanging indent if param 1 is 1
\ifodd #1
\let\oldpar\par
\def\par{\hangindent=\cslhangindent\oldpar}
\fi
% set entry spacing
\setlength{\parskip}{#2\cslentryspacingunit}
}%
{}
\usepackage{calc}
\newcommand{\CSLBlock}[1]{#1\hfill\break}
\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}}
\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}\break}
\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1}
% Set include paths
\makeatletter
\providecommand*{\input@path}{}
Expand Down Expand Up @@ -375,75 +410,22 @@
% General Settings
\KOMAoptions{cleardoublepage=empty}
\raggedbottom
\ifxetex
\ifXeTeX
% Load polyglossia as late as possible: uses bidi with RTL langages (e.g. Hebrew, Arabic)
\usepackage{polyglossia}
\setmainlanguage[variant=british]{english}
\else
\usepackage[shorthands=off,main=british]{babel}
\usepackage[main=british]{babel}
% get rid of language-specific shorthands (see #6817):
\let\LanguageShortHands\languageshorthands
\def\languageshorthands#1{}
\fi
\ifluatex
\ifLuaTeX
\usepackage{selnolig} % disable illegal ligatures
\fi
\newlength{\cslhangindent}
\setlength{\cslhangindent}{1.5em}
\newlength{\csllabelwidth}
\setlength{\csllabelwidth}{3em}
\newenvironment{CSLReferences}[2] % #1 hanging-ident, #2 entry spacing
{% don't indent paragraphs
\setlength{\parindent}{0pt}
% turn on hanging indent if param 1 is 1
\ifodd #1 \everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces\fi
% set entry spacing
\ifnum #2 > 0
\setlength{\parskip}{#2\baselineskip}
\fi
}%
{}
\usepackage{calc}
\newcommand{\CSLBlock}[1]{#1\hfill\break}
\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}}
\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}\break}
\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1}

\title{Technical Documents}
\usepackage{etoolbox}
\makeatletter
\providecommand{\subtitle}[1]{% add subtitle to \maketitle
\apptocmd{\@title}{\par {\large #1 \par}}{}{}
}
\makeatother
\subtitle{Demonstrating the Power of Markdown with Pandoc}
\author{Gabriel Nützi \and The Community}
\date{2. December 2020}

\begin{document}
\begin{titlepage}
\makeatletter
\begin{center}
\includesvg[inkscapearea=page,width=0.5\textwidth]{files/Logo.svg}
\end{center}
\vspace{1cm}
\begin{center}
\Huge \textbf{\@title}
\end{center}
\begin{center}
\LARGE Demonstrating the Power of Markdown with Pandoc
\end{center}
\vspace{1cm}
\begin{center}
\textbf{Gabriel Nützi} \\ \& \\ \textbf{The Community}
\end{center}
\begin{center}
\@date
\end{center}
\begin{center}
\vfill
Zürich, Switzerland
\vspace{1cm}
\end{center}
\makeatother
\end{titlepage}
\maketitle
\begin{abstract}
This is a setup demonstrating the power and use of markdown for
technical documents by using a fully automated conversion sequence with
Expand Down Expand Up @@ -1027,7 +1009,7 @@ \chapter*{References}\label{references}}
\leavevmode\vadjust pre{\hypertarget{ref-nuetzig_thesis_2016}{}}%
\CSLLeftMargin{{[}1{]} }
\CSLRightInline{G. Nützi, {‘Non-smooth granular rigid body dynamics with
applications to chute flows,’} PhD thesis, ETH Zurich; ETH Zürich,
applications to chute flows’}, PhD thesis, ETH Zurich; ETH Zürich,
Zürich, 2016. }

\leavevmode\vadjust pre{\hypertarget{ref-rockafellar_convex_2015}{}}%
Expand Down
3 changes: 3 additions & 0 deletions convert/pandoc/includes/Template.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
$if(keywords)$
<meta name="keywords" content="$for(keywords)$$keywords$$sep$, $endfor$" />
$endif$
$if(description-meta)$
<meta name="description" content="$description-meta$" />
$endif$
<title>$if(title-prefix)$$title-prefix$ – $endif$$pagetitle$</title>
<style>
$styles.html()$
Expand Down
Loading

0 comments on commit b37eaa8

Please sign in to comment.