git.iko.soy/typeable/pandoc
on master help sign in
New method for building man pages.
a04c15aJohn MacFarlane
INSTALL+2−4
@@ -75,11 +75,9 @@ Quick install
75 --extra-include-dirs=/usr/local/Cellar/icu4c/51.1/include \
75 --extra-include-dirs=/usr/local/Cellar/icu4c/51.1/include \
76 -funicode_collation text-icu pandoc-citeproc
76 -funicode_collation text-icu pandoc-citeproc
77
77
78−To build the `pandoc.1` and `pandoc_markdown.5` man pages, you
78+To build the `pandoc.1` man page:
79−can ues pandoc itself:
80
79
81− pandoc --man1 > pandoc.1
80+ make man/man1/pandoc.1
82− pandoc --man5 > pandoc_markdown.5
83
81
84To build the `pandoc-citeproc` man pages, go to the pandoc-citeproc
82To build the `pandoc-citeproc` man pages, go to the pandoc-citeproc
85build directory, and
83build directory, and
Makefile+13−11
@@ -1,18 +1,17 @@
1version=$(shell grep '^Version:' pandoc.cabal | awk '{print $$2;}')
1version=$(shell grep '^Version:' pandoc.cabal | awk '{print $$2;}')
2−setup=dist/setup/setup
2+pandoc=$(shell find dist -name pandoc -type f -exec ls -t {} \; | head -1)
3−PREFIX ?= /usr/local
4
3
5quick:
4quick:
6 cabal configure --enable-tests --disable-optimization
5 cabal configure --enable-tests --disable-optimization
7 cabal build
6 cabal build
8
7
9full:
8full:
10− cabal configure --enable-tests --enable-optimization -ftrypandoc -fmake-pandoc-man-pages -fembed_data_files --enable-benchmarks
9+ cabal configure --enable-tests --enable-optimization -ftrypandoc -fembed_data_files --enable-benchmarks
11 cabal build
10 cabal build
12 cabal haddock
11 cabal haddock
13
12
14deps:
13deps:
15− cabal install --only-dependencies --enable-tests -ftrypandoc -fmake-pandoc-man-pages -fembed_data_files --enable-benchmarks
14+ cabal install --only-dependencies --enable-tests -ftrypandoc -fembed_data_files --enable-benchmarks
16
15
17prof:
16prof:
18 cabal configure --enable-library-profiling --enable-executable-profiling --enable-optimization --enable-tests
17 cabal configure --enable-library-profiling --enable-executable-profiling --enable-optimization --enable-tests
@@ -28,7 +27,7 @@ install: full
28 cabal copy
27 cabal copy
29 cabal register
28 cabal register
30
29
31−dist: man
30+dist:
32 cabal sdist
31 cabal sdist
33 rm -rf "pandoc-${version}"
32 rm -rf "pandoc-${version}"
34 tar xvzf dist/pandoc-${version}.tar.gz
33 tar xvzf dist/pandoc-${version}.tar.gz
@@ -41,11 +40,14 @@ debpkg:
41osxpkg:
40osxpkg:
42 ./make_osx_package.sh
41 ./make_osx_package.sh
43
42
44−%.1: %.1.template README
43+man/man1/pandoc.1: README man/pandoc.1.template
45− ${makemanpages}
44+ @[ -n "$(pandoc)" ] || \
46−
45+ (echo "Could not find pandoc in dist/" && exit 1)
47−%.5: %.5.template README
46+ $(pandoc) $< -t man -s --template man/pandoc.1.template \
48− ${makemanpages}
47+ --filter man/capitalizeHeaders.hs \
48+ --filter man/removeNotes.hs \
49+ --filter man/removeLinks.hs \
50+ -o $@
49
51
50download_stats:
52download_stats:
51 curl https://api.github.com/repos/jgm/pandoc/releases | \
53 curl https://api.github.com/repos/jgm/pandoc/releases | \
@@ -53,6 +55,6 @@ download_stats:
53
55
54clean:
56clean:
55 cabal clean
57 cabal clean
56− -rm -rf $(BINDIST) $(BINDIST).tar.gz
58+ -rm man/man1/pandoc.1
57
59
58.PHONY: deps quick full install man clean test bench haddock osxpkg dist bindist prof download_stats
60.PHONY: deps quick full install man clean test bench haddock osxpkg dist bindist prof download_stats
README−8
@@ -240,14 +240,6 @@ General options
240 `epub.css`, `templates`, `slidy`, `slideous`, or `s5` directory
240 `epub.css`, `templates`, `slidy`, `slideous`, or `s5` directory
241 placed in this directory will override pandoc's normal defaults.
241 placed in this directory will override pandoc's normal defaults.
242
242
243−`--man1`
244−
245−: Write `pandoc.1` man page to *stdout*.
246−
247−`--man5`
248−
249−: Write `pandoc_markdown.5` man page to *stdout*.
250−
251`--verbose`
243`--verbose`
252
244
253: Give verbose debugging output. Currently this only has an effect
245: Give verbose debugging output. Currently this only has an effect
data/pandoc_markdown.5.templatedeleted−11
@@ -1,11 +0,0 @@
1−$if(has-tables)$
2−.\"t
3−$endif$
4−.TH PANDOC_MARKDOWN 5 "$date$" "$version$"
5−.SH NAME
6−pandoc_markdown - markdown syntax for pandoc(1)
7−.SH DESCRIPTION
8−$body$
9−.SH SEE ALSO
10−.PP
11−\f[C]pandoc\f[] (1).
man/capitalizeHeaders.hsnew file+18
@@ -0,0 +1,18 @@
1+import Text.Pandoc.JSON
2+import Text.Pandoc.Walk
3+import Data.Char (toUpper)
4+
5+main :: IO ()
6+main = toJSONFilter capitalizeHeaders
7+
8+capitalizeHeaders :: Block -> Block
9+capitalizeHeaders (Header 1 attr xs) = Header 1 attr $ walk capitalize xs
10+capitalizeHeaders x = walk capitalizeHeaderLinks x
11+
12+capitalize :: Inline -> Inline
13+capitalize (Str xs) = Str $ map toUpper xs
14+capitalize x = x
15+
16+capitalizeHeaderLinks :: Inline -> Inline
17+capitalizeHeaderLinks (Link xs t@('#':_,_)) = Link (walk capitalize xs) t
18+capitalizeHeaderLinks x = x
data/pandoc.1.template → man/pandoc.1.templaterenamed−6
@@ -5,12 +5,6 @@ $endif$
5.SH NAME
5.SH NAME
6pandoc - general markup converter
6pandoc - general markup converter
7$body$
7$body$
8−.SH PANDOC'S MARKDOWN
9−For a complete description of pandoc's extensions to standard markdown,
10−see \f[C]pandoc_markdown\f[] (5).
11−.SH SEE ALSO
12−.PP
13−\f[C]pandoc_markdown\f[] (5).
14.PP
8.PP
15The Pandoc source code and all documentation may be downloaded
9The Pandoc source code and all documentation may be downloaded
16from <http://pandoc.org>.
10from <http://pandoc.org>.
man/removeLinks.hsnew file+9
@@ -0,0 +1,9 @@
1+import Text.Pandoc.JSON
2+
3+main :: IO ()
4+main = toJSONFilter removeLinks
5+
6+removeLinks :: Inline -> [Inline]
7+removeLinks (Link l _) = l
8+removeLinks x = [x]
9+
man/removeNotes.hsnew file+9
@@ -0,0 +1,9 @@
1+import Text.Pandoc.JSON
2+
3+main :: IO ()
4+main = toJSONFilter removeNotes
5+
6+removeNotes :: Inline -> Inline
7+removeNotes (Note _) = Str ""
8+removeNotes x = x
9+
pandoc.cabal+2−6
@@ -1,5 +1,5 @@
1Name: pandoc
1Name: pandoc
2−Version: 1.14.1
2+Version: 1.15
3Cabal-Version: >= 1.10
3Cabal-Version: >= 1.10
4Build-Type: Custom
4Build-Type: Custom
5License: GPL
5License: GPL
@@ -106,9 +106,6 @@ Data-Files:
106 data/sample.lua
106 data/sample.lua
107 -- documentation
107 -- documentation
108 README, COPYRIGHT
108 README, COPYRIGHT
109− -- man page templates
110− data/pandoc.1.template
111− data/pandoc_markdown.5.template
112Extra-Source-Files:
109Extra-Source-Files:
113 -- documentation
110 -- documentation
114 INSTALL, BUGS, CONTRIBUTING.md, changelog
111 INSTALL, BUGS, CONTRIBUTING.md, changelog
@@ -355,8 +352,7 @@ Library
355 Text.Pandoc.Templates,
352 Text.Pandoc.Templates,
356 Text.Pandoc.XML,
353 Text.Pandoc.XML,
357 Text.Pandoc.SelfContained,
354 Text.Pandoc.SelfContained,
358− Text.Pandoc.Process,
355+ Text.Pandoc.Process
359− Text.Pandoc.ManPages
360 Other-Modules: Text.Pandoc.Readers.Docx.Lists,
356 Other-Modules: Text.Pandoc.Readers.Docx.Lists,
361 Text.Pandoc.Readers.Docx.Reducible,
357 Text.Pandoc.Readers.Docx.Reducible,
362 Text.Pandoc.Readers.Docx.Parse,
358 Text.Pandoc.Readers.Docx.Parse,
pandoc.hs−15
@@ -39,7 +39,6 @@ import Text.Pandoc.Shared ( tabFilter, readDataFileUTF8, readDataFile,
39 safeRead, headerShift, normalize, err, warn,
39 safeRead, headerShift, normalize, err, warn,
40 openURL )
40 openURL )
41import Text.Pandoc.MediaBag ( mediaDirectory, extractMediaBag, MediaBag )
41import Text.Pandoc.MediaBag ( mediaDirectory, extractMediaBag, MediaBag )
42−import Text.Pandoc.ManPages ( manPandoc1, manPandocMarkdown5 )
43import Text.Pandoc.XML ( toEntities )
42import Text.Pandoc.XML ( toEntities )
44import Text.Pandoc.SelfContained ( makeSelfContained )
43import Text.Pandoc.SelfContained ( makeSelfContained )
45import Text.Pandoc.Process (pipeProcess)
44import Text.Pandoc.Process (pipeProcess)
@@ -870,20 +869,6 @@ options =
870 (\opt -> return opt { optIgnoreArgs = True }))
869 (\opt -> return opt { optIgnoreArgs = True }))
871 "" -- "Ignore command-line arguments."
870 "" -- "Ignore command-line arguments."
872
871
873− , Option "" ["man1"]
874− (NoArg
875− (\_ -> do
876− manPandoc1 >>= UTF8.hPutStr stdout
877− exitWith ExitSuccess ))
878− "" -- "Print pandoc.1 man page"
879−
880− , Option "" ["man5"]
881− (NoArg
882− (\_ -> do
883− manPandocMarkdown5 >>= UTF8.hPutStr stdout
884− exitWith ExitSuccess ))
885− "" -- "Print pandoc_markdown.5 man page"
886−
887 , Option "" ["verbose"]
872 , Option "" ["verbose"]
888 (NoArg
873 (NoArg
889 (\opt -> return opt { optVerbose = True }))
874 (\opt -> return opt { optVerbose = True }))
src/Text/Pandoc/ManPages.hsdeleted−101
@@ -1,101 +0,0 @@
1−{-# LANGUAGE CPP #-}
2−{-
3−Copyright (C) 2013-2015 John MacFarlane <jgm@berkeley.edu>
4−
5−This program is free software; you can redistribute it and/or modify
6−it under the terms of the GNU General Public License as published by
7−the Free Software Foundation; either version 2 of the License, or
8−(at your option) any later version.
9−
10−This program is distributed in the hope that it will be useful,
11−but WITHOUT ANY WARRANTY; without even the implied warranty of
12−MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13−GNU General Public License for more details.
14−
15−You should have received a copy of the GNU General Public License
16−along with this program; if not, write to the Free Software
17−Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18−-}
19−
20−{- |
21− Module : Text.Pandoc.ManPages
22− Copyright : Copyright (C) 2013-2015 John MacFarlane
23− License : GNU GPL, version 2 or above
24−
25− Maintainer : John MacFarlane <jgm@berkeley.edu>
26− Stability : alpha
27− Portability : portable
28−
29−Functions to build pandoc's man pages (pandoc.1 and pandoc_markdown.5)
30−from pandoc's README.
31−-}
32−module Text.Pandoc.ManPages (
33− manPandoc1,
34− manPandocMarkdown5
35− ) where
36−import Text.Pandoc
37−import Text.Pandoc.Error (handleError)
38−import Data.Char (toUpper)
39−import System.FilePath
40−import Text.Pandoc.Shared (normalize, readDataFileUTF8)
41−
42−manPandoc1 :: IO String
43−manPandoc1 = do
44− readme <- readDataFileUTF8 Nothing "README"
45− let (Pandoc meta blocks) = normalize $ handleError
46− $ readMarkdown def readme
47− let manBlocks = removeSect [Str "Wrappers"]
48− $ removeSect [Str "Pandoc's",Space,Str "markdown"] blocks
49− makeManPage "pandoc.1" meta manBlocks
50−
51−manPandocMarkdown5 :: IO String
52−manPandocMarkdown5 = do
53− readme <- readDataFileUTF8 Nothing "README"
54− let (Pandoc meta blocks) = normalize $ handleError
55− $ readMarkdown def readme
56− let syntaxBlocks = extractSect [Str "Pandoc's",Space,Str "markdown"] blocks
57− makeManPage "pandoc_markdown.5" meta syntaxBlocks
58−
59−makeManPage :: String -> Meta -> [Block] -> IO String
60−makeManPage page meta blocks = do
61− let templ = page <.> "template"
62− manTemplate <- readDataFileUTF8 Nothing templ
63− return $ writeManPage manTemplate (Pandoc meta blocks)
64−
65−writeManPage :: String -> Pandoc -> String
66−writeManPage templ doc =
67− writeMan def{ writerStandalone = True
68− , writerTemplate = templ
69− , writerVariables = [("version", pandocVersion)] } $
70− bottomUp (concatMap removeLinks) $
71− bottomUp capitalizeHeaders doc
72−
73−removeLinks :: Inline -> [Inline]
74−removeLinks (Link l _) = l
75−removeLinks x = [x]
76−
77−capitalizeHeaders :: Block -> Block
78−capitalizeHeaders (Header 1 attr xs) = Header 1 attr $ bottomUp capitalize xs
79−capitalizeHeaders x = x
80−
81−capitalize :: Inline -> Inline
82−capitalize (Str xs) = Str $ map toUpper xs
83−capitalize x = x
84−
85−removeSect :: [Inline] -> [Block] -> [Block]
86−removeSect ils (Header 1 _ x:xs) | x == ils =
87− dropWhile (not . isHeader1) xs
88−removeSect ils (x:xs) = x : removeSect ils xs
89−removeSect _ [] = []
90−
91−extractSect :: [Inline] -> [Block] -> [Block]
92−extractSect ils (Header 1 _ z:xs) | z == ils =
93− bottomUp promoteHeader $ takeWhile (not . isHeader1) xs
94− where promoteHeader (Header n attr x) = Header (n-1) attr x
95− promoteHeader x = x
96−extractSect ils (_:xs) = extractSect ils xs
97−extractSect _ [] = []
98−
99−isHeader1 :: Block -> Bool
100−isHeader1 (Header 1 _ _ ) = True
101−isHeader1 _ = False