git.iko.soy/typeable/pandoc
on master help sign in
Merge branch 'master' into patch-1
commit51bb7453e41e5e7e28a60cb22cb4f4d082b7fbdf authorAndrew Dunning <adunning@users.noreply.github.com> dateFri 8 Sep 2017, 07:06 (9 years ago) parent3654c437320054
24 files changed+1193−222
data/pandoc.lua+2−2 data/templates/default.latex+9−9 doc/ldoc.ltp+38 doc/lua-filters.md+741−1 linux/Dockerfile+6−4 pandoc.cabal+101−92 src/Text/Pandoc/Parsing.hs+1−1 src/Text/Pandoc/Readers/HTML.hs+17−17 src/Text/Pandoc/Readers/LaTeX.hs+31−14 src/Text/Pandoc/Readers/Muse.hs+41−11 src/Text/Pandoc/Readers/RST.hs+9−9 src/Text/Pandoc/Writers/HTML.hs+9−2 src/Text/Pandoc/Writers/LaTeX.hs+13−2 src/Text/Pandoc/Writers/Markdown.hs+11−8 src/Text/Pandoc/Writers/Org.hs+26−37 stack.pkg.yaml+1−1 test/Tests/Readers/Muse.hs+38−5 test/Tests/Readers/RST.hs+13 test/command/3497.md+1−1 test/command/3771.md+14 test/command/3880.md+6 test/command/3880.txt+1 test/writers-lang-and-dir.latex+6−6 tools/pandoc-template-mode.el+58
data/pandoc.lua+2−2
@@ -135,7 +135,7 @@ end
135135-- @section document
136136
137137--- A complete pandoc document
138−-- @function Panoc
138+-- @function Pandoc
139139-- @tparam {Block,...} blocks document content
140140-- @tparam[opt] Meta meta document meta data
141141function M.Pandoc(blocks, meta)
@@ -772,7 +772,7 @@ M.UpperAlpha = "UpperAlpha"
772772-- `--from` command line option.
773773-- @tparam string markup the markup to be parsed
774774-- @tparam[opt] string format format specification, defaults to "markdown".
775−-- @return Doc pandoc document
775+-- @treturn Pandoc pandoc document
776776-- @usage
777777-- local org_markup = "/emphasis/" -- Input to be read
778778-- local document = pandoc.read(org_markup, "org")
data/templates/default.latex+9−9
@@ -259,6 +259,15 @@ $else$
259259\fi
260260$endif$
261261$endif$
262+
263+% set default figure placement to htbp
264+\makeatletter
265+\def\fps@figure{htbp}
266+\makeatother
267+
268+$for(header-includes)$
269+$header-includes$
270+$endfor$
262271$if(lang)$
263272\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
264273 \usepackage[shorthands=off,$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel}
@@ -292,15 +301,6 @@ $if(dir)$
292301\fi
293302$endif$
294303
295−% set default figure placement to htbp
296−\makeatletter
297−\def\fps@figure{htbp}
298−\makeatother
299−
300−$for(header-includes)$
301−$header-includes$
302−$endfor$
303−
304304$if(title)$
305305\title{$title$$if(thanks)$\thanks{$thanks$}$endif$}
306306$endif$
doc/ldoc.ltpnew file+38
@@ -0,0 +1,38 @@
1+# local iter = ldoc.modules.iter
2+# local M = ldoc.markup
3+
4+<h1>Module $(module.name)</h1>
5+
6+<p>$(M(module.summary))</p>
7+
8+# for kind, items in module.kinds() do
9+
10+<h2>$(kind)</h2>
11+ <dl>
12+# for item in items() do ldoc.item = item -- provides context for M()
13+ <dt><span id="$(item.name)"><code>$(ldoc.display_name(item))</code></span></dt>
14+ <dd>
15+ <p>$(item.summary)</p>
16+# if item.params and #item.params > 0 then
17+ $(module.kinds:type_of(item).subnames):
18+ <dl>
19+# for p in iter(item.params) do
20+ <dt><code>$(p)</code>:</dt>
21+ <dd>$(M(item.params.map[p]))</dd>
22+# end -- for
23+ </dl>
24+# end -- if params
25+# if item.ret then
26+ <p>Returns: $(item.ret[1])</p>
27+# end -- if returns
28+# if item.usage then
29+ <p>Usage:</p>
30+ <pre><code>$(item.usage[1])</code></pre>
31+# end -- if usage
32+# if item.see then
33+ See also: <a href="#$(item.see[1].label)">$(item.see[1].label)</a>
34+
35+# end -- if see
36+# end -- for items
37+ </dl>
38+# end -- for kinds
doc/lua-filters.md+741−1
@@ -1,6 +1,6 @@
11% Pandoc Lua Filters
22% Albert Krewinkel, John MacFarlane
3−% August 21, 2017
3+% August 31, 2017
44
55# Introduction
66
@@ -111,6 +111,11 @@ inline element must return an inline, and a block element must
111111remain a block element after filter application. Pandoc will
112112throw an error if this condition is violated.
113113
114+If there is no function matching the element's node type, then
115+the filtering system will look for a more general fallback
116+function. Two fallback functions are supported, `Inline` and
117+`Block`. Each matches elements of the respective type.
118+
114119Elements without matching functions are left untouched.
115120
116121See [module documentation](pandoc-module.html) for a list of pandoc
@@ -304,3 +309,738 @@ then running `pandoc --lua-filter=meta-vars.lua occupations.md` will output:
304309</dd>
305310</dl>
306311```
312+
313+# Module pandoc
314+
315+Lua functions for pandoc scripts.
316+
317+## Pandoc Document
318+
319+[`Pandoc (blocks[, meta])`]{#Pandoc}
320+
321+: A complete pandoc document
322+
323+ Parameters:
324+
325+ `blocks`:
326+ : document content
327+
328+ `meta`:
329+ : document meta data
330+
331+## MetaValue
332+
333+[`MetaBlocks (blocks)`]{#MetaBlocks}
334+
335+: Meta blocks
336+
337+ Parameters:
338+
339+ `blocks`:
340+ : blocks
341+
342+[`MetaInlines (inlines)`]{#MetaInlines}
343+
344+: Meta inlines
345+
346+ Parameters:
347+
348+ `inlines`:
349+ : inlines
350+
351+[`MetaList (meta_values)`]{#MetaList}
352+
353+: Meta list
354+
355+ Parameters:
356+
357+ `meta_values`:
358+ : list of meta values
359+
360+[`MetaMap (key_value_map)`]{#MetaMap}
361+
362+: Meta map
363+
364+ Parameters:
365+
366+ `key_value_map`:
367+ : a string-indexed map of meta values
368+
369+[`MetaString (str)`]{#MetaString}
370+
371+: Creates string to be used in meta data.
372+
373+ Parameters:
374+
375+ `str`:
376+ : string value
377+
378+[`MetaBool (bool)`]{#MetaBool}
379+
380+: Creates boolean to be used in meta data.
381+
382+ Parameters:
383+
384+ `bool`:
385+ : boolean value
386+
387+## Blocks
388+
389+[`Block`]{#Block}
390+
391+: Block elements
392+
393+[`BlockQuote (content)`]{#BlockQuote}
394+
395+: Creates a block quote element
396+
397+ Parameters:
398+
399+ `content`:
400+ : block content
401+
402+ Returns: block quote element
403+
404+[`BulletList (content)`]{#BulletList}
405+
406+: Creates a bullet (i.e.
407+
408+ Parameters:
409+
410+ `content`:
411+ : list of items
412+
413+ Returns: block quote element
414+
415+[`CodeBlock (text[, attr])`]{#CodeBlock}
416+
417+: Creates a code block element
418+
419+ Parameters:
420+
421+ `text`:
422+ : code string
423+
424+ `attr`:
425+ : element attributes
426+
427+ Returns: code block element
428+
429+[`DefinitionList (content)`]{#DefinitionList}
430+
431+: Creates a definition list, containing terms and their
432+ explanation.
433+
434+ Parameters:
435+
436+ `content`:
437+ : list of items
438+
439+ Returns: block quote element
440+
441+[`Div (content[, attr])`]{#Div}
442+
443+: Creates a div element
444+
445+ Parameters:
446+
447+ `content`:
448+ : block content
449+
450+ `attr`:
451+ : element attributes
452+
453+ Returns: code block element
454+
455+[`Header (level, content[, attr])`]{#Header}
456+
457+: Creates a block quote element.
458+
459+ Parameters:
460+
461+ `level`:
462+ : header level
463+
464+ `content`:
465+ : inline content
466+
467+ `attr`:
468+ : element attributes
469+
470+ Returns: header element
471+
472+[`HorizontalRule ()`]{#HorizontalRule}
473+
474+: Creates a horizontal rule.
475+
476+ Returns: horizontal rule
477+
478+[`LineBlock (content)`]{#LineBlock}
479+
480+: Creates a line block element.
481+
482+ Parameters:
483+
484+ `content`:
485+ : inline content
486+
487+ Returns: block quote element
488+
489+[`Null ()`]{#Null}
490+
491+: Creates a null element.
492+
493+ Returns: null element
494+
495+[`OrderedList (items[, listAttributes])`]{#OrderedList}
496+
497+: Creates an ordered list.
498+
499+ Parameters:
500+
501+ `items`:
502+ : list items
503+
504+ `listAttributes`:
505+ : list parameters
506+
507+ Returns:
508+
509+[`Para (content)`]{#Para}
510+
511+: Creates a para element.
512+
513+ Parameters:
514+
515+ `content`:
516+ : inline content
517+
518+ Returns: block quote element
519+
520+[`Plain (content)`]{#Plain}
521+
522+: Creates a plain element.
523+
524+ Parameters:
525+
526+ `content`:
527+ : inline content
528+
529+ Returns: block quote element
530+
531+[`RawBlock (format, text)`]{#RawBlock}
532+
533+: Creates a raw content block of the specified format.
534+
535+ Parameters:
536+
537+ `format`:
538+ : format of content
539+
540+ `text`:
541+ : string content
542+
543+ Returns: block quote element
544+
545+[`Table (caption, aligns, widths, headers, rows)`]{#Table}
546+
547+: Creates a table element.
548+
549+ Parameters:
550+
551+ `caption`:
552+ : table caption
553+
554+ `aligns`:
555+ : alignments
556+
557+ `widths`:
558+ : column widths
559+
560+ `headers`:
561+ : header row
562+
563+ `rows`:
564+ : table rows
565+
566+ Returns: block quote element
567+
568+## Inline
569+
570+[`Inline`]{#Inline}
571+
572+: Inline element class
573+
574+[`Cite (content, citations)`]{#Cite}
575+
576+: Creates a Cite inline element
577+
578+ Parameters:
579+
580+ `content`:
581+ : List of inlines
582+
583+ `citations`:
584+ : List of citations
585+
586+ Returns: citations element
587+
588+[`Code (text[, attr])`]{#Code}
589+
590+: Creates a Code inline element
591+
592+ Parameters:
593+
594+ `text`:
595+ : brief image description
596+
597+ `attr`:
598+ : additional attributes
599+
600+ Returns: code element
601+
602+[`Emph (content)`]{#Emph}
603+
604+: Creates an inline element representing emphasised text.
605+
606+ Parameters:
607+
608+ `content`:
609+ : inline content
610+
611+ Returns: emphasis element
612+
613+[`Image (caption, src[, title[, attr]])`]{#Image}
614+
615+: Creates a Image inline element
616+
617+ Parameters:
618+
619+ `caption`:
620+ : text used to describe the image
621+
622+ `src`:
623+ : path to the image file
624+
625+ `title`:
626+ : brief image description
627+
628+ `attr`:
629+ : additional attributes
630+
631+ Returns: image element
632+
633+[`LineBreak ()`]{#LineBreak}
634+
635+: Create a LineBreak inline element
636+
637+ Returns: linebreak element
638+
639+[`Link (content, target[, title[, attr]])`]{#Link}
640+
641+: Creates a link inline element, usually a hyperlink.
642+
643+ Parameters:
644+
645+ `content`:
646+ : text for this link
647+
648+ `target`:
649+ : the link target
650+
651+ `title`:
652+ : brief link description
653+
654+ `attr`:
655+ : additional attributes
656+
657+ Returns: image element
658+
659+[`Math (mathtype, text)`]{#Math}
660+
661+: Creates a Math element, either inline or displayed.
662+
663+ Parameters:
664+
665+ `mathtype`:
666+ : rendering specifier
667+
668+ `text`:
669+ : Math content
670+
671+ Returns: Math element
672+
673+[`DisplayMath (text)`]{#DisplayMath}
674+
675+: Creates a DisplayMath element (DEPRECATED).
676+
677+ Parameters:
678+
679+ `text`:
680+ : Math content
681+
682+ Returns: Math element
683+
684+[`InlineMath (text)`]{#InlineMath}
685+
686+: Creates an InlineMath inline element (DEPRECATED).
687+
688+ Parameters:
689+
690+ `text`:
691+ : Math content
692+
693+ Returns: Math element
694+
695+[`Note (content)`]{#Note}
696+
697+: Creates a Note inline element
698+
699+ Parameters:
700+
701+ `content`:
702+ : footnote block content
703+
704+[`Quoted (quotetype, content)`]{#Quoted}
705+
706+: Creates a Quoted inline element given the quote type and
707+ quoted content.
708+
709+ Parameters:
710+
711+ `quotetype`:
712+ : type of quotes to be used
713+
714+ `content`:
715+ : inline content
716+
717+ Returns: quoted element
718+
719+[`SingleQuoted (content)`]{#SingleQuoted}
720+
721+: Creates a single-quoted inline element (DEPRECATED).
722+
723+ Parameters:
724+
725+ `content`:
726+ : inline content
727+
728+ Returns: quoted element
729+
730+ See also: [Quoted](#Quoted)
731+
732+[`DoubleQuoted (content)`]{#DoubleQuoted}
733+
734+: Creates a single-quoted inline element (DEPRECATED).
735+
736+ Parameters:
737+
738+ `content`:
739+ : inline content
740+
741+ Returns: quoted element
742+
743+ See also: [Quoted](#Quoted)
744+
745+[`RawInline (format, text)`]{#RawInline}
746+
747+: Creates a RawInline inline element
748+
749+ Parameters:
750+
751+ `format`:
752+ : format of the contents
753+
754+ `text`:
755+ : string content
756+
757+ Returns: raw inline element
758+
759+[`SmallCaps (content)`]{#SmallCaps}
760+
761+: Creates text rendered in small caps
762+
763+ Parameters:
764+
765+ `content`:
766+ : inline content
767+
768+ Returns: smallcaps element
769+
770+[`SoftBreak ()`]{#SoftBreak}
771+
772+: Creates a SoftBreak inline element.
773+
774+ Returns: softbreak element
775+
776+[`Space ()`]{#Space}
777+
778+: Create a Space inline element
779+
780+ Returns: space element
781+
782+[`Span (content[, attr])`]{#Span}
783+
784+: Creates a Span inline element
785+
786+ Parameters:
787+
788+ `content`:
789+ : inline content
790+
791+ `attr`:
792+ : additional attributes
793+
794+ Returns: span element
795+
796+[`Str (text)`]{#Str}
797+
798+: Creates a Str inline element
799+
800+ Parameters:
801+
802+ `text`:
803+ : content
804+
805+ Returns: string element
806+
807+[`Strikeout (content)`]{#Strikeout}
808+
809+: Creates text which is striked out.
810+
811+ Parameters:
812+
813+ `content`:
814+ : inline content
815+
816+ Returns: strikeout element
817+
818+[`Strong (content)`]{#Strong}
819+
820+: Creates a Strong element, whose text is usually displayed in
821+ a bold font.
822+
823+ Parameters:
824+
825+ `content`:
826+ : inline content
827+
828+ Returns: strong element
829+
830+[`Subscript (content)`]{#Subscript}
831+
832+: Creates a Subscript inline element
833+
834+ Parameters:
835+
836+ `content`:
837+ : inline content
838+
839+ Returns: subscript element
840+
841+[`Superscript (content)`]{#Superscript}
842+
843+: Creates a Superscript inline element
844+
845+ Parameters:
846+
847+ `content`:
848+ : inline content
849+
850+ Returns: strong element
851+
852+## Helpers
853+
854+[`Attr ([identifier[, classes[, attributes]]])`]{#Attr}
855+
856+: Create a new set of attributes (Attr).
857+
858+ Parameters:
859+
860+ `identifier`:
861+ : element identifier
862+
863+ `classes`:
864+ : element classes
865+
866+ `attributes`:
867+ : table containing string keys and values
868+
869+ Returns: element attributes
870+
871+[`Citation (id, mode[, prefix[, suffix[, note_num[, hash]]]])`]{#Citation}
872+
873+: Creates a single citation.
874+
875+ Parameters:
876+
877+ `id`:
878+ : citation identifier (like a bibtex key)
879+
880+ `mode`:
881+ : citation mode
882+
883+ `prefix`:
884+ : citation prefix
885+
886+ `suffix`:
887+ : citation suffix
888+
889+ `note_num`:
890+ : note number
891+
892+ `hash`:
893+ : hash number
894+
895+## Constants
896+
897+[`AuthorInText`]{#AuthorInText}
898+
899+: Author name is mentioned in the text.
900+
901+ See also: [Citation](#Citation)
902+
903+[`SuppressAuthor`]{#SuppressAuthor}
904+
905+: Author name is suppressed.
906+
907+ See also: [Citation](#Citation)
908+
909+[`NormalCitation`]{#NormalCitation}
910+
911+: Default citation style is used.
912+
913+ See also: [Citation](#Citation)
914+
915+[`AlignLeft`]{#AlignLeft}
916+
917+: Table cells aligned left.
918+
919+ See also: [Table](#Table)
920+
921+[`AlignRight`]{#AlignRight}
922+
923+: Table cells right-aligned.
924+
925+ See also: [Table](#Table)
926+
927+[`AlignCenter`]{#AlignCenter}
928+
929+: Table cell content is centered.
930+
931+ See also: [Table](#Table)
932+
933+[`AlignDefault`]{#AlignDefault}
934+
935+: Table cells are alignment is unaltered.
936+
937+ See also: [Table](#Table)
938+
939+[`DefaultDelim`]{#DefaultDelim}
940+
941+: Default list number delimiters are used.
942+
943+ See also: [OrderedList](#OrderedList)
944+
945+[`Period`]{#Period}
946+
947+: List numbers are delimited by a period.
948+
949+ See also: [OrderedList](#OrderedList)
950+
951+[`OneParen`]{#OneParen}
952+
953+: List numbers are delimited by a single parenthesis.
954+
955+ See also: [OrderedList](#OrderedList)
956+
957+[`TwoParens`]{#TwoParens}
958+
959+: List numbers are delimited by a double parentheses.
960+
961+ See also: [OrderedList](#OrderedList)
962+
963+[`DefaultStyle`]{#DefaultStyle}
964+
965+: List are numbered in the default style
966+
967+ See also: [OrderedList](#OrderedList)
968+
969+[`Example`]{#Example}
970+
971+: List items are numbered as examples.
972+
973+ See also: [OrderedList](#OrderedList)
974+
975+[`Decimal`]{#Decimal}
976+
977+: List are numbered using decimal integers.
978+
979+ See also: [OrderedList](#OrderedList)
980+
981+[`LowerRoman`]{#LowerRoman}
982+
983+: List are numbered using lower-case roman numerals.
984+
985+ See also: [OrderedList](#OrderedList)
986+
987+[`UpperRoman`]{#UpperRoman}
988+
989+: List are numbered using upper-case roman numerals
990+
991+ See also: [OrderedList](#OrderedList)
992+
993+[`LowerAlpha`]{#LowerAlpha}
994+
995+: List are numbered using lower-case alphabetic characters.
996+
997+ See also: [OrderedList](#OrderedList)
998+
999+[`UpperAlpha`]{#UpperAlpha}
1000+
1001+: List are numbered using upper-case alphabetic characters.
1002+
1003+ See also: [OrderedList](#OrderedList)
1004+
1005+## Helper Functions
1006+
1007+[`read (markup[, format])`]{#read}
1008+
1009+: Parse the given string into a Pandoc document.
1010+
1011+ Parameters:
1012+
1013+ `markup`:
1014+ : the markup to be parsed
1015+
1016+ `format`:
1017+ : format specification, defaults to \"markdown\".
1018+
1019+ Returns: pandoc document
1020+
1021+ Usage:
1022+
1023+ local org_markup = "/emphasis/" -- Input to be read
1024+ local document = pandoc.read(org_markup, "org")
1025+ -- Get the first block of the document
1026+ local block = document.blocks[1]
1027+ -- The inline element in that block is an `Emph`
1028+ assert(block.content[1].t == "Emph")
1029+
1030+[`global_filter ()`]{#global_filter}
1031+
1032+: Use functions defined in the global namespace to create a
1033+ pandoc filter.
1034+
1035+ Returns: A list of filter functions
1036+
1037+ Usage:
1038+
1039+ -- within a file defining a pandoc filter:
1040+ function Str(text)
1041+ return pandoc.Str(utf8.upper(text))
1042+ end
1043+
1044+ return {pandoc.global_filter()}
1045+ -- the above is equivallent to
1046+ -- return {{Str = Str}}
linux/Dockerfile+6−4
@@ -5,7 +5,7 @@ ADD https://raw.githubusercontent.com/mitchty/alpine-ghc/master/mitch.tishmack%4
55 /etc/apk/keys/mitch.tishmack@gmail.com-55881c97.rsa.pub
66RUN apk update
77RUN apk add alpine-sdk git ca-certificates ghc cabal stack zlib-dev \
8− dpkg fakeroot sed gawk grep
8+ dpkg fakeroot sed gawk grep bash linux-headers
99RUN stack update
1010RUN stack config set system-ghc --global true
1111RUN mkdir -p /etc/stack
@@ -16,13 +16,15 @@ RUN git clone https://github.com/jgm/pandoc
1616WORKDIR /usr/src/pandoc
1717RUN stack install --stack-yaml stack.pkg.yaml --only-dependencies \
1818 --flag 'pandoc:embed_data_files' \
19− --test --ghc-options '-O2 -optc-Os -optl-static -fPIC' \
19+ --ghc-options '-O2 -optc-Os -optl=-pthread -optl=-static -fPIC' \
2020 pandoc pandoc-citeproc
2121CMD git pull && \
2222 git checkout -b work $TREE && \
2323 stack install --stack-yaml stack.pkg.yaml \
24− --local-bin-path /artifacts --flag 'pandoc:embed_data_files' \
25− --test --ghc-options '-O2 -optc-Os -optl-static -fPIC' \
24+ --flag 'pandoc:static' \
25+ --flag 'pandoc:embed_data_files' \
26+ --ghc-options '-O2 -optc-Os -optl=-pthread -optl=-static -fPIC' \
27+ --local-bin-path /artifacts \
2628 pandoc pandoc-citeproc && \
2729 bash linux/make_deb.sh && \
2830 bash linux/make_tarball.sh
pandoc.cabal+101−92
@@ -1,19 +1,19 @@
1−Name: pandoc
2−Version: 2.0
3−Cabal-Version: >= 1.10
4−Build-Type: Custom
5−License: GPL
6−License-File: COPYING.md
7−Copyright: (c) 2006-2017 John MacFarlane
8−Author: John MacFarlane <jgm@berkeley.edu>
9−Maintainer: John MacFarlane <jgm@berkeley.edu>
10−Bug-Reports: https://github.com/jgm/pandoc/issues
11−Stability: alpha
12−Homepage: http://pandoc.org
13−Category: Text
14−Tested-With: GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2
15−Synopsis: Conversion between markup formats
16−Description: Pandoc is a Haskell library for converting from one markup
1+name: pandoc
2+version: 2.0
3+cabal-version: >= 1.10
4+build-type: Custom
5+license: GPL
6+license-file: COPYING.md
7+copyright: (c) 2006-2017 John MacFarlane
8+author: John MacFarlane <jgm@berkeley.edu>
9+maintainer: John MacFarlane <jgm@berkeley.edu>
10+bug-reports: https://github.com/jgm/pandoc/issues
11+stability: alpha
12+homepage: http://pandoc.org
13+category: Text
14+tested-with: GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2
15+synopsis: Conversion between markup formats
16+description: Pandoc is a Haskell library for converting from one markup
1717 format to another, and a command-line tool that uses
1818 this library. It can read several dialects of Markdown and
1919 (subsets of) HTML, reStructuredText, LaTeX, DocBook,
@@ -35,7 +35,7 @@ Description: Pandoc is a Haskell library for converting from one markup
3535 which convert this native representation into a target
3636 format. Thus, adding an input or output format requires
3737 only adding a reader or writer.
38−Data-Files:
38+data-files:
3939 -- templates
4040 data/templates/default.html4
4141 data/templates/default.html5
@@ -119,7 +119,7 @@ Data-Files:
119119 data/jats.csl
120120 -- documentation
121121 MANUAL.txt, COPYRIGHT
122−Extra-Source-Files:
122+extra-source-files:
123123 -- documentation
124124 INSTALL.md, BUGS, README.md, CONTRIBUTING.md, changelog
125125 man/pandoc.1
@@ -138,6 +138,7 @@ Extra-Source-Files:
138138 test/*.native
139139 test/command/*.md
140140 test/command/3533-rst-csv-tables.csv
141+ test/command/3880.txt
141142 test/command/abbrevs
142143 test/command/SVG_logo-without-xml-declaration.svg
143144 test/command/SVG_logo.svg
@@ -260,32 +261,39 @@ Extra-Source-Files:
260261 test/odt/markdown/*.md
261262 test/odt/native/*.native
262263 test/lua/*.lua
263−Source-repository head
264+source-repository head
264265 type: git
265266 location: git://github.com/jgm/pandoc.git
266267
267−Flag embed_data_files
268+flag static
269+ Description: Use static linking for pandoc executable.
270+ Default: False
271+
272+flag embed_data_files
268273 Description: Embed data files in binary for relocatable executable.
269274 Default: False
270275
271−Flag trypandoc
276+flag trypandoc
272277 Description: Build trypandoc cgi executable.
273278 Default: False
274279
275−Flag weigh-pandoc
280+flag weigh-pandoc
276281 Description: Build weigh-pandoc to measure memory usage.
277282 Default: False
278283
279−Flag network-uri
284+flag network-uri
280285 Description: Get Network.URI from the network-uri package
281286 Default: True
282287
283−Flag old-locale
288+flag old-locale
284289 Description: Use old-locale and time < 1.5
285290 Default: False
286291
287−Library
288− Build-Depends: base >= 4.7 && < 5,
292+custom-setup
293+ setup-depends: base, Cabal
294+
295+library
296+ build-depends: base >= 4.7 && < 5,
289297 syb >= 0.1 && < 0.8,
290298 containers >= 0.4.2.1 && < 0.6,
291299 unordered-containers >= 0.2 && < 0.3,
@@ -331,37 +339,37 @@ Library
331339 http-types >= 0.8 && < 0.10,
332340 csv-conduit >= 0.6 && < 0.7
333341 if os(windows)
334− Cpp-options: -D_WINDOWS
342+ cpp-options: -D_WINDOWS
335343 else
336− Build-Depends: unix >= 2.4 && < 2.8
344+ build-depends: unix >= 2.4 && < 2.8
337345 if flag(old-locale)
338− Build-Depends: old-locale >= 1 && < 1.1,
346+ build-depends: old-locale >= 1 && < 1.1,
339347 time >= 1.2 && < 1.5
340348 else
341− Build-Depends: time >= 1.5 && < 1.9
349+ build-depends: time >= 1.5 && < 1.9
342350 if flag(network-uri)
343− Build-Depends: network-uri >= 2.6 && < 2.7, network >= 2.6
351+ build-depends: network-uri >= 2.6 && < 2.7, network >= 2.6
344352 else
345− Build-Depends: network >= 2 && < 2.6
353+ build-depends: network >= 2 && < 2.6
346354 if flag(embed_data_files)
347355 cpp-options: -DEMBED_DATA_FILES
348356 build-depends: file-embed >= 0.0 && < 0.1
349357 other-modules: Text.Pandoc.Data
350358 if os(windows)
351− Cpp-options: -D_WINDOWS
352− Ghc-Options: -Wall -fno-warn-unused-do-bind
353− Ghc-Prof-Options: -fprof-auto-exported
354− Default-Language: Haskell98
355− Other-Extensions: PatternGuards, OverloadedStrings,
359+ cpp-options: -D_WINDOWS
360+ ghc-options: -Wall -fno-warn-unused-do-bind
361+ ghc-prof-options: -fprof-auto-exported
362+ default-language: Haskell98
363+ other-extensions: PatternGuards, OverloadedStrings,
356364 ScopedTypeVariables, GeneralizedNewtypeDeriving,
357365 RelaxedPolyRec, DeriveDataTypeable, TypeSynonymInstances,
358366 FlexibleInstances
359− Hs-Source-Dirs: src
367+ hs-source-dirs: src
360368 if impl(ghc < 7.10)
361− Hs-Source-Dirs: prelude
362− Other-Modules: Prelude
369+ hs-source-dirs: prelude
370+ other-modules: Prelude
363371
364− Exposed-Modules: Text.Pandoc,
372+ exposed-modules: Text.Pandoc,
365373 Text.Pandoc.App,
366374 Text.Pandoc.Options,
367375 Text.Pandoc.Extensions,
@@ -439,7 +447,7 @@ Library
439447 Text.Pandoc.Emoji,
440448 Text.Pandoc.ImageSize,
441449 Text.Pandoc.Class
442− Other-Modules: Text.Pandoc.Readers.Docx.Lists,
450+ other-modules: Text.Pandoc.Readers.Docx.Lists,
443451 Text.Pandoc.Readers.Docx.Combine,
444452 Text.Pandoc.Readers.Docx.Parse,
445453 Text.Pandoc.Readers.Docx.Util,
@@ -476,66 +484,67 @@ Library
476484 Text.Pandoc.Compat.Time,
477485 Paths_pandoc
478486
479− Buildable: True
480−
481−Executable pandoc
482− Build-Depends: pandoc, base >= 4.7 && < 5
483− Ghc-Options: -rtsopts -with-rtsopts=-K16m -Wall -fno-warn-unused-do-bind
484− Ghc-Prof-Options: -fprof-auto-exported -rtsopts -with-rtsopts=-K16m
487+ buildable: True
485488
486− Default-Language: Haskell98
487− Other-Extensions: PatternGuards, OverloadedStrings,
489+executable pandoc
490+ build-depends: pandoc, base >= 4.7 && < 5
491+ ghc-options: -rtsopts -with-rtsopts=-K16m -Wall -fno-warn-unused-do-bind
492+ ghc-prof-options: -fprof-auto-exported -rtsopts -with-rtsopts=-K16m
493+ if flag(static)
494+ ld-options: -static
495+ default-language: Haskell98
496+ other-extensions: PatternGuards, OverloadedStrings,
488497 ScopedTypeVariables, GeneralizedNewtypeDeriving,
489498 RelaxedPolyRec, DeriveDataTypeable, TypeSynonymInstances,
490499 FlexibleInstances
491− Hs-Source-Dirs: .
500+ hs-source-dirs: .
492501 if impl(ghc < 7.10)
493− Hs-Source-Dirs: prelude
494− Other-Modules: Prelude
495− Main-Is: pandoc.hs
496− Buildable: True
497− Other-Modules: Paths_pandoc
502+ hs-source-dirs: prelude
503+ other-modules: Prelude
504+ main-is: pandoc.hs
505+ buildable: True
506+ other-modules: Paths_pandoc
498507
499−Executable trypandoc
500− Main-Is: trypandoc.hs
501− Hs-Source-Dirs: trypandoc
508+executable trypandoc
509+ main-is: trypandoc.hs
510+ hs-source-dirs: trypandoc
502511 if impl(ghc < 7.10)
503− Hs-Source-Dirs: prelude
504− Other-Modules: Prelude
512+ hs-source-dirs: prelude
513+ other-modules: Prelude
505514 default-language: Haskell2010
506515 if flag(trypandoc)
507− Build-Depends: base, aeson, pandoc,
516+ build-depends: base, aeson, pandoc,
508517 text, wai-extra, wai >= 0.3, http-types
509− Buildable: True
518+ buildable: True
510519 else
511− Buildable: False
520+ buildable: False
512521
513−Executable weigh-pandoc
514− Main-Is: weigh-pandoc.hs
515− Hs-Source-Dirs: benchmark
522+executable weigh-pandoc
523+ main-is: weigh-pandoc.hs
524+ hs-source-dirs: benchmark
516525 if impl(ghc < 7.10)
517− Hs-Source-Dirs: prelude
518− Other-Modules: Prelude
526+ hs-source-dirs: prelude
527+ other-modules: Prelude
519528 if flag(weigh-pandoc)
520− Build-Depends: pandoc,
529+ build-depends: pandoc,
521530 base >= 4.2 && < 5,
522531 text,
523532 weigh >= 0.0 && < 0.1,
524533 mtl >= 2.2 && < 2.3
525− Buildable: True
534+ buildable: True
526535 else
527− Buildable: False
528− Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind
529− Default-Language: Haskell98
536+ buildable: False
537+ ghc-options: -rtsopts -Wall -fno-warn-unused-do-bind
538+ default-language: Haskell98
530539
531−Test-Suite test-pandoc
532− Type: exitcode-stdio-1.0
533− Main-Is: test-pandoc.hs
534− Hs-Source-Dirs: test
540+test-suite test-pandoc
541+ type: exitcode-stdio-1.0
542+ main-is: test-pandoc.hs
543+ hs-source-dirs: test
535544 if impl(ghc < 7.10)
536− Hs-Source-Dirs: prelude
537− Other-Modules: Prelude
538− Build-Depends: base >= 4.2 && < 5,
545+ hs-source-dirs: prelude
546+ other-modules: Prelude
547+ build-depends: base >= 4.2 && < 5,
539548 syb >= 0.1 && < 0.8,
540549 pandoc,
541550 pandoc-types >= 1.17.1 && < 1.18,
@@ -557,7 +566,7 @@ Test-Suite test-pandoc
557566 executable-path >= 0.0 && < 0.1,
558567 zip-archive >= 0.2.3.4 && < 0.4,
559568 mtl >= 2.2 && < 2.3
560− Other-Modules: Tests.Old
569+ other-modules: Tests.Old
561570 Tests.Command
562571 Tests.Helpers
563572 Tests.Lua
@@ -585,21 +594,21 @@ Test-Suite test-pandoc
585594 Tests.Writers.RST
586595 Tests.Writers.TEI
587596 Tests.Writers.Muse
588− Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind -threaded
589− Default-Language: Haskell98
597+ ghc-options: -rtsopts -Wall -fno-warn-unused-do-bind -threaded
598+ default-language: Haskell98
590599
591600benchmark benchmark-pandoc
592− Type: exitcode-stdio-1.0
593− Main-Is: benchmark-pandoc.hs
594− Hs-Source-Dirs: benchmark
601+ type: exitcode-stdio-1.0
602+ main-is: benchmark-pandoc.hs
603+ hs-source-dirs: benchmark
595604 if impl(ghc < 7.10)
596− Hs-Source-Dirs: prelude
597− Other-Modules: Prelude
598− Build-Depends: pandoc,
605+ hs-source-dirs: prelude
606+ other-modules: Prelude
607+ build-depends: pandoc,
599608 time, bytestring, containers,
600609 base >= 4.2 && < 5,
601610 text >= 0.11 && < 1.3,
602611 syb >= 0.1 && < 0.8,
603612 criterion >= 1.0 && < 1.3
604− Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind
605− Default-Language: Haskell98
613+ ghc-options: -rtsopts -Wall -fno-warn-unused-do-bind
614+ default-language: Haskell98
src/Text/Pandoc/Parsing.hs+1−1
@@ -838,7 +838,7 @@ blankLineBlockLine = try (char '|' >> blankline)
838838lineBlockLines :: Monad m => ParserT [Char] st m [String]
839839lineBlockLines = try $ do
840840 lines' <- many1 (lineBlockLine <|> ((:[]) <$> blankLineBlockLine))
841− skipMany1 $ blankline <|> blankLineBlockLine
841+ skipMany $ blankline
842842 return lines'
843843
844844-- | Parse a table using 'headerParser', 'rowParser',
src/Text/Pandoc/Readers/HTML.hs+17−17
@@ -58,7 +58,7 @@ import Data.Maybe ( fromMaybe, isJust, isNothing )
5858import Data.List.Split ( wordsBy )
5959import Data.List ( intercalate, isPrefixOf )
6060import Data.Char ( isDigit, isLetter, isAlphaNum )
61−import Control.Monad ( guard, mzero, void, unless, mplus )
61+import Control.Monad ( guard, mzero, void, unless, mplus, msum )
6262import Control.Arrow ((***))
6363import Control.Applicative ( (<|>) )
6464import Data.Monoid (First (..))
@@ -576,23 +576,23 @@ pPara = do
576576 return $ B.para contents
577577
578578pFigure :: PandocMonad m => TagParser m Blocks
579−pFigure = do
579+pFigure = try $ do
580580 TagOpen _ _ <- pSatisfy (matchTagOpen "figure" [])
581581 skipMany pBlank
582− let pImg = pOptInTag "p" pImage <* skipMany pBlank
583− pCapt = option mempty $ pInTags "figcaption" inline <* skipMany pBlank
584− pImgCapt = do
585− img <- pImg
586− cap <- pCapt
587− return (img, cap)
588− pCaptImg = do
589− cap <- pCapt
590− img <- pImg
591− return (img, cap)
592− (imgMany, caption) <- pImgCapt <|> pCaptImg
582+ let pImg = (\x -> (Just x, Nothing)) <$>
583+ (pOptInTag "p" pImage <* skipMany pBlank)
584+ pCapt = (\x -> (Nothing, Just x)) <$>
585+ (pInTags "figcaption" inline <* skipMany pBlank)
586+ pSkip = (Nothing, Nothing) <$ pSatisfy (not . matchTagClose "figure")
587+ res <- many (pImg <|> pCapt <|> pSkip)
588+ let mbimg = msum $ map fst res
589+ let mbcap = msum $ map snd res
593590 TagClose _ <- pSatisfy (matchTagClose "figure")
594− let (Image attr _ (url, tit)):_ = B.toList imgMany
595− return $ B.para $ B.imageWith attr url ("fig:" ++ tit) caption
591+ let caption = fromMaybe mempty mbcap
592+ case B.toList <$> mbimg of
593+ Just [Image attr _ (url, tit)] ->
594+ return $ B.para $ B.imageWith attr url ("fig:" ++ tit) caption
595+ _ -> mzero
596596
597597pCodeBlock :: PandocMonad m => TagParser m Blocks
598598pCodeBlock = try $ do
@@ -961,7 +961,7 @@ blockHtmlTags = Set.fromList
961961 "dir", "div", "dl", "dt", "fieldset", "figcaption", "figure",
962962 "footer", "form", "h1", "h2", "h3", "h4",
963963 "h5", "h6", "head", "header", "hgroup", "hr", "html",
964− "isindex", "main", "menu", "noframes", "ol", "output", "p", "pre",
964+ "isindex", "main", "menu", "meta", "noframes", "ol", "output", "p", "pre",
965965 "section", "table", "tbody", "textarea",
966966 "thead", "tfoot", "ul", "dd",
967967 "dt", "frameset", "li", "tbody", "td", "tfoot",
@@ -1048,7 +1048,7 @@ x `closes` "p" | x `elem` ["address", "article", "aside", "blockquote",
10481048 "dir", "div", "dl", "fieldset", "footer", "form", "h1", "h2", "h3", "h4",
10491049 "h5", "h6", "header", "hr", "main", "menu", "nav", "ol", "p", "pre", "section",
10501050 "table", "ul"] = True
1051−"meta" `closes` "meta" = True
1051+_ `closes` "meta" = True
10521052"form" `closes` "form" = True
10531053"label" `closes` "label" = True
10541054"map" `closes` "map" = True
src/Text/Pandoc/Readers/LaTeX.hs+31−14
@@ -770,11 +770,13 @@ keyval = try $ do
770770keyvals :: PandocMonad m => LP m [(String, String)]
771771keyvals = try $ symbol '[' >> manyTill keyval (symbol ']')
772772
773−accent :: (Char -> String) -> Inlines -> LP m Inlines
774−accent f ils =
773+accent :: PandocMonad m => Char -> (Char -> String) -> LP m Inlines
774+accent c f = try $ do
775+ ils <- tok
775776 case toList ils of
776777 (Str (x:xs) : ys) -> return $ fromList (Str (f x ++ xs) : ys)
777− [] -> mzero
778+ [Space] -> return $ str [c]
779+ [] -> return $ str [c]
778780 _ -> return ils
779781
780782grave :: Char -> String
@@ -961,6 +963,19 @@ hacek 'Z' = "Ž"
961963hacek 'z' = "ž"
962964hacek c = [c]
963965
966+ogonek :: Char -> String
967+ogonek 'a' = "ą"
968+ogonek 'e' = "ę"
969+ogonek 'o' = "ǫ"
970+ogonek 'i' = "į"
971+ogonek 'u' = "ų"
972+ogonek 'A' = "Ą"
973+ogonek 'E' = "Ę"
974+ogonek 'I' = "Į"
975+ogonek 'O' = "Ǫ"
976+ogonek 'U' = "Ų"
977+ogonek c = [c]
978+
964979breve :: Char -> String
965980breve 'A' = "Ă"
966981breve 'a' = "ă"
@@ -1275,17 +1290,19 @@ inlineCommands = M.fromList $
12751290 , ("copyright", lit "©")
12761291 , ("textasciicircum", lit "^")
12771292 , ("textasciitilde", lit "~")
1278− , ("H", try $ tok >>= accent hungarumlaut)
1279− , ("`", option (str "`") $ try $ tok >>= accent grave)
1280− , ("'", option (str "'") $ try $ tok >>= accent acute)
1281− , ("^", option (str "^") $ try $ tok >>= accent circ)
1282− , ("~", option (str "~") $ try $ tok >>= accent tilde)
1283− , ("\"", option (str "\"") $ try $ tok >>= accent umlaut)
1284− , (".", option (str ".") $ try $ tok >>= accent dot)
1285− , ("=", option (str "=") $ try $ tok >>= accent macron)
1286− , ("c", option (str "c") $ try $ tok >>= accent cedilla)
1287− , ("v", option (str "v") $ try $ tok >>= accent hacek)
1288− , ("u", option (str "u") $ try $ tok >>= accent breve)
1293+ , ("H", accent '\779' hungarumlaut)
1294+ , ("`", accent '`' grave)
1295+ , ("'", accent '\'' acute)
1296+ , ("^", accent '^' circ)
1297+ , ("~", accent '~' tilde)
1298+ , ("\"", accent '\776' umlaut)
1299+ , (".", accent '\775' dot)
1300+ , ("=", accent '\772' macron)
1301+ , ("c", accent '\807' cedilla)
1302+ , ("v", accent 'ˇ' hacek)
1303+ , ("u", accent '\774' breve)
1304+ , ("k", accent '\808' ogonek)
1305+ , ("textogonekcentered", accent '\808' ogonek)
12891306 , ("i", lit "i")
12901307 , ("\\", linebreak <$ (do inTableCell <- sInTableCell <$> getState
12911308 guard $ not inTableCell
src/Text/Pandoc/Readers/Muse.hs+41−11
@@ -1,3 +1,4 @@
1+{-# LANGUAGE FlexibleContexts #-}
12{-
23 Copyright (C) 2017 Alexander Krotov <ilabdsf@gmail.com>
34
@@ -32,7 +33,6 @@ TODO:
3233- {{{ }}} syntax for <example>
3334- Page breaks (five "*")
3435- Headings with anchors (make it round trip with Muse writer)
35−- Verse markup (">")
3636- Org tables
3737- table.el tables
3838- Images with attributes (floating and width)
@@ -101,6 +101,9 @@ parseBlocks = do
101101-- utility functions
102102--
103103
104+eol :: Stream s m Char => ParserT s st m ()
105+eol = void newline <|> eof
106+
104107nested :: PandocMonad m => MuseParser m a -> MuseParser m a
105108nested p = do
106109 nestlevel <- stateMaxNestingLevel <$> getState
@@ -180,7 +183,9 @@ blockElements = choice [ comment
180183 , centerTag
181184 , rightTag
182185 , quoteTag
186+ , divTag
183187 , verseTag
188+ , lineBlock
184189 , bulletList
185190 , orderedList
186191 , definitionList
@@ -194,7 +199,7 @@ comment = try $ do
194199 char ';'
195200 space
196201 many $ noneOf "\n"
197− void newline <|> eof
202+ eol
198203 return mempty
199204
200205separator :: PandocMonad m => MuseParser m (F Blocks)
@@ -202,7 +207,7 @@ separator = try $ do
202207 string "----"
203208 many $ char '-'
204209 many spaceChar
205− void newline <|> eof
210+ eol
206211 return $ return B.horizontalRule
207212
208213header :: PandocMonad m => MuseParser m (F Blocks)
@@ -212,8 +217,8 @@ header = try $ do
212217 getPosition >>= \pos -> guard (st == NullState && q == NoQuote && sourceColumn pos == 1)
213218 level <- liftM length $ many1 $ char '*'
214219 guard $ level <= 5
215− skipSpaces
216− content <- trimInlinesF . mconcat <$> manyTill inline newline
220+ spaceChar
221+ content <- trimInlinesF . mconcat <$> manyTill inline eol
217222 attr <- registerHeader ("", [], []) (runF content defaultParserState)
218223 return $ B.headerWith attr level <$> content
219224
@@ -245,6 +250,12 @@ rightTag = blockTag id "right"
245250quoteTag :: PandocMonad m => MuseParser m (F Blocks)
246251quoteTag = withQuoteContext InDoubleQuote $ blockTag B.blockQuote "quote"
247252
253+-- <div> tag is supported by Emacs Muse, but not Amusewiki 2.025
254+divTag :: PandocMonad m => MuseParser m (F Blocks)
255+divTag = do
256+ (attrs, content) <- parseHtmlContentWithAttrs "div" block
257+ return $ (B.divWith attrs) <$> mconcat content
258+
248259verseLine :: PandocMonad m => MuseParser m String
249260verseLine = do
250261 line <- anyLine <|> many1Till anyChar eof
@@ -261,8 +272,7 @@ verseLines = do
261272verseTag :: PandocMonad m => MuseParser m (F Blocks)
262273verseTag = do
263274 (_, content) <- htmlElement "verse"
264− parsedContent <- parseFromString verseLines content
265− return parsedContent
275+ parseFromString verseLines content
266276
267277commentTag :: PandocMonad m => MuseParser m (F Blocks)
268278commentTag = parseHtmlContent "comment" anyChar >> return mempty
@@ -299,6 +309,26 @@ noteBlock = try $ do
299309 blocksTillNote =
300310 many1Till block (eof <|> () <$ lookAhead noteMarker)
301311
312+--
313+-- Verse markup
314+--
315+
316+lineVerseLine :: PandocMonad m => MuseParser m String
317+lineVerseLine = try $ do
318+ char '>'
319+ white <- many1 (char ' ' >> pure '\160')
320+ rest <- anyLine
321+ return $ tail white ++ rest
322+
323+blanklineVerseLine :: PandocMonad m => MuseParser m Char
324+blanklineVerseLine = try $ char '>' >> blankline
325+
326+lineBlock :: PandocMonad m => MuseParser m (F Blocks)
327+lineBlock = try $ do
328+ lns <- many1 (pure <$> blanklineVerseLine <|> lineVerseLine)
329+ lns' <- mapM (parseFromString' (trimInlinesF . mconcat <$> many inline)) lns
330+ return $ B.lineBlock <$> sequence lns'
331+
302332--
303333-- lists
304334--
@@ -379,8 +409,8 @@ definitionListItem = try $ do
379409 pure $ do lineContent' <- lineContent
380410 pure (B.text term, [lineContent'])
381411 where
382− termParser = (many1 spaceChar) >> -- Initial space as required by Amusewiki, but not Emacs Muse
383− (many1Till anyChar $ lookAhead (void (try (spaceChar >> string "::")) <|> void newline))
412+ termParser = many1 spaceChar >> -- Initial space as required by Amusewiki, but not Emacs Muse
413+ many1Till anyChar (lookAhead (void (try (spaceChar >> string "::")) <|> void newline))
384414 endOfInput = try $ skipMany blankline >> skipSpaces >> eof
385415 twoBlankLines = try $ blankline >> skipMany1 blankline
386416 newDefinitionListItem = try $ void termParser
@@ -438,10 +468,10 @@ museAppendElement tbl element =
438468
439469tableCell :: PandocMonad m => MuseParser m (F Blocks)
440470tableCell = try $ liftM B.plain . trimInlinesF . mconcat <$> manyTill inline (lookAhead cellEnd)
441− where cellEnd = try $ void (many1 spaceChar >> char '|') <|> void newline <|> eof
471+ where cellEnd = try $ void (many1 spaceChar >> char '|') <|> eol
442472
443473tableElements :: PandocMonad m => MuseParser m [MuseTableElement]
444−tableElements = tableParseElement `sepEndBy1` (void newline <|> eof)
474+tableElements = tableParseElement `sepEndBy1` eol
445475
446476elementsToTable :: [MuseTableElement] -> F MuseTable
447477elementsToTable = foldM museAppendElement emptyTable
src/Text/Pandoc/Readers/RST.hs+9−9
@@ -219,7 +219,6 @@ block = choice [ codeBlock
219219 , directive
220220 , anchor
221221 , comment
222− , include
223222 , header
224223 , hrule
225224 , lineBlock -- must go before definitionList
@@ -460,16 +459,16 @@ tab-width
460459encoding
461460-}
462461
463−include :: PandocMonad m => RSTParser m Blocks
464−include = try $ do
465− string ".. include::"
466− skipMany spaceChar
467− f <- trim <$> anyLine
468− fields <- many $ rawFieldListItem 3
462+includeDirective :: PandocMonad m
463+ => String -> [(String, String)] -> String
464+ -> RSTParser m Blocks
465+includeDirective top fields body = do
466+ let f = trim top
467+ guard $ not (null f)
468+ guard $ null (trim body)
469469 -- options
470470 let (startLine :: Maybe Int) = lookup "start-line" fields >>= safeRead
471471 let (endLine :: Maybe Int) = lookup "end-line" fields >>= safeRead
472− guard $ not (null f)
473472 oldPos <- getPosition
474473 oldInput <- getInput
475474 containers <- stateContainers <$> getState
@@ -501,7 +500,7 @@ include = try $ do
501500 Just patt -> drop 1 .
502501 dropWhile (not . (patt `isInfixOf`))
503502 Nothing -> id) $ contentLines'
504− let contents' = unlines contentLines''
503+ let contents' = unlines contentLines'' ++ "\n"
505504 case lookup "code" fields of
506505 Just lang -> do
507506 let numberLines = lookup "number-lines" fields
@@ -687,6 +686,7 @@ directive' = do
687686 $ lookup "height" fields >>=
688687 (lengthToDim . filter (not . isSpace))
689688 case label of
689+ "include" -> includeDirective top fields body'
690690 "table" -> tableDirective top fields body'
691691 "list-table" -> listTableDirective top fields body'
692692 "csv-table" -> csvTableDirective top fields body'
src/Text/Pandoc/Writers/HTML.hs+9−2
@@ -47,7 +47,7 @@ import Control.Monad.State.Strict
4747import Data.Char (ord, toLower)
4848import Data.Text (Text)
4949import qualified Data.Text.Lazy as TL
50−import Data.List (intersperse, isPrefixOf)
50+import Data.List (intersperse, isPrefixOf, partition, intercalate)
5151import Data.Maybe (catMaybes, fromMaybe, isJust, isNothing)
5252import Data.Monoid ((<>))
5353import qualified Data.Set as Set
@@ -569,8 +569,15 @@ imgAttrsToHtml opts attr = do
569569 isNotDim _ = True
570570
571571dimensionsToAttrList :: Attr -> [(String, String)]
572−dimensionsToAttrList attr = (go Width) ++ (go Height)
572+dimensionsToAttrList attr = consolidateStyles $ go Width ++ go Height
573573 where
574+ consolidateStyles :: [(String, String)] -> [(String, String)]
575+ consolidateStyles xs =
576+ case partition isStyle xs of
577+ ([], _) -> xs
578+ (ss, rest) -> ("style", intercalate ";" $ map snd ss) : rest
579+ isStyle ("style", _) = True
580+ isStyle _ = False
574581 go dir = case (dimension dir attr) of
575582 (Just (Pixel a)) -> [(show dir, show a)]
576583 (Just x) -> [("style", show dir ++ ":" ++ show x)]
src/Text/Pandoc/Writers/LaTeX.hs+13−2
@@ -628,6 +628,7 @@ blockToLaTeX (OrderedList (start, numstyle, numdelim) lst) = do
628628 put $ st {stOLLevel = oldlevel + 1}
629629 items <- mapM listItemToLaTeX lst
630630 modify (\s -> s {stOLLevel = oldlevel})
631+ let beamer = stBeamer st
631632 let tostyle x = case numstyle of
632633 Decimal -> "\\arabic" <> braces x
633634 UpperRoman -> "\\Roman" <> braces x
@@ -641,11 +642,21 @@ blockToLaTeX (OrderedList (start, numstyle, numdelim) lst) = do
641642 TwoParens -> parens x
642643 Period -> x <> "."
643644 _ -> x <> "."
645+ let exemplar = case numstyle of
646+ Decimal -> "1"
647+ UpperRoman -> "I"
648+ LowerRoman -> "i"
649+ UpperAlpha -> "A"
650+ LowerAlpha -> "a"
651+ Example -> "1"
652+ DefaultStyle -> "1"
644653 let enum = text $ "enum" ++ map toLower (toRomanNumeral oldlevel)
645654 let stylecommand = if numstyle == DefaultStyle && numdelim == DefaultDelim
646655 then empty
647− else "\\def" <> "\\label" <> enum <>
648− braces (todelim $ tostyle enum)
656+ else if beamer
657+ then brackets (todelim exemplar)
658+ else "\\def" <> "\\label" <> enum <>
659+ braces (todelim $ tostyle enum)
649660 let resetcounter = if start == 1 || oldlevel > 4
650661 then empty
651662 else "\\setcounter" <> braces enum <>
src/Text/Pandoc/Writers/Markdown.hs+11−8
@@ -288,6 +288,7 @@ escapeString opts (c:cs) =
288288 | otherwise -> "&gt;" ++ escapeString opts cs
289289 _ | c `elem` ['\\','`','*','_','[',']','#'] ->
290290 '\\':c:escapeString opts cs
291+ '|' | isEnabled Ext_pipe_tables opts -> '\\':'|':escapeString opts cs
291292 '^' | isEnabled Ext_superscript opts -> '\\':'^':escapeString opts cs
292293 '~' | isEnabled Ext_subscript opts -> '\\':'~':escapeString opts cs
293294 '$' | isEnabled Ext_tex_math_dollars opts -> '\\':'$':escapeString opts cs
@@ -787,6 +788,7 @@ blockListToMarkdown :: PandocMonad m
787788 -> MD m Doc
788789blockListToMarkdown opts blocks = do
789790 inlist <- asks envInList
791+ isPlain <- asks envPlain
790792 -- a) insert comment between list and indented code block, or the
791793 -- code block will be treated as a list continuation paragraph
792794 -- b) change Plain to Para unless it's followed by a RawBlock
@@ -813,9 +815,11 @@ blockListToMarkdown opts blocks = do
813815 isListBlock (OrderedList _ _) = True
814816 isListBlock (DefinitionList _) = True
815817 isListBlock _ = False
816− commentSep = if isEnabled Ext_raw_html opts
817− then RawBlock "html" "<!-- -->\n"
818− else RawBlock "markdown" "&nbsp;\n"
818+ commentSep = if isPlain
819+ then Null
820+ else if isEnabled Ext_raw_html opts
821+ then RawBlock "html" "<!-- -->\n"
822+ else RawBlock "markdown" "&nbsp;\n"
819823 mapM (blockToMarkdown opts) (fixBlocks blocks) >>= return . cat
820824
821825getKey :: Doc -> Key
@@ -931,7 +935,7 @@ avoidBadWrapsInList (s:Str cs:[])
931935avoidBadWrapsInList (x:xs) = x : avoidBadWrapsInList xs
932936
933937isOrderedListMarker :: String -> Bool
934−isOrderedListMarker xs = (last xs `elem` ['.',')']) &&
938+isOrderedListMarker xs = not (null xs) && (last xs `elem` ['.',')']) &&
935939 isRight (runParser (anyOrderedListMarker >> eof)
936940 defaultParserState "" xs)
937941
@@ -946,11 +950,10 @@ inlineToMarkdown opts (Span attrs ils) = do
946950 contents <- inlineListToMarkdown opts ils
947951 return $ case plain of
948952 True -> contents
949− False | isEnabled Ext_bracketed_spans opts ->
953+ False | attrs == nullAttr -> contents
954+ | isEnabled Ext_bracketed_spans opts ->
950955 "[" <> contents <> "]" <>
951− if attrs == nullAttr
952− then "{}"
953− else linkAttributes opts attrs
956+ linkAttributes opts attrs
954957 | isEnabled Ext_raw_html opts ||
955958 isEnabled Ext_native_spans opts ->
956959 tagWithAttrs "span" attrs <> contents <> text "</span>"
src/Text/Pandoc/Writers/Org.hs+26−37
@@ -129,36 +129,25 @@ blockToOrg (Div (_,classes@(cls:_),kvs) bs) | "drawer" `elem` classes = do
129129 blankline $$ contents $$
130130 blankline $$ drawerEndTag $$
131131 blankline
132−blockToOrg (Div attrs bs) = do
132+blockToOrg (Div (ident, classes, kv) bs) = do
133133 contents <- blockListToOrg bs
134+ -- if one class looks like the name of a greater block then output as such:
135+ -- The ID, if present, is added via the #+NAME keyword; other classes and
136+ -- key-value pairs are kept as #+ATTR_HTML attributes.
134137 let isGreaterBlockClass = (`elem` ["center", "quote"]) . map toLower
135− return $ case attrs of
136− ("", [], []) ->
137− -- nullAttr, treat contents as if it wasn't wrapped
138− blankline $$ contents $$ blankline
139− (ident, [], []) ->
140− -- only an id: add id as an anchor, unwrap the rest
141− blankline $$ "<<" <> text ident <> ">>" $$ contents $$ blankline
142− (ident, classes, kv) ->
143− -- if one class looks like the name of a greater block then output as
144− -- such: The ID, if present, is added via the #+NAME keyword; other
145− -- classes and key-value pairs are kept as #+ATTR_HTML attributes.
146− let
147− (blockTypeCand, classes') = partition isGreaterBlockClass classes
148− in case blockTypeCand of
149− (blockType:classes'') ->
150− blankline $$ attrHtml (ident, classes'' <> classes', kv) $$
151− "#+BEGIN_" <> text blockType $$ contents $$
152− "#+END_" <> text blockType $$ blankline
153− _ ->
154− -- fallback: wrap in div tags
155− let
156− startTag = tagWithAttrs "div" attrs
157− endTag = text "</div>"
158− in blankline $$ "#+BEGIN_HTML" $$
159− nest 2 startTag $$ "#+END_HTML" $$ blankline $$
160− contents $$ blankline $$ "#+BEGIN_HTML" $$
161− nest 2 endTag $$ "#+END_HTML" $$ blankline
138+ (blockTypeCand, classes') = partition isGreaterBlockClass classes
139+ return $ case blockTypeCand of
140+ (blockType:classes'') ->
141+ blankline $$ attrHtml (ident, classes'' <> classes', kv) $$
142+ "#+BEGIN_" <> text blockType $$ contents $$
143+ "#+END_" <> text blockType $$ blankline
144+ _ ->
145+ -- fallback with id: add id as an anchor if present, discard classes and
146+ -- key-value pairs, unwrap the content.
147+ let contents' = if not (null ident)
148+ then "<<" <> text ident <> ">>" $$ contents
149+ else contents
150+ in blankline $$ contents' $$ blankline
162151blockToOrg (Plain inlines) = inlineListToOrg inlines
163152-- title beginning with fig: indicates that the image is a figure
164153blockToOrg (Para [Image attr txt (src,'f':'i':'g':':':tit)]) = do
@@ -173,7 +162,7 @@ blockToOrg (Para inlines) = do
173162blockToOrg (LineBlock lns) = do
174163 let splitStanza [] = []
175164 splitStanza xs = case break (== mempty) xs of
176− (l, []) -> l : []
165+ (l, []) -> [l]
177166 (l, _:r) -> l : splitStanza r
178167 let joinWithLinefeeds = nowrap . mconcat . intersperse cr
179168 let joinWithBlankLines = mconcat . intersperse blankline
@@ -213,7 +202,7 @@ blockToOrg (Table caption' _ _ headers rows) = do
213202 caption'' <- inlineListToOrg caption'
214203 let caption = if null caption'
215204 then empty
216− else ("#+CAPTION: " <> caption'')
205+ else "#+CAPTION: " <> caption''
217206 headers' <- mapM blockListToOrg headers
218207 rawRows <- mapM (mapM blockListToOrg) rows
219208 let numChars = maximum . map offset
@@ -289,8 +278,8 @@ propertiesDrawer (ident, classes, kv) =
289278 let
290279 drawerStart = text ":PROPERTIES:"
291280 drawerEnd = text ":END:"
292− kv' = if (classes == mempty) then kv else ("CLASS", unwords classes):kv
293− kv'' = if (ident == mempty) then kv' else ("CUSTOM_ID", ident):kv'
281+ kv' = if classes == mempty then kv else ("CLASS", unwords classes):kv
282+ kv'' = if ident == mempty then kv' else ("CUSTOM_ID", ident):kv'
294283 properties = vcat $ map kvToOrgProperty kv''
295284 in
296285 drawerStart <> cr <> properties <> cr <> drawerEnd
@@ -303,7 +292,7 @@ attrHtml :: Attr -> Doc
303292attrHtml ("" , [] , []) = mempty
304293attrHtml (ident, classes, kvs) =
305294 let
306− name = if (null ident) then mempty else "#+NAME: " <> text ident <> cr
295+ name = if null ident then mempty else "#+NAME: " <> text ident <> cr
307296 keyword = "#+ATTR_HTML"
308297 classKv = ("class", unwords classes)
309298 kvStrings = map (\(k,v) -> ":" <> k <> " " <> v) (classKv:kvs)
@@ -370,19 +359,19 @@ inlineToOrg SoftBreak = do
370359 WrapPreserve -> return cr
371360 WrapAuto -> return space
372361 WrapNone -> return space
373−inlineToOrg (Link _ txt (src, _)) = do
362+inlineToOrg (Link _ txt (src, _)) =
374363 case txt of
375364 [Str x] | escapeURI x == src -> -- autolink
376− do return $ "[[" <> text (orgPath x) <> "]]"
365+ return $ "[[" <> text (orgPath x) <> "]]"
377366 _ -> do contents <- inlineListToOrg txt
378367 return $ "[[" <> text (orgPath src) <> "][" <> contents <> "]]"
379−inlineToOrg (Image _ _ (source, _)) = do
368+inlineToOrg (Image _ _ (source, _)) =
380369 return $ "[[" <> text (orgPath source) <> "]]"
381370inlineToOrg (Note contents) = do
382371 -- add to notes in state
383372 notes <- gets stNotes
384373 modify $ \st -> st { stNotes = contents:notes }
385− let ref = show $ (length notes) + 1
374+ let ref = show $ length notes + 1
386375 return $ "[fn:" <> text ref <> "]"
387376
388377orgPath :: String -> String
stack.pkg.yaml+1−1
@@ -14,7 +14,7 @@ packages:
1414- '.'
1515- location:
1616 git: https://github.com/jgm/pandoc-citeproc.git
17− commit: 71ca48b6e0044ea959d8e7882b03cceba9c7960c
17+ commit: 5a7f26b61c8577916093851cdeb31fa9a198edcb
1818 extra-dep: false
1919extra-deps:
2020- hslua-0.8.0
test/Tests/Readers/Muse.hs+38−5
@@ -145,6 +145,38 @@ tests =
145145 , " with a continuation"
146146 ] =?>
147147 blockQuote (para "This is a quotation with a continuation")
148+ , testGroup "Div"
149+ [ "Div without id" =:
150+ "<div>Foo bar</div>" =?>
151+ divWith nullAttr (para "Foo bar")
152+ , "Div with id" =:
153+ "<div id=\"foo\">Foo bar</div>" =?>
154+ divWith ("foo", [], []) (para "Foo bar")
155+ ]
156+ , "Verse" =:
157+ T.unlines [ "> This is"
158+ , "> First stanza"
159+ , ">" -- Emacs produces verbatim ">" here, we follow Amusewiki
160+ , "> And this is"
161+ , "> Second stanza"
162+ , ">"
163+ , ""
164+ , ">"
165+ , ""
166+ , "> Another verse"
167+ , "> is here"
168+ ] =?>
169+ lineBlock [ "This is"
170+ , "First stanza"
171+ , ""
172+ , "And this is"
173+ , "\160\160Second stanza"
174+ , ""
175+ ] <>
176+ lineBlock [ "" ] <>
177+ lineBlock [ "Another verse"
178+ , "\160\160\160is here"
179+ ]
148180 ]
149181 , "Quote tag" =: "<quote>Hello, world</quote>" =?> blockQuote (para $ text "Hello, world")
150182 , "Verse tag" =:
@@ -178,20 +210,21 @@ tests =
178210 ]
179211 , testGroup "Headers"
180212 [ "Part" =:
181− "* First level\n" =?>
213+ "* First level" =?>
182214 header 1 "First level"
183215 , "Chapter" =:
184− "** Second level\n" =?>
216+ "** Second level" =?>
185217 header 2 "Second level"
186218 , "Section" =:
187− "*** Third level\n" =?>
219+ "*** Third level" =?>
188220 header 3 "Third level"
189221 , "Subsection" =:
190− "**** Fourth level\n" =?>
222+ "**** Fourth level" =?>
191223 header 4 "Fourth level"
192224 , "Subsubsection" =:
193− "***** Fifth level\n" =?>
225+ "***** Fifth level" =?>
194226 header 5 "Fifth level"
227+ , "Whitespace is required after *" =: "**Not a header" =?> para "**Not a header"
195228 , "No headers in footnotes" =:
196229 T.unlines [ "Foo[1]"
197230 , "[1] * Bar"
test/Tests/Readers/RST.hs+13
@@ -136,6 +136,19 @@ tests = [ "line block with blank line" =:
136136 para "but must stop here")
137137 , "line block with 3 lines" =: "| a\n| b\n| c"
138138 =?> lineBlock ["a", "b", "c"]
139+ , "line blocks with blank lines" =: T.unlines
140+ [ "|"
141+ , ""
142+ , "|"
143+ , "| a"
144+ , "| b"
145+ , "|"
146+ , ""
147+ , "|"
148+ ] =?>
149+ lineBlock [""] <>
150+ lineBlock ["", "a", "b", ""] <>
151+ lineBlock [""]
139152 , "quoted literal block using >" =: "::\n\n> quoted\n> block\n\nOrdinary paragraph"
140153 =?> codeBlock "> quoted\n> block" <> para "Ordinary paragraph"
141154 , "quoted literal block using | (not a line block)" =: "::\n\n| quoted\n| block\n\nOrdinary paragraph"
test/command/3497.md+1−1
@@ -46,6 +46,6 @@ Also escape things that might become line blocks or tables:
4646% pandoc -t markdown
4747\| hi \|
4848^D
49−\| hi |
49+\| hi \|
5050```
5151
test/command/3771.mdnew file+14
@@ -0,0 +1,14 @@
1+```
2+% pandoc -f html -t org
3+<div class="Section1">
4+ Today is a nice day.
5+</div>
6+<div id="forecast">
7+ Tomorrow will be rainy.
8+</div>
9+^D
10+Today is a nice day.
11+
12+<<forecast>>
13+Tomorrow will be rainy.
14+```
test/command/3880.mdnew file+6
@@ -0,0 +1,6 @@
1+```
2+pandoc -f rst -t native
3+.. include:: command/3880.txt
4+^D
5+[Para [Str "hi"]]
6+```
test/command/3880.txtnew file+1
@@ -0,0 +1 @@
1+hi
test/writers-lang-and-dir.latex+6−6
@@ -44,6 +44,12 @@
4444\let\oldsubparagraph\subparagraph
4545\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
4646\fi
47+
48+% set default figure placement to htbp
49+\makeatletter
50+\def\fps@figure{htbp}
51+\makeatother
52+
4753\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
4854 \usepackage[shorthands=off,ngerman,british,nswissgerman,spanish,french,main=english]{babel}
4955 \newcommand{\textgerman}[2][]{\foreignlanguage{ngerman}{#2}}
@@ -77,12 +83,6 @@
7783 \newenvironment{LTR}{\beginL}{\endL}
7884\fi
7985
80−% set default figure placement to htbp
81−\makeatletter
82−\def\fps@figure{htbp}
83−\makeatother
84−
85−
8686\date{}
8787
8888\begin{document}
tools/pandoc-template-mode.elnew file+58
@@ -0,0 +1,58 @@
1+ ;;; pandoc-template-mode.el --- Pandoc-Template major mode
2+
3+;; Copyright (C) 2017
4+
5+;; Author: Václav Haisman
6+;; Keywords: extensions
7+
8+;; This file is free software; you can redistribute it and/or modify
9+;; it under the terms of the GNU General Public License as published by
10+;; the Free Software Foundation; either version 2, or (at your option)
11+;; any later version.
12+
13+;; This file is distributed in the hope that it will be useful,
14+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+;; GNU General Public License for more details.
17+
18+;; You should have received a copy of the GNU General Public License
19+;; along with GNU Emacs; see the file COPYING. If not, write to
20+;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21+;; Boston, MA 02111-1307, USA.
22+
23+ ;;; Commentary:
24+
25+;;
26+
27+ ;;; Code:
28+
29+(defvar pandoc-template-font-lock-keywords
30+ '(("\\(\\$\\)\\(if\\|for\\)(\\([^)]+\\))\\(\\$\\)"
31+ (1 font-lock-preprocessor-face)
32+ (2 font-lock-keyword-face)
33+ (3 font-lock-variable-name-face)
34+ (4 font-lock-preprocessor-face))
35+ ("\\(\\$\\)\\(endif\\|endfor\\|else\\)\\(\\$\\)"
36+ (1 font-lock-preprocessor-face)
37+ (2 font-lock-keyword-face)
38+ (3 font-lock-preprocessor-face))
39+ ("\\(\\$\\)\\(sep\\)\\(\\$\\)"
40+ (1 font-lock-preprocessor-face)
41+ (2 font-lock-builtin-face)
42+ (3 font-lock-preprocessor-face))
43+ ("\\(\\$\\)\\([^$]+\\)\\(\\$\\)"
44+ (1 font-lock-preprocessor-face)
45+ (2 font-lock-variable-name-face)
46+ (3 font-lock-preprocessor-face))
47+ )
48+ "Keyword highlighting specification for `pandoc-template-mode'.")
49+
50+ ;;;###autoload
51+(define-derived-mode pandoc-template-mode fundamental-mode "Pandoc-Template"
52+ "A major mode for editing Pandoc-Template files."
53+ :syntax-table nil
54+ (setq-local font-lock-defaults
55+ '(pandoc-template-font-lock-keywords)))
56+
57+(provide 'pandoc-template-mode)
58+ ;;; pandoc-template.el ends here