summarylogtreecommitdiffstats
path: root/pandoc-2.0-fix.patch
blob: 23a4e7e87fef022e820bf7c8d32588a43169eeaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
From 78a1a24dd8da1a3f07e1b09a6f26e6fc32312938 Mon Sep 17 00:00:00 2001
From: Abdo Roig-Maranges <abdo.roig@gmail.com>
Date: Sat, 2 Dec 2017 19:23:44 +0100
Subject: [PATCH] adapt to command-line change in pandoc 2.0

pandoc 2 has removed -S from the command line. Instead we must add
+smart as an extension to the format.
---
 Makefile          |  4 ++--
 scripts/pandoc-sh | 11 +++++++++--
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index d4d0f71..0cfa755 100644
--- a/Makefile
+++ b/Makefile
@@ -263,7 +263,7 @@ man/%.1: markdown_src/%.md
 	@if command -v pandoc >/dev/null; then \
 	    echo 'generating $@'; \
 	    ${MKPATH} `dirname '$@'` 2>/dev/null || true; \
-	    ${PANDOC} -Ss -f markdown_github $< -o $@; \
+	    ${PANDOC} -s -f markdown_github $< -o $@; \
 	else \
 	    if [ ! -r docs-warn-stamp ]; then \
 		echo >&2; \
@@ -283,7 +283,7 @@ html/%.html: %.md.work
 	@if command -v pandoc >/dev/null; then \
 	    echo 'generating $@'; \
 	    ${MKPATH} `dirname '$@'` 2>/dev/null || true; \
-	    ${PANDOC} -Ss --toc -f markdown_github $< -o $@; \
+	    ${PANDOC} -s --toc -f markdown_github $< -o $@; \
 	    rm -f $<; \
 	else \
 	    if [ ! -r docs-warn-stamp ]; then \
diff --git a/scripts/pandoc-sh b/scripts/pandoc-sh
index 03cb265..7a6e8bf 100755
--- a/scripts/pandoc-sh
+++ b/scripts/pandoc-sh
@@ -33,13 +33,20 @@ fi
 
 first_arg=1
 for arg in "$@"; do
-    [ $first_arg -eq 1 ] && set -- && first_arg=0
+    if [ $first_arg -eq 1 ]; then
+        if [ $old_pandoc -eq 1 ]; then
+            set -- "-S"
+        else
+            set --
+        fi
+        first_arg=0
+    fi
 
     if [ "$arg" = markdown_github ]; then
 	if [ $old_pandoc -eq 1 ]; then
 	    set -- "$@" markdown
 	else
-	    set -- "$@" markdown_github+pandoc_title_block
+	    set -- "$@" markdown_github+pandoc_title_block+smart
 	fi
     else
 	set -- "$@" "$arg"
From 07905e4c445d963dd34f3f46caad84e1472a210c Mon Sep 17 00:00:00 2001
From: Abdo Roig-Maranges <abdo.roig@gmail.com>
Date: Sat, 2 Dec 2017 20:02:04 +0100
Subject: [PATCH] pandoc feature detection was broken for new pandoc

Pandoc no longer prints input formats in --help, so we cannot detect
availability of markdown_github this way.

There is a --list-input-formats command line argument, but it was
introduced recently.

So, let's check by version. markdown_github was introduced in version
1.10.
---
 scripts/pandoc-sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/scripts/pandoc-sh b/scripts/pandoc-sh
index 7a6e8bf..44ec603 100755
--- a/scripts/pandoc-sh
+++ b/scripts/pandoc-sh
@@ -27,7 +27,11 @@ title="`echo \"$title\" | \
 # use markdown instead of markdown_github on older versions
 # and markdown_github+pandoc_title_block on newer ones
 old_pandoc=0
-if ! ( pandoc --help | grep markdown_github >/dev/null ); then
+pandoc_version=$(pandoc --version | head -1 | cut -d' ' -f2)
+pandoc_major_version=${pandoc_version%%.*}
+pandoc_minor_version=${pandoc_version#*.}
+pandoc_minor_version=${pandoc_minor_version%%.*}
+if [ $pandoc_major_version -le 1 ] && [ $pandoc_minor_version -le 9 ]; then
     old_pandoc=1
 fi