git.iko.soy/typeable/pandoc
on master help sign in
Merge branch 'master' into patch-1
51bb745Andrew Dunning
data/pandoc.lua+2−2
@@ -135,7 +135,7 @@ end
135-- @section document
135-- @section document
136
136
137--- A complete pandoc document
137--- A complete pandoc document
138−-- @function Panoc
138+-- @function Pandoc
139-- @tparam {Block,...} blocks document content
139-- @tparam {Block,...} blocks document content
140-- @tparam[opt] Meta meta document meta data
140-- @tparam[opt] Meta meta document meta data
141function M.Pandoc(blocks, meta)
141function M.Pandoc(blocks, meta)
@@ -772,7 +772,7 @@ M.UpperAlpha = "UpperAlpha"
772-- `--from` command line option.
772-- `--from` command line option.
773-- @tparam string markup the markup to be parsed
773-- @tparam string markup the markup to be parsed
774-- @tparam[opt] string format format specification, defaults to "markdown".
774-- @tparam[opt] string format format specification, defaults to "markdown".
775−-- @return Doc pandoc document
775+-- @treturn Pandoc pandoc document
776-- @usage
776-- @usage
777-- local org_markup = "/emphasis/" -- Input to be read
777-- local org_markup = "/emphasis/" -- Input to be read
778-- local document = pandoc.read(org_markup, "org")
778-- local document = pandoc.read(org_markup, "org")
data/templates/default.latex+9−9
@@ -259,6 +259,15 @@ $else$
259\fi
259\fi
260$endif$
260$endif$
261$endif$
261$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$
262$if(lang)$
271$if(lang)$
263\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
272\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
264 \usepackage[shorthands=off,$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel}
273 \usepackage[shorthands=off,$for(babel-otherlangs)$$babel-otherlangs$,$endfor$main=$babel-lang$]{babel}
@@ -292,15 +301,6 @@ $if(dir)$
292\fi
301\fi
293$endif$
302$endif$
294
303
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−
304$if(title)$
304$if(title)$
305\title{$title$$if(thanks)$\thanks{$thanks$}$endif$}
305\title{$title$$if(thanks)$\thanks{$thanks$}$endif$}
306$endif$
306$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 @@
1% Pandoc Lua Filters
1% Pandoc Lua Filters
2% Albert Krewinkel, John MacFarlane
2% Albert Krewinkel, John MacFarlane
3−% August 21, 2017
3+% August 31, 2017
4
4
5# Introduction
5# Introduction
6
6
@@ -111,6 +111,11 @@ inline element must return an inline, and a block element must
111remain a block element after filter application. Pandoc will
111remain a block element after filter application. Pandoc will
112throw an error if this condition is violated.
112throw an error if this condition is violated.
113
113
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+
114Elements without matching functions are left untouched.
119Elements without matching functions are left untouched.
115
120
116See [module documentation](pandoc-module.html) for a list of pandoc
121See [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:
304</dd>
309</dd>
305</dl>
310</dl>
306```
311```
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
5 /etc/apk/keys/mitch.tishmack@gmail.com-55881c97.rsa.pub
5 /etc/apk/keys/mitch.tishmack@gmail.com-55881c97.rsa.pub
6RUN apk update
6RUN apk update
7RUN apk add alpine-sdk git ca-certificates ghc cabal stack zlib-dev \
7RUN 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
9RUN stack update
9RUN stack update
10RUN stack config set system-ghc --global true
10RUN stack config set system-ghc --global true
11RUN mkdir -p /etc/stack
11RUN mkdir -p /etc/stack
@@ -16,13 +16,15 @@ RUN git clone https://github.com/jgm/pandoc
16WORKDIR /usr/src/pandoc
16WORKDIR /usr/src/pandoc
17RUN stack install --stack-yaml stack.pkg.yaml --only-dependencies \
17RUN stack install --stack-yaml stack.pkg.yaml --only-dependencies \
18 --flag 'pandoc:embed_data_files' \
18 --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' \
20 pandoc pandoc-citeproc
20 pandoc pandoc-citeproc
21CMD git pull && \
21CMD git pull && \
22 git checkout -b work $TREE && \
22 git checkout -b work $TREE && \
23 stack install --stack-yaml stack.pkg.yaml \
23 stack install --stack-yaml stack.pkg.yaml \
24+ --flag 'pandoc:static' \
24− --local-bin-path /artifacts --flag 'pandoc:embed_data_files' \
25+ --flag 'pandoc:embed_data_files' \
25− --test --ghc-options '-O2 -optc-Os -optl-static -fPIC' \
26+ --ghc-options '-O2 -optc-Os -optl=-pthread -optl=-static -fPIC' \
27+ --local-bin-path /artifacts \
26 pandoc pandoc-citeproc && \
28 pandoc pandoc-citeproc && \
27 bash linux/make_deb.sh && \
29 bash linux/make_deb.sh && \
28 bash linux/make_tarball.sh
30 bash linux/make_tarball.sh
pandoc.cabal+101−92
@@ -1,19 +1,19 @@
1−Name: pandoc
1+name: pandoc
2−Version: 2.0
2+version: 2.0
3−Cabal-Version: >= 1.10
3+cabal-version: >= 1.10
4−Build-Type: Custom
4+build-type: Custom
5−License: GPL
5+license: GPL
6−License-File: COPYING.md
6+license-file: COPYING.md
7−Copyright: (c) 2006-2017 John MacFarlane
7+copyright: (c) 2006-2017 John MacFarlane
8−Author: John MacFarlane <jgm@berkeley.edu>
8+author: John MacFarlane <jgm@berkeley.edu>
9−Maintainer: John MacFarlane <jgm@berkeley.edu>
9+maintainer: John MacFarlane <jgm@berkeley.edu>
10−Bug-Reports: https://github.com/jgm/pandoc/issues
10+bug-reports: https://github.com/jgm/pandoc/issues
11−Stability: alpha
11+stability: alpha
12−Homepage: http://pandoc.org
12+homepage: http://pandoc.org
13−Category: Text
13+category: Text
14−Tested-With: GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2
14+tested-with: GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2
15−Synopsis: Conversion between markup formats
15+synopsis: Conversion between markup formats
16−Description: Pandoc is a Haskell library for converting from one markup
16+description: Pandoc is a Haskell library for converting from one markup
17 format to another, and a command-line tool that uses
17 format to another, and a command-line tool that uses
18 this library. It can read several dialects of Markdown and
18 this library. It can read several dialects of Markdown and
19 (subsets of) HTML, reStructuredText, LaTeX, DocBook,
19 (subsets of) HTML, reStructuredText, LaTeX, DocBook,
@@ -35,7 +35,7 @@ Description: Pandoc is a Haskell library for converting from one markup
35 which convert this native representation into a target
35 which convert this native representation into a target
36 format. Thus, adding an input or output format requires
36 format. Thus, adding an input or output format requires
37 only adding a reader or writer.
37 only adding a reader or writer.
38−Data-Files:
38+data-files:
39 -- templates
39 -- templates
40 data/templates/default.html4
40 data/templates/default.html4
41 data/templates/default.html5
41 data/templates/default.html5
@@ -119,7 +119,7 @@ Data-Files:
119 data/jats.csl
119 data/jats.csl
120 -- documentation
120 -- documentation
121 MANUAL.txt, COPYRIGHT
121 MANUAL.txt, COPYRIGHT
122−Extra-Source-Files:
122+extra-source-files:
123 -- documentation
123 -- documentation
124 INSTALL.md, BUGS, README.md, CONTRIBUTING.md, changelog
124 INSTALL.md, BUGS, README.md, CONTRIBUTING.md, changelog
125 man/pandoc.1
125 man/pandoc.1
@@ -138,6 +138,7 @@ Extra-Source-Files:
138 test/*.native
138 test/*.native
139 test/command/*.md
139 test/command/*.md
140 test/command/3533-rst-csv-tables.csv
140 test/command/3533-rst-csv-tables.csv
141+ test/command/3880.txt
141 test/command/abbrevs
142 test/command/abbrevs
142 test/command/SVG_logo-without-xml-declaration.svg
143 test/command/SVG_logo-without-xml-declaration.svg
143 test/command/SVG_logo.svg
144 test/command/SVG_logo.svg
@@ -260,32 +261,39 @@ Extra-Source-Files:
260 test/odt/markdown/*.md
261 test/odt/markdown/*.md
261 test/odt/native/*.native
262 test/odt/native/*.native
262 test/lua/*.lua
263 test/lua/*.lua
263−Source-repository head
264+source-repository head
264 type: git
265 type: git
265 location: git://github.com/jgm/pandoc.git
266 location: git://github.com/jgm/pandoc.git
266
267
268+flag static
269+ Description: Use static linking for pandoc executable.
270+ Default: False
271+
267−Flag embed_data_files
272+flag embed_data_files
268 Description: Embed data files in binary for relocatable executable.
273 Description: Embed data files in binary for relocatable executable.
269 Default: False
274 Default: False
270
275
271−Flag trypandoc
276+flag trypandoc
272 Description: Build trypandoc cgi executable.
277 Description: Build trypandoc cgi executable.
273 Default: False
278 Default: False
274
279
275−Flag weigh-pandoc
280+flag weigh-pandoc
276 Description: Build weigh-pandoc to measure memory usage.
281 Description: Build weigh-pandoc to measure memory usage.
277 Default: False
282 Default: False
278
283
279−Flag network-uri
284+flag network-uri
280 Description: Get Network.URI from the network-uri package
285 Description: Get Network.URI from the network-uri package
281 Default: True
286 Default: True
282
287
283−Flag old-locale
288+flag old-locale
284 Description: Use old-locale and time < 1.5
289 Description: Use old-locale and time < 1.5
285 Default: False
290 Default: False
286
291
287−Library
292+custom-setup
288− Build-Depends: base >= 4.7 && < 5,
293+ setup-depends: base, Cabal
294+
295+library
296+ build-depends: base >= 4.7 && < 5,
289 syb >= 0.1 && < 0.8,
297 syb >= 0.1 && < 0.8,
290 containers >= 0.4.2.1 && < 0.6,
298 containers >= 0.4.2.1 && < 0.6,
291 unordered-containers >= 0.2 && < 0.3,
299 unordered-containers >= 0.2 && < 0.3,
@@ -331,37 +339,37 @@ Library
331 http-types >= 0.8 && < 0.10,
339 http-types >= 0.8 && < 0.10,
332 csv-conduit >= 0.6 && < 0.7
340 csv-conduit >= 0.6 && < 0.7
333 if os(windows)
341 if os(windows)
334− Cpp-options: -D_WINDOWS
342+ cpp-options: -D_WINDOWS
335 else
343 else
336− Build-Depends: unix >= 2.4 && < 2.8
344+ build-depends: unix >= 2.4 && < 2.8
337 if flag(old-locale)
345 if flag(old-locale)
338− Build-Depends: old-locale >= 1 && < 1.1,
346+ build-depends: old-locale >= 1 && < 1.1,
339 time >= 1.2 && < 1.5
347 time >= 1.2 && < 1.5
340 else
348 else
341− Build-Depends: time >= 1.5 && < 1.9
349+ build-depends: time >= 1.5 && < 1.9
342 if flag(network-uri)
350 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
344 else
352 else
345− Build-Depends: network >= 2 && < 2.6
353+ build-depends: network >= 2 && < 2.6
346 if flag(embed_data_files)
354 if flag(embed_data_files)
347 cpp-options: -DEMBED_DATA_FILES
355 cpp-options: -DEMBED_DATA_FILES
348 build-depends: file-embed >= 0.0 && < 0.1
356 build-depends: file-embed >= 0.0 && < 0.1
349 other-modules: Text.Pandoc.Data
357 other-modules: Text.Pandoc.Data
350 if os(windows)
358 if os(windows)
351− Cpp-options: -D_WINDOWS
359+ cpp-options: -D_WINDOWS
352− Ghc-Options: -Wall -fno-warn-unused-do-bind
360+ ghc-options: -Wall -fno-warn-unused-do-bind
353− Ghc-Prof-Options: -fprof-auto-exported
361+ ghc-prof-options: -fprof-auto-exported
354− Default-Language: Haskell98
362+ default-language: Haskell98
355− Other-Extensions: PatternGuards, OverloadedStrings,
363+ other-extensions: PatternGuards, OverloadedStrings,
356 ScopedTypeVariables, GeneralizedNewtypeDeriving,
364 ScopedTypeVariables, GeneralizedNewtypeDeriving,
357 RelaxedPolyRec, DeriveDataTypeable, TypeSynonymInstances,
365 RelaxedPolyRec, DeriveDataTypeable, TypeSynonymInstances,
358 FlexibleInstances
366 FlexibleInstances
359− Hs-Source-Dirs: src
367+ hs-source-dirs: src
360 if impl(ghc < 7.10)
368 if impl(ghc < 7.10)
361− Hs-Source-Dirs: prelude
369+ hs-source-dirs: prelude
362− Other-Modules: Prelude
370+ other-modules: Prelude
363
371
364− Exposed-Modules: Text.Pandoc,
372+ exposed-modules: Text.Pandoc,
365 Text.Pandoc.App,
373 Text.Pandoc.App,
366 Text.Pandoc.Options,
374 Text.Pandoc.Options,
367 Text.Pandoc.Extensions,
375 Text.Pandoc.Extensions,
@@ -439,7 +447,7 @@ Library
439 Text.Pandoc.Emoji,
447 Text.Pandoc.Emoji,
440 Text.Pandoc.ImageSize,
448 Text.Pandoc.ImageSize,
441 Text.Pandoc.Class
449 Text.Pandoc.Class
442− Other-Modules: Text.Pandoc.Readers.Docx.Lists,
450+ other-modules: Text.Pandoc.Readers.Docx.Lists,
443 Text.Pandoc.Readers.Docx.Combine,
451 Text.Pandoc.Readers.Docx.Combine,
444 Text.Pandoc.Readers.Docx.Parse,
452 Text.Pandoc.Readers.Docx.Parse,
445 Text.Pandoc.Readers.Docx.Util,
453 Text.Pandoc.Readers.Docx.Util,
@@ -476,66 +484,67 @@ Library
476 Text.Pandoc.Compat.Time,
484 Text.Pandoc.Compat.Time,
477 Paths_pandoc
485 Paths_pandoc
478
486
479− Buildable: True
487+ 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
485
488
486− Default-Language: Haskell98
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
487− Other-Extensions: PatternGuards, OverloadedStrings,
496+ other-extensions: PatternGuards, OverloadedStrings,
488 ScopedTypeVariables, GeneralizedNewtypeDeriving,
497 ScopedTypeVariables, GeneralizedNewtypeDeriving,
489 RelaxedPolyRec, DeriveDataTypeable, TypeSynonymInstances,
498 RelaxedPolyRec, DeriveDataTypeable, TypeSynonymInstances,
490 FlexibleInstances
499 FlexibleInstances
491− Hs-Source-Dirs: .
500+ hs-source-dirs: .
492 if impl(ghc < 7.10)
501 if impl(ghc < 7.10)
493− Hs-Source-Dirs: prelude
502+ hs-source-dirs: prelude
494− Other-Modules: Prelude
503+ other-modules: Prelude
495− Main-Is: pandoc.hs
504+ main-is: pandoc.hs
496− Buildable: True
505+ buildable: True
497− Other-Modules: Paths_pandoc
506+ other-modules: Paths_pandoc
498
507
499−Executable trypandoc
508+executable trypandoc
500− Main-Is: trypandoc.hs
509+ main-is: trypandoc.hs
501− Hs-Source-Dirs: trypandoc
510+ hs-source-dirs: trypandoc
502 if impl(ghc < 7.10)
511 if impl(ghc < 7.10)
503− Hs-Source-Dirs: prelude
512+ hs-source-dirs: prelude
504− Other-Modules: Prelude
513+ other-modules: Prelude
505 default-language: Haskell2010
514 default-language: Haskell2010
506 if flag(trypandoc)
515 if flag(trypandoc)
507− Build-Depends: base, aeson, pandoc,
516+ build-depends: base, aeson, pandoc,
508 text, wai-extra, wai >= 0.3, http-types
517 text, wai-extra, wai >= 0.3, http-types
509− Buildable: True
518+ buildable: True
510 else
519 else
511− Buildable: False
520+ buildable: False
512
521
513−Executable weigh-pandoc
522+executable weigh-pandoc
514− Main-Is: weigh-pandoc.hs
523+ main-is: weigh-pandoc.hs
515− Hs-Source-Dirs: benchmark
524+ hs-source-dirs: benchmark
516 if impl(ghc < 7.10)
525 if impl(ghc < 7.10)
517− Hs-Source-Dirs: prelude
526+ hs-source-dirs: prelude
518− Other-Modules: Prelude
527+ other-modules: Prelude
519 if flag(weigh-pandoc)
528 if flag(weigh-pandoc)
520− Build-Depends: pandoc,
529+ build-depends: pandoc,
521 base >= 4.2 && < 5,
530 base >= 4.2 && < 5,
522 text,
531 text,
523 weigh >= 0.0 && < 0.1,
532 weigh >= 0.0 && < 0.1,
524 mtl >= 2.2 && < 2.3
533 mtl >= 2.2 && < 2.3
525− Buildable: True
534+ buildable: True
526 else
535 else
527− Buildable: False
536+ buildable: False
528− Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind
537+ ghc-options: -rtsopts -Wall -fno-warn-unused-do-bind
529− Default-Language: Haskell98
538+ default-language: Haskell98
530
539
531−Test-Suite test-pandoc
540+test-suite test-pandoc
532− Type: exitcode-stdio-1.0
541+ type: exitcode-stdio-1.0
533− Main-Is: test-pandoc.hs
542+ main-is: test-pandoc.hs
534− Hs-Source-Dirs: test
543+ hs-source-dirs: test
535 if impl(ghc < 7.10)
544 if impl(ghc < 7.10)
536− Hs-Source-Dirs: prelude
545+ hs-source-dirs: prelude
537− Other-Modules: Prelude
546+ other-modules: Prelude
538− Build-Depends: base >= 4.2 && < 5,
547+ build-depends: base >= 4.2 && < 5,
539 syb >= 0.1 && < 0.8,
548 syb >= 0.1 && < 0.8,
540 pandoc,
549 pandoc,
541 pandoc-types >= 1.17.1 && < 1.18,
550 pandoc-types >= 1.17.1 && < 1.18,
@@ -557,7 +566,7 @@ Test-Suite test-pandoc
557 executable-path >= 0.0 && < 0.1,
566 executable-path >= 0.0 && < 0.1,
558 zip-archive >= 0.2.3.4 && < 0.4,
567 zip-archive >= 0.2.3.4 && < 0.4,
559 mtl >= 2.2 && < 2.3
568 mtl >= 2.2 && < 2.3
560− Other-Modules: Tests.Old
569+ other-modules: Tests.Old
561 Tests.Command
570 Tests.Command
562 Tests.Helpers
571 Tests.Helpers
563 Tests.Lua
572 Tests.Lua
@@ -585,21 +594,21 @@ Test-Suite test-pandoc
585 Tests.Writers.RST
594 Tests.Writers.RST
586 Tests.Writers.TEI
595 Tests.Writers.TEI
587 Tests.Writers.Muse
596 Tests.Writers.Muse
588− Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind -threaded
597+ ghc-options: -rtsopts -Wall -fno-warn-unused-do-bind -threaded
589− Default-Language: Haskell98
598+ default-language: Haskell98
590
599
591benchmark benchmark-pandoc
600benchmark benchmark-pandoc
592− Type: exitcode-stdio-1.0
601+ type: exitcode-stdio-1.0
593− Main-Is: benchmark-pandoc.hs
602+ main-is: benchmark-pandoc.hs
594− Hs-Source-Dirs: benchmark
603+ hs-source-dirs: benchmark
595 if impl(ghc < 7.10)
604 if impl(ghc < 7.10)
596− Hs-Source-Dirs: prelude
605+ hs-source-dirs: prelude
597− Other-Modules: Prelude
606+ other-modules: Prelude
598− Build-Depends: pandoc,
607+ build-depends: pandoc,
599 time, bytestring, containers,
608 time, bytestring, containers,
600 base >= 4.2 && < 5,
609 base >= 4.2 && < 5,
601 text >= 0.11 && < 1.3,
610 text >= 0.11 && < 1.3,
602 syb >= 0.1 && < 0.8,
611 syb >= 0.1 && < 0.8,
603 criterion >= 1.0 && < 1.3
612 criterion >= 1.0 && < 1.3
604− Ghc-Options: -rtsopts -Wall -fno-warn-unused-do-bind
613+ ghc-options: -rtsopts -Wall -fno-warn-unused-do-bind
605− Default-Language: Haskell98
614+ default-language: Haskell98
src/Text/Pandoc/Parsing.hs+1−1
@@ -838,7 +838,7 @@ blankLineBlockLine = try (char '|' >> blankline)
838lineBlockLines :: Monad m => ParserT [Char] st m [String]
838lineBlockLines :: Monad m => ParserT [Char] st m [String]
839lineBlockLines = try $ do
839lineBlockLines = try $ do
840 lines' <- many1 (lineBlockLine <|> ((:[]) <$> blankLineBlockLine))
840 lines' <- many1 (lineBlockLine <|> ((:[]) <$> blankLineBlockLine))
841− skipMany1 $ blankline <|> blankLineBlockLine
841+ skipMany $ blankline
842 return lines'
842 return lines'
843
843
844-- | Parse a table using 'headerParser', 'rowParser',
844-- | Parse a table using 'headerParser', 'rowParser',
src/Text/Pandoc/Readers/HTML.hs+17−17
@@ -58,7 +58,7 @@ import Data.Maybe ( fromMaybe, isJust, isNothing )
58import Data.List.Split ( wordsBy )
58import Data.List.Split ( wordsBy )
59import Data.List ( intercalate, isPrefixOf )
59import Data.List ( intercalate, isPrefixOf )
60import Data.Char ( isDigit, isLetter, isAlphaNum )
60import Data.Char ( isDigit, isLetter, isAlphaNum )
61−import Control.Monad ( guard, mzero, void, unless, mplus )
61+import Control.Monad ( guard, mzero, void, unless, mplus, msum )
62import Control.Arrow ((***))
62import Control.Arrow ((***))
63import Control.Applicative ( (<|>) )
63import Control.Applicative ( (<|>) )
64import Data.Monoid (First (..))
64import Data.Monoid (First (..))
@@ -576,23 +576,23 @@ pPara = do
576 return $ B.para contents
576 return $ B.para contents
577
577
578pFigure :: PandocMonad m => TagParser m Blocks
578pFigure :: PandocMonad m => TagParser m Blocks
579−pFigure = do
579+pFigure = try $ do
580 TagOpen _ _ <- pSatisfy (matchTagOpen "figure" [])
580 TagOpen _ _ <- pSatisfy (matchTagOpen "figure" [])
581 skipMany pBlank
581 skipMany pBlank
582+ let pImg = (\x -> (Just x, Nothing)) <$>
582− let pImg = pOptInTag "p" pImage <* skipMany pBlank
583+ (pOptInTag "p" pImage <* skipMany pBlank)
584+ pCapt = (\x -> (Nothing, Just x)) <$>
583− pCapt = option mempty $ pInTags "figcaption" inline <* skipMany pBlank
585+ (pInTags "figcaption" inline <* skipMany pBlank)
584− pImgCapt = do
586+ pSkip = (Nothing, Nothing) <$ pSatisfy (not . matchTagClose "figure")
585− img <- pImg
587+ res <- many (pImg <|> pCapt <|> pSkip)
586− cap <- pCapt
588+ let mbimg = msum $ map fst res
587− return (img, cap)
589+ let mbcap = msum $ map snd res
588− pCaptImg = do
589− cap <- pCapt
590− img <- pImg
591− return (img, cap)
592− (imgMany, caption) <- pImgCapt <|> pCaptImg
593 TagClose _ <- pSatisfy (matchTagClose "figure")
590 TagClose _ <- pSatisfy (matchTagClose "figure")
594− let (Image attr _ (url, tit)):_ = B.toList imgMany
591+ let caption = fromMaybe mempty mbcap
592+ case B.toList <$> mbimg of
593+ Just [Image attr _ (url, tit)] ->
595− return $ B.para $ B.imageWith attr url ("fig:" ++ tit) caption
594+ return $ B.para $ B.imageWith attr url ("fig:" ++ tit) caption
595+ _ -> mzero
596
596
597pCodeBlock :: PandocMonad m => TagParser m Blocks
597pCodeBlock :: PandocMonad m => TagParser m Blocks
598pCodeBlock = try $ do
598pCodeBlock = try $ do
@@ -961,7 +961,7 @@ blockHtmlTags = Set.fromList
961 "dir", "div", "dl", "dt", "fieldset", "figcaption", "figure",
961 "dir", "div", "dl", "dt", "fieldset", "figcaption", "figure",
962 "footer", "form", "h1", "h2", "h3", "h4",
962 "footer", "form", "h1", "h2", "h3", "h4",
963 "h5", "h6", "head", "header", "hgroup", "hr", "html",
963 "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",
965 "section", "table", "tbody", "textarea",
965 "section", "table", "tbody", "textarea",
966 "thead", "tfoot", "ul", "dd",
966 "thead", "tfoot", "ul", "dd",
967 "dt", "frameset", "li", "tbody", "td", "tfoot",
967 "dt", "frameset", "li", "tbody", "td", "tfoot",
@@ -1048,7 +1048,7 @@ x `closes` "p" | x `elem` ["address", "article", "aside", "blockquote",
1048 "dir", "div", "dl", "fieldset", "footer", "form", "h1", "h2", "h3", "h4",
1048 "dir", "div", "dl", "fieldset", "footer", "form", "h1", "h2", "h3", "h4",
1049 "h5", "h6", "header", "hr", "main", "menu", "nav", "ol", "p", "pre", "section",
1049 "h5", "h6", "header", "hr", "main", "menu", "nav", "ol", "p", "pre", "section",
1050 "table", "ul"] = True
1050 "table", "ul"] = True
1051−"meta" `closes` "meta" = True
1051+_ `closes` "meta" = True
1052"form" `closes` "form" = True
1052"form" `closes` "form" = True
1053"label" `closes` "label" = True
1053"label" `closes` "label" = True
1054"map" `closes` "map" = True
1054"map" `closes` "map" = True
src/Text/Pandoc/Readers/LaTeX.hs+31−14
@@ -770,11 +770,13 @@ keyval = try $ do
770keyvals :: PandocMonad m => LP m [(String, String)]
770keyvals :: PandocMonad m => LP m [(String, String)]
771keyvals = try $ symbol '[' >> manyTill keyval (symbol ']')
771keyvals = try $ symbol '[' >> manyTill keyval (symbol ']')
772
772
773−accent :: (Char -> String) -> Inlines -> LP m Inlines
773+accent :: PandocMonad m => Char -> (Char -> String) -> LP m Inlines
774−accent f ils =
774+accent c f = try $ do
775+ ils <- tok
775 case toList ils of
776 case toList ils of
776 (Str (x:xs) : ys) -> return $ fromList (Str (f x ++ xs) : ys)
777 (Str (x:xs) : ys) -> return $ fromList (Str (f x ++ xs) : ys)
777− [] -> mzero
778+ [Space] -> return $ str [c]
779+ [] -> return $ str [c]
778 _ -> return ils
780 _ -> return ils
779
781
780grave :: Char -> String
782grave :: Char -> String
@@ -961,6 +963,19 @@ hacek 'Z' = "Ž"
961hacek 'z' = "ž"
963hacek 'z' = "ž"
962hacek c = [c]
964hacek c = [c]
963
965
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+
964breve :: Char -> String
979breve :: Char -> String
965breve 'A' = "Ă"
980breve 'A' = "Ă"
966breve 'a' = "ă"
981breve 'a' = "ă"
@@ -1275,17 +1290,19 @@ inlineCommands = M.fromList $
1275 , ("copyright", lit "©")
1290 , ("copyright", lit "©")
1276 , ("textasciicircum", lit "^")
1291 , ("textasciicircum", lit "^")
1277 , ("textasciitilde", lit "~")
1292 , ("textasciitilde", lit "~")
1278− , ("H", try $ tok >>= accent hungarumlaut)
1293+ , ("H", accent '\779' hungarumlaut)
1279− , ("`", option (str "`") $ try $ tok >>= accent grave)
1294+ , ("`", accent '`' grave)
1280− , ("'", option (str "'") $ try $ tok >>= accent acute)
1295+ , ("'", accent '\'' acute)
1281− , ("^", option (str "^") $ try $ tok >>= accent circ)
1296+ , ("^", accent '^' circ)
1282− , ("~", option (str "~") $ try $ tok >>= accent tilde)
1297+ , ("~", accent '~' tilde)
1283− , ("\"", option (str "\"") $ try $ tok >>= accent umlaut)
1298+ , ("\"", accent '\776' umlaut)
1284− , (".", option (str ".") $ try $ tok >>= accent dot)
1299+ , (".", accent '\775' dot)
1285− , ("=", option (str "=") $ try $ tok >>= accent macron)
1300+ , ("=", accent '\772' macron)
1286− , ("c", option (str "c") $ try $ tok >>= accent cedilla)
1301+ , ("c", accent '\807' cedilla)
1287− , ("v", option (str "v") $ try $ tok >>= accent hacek)
1302+ , ("v", accent 'ˇ' hacek)
1288− , ("u", option (str "u") $ try $ tok >>= accent breve)
1303+ , ("u", accent '\774' breve)
1304+ , ("k", accent '\808' ogonek)
1305+ , ("textogonekcentered", accent '\808' ogonek)
1289 , ("i", lit "i")
1306 , ("i", lit "i")
1290 , ("\\", linebreak <$ (do inTableCell <- sInTableCell <$> getState
1307 , ("\\", linebreak <$ (do inTableCell <- sInTableCell <$> getState
1291 guard $ not inTableCell
1308 guard $ not inTableCell
src/Text/Pandoc/Readers/Muse.hs+41−11
@@ -1,3 +1,4 @@
1+{-# LANGUAGE FlexibleContexts #-}
1{-
2{-
2 Copyright (C) 2017 Alexander Krotov <ilabdsf@gmail.com>
3 Copyright (C) 2017 Alexander Krotov <ilabdsf@gmail.com>
3
4
@@ -32,7 +33,6 @@ TODO:
32- {{{ }}} syntax for <example>
33- {{{ }}} syntax for <example>
33- Page breaks (five "*")
34- Page breaks (five "*")
34- Headings with anchors (make it round trip with Muse writer)
35- Headings with anchors (make it round trip with Muse writer)
35−- Verse markup (">")
36- Org tables
36- Org tables
37- table.el tables
37- table.el tables
38- Images with attributes (floating and width)
38- Images with attributes (floating and width)
@@ -101,6 +101,9 @@ parseBlocks = do
101-- utility functions
101-- utility functions
102--
102--
103
103
104+eol :: Stream s m Char => ParserT s st m ()
105+eol = void newline <|> eof
106+
104nested :: PandocMonad m => MuseParser m a -> MuseParser m a
107nested :: PandocMonad m => MuseParser m a -> MuseParser m a
105nested p = do
108nested p = do
106 nestlevel <- stateMaxNestingLevel <$> getState
109 nestlevel <- stateMaxNestingLevel <$> getState
@@ -180,7 +183,9 @@ blockElements = choice [ comment
180 , centerTag
183 , centerTag
181 , rightTag
184 , rightTag
182 , quoteTag
185 , quoteTag
186+ , divTag
183 , verseTag
187 , verseTag
188+ , lineBlock
184 , bulletList
189 , bulletList
185 , orderedList
190 , orderedList
186 , definitionList
191 , definitionList
@@ -194,7 +199,7 @@ comment = try $ do
194 char ';'
199 char ';'
195 space
200 space
196 many $ noneOf "\n"
201 many $ noneOf "\n"
197− void newline <|> eof
202+ eol
198 return mempty
203 return mempty
199
204
200separator :: PandocMonad m => MuseParser m (F Blocks)
205separator :: PandocMonad m => MuseParser m (F Blocks)
@@ -202,7 +207,7 @@ separator = try $ do
202 string "----"
207 string "----"
203 many $ char '-'
208 many $ char '-'
204 many spaceChar
209 many spaceChar
205− void newline <|> eof
210+ eol
206 return $ return B.horizontalRule
211 return $ return B.horizontalRule
207
212
208header :: PandocMonad m => MuseParser m (F Blocks)
213header :: PandocMonad m => MuseParser m (F Blocks)
@@ -212,8 +217,8 @@ header = try $ do
212 getPosition >>= \pos -> guard (st == NullState && q == NoQuote && sourceColumn pos == 1)
217 getPosition >>= \pos -> guard (st == NullState && q == NoQuote && sourceColumn pos == 1)
213 level <- liftM length $ many1 $ char '*'
218 level <- liftM length $ many1 $ char '*'
214 guard $ level <= 5
219 guard $ level <= 5
215− skipSpaces
220+ spaceChar
216− content <- trimInlinesF . mconcat <$> manyTill inline newline
221+ content <- trimInlinesF . mconcat <$> manyTill inline eol
217 attr <- registerHeader ("", [], []) (runF content defaultParserState)
222 attr <- registerHeader ("", [], []) (runF content defaultParserState)
218 return $ B.headerWith attr level <$> content
223 return $ B.headerWith attr level <$> content
219
224
@@ -245,6 +250,12 @@ rightTag = blockTag id "right"
245quoteTag :: PandocMonad m => MuseParser m (F Blocks)
250quoteTag :: PandocMonad m => MuseParser m (F Blocks)
246quoteTag = withQuoteContext InDoubleQuote $ blockTag B.blockQuote "quote"
251quoteTag = withQuoteContext InDoubleQuote $ blockTag B.blockQuote "quote"
247
252
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+
248verseLine :: PandocMonad m => MuseParser m String
259verseLine :: PandocMonad m => MuseParser m String
249verseLine = do
260verseLine = do
250 line <- anyLine <|> many1Till anyChar eof
261 line <- anyLine <|> many1Till anyChar eof
@@ -261,8 +272,7 @@ verseLines = do
261verseTag :: PandocMonad m => MuseParser m (F Blocks)
272verseTag :: PandocMonad m => MuseParser m (F Blocks)
262verseTag = do
273verseTag = do
263 (_, content) <- htmlElement "verse"
274 (_, content) <- htmlElement "verse"
264− parsedContent <- parseFromString verseLines content
275+ parseFromString verseLines content
265− return parsedContent
266
276
267commentTag :: PandocMonad m => MuseParser m (F Blocks)
277commentTag :: PandocMonad m => MuseParser m (F Blocks)
268commentTag = parseHtmlContent "comment" anyChar >> return mempty
278commentTag = parseHtmlContent "comment" anyChar >> return mempty
@@ -299,6 +309,26 @@ noteBlock = try $ do
299 blocksTillNote =
309 blocksTillNote =
300 many1Till block (eof <|> () <$ lookAhead noteMarker)
310 many1Till block (eof <|> () <$ lookAhead noteMarker)
301
311
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+
302--
332--
303-- lists
333-- lists
304--
334--
@@ -379,8 +409,8 @@ definitionListItem = try $ do
379 pure $ do lineContent' <- lineContent
409 pure $ do lineContent' <- lineContent
380 pure (B.text term, [lineContent'])
410 pure (B.text term, [lineContent'])
381 where
411 where
382− termParser = (many1 spaceChar) >> -- Initial space as required by Amusewiki, but not Emacs Muse
412+ termParser = many1 spaceChar >> -- Initial space as required by Amusewiki, but not Emacs Muse
383− (many1Till anyChar $ lookAhead (void (try (spaceChar >> string "::")) <|> void newline))
413+ many1Till anyChar (lookAhead (void (try (spaceChar >> string "::")) <|> void newline))
384 endOfInput = try $ skipMany blankline >> skipSpaces >> eof
414 endOfInput = try $ skipMany blankline >> skipSpaces >> eof
385 twoBlankLines = try $ blankline >> skipMany1 blankline
415 twoBlankLines = try $ blankline >> skipMany1 blankline
386 newDefinitionListItem = try $ void termParser
416 newDefinitionListItem = try $ void termParser
@@ -438,10 +468,10 @@ museAppendElement tbl element =
438
468
439tableCell :: PandocMonad m => MuseParser m (F Blocks)
469tableCell :: PandocMonad m => MuseParser m (F Blocks)
440tableCell = try $ liftM B.plain . trimInlinesF . mconcat <$> manyTill inline (lookAhead cellEnd)
470tableCell = 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
442
472
443tableElements :: PandocMonad m => MuseParser m [MuseTableElement]
473tableElements :: PandocMonad m => MuseParser m [MuseTableElement]
444−tableElements = tableParseElement `sepEndBy1` (void newline <|> eof)
474+tableElements = tableParseElement `sepEndBy1` eol
445
475
446elementsToTable :: [MuseTableElement] -> F MuseTable
476elementsToTable :: [MuseTableElement] -> F MuseTable
447elementsToTable = foldM museAppendElement emptyTable
477elementsToTable = foldM museAppendElement emptyTable
src/Text/Pandoc/Readers/RST.hs+9−9
@@ -219,7 +219,6 @@ block = choice [ codeBlock
219 , directive
219 , directive
220 , anchor
220 , anchor
221 , comment
221 , comment
222− , include
223 , header
222 , header
224 , hrule
223 , hrule
225 , lineBlock -- must go before definitionList
224 , lineBlock -- must go before definitionList
@@ -460,16 +459,16 @@ tab-width
460encoding
459encoding
461-}
460-}
462
461
462+includeDirective :: PandocMonad m
463+ => String -> [(String, String)] -> String
463−include :: PandocMonad m => RSTParser m Blocks
464+ -> RSTParser m Blocks
464−include = try $ do
465+includeDirective top fields body = do
465− string ".. include::"
466+ let f = trim top
466− skipMany spaceChar
467+ guard $ not (null f)
467− f <- trim <$> anyLine
468+ guard $ null (trim body)
468− fields <- many $ rawFieldListItem 3
469 -- options
469 -- options
470 let (startLine :: Maybe Int) = lookup "start-line" fields >>= safeRead
470 let (startLine :: Maybe Int) = lookup "start-line" fields >>= safeRead
471 let (endLine :: Maybe Int) = lookup "end-line" fields >>= safeRead
471 let (endLine :: Maybe Int) = lookup "end-line" fields >>= safeRead
472− guard $ not (null f)
473 oldPos <- getPosition
472 oldPos <- getPosition
474 oldInput <- getInput
473 oldInput <- getInput
475 containers <- stateContainers <$> getState
474 containers <- stateContainers <$> getState
@@ -501,7 +500,7 @@ include = try $ do
501 Just patt -> drop 1 .
500 Just patt -> drop 1 .
502 dropWhile (not . (patt `isInfixOf`))
501 dropWhile (not . (patt `isInfixOf`))
503 Nothing -> id) $ contentLines'
502 Nothing -> id) $ contentLines'
504− let contents' = unlines contentLines''
503+ let contents' = unlines contentLines'' ++ "\n"
505 case lookup "code" fields of
504 case lookup "code" fields of
506 Just lang -> do
505 Just lang -> do
507 let numberLines = lookup "number-lines" fields
506 let numberLines = lookup "number-lines" fields
@@ -687,6 +686,7 @@ directive' = do
687 $ lookup "height" fields >>=
686 $ lookup "height" fields >>=
688 (lengthToDim . filter (not . isSpace))
687 (lengthToDim . filter (not . isSpace))
689 case label of
688 case label of
689+ "include" -> includeDirective top fields body'
690 "table" -> tableDirective top fields body'
690 "table" -> tableDirective top fields body'
691 "list-table" -> listTableDirective top fields body'
691 "list-table" -> listTableDirective top fields body'
692 "csv-table" -> csvTableDirective top fields body'
692 "csv-table" -> csvTableDirective top fields body'
src/Text/Pandoc/Writers/HTML.hs+9−2
@@ -47,7 +47,7 @@ import Control.Monad.State.Strict
47import Data.Char (ord, toLower)
47import Data.Char (ord, toLower)
48import Data.Text (Text)
48import Data.Text (Text)
49import qualified Data.Text.Lazy as TL
49import qualified Data.Text.Lazy as TL
50−import Data.List (intersperse, isPrefixOf)
50+import Data.List (intersperse, isPrefixOf, partition, intercalate)
51import Data.Maybe (catMaybes, fromMaybe, isJust, isNothing)
51import Data.Maybe (catMaybes, fromMaybe, isJust, isNothing)
52import Data.Monoid ((<>))
52import Data.Monoid ((<>))
53import qualified Data.Set as Set
53import qualified Data.Set as Set
@@ -569,8 +569,15 @@ imgAttrsToHtml opts attr = do
569 isNotDim _ = True
569 isNotDim _ = True
570
570
571dimensionsToAttrList :: Attr -> [(String, String)]
571dimensionsToAttrList :: Attr -> [(String, String)]
572−dimensionsToAttrList attr = (go Width) ++ (go Height)
572+dimensionsToAttrList attr = consolidateStyles $ go Width ++ go Height
573 where
573 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
574 go dir = case (dimension dir attr) of
581 go dir = case (dimension dir attr) of
575 (Just (Pixel a)) -> [(show dir, show a)]
582 (Just (Pixel a)) -> [(show dir, show a)]
576 (Just x) -> [("style", show dir ++ ":" ++ show x)]
583 (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
628 put $ st {stOLLevel = oldlevel + 1}
628 put $ st {stOLLevel = oldlevel + 1}
629 items <- mapM listItemToLaTeX lst
629 items <- mapM listItemToLaTeX lst
630 modify (\s -> s {stOLLevel = oldlevel})
630 modify (\s -> s {stOLLevel = oldlevel})
631+ let beamer = stBeamer st
631 let tostyle x = case numstyle of
632 let tostyle x = case numstyle of
632 Decimal -> "\\arabic" <> braces x
633 Decimal -> "\\arabic" <> braces x
633 UpperRoman -> "\\Roman" <> braces x
634 UpperRoman -> "\\Roman" <> braces x
@@ -641,11 +642,21 @@ blockToLaTeX (OrderedList (start, numstyle, numdelim) lst) = do
641 TwoParens -> parens x
642 TwoParens -> parens x
642 Period -> x <> "."
643 Period -> x <> "."
643 _ -> x <> "."
644 _ -> 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"
644 let enum = text $ "enum" ++ map toLower (toRomanNumeral oldlevel)
653 let enum = text $ "enum" ++ map toLower (toRomanNumeral oldlevel)
645 let stylecommand = if numstyle == DefaultStyle && numdelim == DefaultDelim
654 let stylecommand = if numstyle == DefaultStyle && numdelim == DefaultDelim
646 then empty
655 then empty
656+ else if beamer
657+ then brackets (todelim exemplar)
647− else "\\def" <> "\\label" <> enum <>
658+ else "\\def" <> "\\label" <> enum <>
648− braces (todelim $ tostyle enum)
659+ braces (todelim $ tostyle enum)
649 let resetcounter = if start == 1 || oldlevel > 4
660 let resetcounter = if start == 1 || oldlevel > 4
650 then empty
661 then empty
651 else "\\setcounter" <> braces enum <>
662 else "\\setcounter" <> braces enum <>
src/Text/Pandoc/Writers/Markdown.hs+11−8
@@ -288,6 +288,7 @@ escapeString opts (c:cs) =
288 | otherwise -> "&gt;" ++ escapeString opts cs
288 | otherwise -> "&gt;" ++ escapeString opts cs
289 _ | c `elem` ['\\','`','*','_','[',']','#'] ->
289 _ | c `elem` ['\\','`','*','_','[',']','#'] ->
290 '\\':c:escapeString opts cs
290 '\\':c:escapeString opts cs
291+ '|' | isEnabled Ext_pipe_tables opts -> '\\':'|':escapeString opts cs
291 '^' | isEnabled Ext_superscript opts -> '\\':'^':escapeString opts cs
292 '^' | isEnabled Ext_superscript opts -> '\\':'^':escapeString opts cs
292 '~' | isEnabled Ext_subscript opts -> '\\':'~':escapeString opts cs
293 '~' | isEnabled Ext_subscript opts -> '\\':'~':escapeString opts cs
293 '$' | isEnabled Ext_tex_math_dollars opts -> '\\':'$':escapeString opts cs
294 '$' | isEnabled Ext_tex_math_dollars opts -> '\\':'$':escapeString opts cs
@@ -787,6 +788,7 @@ blockListToMarkdown :: PandocMonad m
787 -> MD m Doc
788 -> MD m Doc
788blockListToMarkdown opts blocks = do
789blockListToMarkdown opts blocks = do
789 inlist <- asks envInList
790 inlist <- asks envInList
791+ isPlain <- asks envPlain
790 -- a) insert comment between list and indented code block, or the
792 -- a) insert comment between list and indented code block, or the
791 -- code block will be treated as a list continuation paragraph
793 -- code block will be treated as a list continuation paragraph
792 -- b) change Plain to Para unless it's followed by a RawBlock
794 -- b) change Plain to Para unless it's followed by a RawBlock
@@ -813,9 +815,11 @@ blockListToMarkdown opts blocks = do
813 isListBlock (OrderedList _ _) = True
815 isListBlock (OrderedList _ _) = True
814 isListBlock (DefinitionList _) = True
816 isListBlock (DefinitionList _) = True
815 isListBlock _ = False
817 isListBlock _ = False
818+ commentSep = if isPlain
819+ then Null
816− commentSep = if isEnabled Ext_raw_html opts
820+ else if isEnabled Ext_raw_html opts
817− then RawBlock "html" "<!-- -->\n"
821+ then RawBlock "html" "<!-- -->\n"
818− else RawBlock "markdown" "&nbsp;\n"
822+ else RawBlock "markdown" "&nbsp;\n"
819 mapM (blockToMarkdown opts) (fixBlocks blocks) >>= return . cat
823 mapM (blockToMarkdown opts) (fixBlocks blocks) >>= return . cat
820
824
821getKey :: Doc -> Key
825getKey :: Doc -> Key
@@ -931,7 +935,7 @@ avoidBadWrapsInList (s:Str cs:[])
931avoidBadWrapsInList (x:xs) = x : avoidBadWrapsInList xs
935avoidBadWrapsInList (x:xs) = x : avoidBadWrapsInList xs
932
936
933isOrderedListMarker :: String -> Bool
937isOrderedListMarker :: String -> Bool
934−isOrderedListMarker xs = (last xs `elem` ['.',')']) &&
938+isOrderedListMarker xs = not (null xs) && (last xs `elem` ['.',')']) &&
935 isRight (runParser (anyOrderedListMarker >> eof)
939 isRight (runParser (anyOrderedListMarker >> eof)
936 defaultParserState "" xs)
940 defaultParserState "" xs)
937
941
@@ -946,11 +950,10 @@ inlineToMarkdown opts (Span attrs ils) = do
946 contents <- inlineListToMarkdown opts ils
950 contents <- inlineListToMarkdown opts ils
947 return $ case plain of
951 return $ case plain of
948 True -> contents
952 True -> contents
953+ False | attrs == nullAttr -> contents
949− False | isEnabled Ext_bracketed_spans opts ->
954+ | isEnabled Ext_bracketed_spans opts ->
950 "[" <> contents <> "]" <>
955 "[" <> contents <> "]" <>
951− if attrs == nullAttr
952− then "{}"
953− else linkAttributes opts attrs
956+ linkAttributes opts attrs
954 | isEnabled Ext_raw_html opts ||
957 | isEnabled Ext_raw_html opts ||
955 isEnabled Ext_native_spans opts ->
958 isEnabled Ext_native_spans opts ->
956 tagWithAttrs "span" attrs <> contents <> text "</span>"
959 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
129 blankline $$ contents $$
129 blankline $$ contents $$
130 blankline $$ drawerEndTag $$
130 blankline $$ drawerEndTag $$
131 blankline
131 blankline
132−blockToOrg (Div attrs bs) = do
132+blockToOrg (Div (ident, classes, kv) bs) = do
133 contents <- blockListToOrg bs
133 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.
134 let isGreaterBlockClass = (`elem` ["center", "quote"]) . map toLower
137 let isGreaterBlockClass = (`elem` ["center", "quote"]) . map toLower
138+ (blockTypeCand, classes') = partition isGreaterBlockClass classes
135− return $ case attrs of
139+ return $ case blockTypeCand of
136− ("", [], []) ->
140+ (blockType:classes'') ->
137− -- nullAttr, treat contents as if it wasn't wrapped
141+ blankline $$ attrHtml (ident, classes'' <> classes', kv) $$
138− blankline $$ contents $$ blankline
142+ "#+BEGIN_" <> text blockType $$ contents $$
139− (ident, [], []) ->
143+ "#+END_" <> text blockType $$ blankline
140− -- only an id: add id as an anchor, unwrap the rest
144+ _ ->
141− blankline $$ "<<" <> text ident <> ">>" $$ contents $$ blankline
145+ -- fallback with id: add id as an anchor if present, discard classes and
142− (ident, classes, kv) ->
146+ -- key-value pairs, unwrap the content.
143− -- if one class looks like the name of a greater block then output as
147+ let contents' = if not (null ident)
144− -- such: The ID, if present, is added via the #+NAME keyword; other
148+ then "<<" <> text ident <> ">>" $$ contents
145− -- classes and key-value pairs are kept as #+ATTR_HTML attributes.
149+ else contents
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" $$
150+ in blankline $$ contents' $$ blankline
159− nest 2 startTag $$ "#+END_HTML" $$ blankline $$
160− contents $$ blankline $$ "#+BEGIN_HTML" $$
161− nest 2 endTag $$ "#+END_HTML" $$ blankline
162blockToOrg (Plain inlines) = inlineListToOrg inlines
151blockToOrg (Plain inlines) = inlineListToOrg inlines
163-- title beginning with fig: indicates that the image is a figure
152-- title beginning with fig: indicates that the image is a figure
164blockToOrg (Para [Image attr txt (src,'f':'i':'g':':':tit)]) = do
153blockToOrg (Para [Image attr txt (src,'f':'i':'g':':':tit)]) = do
@@ -173,7 +162,7 @@ blockToOrg (Para inlines) = do
173blockToOrg (LineBlock lns) = do
162blockToOrg (LineBlock lns) = do
174 let splitStanza [] = []
163 let splitStanza [] = []
175 splitStanza xs = case break (== mempty) xs of
164 splitStanza xs = case break (== mempty) xs of
176− (l, []) -> l : []
165+ (l, []) -> [l]
177 (l, _:r) -> l : splitStanza r
166 (l, _:r) -> l : splitStanza r
178 let joinWithLinefeeds = nowrap . mconcat . intersperse cr
167 let joinWithLinefeeds = nowrap . mconcat . intersperse cr
179 let joinWithBlankLines = mconcat . intersperse blankline
168 let joinWithBlankLines = mconcat . intersperse blankline
@@ -213,7 +202,7 @@ blockToOrg (Table caption' _ _ headers rows) = do
213 caption'' <- inlineListToOrg caption'
202 caption'' <- inlineListToOrg caption'
214 let caption = if null caption'
203 let caption = if null caption'
215 then empty
204 then empty
216− else ("#+CAPTION: " <> caption'')
205+ else "#+CAPTION: " <> caption''
217 headers' <- mapM blockListToOrg headers
206 headers' <- mapM blockListToOrg headers
218 rawRows <- mapM (mapM blockListToOrg) rows
207 rawRows <- mapM (mapM blockListToOrg) rows
219 let numChars = maximum . map offset
208 let numChars = maximum . map offset
@@ -289,8 +278,8 @@ propertiesDrawer (ident, classes, kv) =
289 let
278 let
290 drawerStart = text ":PROPERTIES:"
279 drawerStart = text ":PROPERTIES:"
291 drawerEnd = text ":END:"
280 drawerEnd = text ":END:"
292− kv' = if (classes == mempty) then kv else ("CLASS", unwords classes):kv
281+ kv' = if classes == mempty then kv else ("CLASS", unwords classes):kv
293− kv'' = if (ident == mempty) then kv' else ("CUSTOM_ID", ident):kv'
282+ kv'' = if ident == mempty then kv' else ("CUSTOM_ID", ident):kv'
294 properties = vcat $ map kvToOrgProperty kv''
283 properties = vcat $ map kvToOrgProperty kv''
295 in
284 in
296 drawerStart <> cr <> properties <> cr <> drawerEnd
285 drawerStart <> cr <> properties <> cr <> drawerEnd
@@ -303,7 +292,7 @@ attrHtml :: Attr -> Doc
303attrHtml ("" , [] , []) = mempty
292attrHtml ("" , [] , []) = mempty
304attrHtml (ident, classes, kvs) =
293attrHtml (ident, classes, kvs) =
305 let
294 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
307 keyword = "#+ATTR_HTML"
296 keyword = "#+ATTR_HTML"
308 classKv = ("class", unwords classes)
297 classKv = ("class", unwords classes)
309 kvStrings = map (\(k,v) -> ":" <> k <> " " <> v) (classKv:kvs)
298 kvStrings = map (\(k,v) -> ":" <> k <> " " <> v) (classKv:kvs)
@@ -370,19 +359,19 @@ inlineToOrg SoftBreak = do
370 WrapPreserve -> return cr
359 WrapPreserve -> return cr
371 WrapAuto -> return space
360 WrapAuto -> return space
372 WrapNone -> return space
361 WrapNone -> return space
373−inlineToOrg (Link _ txt (src, _)) = do
362+inlineToOrg (Link _ txt (src, _)) =
374 case txt of
363 case txt of
375 [Str x] | escapeURI x == src -> -- autolink
364 [Str x] | escapeURI x == src -> -- autolink
376− do return $ "[[" <> text (orgPath x) <> "]]"
365+ return $ "[[" <> text (orgPath x) <> "]]"
377 _ -> do contents <- inlineListToOrg txt
366 _ -> do contents <- inlineListToOrg txt
378 return $ "[[" <> text (orgPath src) <> "][" <> contents <> "]]"
367 return $ "[[" <> text (orgPath src) <> "][" <> contents <> "]]"
379−inlineToOrg (Image _ _ (source, _)) = do
368+inlineToOrg (Image _ _ (source, _)) =
380 return $ "[[" <> text (orgPath source) <> "]]"
369 return $ "[[" <> text (orgPath source) <> "]]"
381inlineToOrg (Note contents) = do
370inlineToOrg (Note contents) = do
382 -- add to notes in state
371 -- add to notes in state
383 notes <- gets stNotes
372 notes <- gets stNotes
384 modify $ \st -> st { stNotes = contents:notes }
373 modify $ \st -> st { stNotes = contents:notes }
385− let ref = show $ (length notes) + 1
374+ let ref = show $ length notes + 1
386 return $ "[fn:" <> text ref <> "]"
375 return $ "[fn:" <> text ref <> "]"
387
376
388orgPath :: String -> String
377orgPath :: String -> String
stack.pkg.yaml+1−1
@@ -14,7 +14,7 @@ packages:
14- '.'
14- '.'
15- location:
15- location:
16 git: https://github.com/jgm/pandoc-citeproc.git
16 git: https://github.com/jgm/pandoc-citeproc.git
17− commit: 71ca48b6e0044ea959d8e7882b03cceba9c7960c
17+ commit: 5a7f26b61c8577916093851cdeb31fa9a198edcb
18 extra-dep: false
18 extra-dep: false
19extra-deps:
19extra-deps:
20- hslua-0.8.0
20- hslua-0.8.0
test/Tests/Readers/Muse.hs+38−5
@@ -145,6 +145,38 @@ tests =
145 , " with a continuation"
145 , " with a continuation"
146 ] =?>
146 ] =?>
147 blockQuote (para "This is a quotation with a continuation")
147 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+ ]
148 ]
180 ]
149 , "Quote tag" =: "<quote>Hello, world</quote>" =?> blockQuote (para $ text "Hello, world")
181 , "Quote tag" =: "<quote>Hello, world</quote>" =?> blockQuote (para $ text "Hello, world")
150 , "Verse tag" =:
182 , "Verse tag" =:
@@ -178,20 +210,21 @@ tests =
178 ]
210 ]
179 , testGroup "Headers"
211 , testGroup "Headers"
180 [ "Part" =:
212 [ "Part" =:
181− "* First level\n" =?>
213+ "* First level" =?>
182 header 1 "First level"
214 header 1 "First level"
183 , "Chapter" =:
215 , "Chapter" =:
184− "** Second level\n" =?>
216+ "** Second level" =?>
185 header 2 "Second level"
217 header 2 "Second level"
186 , "Section" =:
218 , "Section" =:
187− "*** Third level\n" =?>
219+ "*** Third level" =?>
188 header 3 "Third level"
220 header 3 "Third level"
189 , "Subsection" =:
221 , "Subsection" =:
190− "**** Fourth level\n" =?>
222+ "**** Fourth level" =?>
191 header 4 "Fourth level"
223 header 4 "Fourth level"
192 , "Subsubsection" =:
224 , "Subsubsection" =:
193− "***** Fifth level\n" =?>
225+ "***** Fifth level" =?>
194 header 5 "Fifth level"
226 header 5 "Fifth level"
227+ , "Whitespace is required after *" =: "**Not a header" =?> para "**Not a header"
195 , "No headers in footnotes" =:
228 , "No headers in footnotes" =:
196 T.unlines [ "Foo[1]"
229 T.unlines [ "Foo[1]"
197 , "[1] * Bar"
230 , "[1] * Bar"
test/Tests/Readers/RST.hs+13
@@ -136,6 +136,19 @@ tests = [ "line block with blank line" =:
136 para "but must stop here")
136 para "but must stop here")
137 , "line block with 3 lines" =: "| a\n| b\n| c"
137 , "line block with 3 lines" =: "| a\n| b\n| c"
138 =?> lineBlock ["a", "b", "c"]
138 =?> 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 [""]
139 , "quoted literal block using >" =: "::\n\n> quoted\n> block\n\nOrdinary paragraph"
152 , "quoted literal block using >" =: "::\n\n> quoted\n> block\n\nOrdinary paragraph"
140 =?> codeBlock "> quoted\n> block" <> para "Ordinary paragraph"
153 =?> codeBlock "> quoted\n> block" <> para "Ordinary paragraph"
141 , "quoted literal block using | (not a line block)" =: "::\n\n| quoted\n| block\n\nOrdinary paragraph"
154 , "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:
46% pandoc -t markdown
46% pandoc -t markdown
47\| hi \|
47\| hi \|
48^D
48^D
49−\| hi |
49+\| hi \|
50```
50```
51
51
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 @@
44\let\oldsubparagraph\subparagraph
44\let\oldsubparagraph\subparagraph
45\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
45\renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}}
46\fi
46\fi
47+
48+% set default figure placement to htbp
49+\makeatletter
50+\def\fps@figure{htbp}
51+\makeatother
52+
47\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
53\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex
48 \usepackage[shorthands=off,ngerman,british,nswissgerman,spanish,french,main=english]{babel}
54 \usepackage[shorthands=off,ngerman,british,nswissgerman,spanish,french,main=english]{babel}
49 \newcommand{\textgerman}[2][]{\foreignlanguage{ngerman}{#2}}
55 \newcommand{\textgerman}[2][]{\foreignlanguage{ngerman}{#2}}
@@ -77,12 +83,6 @@
77 \newenvironment{LTR}{\beginL}{\endL}
83 \newenvironment{LTR}{\beginL}{\endL}
78\fi
84\fi
79
85
80−% set default figure placement to htbp
81−\makeatletter
82−\def\fps@figure{htbp}
83−\makeatother
84−
85−
86\date{}
86\date{}
87
87
88\begin{document}
88\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