Skip to content

Commit b37eaa8

Browse files
authored
Merge pull request #20 from gabyx/feature/pandoc-update-2.14
Pandoc update 2.14.0.1
2 parents a7e2a72 + 95b3bd2 commit b37eaa8

File tree

7 files changed

+253
-179
lines changed

7 files changed

+253
-179
lines changed

.vscode/tasks.json

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,32 @@
77
"label": "🛠️ Convert Markdown ⇉ HTML",
88
"type": "shell",
99
"command": "${workspaceFolder}/gradlew",
10-
"args": ["-t", "build-html", "-Ppython=${config:python.pythonPath}"],
10+
"args": ["-t", "build-html", "-Ppython=${config:python.pythonPath}", "--warning-mode", "all"],
1111
"problemMatcher": [],
1212
"presentation": {
13+
"panel": "dedicated",
1314
"group": "converter"
1415
}
1516
},
1617
{
1718
"label": "🛠️ Convert Markdown ⇉ PDF",
1819
"type": "shell",
1920
"command": "${workspaceFolder}/gradlew",
20-
"args": ["-t", "build-pdf-tex", "-Ppython=${config:python.pythonPath}"],
21+
"args": ["-t", "build-pdf-tex", "-Ppython=${config:python.pythonPath}", "--warning-mode", "all"],
2122
"problemMatcher": [],
2223
"presentation": {
24+
"panel": "dedicated",
2325
"group": "converter"
2426
}
2527
},
2628
{
2729
"label": "🛠️ Convert Markdown ⇉ Jira",
2830
"type": "shell",
2931
"command": "${workspaceFolder}/gradlew",
30-
"args": ["-t", "build-jira", "-Ppython=${config:python.pythonPath}"],
32+
"args": ["-t", "build-jira", "-Ppython=${config:python.pythonPath}", "--warning-mode", "all"],
3133
"problemMatcher": [],
3234
"presentation": {
35+
"panel": "dedicated",
3336
"group": "converter"
3437
}
3538
},
@@ -51,22 +54,35 @@
5154
"label": "📄 View HTML",
5255
"type": "shell",
5356
"command": "${workspaceFolder}/gradlew",
54-
"args": ["-t", "view-html", "-Ppython=${config:python.pythonPath}"],
57+
"args": ["-t", "view-html", "-Ppython=${config:python.pythonPath}", "--warning-mode", "all"],
5558
"problemMatcher": [],
5659
"presentation": {
5760
"group": "converter"
5861
}
5962
},
63+
{
64+
"label": "🛠️ Convert Markdown ⇉ HTML, PDF",
65+
"type": "shell",
66+
"command": "${workspaceFolder}/gradlew",
67+
"args": ["-parallel", "-t", "build-html", "build-pdf", "-Ppython=${config:python.pythonPath}", "--warning-mode", "all"],
68+
"problemMatcher": [],
69+
"isBackground": true,
70+
"presentation": {
71+
"panel": "dedicated",
72+
"group": "converter"
73+
}
74+
},
6075
{
6176
"label": "🛠️ Convert Markdown ⇉ HTML, PDF + 📄 View HTML",
62-
"dependsOn": ["🛠️ Convert Markdown ⇉ HTML", "🛠️ Convert Markdown ⇉ PDF", "📄 View HTML"],
77+
"dependsOn": ["🛠️ Convert Markdown ⇉ HTML, PDF", "📄 View HTML"],
6378
"problemMatcher": [],
6479
"presentation": {
6580
"group": "converter"
6681
}
6782
},
6883
{
6984
"label": "🛠️ Convert Markdown ⇉ HTML + 📄 View HTML",
85+
"type": "shell",
7086
"dependsOn": ["🛠️ Convert Markdown ⇉ HTML", "📄 View HTML"],
7187
"problemMatcher": [],
7288
"presentation": {

Content.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
88
<meta name="author" content="Gabriel Nützi" />
99
<meta name="author" content="The Community" />
10-
<title>Technical Documents</title>
10+
<title>Technical Documents</title>
1111
<style>
1212
code{white-space: pre-wrap;}
1313
span.smallcaps{font-variant: small-caps;}
@@ -524,7 +524,7 @@ <h3 data-number="2.3.2" id="sec:multi-line-table"><span class="header-section-nu
524524
<h1 class="unnumbered" id="references">References</h1>
525525
<div id="refs" class="references csl-bib-body" role="doc-bibliography">
526526
<div id="ref-nuetzig_thesis_2016" class="csl-entry" role="doc-biblioentry">
527-
<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>
527+
<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>
528528
</div>
529529
<div id="ref-rockafellar_convex_2015" class="csl-entry" role="doc-biblioentry">
530530
<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>

Content.pdf

0 Bytes
Binary file not shown.

build.gradle.kts

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import java.lang.module.ModuleDescriptor.Version
2+
13
plugins {
24
//id "com.liferay.yarn" version "7.2.6"
35
id("org.siouan.frontend-jdk11") version "5.1.0"
@@ -6,6 +8,8 @@ plugins {
68
@Suppress("unchecked_cast", "nothing_to_inline")
79
inline fun <T> uncheckedCast(target: Any?): T = target as T
810

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

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

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

55+
fun List<String>.runCommand(
56+
workingDir: File = File(".")
57+
): String? = runCatching {
58+
ProcessBuilder(this)
59+
.directory(workingDir)
60+
.start().also { it.waitFor() }
61+
.inputStream.bufferedReader().readText()
62+
}.getOrNull()
63+
64+
65+
fun checkPandocInstall(pandocExe: String){
66+
var pandocAvailable = false
67+
var version : String? = listOf<String>(pandocExe, "--version").runCommand()
68+
69+
if(version != null){
70+
var m = Regex("""pandoc\s*(.*)""").find(version)
71+
if(m != null) {
72+
var v = Version.parse(m.groupValues[1])
73+
if(v.compareTo(pandocVersionMin) >= 0){
74+
pandocAvailable = true
75+
}
76+
}
77+
}
78+
79+
if(!pandocAvailable) {
80+
throw RuntimeException(
81+
"Pandoc version should be >= ${pandocVersionMin.toString()}")
82+
} else {
83+
logger.quiet("Pandoc exectuable found.")
84+
}
85+
}
86+
87+
5088
val initBuild by tasks.register<Task>("initBuild") {
5189
group = "TechnicalMarkdown"
5290
description = "Setups node/yarn and modules."
@@ -76,7 +114,7 @@ val defineEnvironment by tasks.register<Task>("defineEnvironment") {
76114

77115
logger.quiet("Checking executables ...")
78116
checkCmd(arrayOf(pythonExe, "--version"), null)
79-
checkCmd(arrayOf(pandocExe, "--version"), null)
117+
checkPandocInstall(pandocExe)
80118

81119
logger.quiet("Pandoc Exe: $pandocExe")
82120
logger.quiet("Python Exe: $pythonExe")
@@ -179,7 +217,10 @@ abstract class PandocTask @Inject constructor() : Exec() {
179217
additionalArgs.convention(arrayOf())
180218
markdownFiles.convention(project.fileTree("${project.rootDir}/chapters/"){include("**/*.md", "**/*.html")})
181219
assetFiles.convention(project.fileTree("${project.rootDir}/files/"){ include("**/*") })
182-
convertFiles.convention(project.fileTree("${project.rootDir}/convert/"){ include("**/*") })
220+
convertFiles.convention(project.fileTree("${project.rootDir}/convert/"){
221+
include("pandoc/**/*")
222+
include("scripts/**/*")
223+
})
183224

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

257298
val buildHTML = tasks.register<PandocTask>("build-html") {
258-
dependsOn(initBuild, defineEnvironment, compileLess)
299+
dependsOn(initBuild, defineEnvironment, convertTables, compileLess)
259300
inputFile.set(mainFileMarkdown)
260301
exportType.set("html")
261302
verbose.set(true)

build/output-tex/input.tex

Lines changed: 53 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
% Options for packages loaded elsewhere
22
\PassOptionsToPackage{unicode,linktoc=all,hidelinks}{hyperref}
33
\PassOptionsToPackage{hyphens}{url}
4-
\PassOptionsToPackage{dvipsnames,svgnames*,x11names*}{xcolor}
4+
\PassOptionsToPackage{dvipsnames,svgnames,x11names}{xcolor}
55
%
66
\documentclass[
77
12pt,
@@ -17,13 +17,24 @@
1717
headings=optiontohead,
1818
svgnames,
1919
dvipsnames]{scrreprt}
20-
\usepackage{amsmath}
21-
\usepackage{ifxetex,ifluatex}
22-
\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
20+
\title{Technical Documents}
21+
\usepackage{etoolbox}
22+
\makeatletter
23+
\providecommand{\subtitle}[1]{% add subtitle to \maketitle
24+
\apptocmd{\@title}{\par {\large #1 \par}}{}{}
25+
}
26+
\makeatother
27+
\subtitle{Demonstrating the Power of Markdown with Pandoc}
28+
\author{Gabriel Nützi \and The Community}
29+
\date{2. December 2020}
30+
31+
\usepackage{amsmath,amssymb}
32+
\usepackage{lmodern}
33+
\usepackage{iftex}
34+
\ifPDFTeX
2335
\usepackage[T1]{fontenc}
2436
\usepackage[utf8]{inputenc}
2537
\usepackage{textcomp} % provide euro and other symbols
26-
\usepackage{amssymb}
2738
\else % if luatex or xetex
2839
\usepackage{unicode-math}
2940
\defaultfontfeatures{Scale=MatchLowercase}
@@ -33,6 +44,7 @@
3344
\setmonofont[]{Latin Modern Mono}
3445
\setmathfont[]{Latin Modern Math}
3546
\fi
47+
% Use upquote if available, for straight quotes in verbatim environments
3648
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
3749
\IfFileExists{microtype.sty}{% use microtype if available
3850
\usepackage[]{microtype}
@@ -56,10 +68,10 @@
5668
pdfauthor={Gabriel Nützi; The Community},
5769
pdflang={en-GB},
5870
colorlinks=true,
59-
linkcolor=DarkBlue,
60-
filecolor=DarkBlue,
61-
citecolor=DarkBlue,
62-
urlcolor=MediumBlue,
71+
linkcolor={DarkBlue},
72+
filecolor={DarkBlue},
73+
citecolor={DarkBlue},
74+
urlcolor={MediumBlue},
6375
pdfcreator={LaTeX via pandoc}}
6476
\urlstyle{same} % disable monospaced font for URLs
6577
\usepackage{color}
@@ -100,7 +112,7 @@
100112
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.10,0.09,0.49}{#1}}
101113
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{#1}}
102114
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{#1}}}}
103-
\usepackage{longtable,booktabs}
115+
\usepackage{longtable,booktabs,array}
104116
\usepackage{calc} % for calculating minipage widths
105117
% Correct order of tables after \paragraph or \subparagraph
106118
\usepackage{etoolbox}
@@ -114,6 +126,29 @@
114126
\providecommand{\tightlist}{%
115127
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
116128
\setcounter{secnumdepth}{3}
129+
\newlength{\cslhangindent}
130+
\setlength{\cslhangindent}{1.5em}
131+
\newlength{\csllabelwidth}
132+
\setlength{\csllabelwidth}{3em}
133+
\newlength{\cslentryspacingunit} % times entry-spacing
134+
\setlength{\cslentryspacingunit}{\parskip}
135+
\newenvironment{CSLReferences}[2] % #1 hanging-ident, #2 entry spacing
136+
{% don't indent paragraphs
137+
\setlength{\parindent}{0pt}
138+
% turn on hanging indent if param 1 is 1
139+
\ifodd #1
140+
\let\oldpar\par
141+
\def\par{\hangindent=\cslhangindent\oldpar}
142+
\fi
143+
% set entry spacing
144+
\setlength{\parskip}{#2\cslentryspacingunit}
145+
}%
146+
{}
147+
\usepackage{calc}
148+
\newcommand{\CSLBlock}[1]{#1\hfill\break}
149+
\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}}
150+
\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}\break}
151+
\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1}
117152
% Set include paths
118153
\makeatletter
119154
\providecommand*{\input@path}{}
@@ -375,75 +410,22 @@
375410
% General Settings
376411
\KOMAoptions{cleardoublepage=empty}
377412
\raggedbottom
378-
\ifxetex
413+
\ifXeTeX
379414
% Load polyglossia as late as possible: uses bidi with RTL langages (e.g. Hebrew, Arabic)
380415
\usepackage{polyglossia}
381416
\setmainlanguage[variant=british]{english}
382417
\else
383-
\usepackage[shorthands=off,main=british]{babel}
418+
\usepackage[main=british]{babel}
419+
% get rid of language-specific shorthands (see #6817):
420+
\let\LanguageShortHands\languageshorthands
421+
\def\languageshorthands#1{}
384422
\fi
385-
\ifluatex
423+
\ifLuaTeX
386424
\usepackage{selnolig} % disable illegal ligatures
387425
\fi
388-
\newlength{\cslhangindent}
389-
\setlength{\cslhangindent}{1.5em}
390-
\newlength{\csllabelwidth}
391-
\setlength{\csllabelwidth}{3em}
392-
\newenvironment{CSLReferences}[2] % #1 hanging-ident, #2 entry spacing
393-
{% don't indent paragraphs
394-
\setlength{\parindent}{0pt}
395-
% turn on hanging indent if param 1 is 1
396-
\ifodd #1 \everypar{\setlength{\hangindent}{\cslhangindent}}\ignorespaces\fi
397-
% set entry spacing
398-
\ifnum #2 > 0
399-
\setlength{\parskip}{#2\baselineskip}
400-
\fi
401-
}%
402-
{}
403-
\usepackage{calc}
404-
\newcommand{\CSLBlock}[1]{#1\hfill\break}
405-
\newcommand{\CSLLeftMargin}[1]{\parbox[t]{\csllabelwidth}{#1}}
406-
\newcommand{\CSLRightInline}[1]{\parbox[t]{\linewidth - \csllabelwidth}{#1}\break}
407-
\newcommand{\CSLIndent}[1]{\hspace{\cslhangindent}#1}
408-
409-
\title{Technical Documents}
410-
\usepackage{etoolbox}
411-
\makeatletter
412-
\providecommand{\subtitle}[1]{% add subtitle to \maketitle
413-
\apptocmd{\@title}{\par {\large #1 \par}}{}{}
414-
}
415-
\makeatother
416-
\subtitle{Demonstrating the Power of Markdown with Pandoc}
417-
\author{Gabriel Nützi \and The Community}
418-
\date{2. December 2020}
419426

420427
\begin{document}
421-
\begin{titlepage}
422-
\makeatletter
423-
\begin{center}
424-
\includesvg[inkscapearea=page,width=0.5\textwidth]{files/Logo.svg}
425-
\end{center}
426-
\vspace{1cm}
427-
\begin{center}
428-
\Huge \textbf{\@title}
429-
\end{center}
430-
\begin{center}
431-
\LARGE Demonstrating the Power of Markdown with Pandoc
432-
\end{center}
433-
\vspace{1cm}
434-
\begin{center}
435-
\textbf{Gabriel Nützi} \\ \& \\ \textbf{The Community}
436-
\end{center}
437-
\begin{center}
438-
\@date
439-
\end{center}
440-
\begin{center}
441-
\vfill
442-
Zürich, Switzerland
443-
\vspace{1cm}
444-
\end{center}
445-
\makeatother
446-
\end{titlepage}
428+
\maketitle
447429
\begin{abstract}
448430
This is a setup demonstrating the power and use of markdown for
449431
technical documents by using a fully automated conversion sequence with
@@ -1027,7 +1009,7 @@ \chapter*{References}\label{references}}
10271009
\leavevmode\vadjust pre{\hypertarget{ref-nuetzig_thesis_2016}{}}%
10281010
\CSLLeftMargin{{[}1{]} }
10291011
\CSLRightInline{G. Nützi, {‘Non-smooth granular rigid body dynamics with
1030-
applications to chute flows,’} PhD thesis, ETH Zurich; ETH Zürich,
1012+
applications to chute flows’}, PhD thesis, ETH Zurich; ETH Zürich,
10311013
Zürich, 2016. }
10321014

10331015
\leavevmode\vadjust pre{\hypertarget{ref-rockafellar_convex_2015}{}}%

convert/pandoc/includes/Template.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
$if(keywords)$
1515
<meta name="keywords" content="$for(keywords)$$keywords$$sep$, $endfor$" />
1616
$endif$
17+
$if(description-meta)$
18+
<meta name="description" content="$description-meta$" />
19+
$endif$
1720
<title>$if(title-prefix)$$title-prefix$ – $endif$$pagetitle$</title>
1821
<style>
1922
$styles.html()$

0 commit comments

Comments
 (0)