pandoc 1.17.2 → 1.18
raw patch · 143 files changed
+7957/−6230 lines, 143 filesdep +doctemplatesdep +unixdep ~HUnitdep ~aesondep ~basesetup-changedbinary-addedPVP ok
version bump matches the API change (PVP)
Dependencies added: doctemplates, unix
Dependency ranges changed: HUnit, aeson, base, directory, http-client, http-client-tls, mtl, pandoc-types, texmath
API changes (from Hackage documentation)
- Text.Pandoc.Error: instance Text.Pandoc.Compat.Except.Error Text.Pandoc.Error.PandocError
- Text.Pandoc.Options: [writerChapters] :: WriterOptions -> Bool
- Text.Pandoc.Templates: instance GHC.Base.Monoid Text.Pandoc.Templates.Template
- Text.Pandoc.Templates: instance Text.Pandoc.Templates.TemplateTarget Data.ByteString.Lazy.Internal.ByteString
- Text.Pandoc.Templates: instance Text.Pandoc.Templates.TemplateTarget Data.Text.Internal.Text
- Text.Pandoc.Templates: instance Text.Pandoc.Templates.TemplateTarget GHC.Base.String
- Text.Pandoc.Templates: instance Text.Pandoc.Templates.TemplateTarget Text.Blaze.Html.Html
- Text.Pandoc.Templates: toTarget :: TemplateTarget a => Text -> a
+ Text.Pandoc.Options: Chapter :: Division
+ Text.Pandoc.Options: EndOfBlock :: ReferenceLocation
+ Text.Pandoc.Options: EndOfDocument :: ReferenceLocation
+ Text.Pandoc.Options: EndOfSection :: ReferenceLocation
+ Text.Pandoc.Options: Ext_angle_brackets_escapable :: Extension
+ Text.Pandoc.Options: Ext_bracketed_spans :: Extension
+ Text.Pandoc.Options: Part :: Division
+ Text.Pandoc.Options: Section :: Division
+ Text.Pandoc.Options: [writerReferenceLocation] :: WriterOptions -> ReferenceLocation
+ Text.Pandoc.Options: [writerTopLevelDivision] :: WriterOptions -> Division
+ Text.Pandoc.Options: data Division
+ Text.Pandoc.Options: data ReferenceLocation
+ Text.Pandoc.Options: instance Data.Data.Data Text.Pandoc.Options.Division
+ Text.Pandoc.Options: instance Data.Data.Data Text.Pandoc.Options.ReferenceLocation
+ Text.Pandoc.Options: instance GHC.Classes.Eq Text.Pandoc.Options.Division
+ Text.Pandoc.Options: instance GHC.Classes.Eq Text.Pandoc.Options.ReferenceLocation
+ Text.Pandoc.Options: instance GHC.Classes.Ord Text.Pandoc.Options.Division
+ Text.Pandoc.Options: instance GHC.Generics.Generic Text.Pandoc.Options.Division
+ Text.Pandoc.Options: instance GHC.Generics.Generic Text.Pandoc.Options.ReferenceLocation
+ Text.Pandoc.Options: instance GHC.Read.Read Text.Pandoc.Options.Division
+ Text.Pandoc.Options: instance GHC.Read.Read Text.Pandoc.Options.ReferenceLocation
+ Text.Pandoc.Options: instance GHC.Show.Show Text.Pandoc.Options.Division
+ Text.Pandoc.Options: instance GHC.Show.Show Text.Pandoc.Options.ReferenceLocation
+ Text.Pandoc.Shared: filteredFilesFromArchive :: Archive -> (FilePath -> Bool) -> [(FilePath, ByteString)]
+ Text.Pandoc.Shared: inlineListToIdentifier :: [Inline] -> String
+ Text.Pandoc.Shared: linesToPara :: [[Inline]] -> Block
+ Text.Pandoc.Writers.Markdown: instance Data.Default.Class.Default Text.Pandoc.Writers.Markdown.WriterEnv
- Text.Pandoc.Options: WriterOptions :: Bool -> String -> [(String, String)] -> Int -> Bool -> HTMLSlideVariant -> Bool -> HTMLMathMethod -> Bool -> Bool -> [Int] -> Bool -> Set Extension -> Bool -> Int -> WrapOption -> Int -> ObfuscationMethod -> String -> Maybe String -> Maybe FilePath -> CiteMethod -> Bool -> Bool -> Bool -> Bool -> Maybe Int -> Bool -> Bool -> Bool -> Style -> Bool -> Bool -> Maybe EPUBVersion -> String -> Maybe String -> [FilePath] -> Int -> Int -> Maybe FilePath -> Maybe FilePath -> MediaBag -> Bool -> [String] -> WriterOptions
+ Text.Pandoc.Options: WriterOptions :: Bool -> String -> [(String, String)] -> Int -> Bool -> HTMLSlideVariant -> Bool -> HTMLMathMethod -> Bool -> Bool -> [Int] -> Bool -> Set Extension -> Bool -> Int -> WrapOption -> Int -> ObfuscationMethod -> String -> Maybe String -> Maybe FilePath -> CiteMethod -> Bool -> Bool -> Bool -> Bool -> Maybe Int -> Division -> Bool -> Bool -> Style -> Bool -> Bool -> Maybe EPUBVersion -> String -> Maybe String -> [FilePath] -> Int -> Int -> Maybe FilePath -> Maybe FilePath -> MediaBag -> Bool -> [String] -> ReferenceLocation -> WriterOptions
- Text.Pandoc.Templates: data Template
+ Text.Pandoc.Templates: data Template :: *
Files
- CONTRIBUTING.md +6/−6
- COPYING +0/−346
- COPYING.md +361/−0
- COPYRIGHT +1/−1
- INSTALL +0/−234
- INSTALL.md +339/−0
- MANUAL.txt +4164/−0
- README +0/−4007
- README.md +144/−0
- Setup.hs +1/−5
- changelog +441/−7
- data/sample.lua +5/−0
- data/templates/default.beamer +25/−1
- data/templates/default.epub +3/−3
- data/templates/default.epub3 +3/−3
- data/templates/default.html5 +3/−3
- data/templates/default.latex +12/−0
- data/templates/default.revealjs +7/−3
- data/templates/default.slidy +1/−1
- man/pandoc.1 +247/−65
- pandoc.cabal +24/−24
- pandoc.hs +135/−48
- prelude/Prelude.hs +1/−5
- src/Text/Pandoc.hs +4/−3
- src/Text/Pandoc/Compat/Directory.hs +0/−21
- src/Text/Pandoc/Compat/Except.hs +0/−37
- src/Text/Pandoc/Compat/Monoid.hs +0/−17
- src/Text/Pandoc/Compat/TagSoupEntity.hs +0/−15
- src/Text/Pandoc/Compat/Time.hs +12/−0
- src/Text/Pandoc/Data.hsb +1/−1
- src/Text/Pandoc/Error.hs +8/−9
- src/Text/Pandoc/ImageSize.hs +1/−2
- src/Text/Pandoc/Options.hs +26/−4
- src/Text/Pandoc/PDF.hs +3/−2
- src/Text/Pandoc/Parsing.hs +22/−10
- src/Text/Pandoc/Pretty.hs +1/−13
- src/Text/Pandoc/Readers/DocBook.hs +7/−7
- src/Text/Pandoc/Readers/Docx.hs +25/−22
- src/Text/Pandoc/Readers/Docx/Lists.hs +2/−2
- src/Text/Pandoc/Readers/Docx/Parse.hs +34/−60
- src/Text/Pandoc/Readers/Docx/StyleMap.hs +2/−0
- src/Text/Pandoc/Readers/EPUB.hs +7/−6
- src/Text/Pandoc/Readers/HTML.hs +1/−1
- src/Text/Pandoc/Readers/Haddock.hs +1/−1
- src/Text/Pandoc/Readers/LaTeX.hs +11/−4
- src/Text/Pandoc/Readers/Markdown.hs +16/−4
- src/Text/Pandoc/Readers/MediaWiki.hs +15/−9
- src/Text/Pandoc/Readers/OPML.hs +3/−3
- src/Text/Pandoc/Readers/Odt.hs +28/−16
- src/Text/Pandoc/Readers/Odt/Arrows/State.hs +1/−1
- src/Text/Pandoc/Readers/Odt/Arrows/Utils.hs +1/−1
- src/Text/Pandoc/Readers/Odt/ContentReader.hs +113/−10
- src/Text/Pandoc/Readers/Odt/Generic/Fallible.hs +2/−1
- src/Text/Pandoc/Readers/Odt/StyleReader.hs +20/−12
- src/Text/Pandoc/Readers/Org/Blocks.hs +53/−87
- src/Text/Pandoc/Readers/Org/ExportSettings.hs +5/−3
- src/Text/Pandoc/Readers/Org/Inlines.hs +9/−26
- src/Text/Pandoc/Readers/Org/Meta.hs +181/−0
- src/Text/Pandoc/Readers/Org/ParserState.hs +6/−0
- src/Text/Pandoc/Readers/Org/Shared.hs +23/−2
- src/Text/Pandoc/Readers/RST.hs +12/−13
- src/Text/Pandoc/Readers/Textile.hs +101/−35
- src/Text/Pandoc/Readers/Txt2Tags.hs +2/−2
- src/Text/Pandoc/Shared.hs +27/−19
- src/Text/Pandoc/Templates.hs +9/−264
- src/Text/Pandoc/UTF8.hs +2/−7
- src/Text/Pandoc/Writers/AsciiDoc.hs +24/−8
- src/Text/Pandoc/Writers/CommonMark.hs +2/−1
- src/Text/Pandoc/Writers/ConTeXt.hs +24/−16
- src/Text/Pandoc/Writers/Custom.hs +2/−0
- src/Text/Pandoc/Writers/Docbook.hs +25/−12
- src/Text/Pandoc/Writers/Docx.hs +214/−127
- src/Text/Pandoc/Writers/DokuWiki.hs +5/−2
- src/Text/Pandoc/Writers/EPUB.hs +4/−6
- src/Text/Pandoc/Writers/FB2.hs +3/−1
- src/Text/Pandoc/Writers/HTML.hs +10/−5
- src/Text/Pandoc/Writers/Haddock.hs +2/−0
- src/Text/Pandoc/Writers/ICML.hs +9/−7
- src/Text/Pandoc/Writers/LaTeX.hs +20/−7
- src/Text/Pandoc/Writers/Man.hs +7/−6
- src/Text/Pandoc/Writers/Markdown.hs +159/−98
- src/Text/Pandoc/Writers/MediaWiki.hs +3/−0
- src/Text/Pandoc/Writers/Native.hs +2/−0
- src/Text/Pandoc/Writers/OpenDocument.hs +2/−0
- src/Text/Pandoc/Writers/Org.hs +60/−14
- src/Text/Pandoc/Writers/RST.hs +9/−2
- src/Text/Pandoc/Writers/RTF.hs +2/−0
- src/Text/Pandoc/Writers/TEI.hs +19/−17
- src/Text/Pandoc/Writers/Texinfo.hs +3/−0
- src/Text/Pandoc/Writers/Textile.hs +3/−0
- src/Text/Pandoc/Writers/ZimWiki.hs +5/−1
- src/Text/Pandoc/XML.hs +2/−2
- stack.yaml +3/−5
- tests/Tests/Arbitrary.hs +0/−194
- tests/Tests/Readers/Docx.hs +4/−0
- tests/Tests/Readers/HTML.hs +1/−2
- tests/Tests/Readers/LaTeX.hs +1/−2
- tests/Tests/Readers/Markdown.hs +16/−4
- tests/Tests/Readers/Odt.hs +4/−7
- tests/Tests/Readers/Org.hs +159/−79
- tests/Tests/Readers/RST.hs +12/−5
- tests/Tests/Readers/Txt2Tags.hs +1/−2
- tests/Tests/Shared.hs +1/−1
- tests/Tests/Walk.hs +1/−1
- tests/Tests/Writers/AsciiDoc.hs +1/−1
- tests/Tests/Writers/ConTeXt.hs +1/−1
- tests/Tests/Writers/Docbook.hs +57/−2
- tests/Tests/Writers/Docx.hs +58/−41
- tests/Tests/Writers/HTML.hs +1/−1
- tests/Tests/Writers/LaTeX.hs +58/−5
- tests/Tests/Writers/Markdown.hs +139/−3
- tests/Tests/Writers/Native.hs +1/−1
- tests/Tests/Writers/Plain.hs +1/−1
- tests/Tests/Writers/RST.hs +1/−1
- tests/Tests/Writers/TEI.hs +1/−1
- tests/docx/custom-style-reference.docx binary
- tests/docx/custom-style-roundtrip-end.native +5/−0
- tests/docx/custom-style-roundtrip-start.native +5/−0
- tests/docx/nested_anchors_in_header.docx binary
- tests/docx/nested_anchors_in_header.native +10/−0
- tests/lhs-test.latex +6/−0
- tests/lhs-test.latex+lhs +6/−0
- tests/mallard-reader.native +0/−3
- tests/markdown-reader-more.native +11/−3
- tests/markdown-reader-more.txt +3/−0
- tests/odt/native/image.native +1/−0
- tests/odt/native/imageIndex.native +1/−0
- tests/odt/native/imageWithCaption.native +1/−0
- tests/odt/native/orderedListMixed.native +1/−1
- tests/odt/native/orderedListRoman.native +1/−1
- tests/odt/native/orderedListSimple.native +1/−1
- tests/odt/native/referenceToText.native +1/−1
- tests/odt/odt/orderedListMixed.odt binary
- tests/odt/odt/orderedListRoman.odt binary
- tests/odt/odt/orderedListSimple.odt binary
- tests/odt/odt/referenceToText.odt binary
- tests/rst-reader.native +8/−2
- tests/textile-reader.native +4/−1
- tests/textile-reader.textile +7/−0
- tests/writer.asciidoc +4/−4
- tests/writer.latex +7/−1
- tests/writer.org +6/−6
- tests/writers-lang-and-dir.latex +6/−0
CONTRIBUTING.md view
@@ -29,7 +29,7 @@ ------------- A less than perfect conversion does not necessarily mean there's-a bug in pandoc. Quoting from the README:+a bug in pandoc. Quoting from the MANUAL: > Because Pandoc's intermediate representation of a document is less > expressive than many of the formats it converts between, one should@@ -124,7 +124,7 @@ below under [Tests](#tests).) If you are adding a new writer or reader, you must include tests. -7. If you are adding a new feature, include updates to the README.+7. If you are adding a new feature, include updates to MANUAL.txt. 8. All code must be released under the general license governing pandoc (GPL v2).@@ -132,7 +132,7 @@ 9. It is better not to introduce new dependencies. Dependencies on external C libraries should especially be avoided. -10. We aim for compatibility with ghc versions from 7.4.2 to the+10. We aim for compatibility with ghc versions from 7.8.3 to the latest release. All pull requests and commits are tested automatically on travis-ci.org, using GHC versions in the `Tested-With` stanza of `pandoc.cabal`. We currently relax@@ -152,7 +152,7 @@ or, if you're using [stack], - stack init+ stack setup stack test The test program is `tests/test-pandoc.hs`.@@ -259,7 +259,7 @@ - `Text.Pandoc.Shared` is a grab-bag of shared utility functions. - `Text.Pandoc.Writers.Shared` contains utilities used in writers only. - `Text.Pandoc.Slides` contains functions for splitting a markdown document- into slides, using the conventions described in the README.+ into slides, using the conventions described in the MANUAL. - `Text.Pandoc.Templates` defines pandoc's templating system. - `Text.Pandoc.UTF8` contains functions for converting text to and from UTF8 bytestrings (strict and lazy).@@ -270,7 +270,7 @@ [pandoc-discuss]: http://groups.google.com/group/pandoc-discuss [issue tracker]: https://github.com/jgm/pandoc/issues-[User's Guide]: http://pandoc.org/README.html+[User's Guide]: http://pandoc.org/MANUAL.html [FAQs]: http://pandoc.org/faqs.html [EditorConfig]: http://editorconfig.org/ [Haskell platform]: http://www.haskell.org/platform/
− COPYING
@@ -1,346 +0,0 @@-GNU GENERAL PUBLIC LICENSE-==========================--Version 2, June 1991--Copyright (C) 1989, 1991 Free Software Foundation, Inc. -51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA--Everyone is permitted to copy and distribute verbatim copies-of this license document, but changing it is not allowed.--Preamble-----------The licenses for most software are designed to take away your-freedom to share and change it. By contrast, the GNU General Public-License is intended to guarantee your freedom to share and change free-software--to make sure the software is free for all its users. This-General Public License applies to most of the Free Software-Foundation's software and to any other program whose authors commit to-using it. (Some other Free Software Foundation software is covered by-the GNU Library General Public License instead.) You can apply it to-your programs, too.--When we speak of free software, we are referring to freedom, not-price. Our General Public Licenses are designed to make sure that you-have the freedom to distribute copies of free software (and charge for-this service if you wish), that you receive source code or can get it-if you want it, that you can change the software or use pieces of it-in new free programs; and that you know you can do these things.--To protect your rights, we need to make restrictions that forbid-anyone to deny you these rights or to ask you to surrender the rights.-These restrictions translate to certain responsibilities for you if you-distribute copies of the software, or if you modify it.--For example, if you distribute copies of such a program, whether-gratis or for a fee, you must give the recipients all the rights that-you have. You must make sure that they, too, receive or can get the-source code. And you must show them these terms so they know their-rights.--We protect your rights with two steps: (1) copyright the software, and-(2) offer you this license which gives you legal permission to copy,-distribute and/or modify the software.--Also, for each author's protection and ours, we want to make certain-that everyone understands that there is no warranty for this free-software. If the software is modified by someone else and passed on, we-want its recipients to know that what they have is not the original, so-that any problems introduced by others will not reflect on the original-authors' reputations.--Finally, any free program is threatened constantly by software-patents. We wish to avoid the danger that redistributors of a free-program will individually obtain patent licenses, in effect making the-program proprietary. To prevent this, we have made it clear that any-patent must be licensed for everyone's free use or not licensed at all.--The precise terms and conditions for copying, distribution and-modification follow.--GNU GENERAL PUBLIC LICENSE-----------------------------TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION--0. This License applies to any program or other work which contains- a notice placed by the copyright holder saying it may be distributed- under the terms of this General Public License. The "Program", below,- refers to any such program or work, and a "work based on the Program"- means either the Program or any derivative work under copyright law:- that is to say, a work containing the Program or a portion of it,- either verbatim or with modifications and/or translated into another- language. (Hereinafter, translation is included without limitation in- the term "modification".) Each licensee is addressed as "you".-- Activities other than copying, distribution and modification are not- covered by this License; they are outside its scope. The act of- running the Program is not restricted, and the output from the Program- is covered only if its contents constitute a work based on the- Program (independent of having been made by running the Program).- Whether that is true depends on what the Program does.--1. You may copy and distribute verbatim copies of the Program's- source code as you receive it, in any medium, provided that you- conspicuously and appropriately publish on each copy an appropriate- copyright notice and disclaimer of warranty; keep intact all the- notices that refer to this License and to the absence of any warranty;- and give any other recipients of the Program a copy of this License- along with the Program.-- You may charge a fee for the physical act of transferring a copy, and- you may at your option offer warranty protection in exchange for a fee.--2. You may modify your copy or copies of the Program or any portion- of it, thus forming a work based on the Program, and copy and- distribute such modifications or work under the terms of Section 1- above, provided that you also meet all of these conditions:-- a) You must cause the modified files to carry prominent notices- stating that you changed the files and the date of any change.-- b) You must cause any work that you distribute or publish, that in- whole or in part contains or is derived from the Program or any- part thereof, to be licensed as a whole at no charge to all third- parties under the terms of this License.-- c) If the modified program normally reads commands interactively- when run, you must cause it, when started running for such- interactive use in the most ordinary way, to print or display an- announcement including an appropriate copyright notice and a- notice that there is no warranty (or else, saying that you provide- a warranty) and that users may redistribute the program under- these conditions, and telling the user how to view a copy of this- License. (Exception: if the Program itself is interactive but- does not normally print such an announcement, your work based on- the Program is not required to print an announcement.)-- These requirements apply to the modified work as a whole. If- identifiable sections of that work are not derived from the Program,- and can be reasonably considered independent and separate works in- themselves, then this License, and its terms, do not apply to those- sections when you distribute them as separate works. But when you- distribute the same sections as part of a whole which is a work based- on the Program, the distribution of the whole must be on the terms of- this License, whose permissions for other licensees extend to the- entire whole, and thus to each and every part regardless of who wrote it.-- Thus, it is not the intent of this section to claim rights or contest- your rights to work written entirely by you; rather, the intent is to- exercise the right to control the distribution of derivative or- collective works based on the Program.-- In addition, mere aggregation of another work not based on the Program- with the Program (or with a work based on the Program) on a volume of- a storage or distribution medium does not bring the other work under- the scope of this License.--3. You may copy and distribute the Program (or a work based on it,- under Section 2) in object code or executable form under the terms of- Sections 1 and 2 above provided that you also do one of the following:-- a) Accompany it with the complete corresponding machine-readable- source code, which must be distributed under the terms of Sections- 1 and 2 above on a medium customarily used for software interchange; or,-- b) Accompany it with a written offer, valid for at least three- years, to give any third party, for a charge no more than your- cost of physically performing source distribution, a complete- machine-readable copy of the corresponding source code, to be- distributed under the terms of Sections 1 and 2 above on a medium- customarily used for software interchange; or,-- c) Accompany it with the information you received as to the offer- to distribute corresponding source code. (This alternative is- allowed only for noncommercial distribution and only if you- received the program in object code or executable form with such- an offer, in accord with Subsection b above.)-- The source code for a work means the preferred form of the work for- making modifications to it. For an executable work, complete source- code means all the source code for all modules it contains, plus any- associated interface definition files, plus the scripts used to- control compilation and installation of the executable. However, as a- special exception, the source code distributed need not include- anything that is normally distributed (in either source or binary- form) with the major components (compiler, kernel, and so on) of the- operating system on which the executable runs, unless that component- itself accompanies the executable.-- If distribution of executable or object code is made by offering- access to copy from a designated place, then offering equivalent- access to copy the source code from the same place counts as- distribution of the source code, even though third parties are not- compelled to copy the source along with the object code.--4. You may not copy, modify, sublicense, or distribute the Program- except as expressly provided under this License. Any attempt- otherwise to copy, modify, sublicense or distribute the Program is- void, and will automatically terminate your rights under this License.- However, parties who have received copies, or rights, from you under- this License will not have their licenses terminated so long as such- parties remain in full compliance.--5. You are not required to accept this License, since you have not- signed it. However, nothing else grants you permission to modify or- distribute the Program or its derivative works. These actions are- prohibited by law if you do not accept this License. Therefore, by- modifying or distributing the Program (or any work based on the- Program), you indicate your acceptance of this License to do so, and- all its terms and conditions for copying, distributing or modifying- the Program or works based on it.--6. Each time you redistribute the Program (or any work based on the- Program), the recipient automatically receives a license from the- original licensor to copy, distribute or modify the Program subject to- these terms and conditions. You may not impose any further- restrictions on the recipients' exercise of the rights granted herein.- You are not responsible for enforcing compliance by third parties to- this License.--7. If, as a consequence of a court judgment or allegation of patent- infringement or for any other reason (not limited to patent issues),- conditions are imposed on you (whether by court order, agreement or- otherwise) that contradict the conditions of this License, they do not- excuse you from the conditions of this License. If you cannot- distribute so as to satisfy simultaneously your obligations under this- License and any other pertinent obligations, then as a consequence you- may not distribute the Program at all. For example, if a patent- license would not permit royalty-free redistribution of the Program by- all those who receive copies directly or indirectly through you, then- the only way you could satisfy both it and this License would be to- refrain entirely from distribution of the Program.-- If any portion of this section is held invalid or unenforceable under- any particular circumstance, the balance of the section is intended to- apply and the section as a whole is intended to apply in other- circumstances.-- It is not the purpose of this section to induce you to infringe any- patents or other property right claims or to contest validity of any- such claims; this section has the sole purpose of protecting the- integrity of the free software distribution system, which is- implemented by public license practices. Many people have made- generous contributions to the wide range of software distributed- through that system in reliance on consistent application of that- system; it is up to the author/donor to decide if he or she is willing- to distribute software through any other system and a licensee cannot- impose that choice.-- This section is intended to make thoroughly clear what is believed to- be a consequence of the rest of this License.--8. If the distribution and/or use of the Program is restricted in- certain countries either by patents or by copyrighted interfaces, the- original copyright holder who places the Program under this License- may add an explicit geographical distribution limitation excluding- those countries, so that distribution is permitted only in or among- countries not thus excluded. In such case, this License incorporates- the limitation as if written in the body of this License.--9. The Free Software Foundation may publish revised and/or new versions- of the General Public License from time to time. Such new versions will- be similar in spirit to the present version, but may differ in detail to- address new problems or concerns.-- Each version is given a distinguishing version number. If the Program- specifies a version number of this License which applies to it and "any- later version", you have the option of following the terms and conditions- either of that version or of any later version published by the Free- Software Foundation. If the Program does not specify a version number of- this License, you may choose any version ever published by the Free Software- Foundation.--10. If you wish to incorporate parts of the Program into other free- programs whose distribution conditions are different, write to the author- to ask for permission. For software which is copyrighted by the Free- Software Foundation, write to the Free Software Foundation; we sometimes- make exceptions for this. Our decision will be guided by the two goals- of preserving the free status of all derivatives of our free software and- of promoting the sharing and reuse of software generally.--NO WARRANTY--11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY- FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN- OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES- PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED- OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS- TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE- PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,- REPAIR OR CORRECTION.--12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING- WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR- REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,- INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING- OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED- TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY- YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER- PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE- POSSIBILITY OF SUCH DAMAGES.--END OF TERMS AND CONDITIONS--How to Apply These Terms to Your New Programs------------------------------------------------If you develop a new program, and you want it to be of the greatest-possible use to the public, the best way to achieve this is to make it-free software which everyone can redistribute and change under these terms.--To do so, attach the following notices to the program. It is safest-to attach them to the start of each source file to most effectively-convey the exclusion of warranty; and each file should have at least-the "copyright" line and a pointer to where the full notice is found.-- <one line to give the program's name and a brief idea of what it does.>- Copyright (C) <year> <name of author>-- This program is free software; you can redistribute it and/or modify- it under the terms of the GNU General Public License as published by- the Free Software Foundation; either version 2 of the License, or- (at your option) any later version.-- This program is distributed in the hope that it will be useful,- but WITHOUT ANY WARRANTY; without even the implied warranty of- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- GNU General Public License for more details.-- You should have received a copy of the GNU General Public License- along with this program; if not, write to the Free Software- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA--Also add information on how to contact you by electronic and paper mail.--If the program is interactive, make it output a short notice like this-when it starts in an interactive mode:-- Gnomovision version 69, Copyright (C) year name of author- Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.- This is free software, and you are welcome to redistribute it- under certain conditions; type `show c' for details.--The hypothetical commands `show w' and `show c' should show the appropriate-parts of the General Public License. Of course, the commands you use may-be called something other than `show w' and `show c'; they could even be-mouse-clicks or menu items--whatever suits your program.--You should also get your employer (if you work as a programmer) or your-school, if any, to sign a "copyright disclaimer" for the program, if-necessary. Here is a sample; alter the names:-- Yoyodyne, Inc., hereby disclaims all copyright interest in the program- `Gnomovision' (which makes passes at compilers) written by James Hacker.-- <signature of Ty Coon>, 1 April 1989- Ty Coon, President of Vice--This General Public License does not permit incorporating your program into-proprietary programs. If your program is a subroutine library, you may-consider it more useful to permit linking proprietary applications with the-library. If this is what you want to do, use the GNU Library General-Public License instead of this License.
+ COPYING.md view
@@ -0,0 +1,361 @@+### GNU GENERAL PUBLIC LICENSE++Version 2, June 1991++ Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA++ Everyone is permitted to copy and distribute verbatim copies+ of this license document, but changing it is not allowed.++### Preamble++The licenses for most software are designed to take away your freedom+to share and change it. By contrast, the GNU General Public License is+intended to guarantee your freedom to share and change free+software--to make sure the software is free for all its users. This+General Public License applies to most of the Free Software+Foundation's software and to any other program whose authors commit to+using it. (Some other Free Software Foundation software is covered by+the GNU Lesser General Public License instead.) You can apply it to+your programs, too.++When we speak of free software, we are referring to freedom, not+price. Our General Public Licenses are designed to make sure that you+have the freedom to distribute copies of free software (and charge for+this service if you wish), that you receive source code or can get it+if you want it, that you can change the software or use pieces of it+in new free programs; and that you know you can do these things.++To protect your rights, we need to make restrictions that forbid+anyone to deny you these rights or to ask you to surrender the rights.+These restrictions translate to certain responsibilities for you if+you distribute copies of the software, or if you modify it.++For example, if you distribute copies of such a program, whether+gratis or for a fee, you must give the recipients all the rights that+you have. You must make sure that they, too, receive or can get the+source code. And you must show them these terms so they know their+rights.++We protect your rights with two steps: (1) copyright the software, and+(2) offer you this license which gives you legal permission to copy,+distribute and/or modify the software.++Also, for each author's protection and ours, we want to make certain+that everyone understands that there is no warranty for this free+software. If the software is modified by someone else and passed on,+we want its recipients to know that what they have is not the+original, so that any problems introduced by others will not reflect+on the original authors' reputations.++Finally, any free program is threatened constantly by software+patents. We wish to avoid the danger that redistributors of a free+program will individually obtain patent licenses, in effect making the+program proprietary. To prevent this, we have made it clear that any+patent must be licensed for everyone's free use or not licensed at+all.++The precise terms and conditions for copying, distribution and+modification follow.++### TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION++**0.** This License applies to any program or other work which+contains a notice placed by the copyright holder saying it may be+distributed under the terms of this General Public License. The+"Program", below, refers to any such program or work, and a "work+based on the Program" means either the Program or any derivative work+under copyright law: that is to say, a work containing the Program or+a portion of it, either verbatim or with modifications and/or+translated into another language. (Hereinafter, translation is+included without limitation in the term "modification".) Each licensee+is addressed as "you".++Activities other than copying, distribution and modification are not+covered by this License; they are outside its scope. The act of+running the Program is not restricted, and the output from the Program+is covered only if its contents constitute a work based on the Program+(independent of having been made by running the Program). Whether that+is true depends on what the Program does.++**1.** You may copy and distribute verbatim copies of the Program's+source code as you receive it, in any medium, provided that you+conspicuously and appropriately publish on each copy an appropriate+copyright notice and disclaimer of warranty; keep intact all the+notices that refer to this License and to the absence of any warranty;+and give any other recipients of the Program a copy of this License+along with the Program.++You may charge a fee for the physical act of transferring a copy, and+you may at your option offer warranty protection in exchange for a+fee.++**2.** You may modify your copy or copies of the Program or any+portion of it, thus forming a work based on the Program, and copy and+distribute such modifications or work under the terms of Section 1+above, provided that you also meet all of these conditions:++ +**a)** You must cause the modified files to carry prominent notices+stating that you changed the files and the date of any change.++ +**b)** You must cause any work that you distribute or publish, that in+whole or in part contains or is derived from the Program or any part+thereof, to be licensed as a whole at no charge to all third parties+under the terms of this License.++ +**c)** If the modified program normally reads commands interactively+when run, you must cause it, when started running for such interactive+use in the most ordinary way, to print or display an announcement+including an appropriate copyright notice and a notice that there is+no warranty (or else, saying that you provide a warranty) and that+users may redistribute the program under these conditions, and telling+the user how to view a copy of this License. (Exception: if the+Program itself is interactive but does not normally print such an+announcement, your work based on the Program is not required to print+an announcement.)++These requirements apply to the modified work as a whole. If+identifiable sections of that work are not derived from the Program,+and can be reasonably considered independent and separate works in+themselves, then this License, and its terms, do not apply to those+sections when you distribute them as separate works. But when you+distribute the same sections as part of a whole which is a work based+on the Program, the distribution of the whole must be on the terms of+this License, whose permissions for other licensees extend to the+entire whole, and thus to each and every part regardless of who wrote+it.++Thus, it is not the intent of this section to claim rights or contest+your rights to work written entirely by you; rather, the intent is to+exercise the right to control the distribution of derivative or+collective works based on the Program.++In addition, mere aggregation of another work not based on the Program+with the Program (or with a work based on the Program) on a volume of+a storage or distribution medium does not bring the other work under+the scope of this License.++**3.** You may copy and distribute the Program (or a work based on it,+under Section 2) in object code or executable form under the terms of+Sections 1 and 2 above provided that you also do one of the following:++ +**a)** Accompany it with the complete corresponding machine-readable+source code, which must be distributed under the terms of Sections 1+and 2 above on a medium customarily used for software interchange; or,++ +**b)** Accompany it with a written offer, valid for at least three+years, to give any third party, for a charge no more than your cost of+physically performing source distribution, a complete machine-readable+copy of the corresponding source code, to be distributed under the+terms of Sections 1 and 2 above on a medium customarily used for+software interchange; or,++ +**c)** Accompany it with the information you received as to the offer+to distribute corresponding source code. (This alternative is allowed+only for noncommercial distribution and only if you received the+program in object code or executable form with such an offer, in+accord with Subsection b above.)++The source code for a work means the preferred form of the work for+making modifications to it. For an executable work, complete source+code means all the source code for all modules it contains, plus any+associated interface definition files, plus the scripts used to+control compilation and installation of the executable. However, as a+special exception, the source code distributed need not include+anything that is normally distributed (in either source or binary+form) with the major components (compiler, kernel, and so on) of the+operating system on which the executable runs, unless that component+itself accompanies the executable.++If distribution of executable or object code is made by offering+access to copy from a designated place, then offering equivalent+access to copy the source code from the same place counts as+distribution of the source code, even though third parties are not+compelled to copy the source along with the object code.++**4.** You may not copy, modify, sublicense, or distribute the Program+except as expressly provided under this License. Any attempt otherwise+to copy, modify, sublicense or distribute the Program is void, and+will automatically terminate your rights under this License. However,+parties who have received copies, or rights, from you under this+License will not have their licenses terminated so long as such+parties remain in full compliance.++**5.** You are not required to accept this License, since you have not+signed it. However, nothing else grants you permission to modify or+distribute the Program or its derivative works. These actions are+prohibited by law if you do not accept this License. Therefore, by+modifying or distributing the Program (or any work based on the+Program), you indicate your acceptance of this License to do so, and+all its terms and conditions for copying, distributing or modifying+the Program or works based on it.++**6.** Each time you redistribute the Program (or any work based on+the Program), the recipient automatically receives a license from the+original licensor to copy, distribute or modify the Program subject to+these terms and conditions. You may not impose any further+restrictions on the recipients' exercise of the rights granted herein.+You are not responsible for enforcing compliance by third parties to+this License.++**7.** If, as a consequence of a court judgment or allegation of+patent infringement or for any other reason (not limited to patent+issues), conditions are imposed on you (whether by court order,+agreement or otherwise) that contradict the conditions of this+License, they do not excuse you from the conditions of this License.+If you cannot distribute so as to satisfy simultaneously your+obligations under this License and any other pertinent obligations,+then as a consequence you may not distribute the Program at all. For+example, if a patent license would not permit royalty-free+redistribution of the Program by all those who receive copies directly+or indirectly through you, then the only way you could satisfy both it+and this License would be to refrain entirely from distribution of the+Program.++If any portion of this section is held invalid or unenforceable under+any particular circumstance, the balance of the section is intended to+apply and the section as a whole is intended to apply in other+circumstances.++It is not the purpose of this section to induce you to infringe any+patents or other property right claims or to contest validity of any+such claims; this section has the sole purpose of protecting the+integrity of the free software distribution system, which is+implemented by public license practices. Many people have made+generous contributions to the wide range of software distributed+through that system in reliance on consistent application of that+system; it is up to the author/donor to decide if he or she is willing+to distribute software through any other system and a licensee cannot+impose that choice.++This section is intended to make thoroughly clear what is believed to+be a consequence of the rest of this License.++**8.** If the distribution and/or use of the Program is restricted in+certain countries either by patents or by copyrighted interfaces, the+original copyright holder who places the Program under this License+may add an explicit geographical distribution limitation excluding+those countries, so that distribution is permitted only in or among+countries not thus excluded. In such case, this License incorporates+the limitation as if written in the body of this License.++**9.** The Free Software Foundation may publish revised and/or new+versions of the General Public License from time to time. Such new+versions will be similar in spirit to the present version, but may+differ in detail to address new problems or concerns.++Each version is given a distinguishing version number. If the Program+specifies a version number of this License which applies to it and+"any later version", you have the option of following the terms and+conditions either of that version or of any later version published by+the Free Software Foundation. If the Program does not specify a+version number of this License, you may choose any version ever+published by the Free Software Foundation.++**10.** If you wish to incorporate parts of the Program into other+free programs whose distribution conditions are different, write to+the author to ask for permission. For software which is copyrighted by+the Free Software Foundation, write to the Free Software Foundation;+we sometimes make exceptions for this. Our decision will be guided by+the two goals of preserving the free status of all derivatives of our+free software and of promoting the sharing and reuse of software+generally.++**NO WARRANTY**++**11.** BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO+WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR+OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE+PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.++**12.** IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY+AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE+PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A+FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH+DAMAGES.++### END OF TERMS AND CONDITIONS++### How to Apply These Terms to Your New Programs++If you develop a new program, and you want it to be of the greatest+possible use to the public, the best way to achieve this is to make it+free software which everyone can redistribute and change under these+terms.++To do so, attach the following notices to the program. It is safest to+attach them to the start of each source file to most effectively+convey the exclusion of warranty; and each file should have at least+the "copyright" line and a pointer to where the full notice is found.++ one line to give the program's name and an idea of what it does.+ Copyright (C) yyyy name of author++ This program is free software; you can redistribute it and/or+ modify it under the terms of the GNU General Public License+ as published by the Free Software Foundation; either version 2+ of the License, or (at your option) any later version.++ This program is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ GNU General Public License for more details.++ You should have received a copy of the GNU General Public License+ along with this program; if not, write to the Free Software+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.++Also add information on how to contact you by electronic and paper+mail.++If the program is interactive, make it output a short notice like this+when it starts in an interactive mode:++ Gnomovision version 69, Copyright (C) year name of author+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details+ type `show w'. This is free software, and you are welcome+ to redistribute it under certain conditions; type `show c' + for details.++The hypothetical commands \`show w' and \`show c' should show the+appropriate parts of the General Public License. Of course, the+commands you use may be called something other than \`show w' and+\`show c'; they could even be mouse-clicks or menu items--whatever+suits your program.++You should also get your employer (if you work as a programmer) or+your school, if any, to sign a "copyright disclaimer" for the program,+if necessary. Here is a sample; alter the names:++ Yoyodyne, Inc., hereby disclaims all copyright+ interest in the program `Gnomovision'+ (which makes passes at compilers) written + by James Hacker.++ signature of Ty Coon, 1 April 1989+ Ty Coon, President of Vice++This General Public License does not permit incorporating your program+into proprietary programs. If your program is a subroutine library,+you may consider it more useful to permit linking proprietary+applications with the library. If this is what you want to do, use the+[GNU Lesser General Public+License](http://www.gnu.org/licenses/lgpl.html) instead of this+License.
COPYRIGHT view
@@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -The GNU General Public License is available in the file COPYING in+The GNU General Public License is available in the file COPYING.md in the source distribution. On Debian systems, the complete text of the GPL can be found in `/usr/share/common-licenses/GPL`.
− INSTALL
@@ -1,234 +0,0 @@-% Installing pandoc--These instructions explain how to install pandoc from source.-Binary packages or ports of pandoc are available for freebsd-and several linux distributions, so check your package manager.-There are also binary installers for Windows and Mac OS X.--If you are installing the development version from github, see also:-https://github.com/jgm/pandoc/wiki/Installing-the-development-version-of-pandoc--Quick install with stack---------------------------1. Install [stack](http://docs.haskellstack.org/en/stable/install_and_upgrade.html).--2. If you used git to get the pandoc source (as opposed to unpacking- a release tarball), do-- git submodule update --init--3. In the pandoc source directory,-- stack install-- You may be prompted to run `stack setup`, which will automatically- download the ghc compiler if needed.---Quick install with cabal---------------------------1. Install the [Haskell platform]. This will give you [GHC] and- the [cabal-install] build tool.--2. Update your package database:-- cabal update--3. Use `cabal` to install pandoc and its dependencies:-- cabal install pandoc-- This procedure will install the released version of pandoc,- which will be downloaded automatically from HackageDB.-- If this step fails, and you are using an older version- of the Haskell Platform, e.g. on Debian stable, you may need to- upgrade your version of cabal:-- cabal install cabal-install- ~/.cabal/bin/cabal update- ~/.cabal/bin/cabal install pandoc-- If you want to install a modified or development version- of pandoc instead, switch to the source directory and do- as above, but without the 'pandoc':-- cabal install-- Note: If you obtained the source from the git repository (rather- than a release tarball), you'll need to do-- git submodule update --init-- to fetch the contents of `data/templates` before `cabal install`.--4. Make sure the `$CABALDIR/bin` directory is in your path. You should- now be able to run `pandoc`:-- pandoc --help-- [Not sure where `$CABALDIR` is?](http://www.haskell.org/haskellwiki/Cabal-Install#The_cabal-install_configuration_file)--5. If you want to process citations with pandoc, you will also need to- install a separate package, `pandoc-citeproc`. This can be installed- using cabal:-- cabal install pandoc-citeproc-- By default `pandoc-citeproc` uses the "i;unicode-casemap" method- to sort bibliography entries (RFC 5051). If you would like to- use the locale-sensitive unicode collation algorithm instead,- specify the `unicode_collation` flag:-- cabal install pandoc-citeproc -funicode_collation-- Note that this requires the `text-icu` library, which in turn- depends on the C library `icu4c`. Installation directions- vary by platform. Here is how it might work on OSX with homebrew:-- brew install icu4c- cabal install --extra-lib-dirs=/usr/local/Cellar/icu4c/51.1/lib \- --extra-include-dirs=/usr/local/Cellar/icu4c/51.1/include \- -funicode_collation text-icu pandoc-citeproc--The `pandoc.1` man page will be installed automatically. cabal shows-you where it is installed: you may need to set your `MANPATH`-accordingly. If `README` has been modified, the man page can be-rebuilt: `make man/pandoc.1`.--The `pandoc-citeproc.1` man page will also be installed automatically.--[GHC]: http://www.haskell.org/ghc/-[Haskell platform]: http://hackage.haskell.org/platform/-[cabal-install]: http://hackage.haskell.org/trac/hackage/wiki/CabalInstall--Custom install-----------------This is a step-by-step procedure that offers maximal control-over the build and installation. Most users should use the-quick install, but this information may be of use to packagers.-For more details, see the [Cabal User's Guide]. These instructions-assume that the pandoc source directory is your working directory.--1. Install dependencies: in addition to the [Haskell platform],- you will need a number of additional libraries. You can install- them all with-- cabal update- cabal install --only-dependencies--2. Configure:-- cabal configure --prefix=DIR --bindir=DIR --libdir=DIR \- --datadir=DIR --libsubdir=DIR --datasubdir=DIR --docdir=DIR \- --htmldir=DIR --program-prefix=PREFIX --program-suffix=SUFFIX \- --mandir=DIR --flags=FLAGSPEC-- All of the options have sensible defaults that can be overridden- as needed.-- `FLAGSPEC` is a list of Cabal configuration flags, optionally- preceded by a `-` (to force the flag to `false`), and separated- by spaces. Pandoc's flags include:-- - `embed_data_files`: embed all data files into the binary (default no).- This is helpful if you want to create a relocatable binary.- Note: if this option is selected, you need to install the- `hsb2hs` preprocessor: `cabal install hsb2hs` (version 0.3.1 or- higher is required).-- - `https`: enable support for downloading resources over https- (using the `http-client` and `http-client-tls` libraries).--3. Build:-- cabal build--4. Build API documentation:-- cabal haddock --html-location=URL --hyperlink-source--5. Copy the files:-- cabal copy --destdir=PATH-- The default destdir is `/`.--6. Register pandoc as a GHC package:-- cabal register-- Package managers may want to use the `--gen-script` option to- generate a script that can be run to register the package at- install time.--Creating a relocatable binary--------------------------------It is possible to compile pandoc such that the data files-pandoc uses are embedded in the binary. The resulting binary-can be run from any directory and is completely self-contained.-- cabal install hsb2hs # a required build tool- cabal install --flags="embed_data_files" citeproc-hs- cabal configure --flags="embed_data_files"- cabal build--You can find the pandoc executable in `dist/build/pandoc`. Copy this wherever-you please.--Or alternatively with `stack`:-- stack install pandoc --flag pandoc:embed_data_files--[zip-archive]: http://hackage.haskell.org/package/zip-archive-[highlighting-kate]: http://hackage.haskell.org/package/highlighting-kate-[blaze-html]: http://hackage.haskell.org/package/blaze-html-[Cabal User's Guide]: http://www.haskell.org/cabal/release/latest/doc/users-guide/builders.html#setup-configure-paths--Running tests----------------Pandoc comes with an automated test suite integrated to cabal.-To build the tests:-- cabal configure --enable-tests && cabal build--To run the tests:-- cabal test--To run particular tests (pattern-matching on their names), use-the `-t` option:-- cabal test --test-options='-t markdown'--If you add a new feature to pandoc, please add tests as well, following-the pattern of the existing tests. The test suite code is in-`tests/test-pandoc.hs`. If you are adding a new reader or writer, it is-probably easiest to add some data files to the `tests` directory, and-modify `tests/Tests/Old.hs`. Otherwise, it is better to modify the module-under the `tests/Tests` hierarchy corresponding to the pandoc module you-are changing.--Running benchmarks---------------------To build the benchmarks:-- cabal configure --enable-benchmarks && cabal build--To run the benchmarks:-- cabal bench--To use a smaller sample size so the benchmarks run faster:-- cabal bench --benchmark-options='-s 20'--To run just the markdown benchmarks:-- cabal bench --benchmark-options='markdown'
+ INSTALL.md view
@@ -0,0 +1,339 @@+# Installing pandoc++## Windows++ - There is a package installer at pandoc's [download page].++ - For PDF output, you'll also need to install LaTeX.+ We recommend [MiKTeX](http://miktex.org/).++## Mac OS X++ - There is a package installer at pandoc's [download page].+ If you later want to uninstall the package, you can do so+ by downloading [this script][uninstaller]+ and running it with `perl uninstall-pandoc.pl`.++ - You can also install pandoc using+ [homebrew](http://brew.sh): `brew install pandoc`.++ - For PDF output, you'll also need LaTeX. Because a full [MacTeX]+ installation takes more than a gigabyte of disk space, we recommend+ installing [BasicTeX](http://www.tug.org/mactex/morepackages.html)+ (64M) and using the `tlmgr` tool to install additional packages+ as needed. If you get errors warning of fonts not found, try++ tlmgr install collection-fontsrecommended++## Linux++ - First, try your package manager.+ Pandoc is in the [Debian], [Ubuntu], [Slackware],+ [Arch], [Fedora], [NiXOS], [openSUSE], and [gentoo] repositories.+ Note, however, that versions in the repositories are often+ old.++ - For 64-bit [Debian] and [Ubuntu], we provide a debian package+ on the [download page].++ sudo dpkg -i $DEB++ where `$DEB` is the path to the downloaded deb, will+ will install the `pandoc` and `pandoc-citeproc` executables+ and man pages. If you use an RPM-based distro, you may be+ able to install this deb using `alien`, or try++ ar p $DEB data.tar.gz | sudo tar xvz --strip-components 2 -C /usr/local++ - If you'd rather install pandoc in your home directory, say+ in `$HOME/.local`, then you can extract the files manually+ from the deb:++ ar p $DEB data.tar.gz | tar xvz --strip-components 2 -C $HOME/.local/++ where, again, `$DEB` is the path to the downloaded deb.++ - If the version in your repository is too old and you cannot+ use the deb we provide, you can install from source, using the+ instructions below under [Installing from source].+ Note that most distros have the Haskell platform in their+ package repositories. For example, on Debian/Ubuntu,+ you can install it with `apt-get install haskell-platform`.++ - For PDF output, you'll need LaTeX. We recommend installing+ [TeX Live](http://www.tug.org/texlive/) via your package+ manager. (On Debian/Ubuntu, `apt-get install texlive`.)++## BSD++ - Pandoc is in the [NetBSD] and [FreeBSD ports] repositories.++## Compiling from source++If for some reason a binary package is not available for your+platform, or if you want to hack on pandoc or use a non-released+version, you can install from source.++### Getting the pandoc source code++Source tarballs can be found at+<https://hackage.haskell.org/package/pandoc>. For example, to+fetch the source for version 1.17.0.3:++ wget https://hackage.haskell.org/package/pandoc-1.17.0.3/pandoc-1.17.0.3.tar.gz+ tar xvzf pandoc-1.17.0.3.tar.gz+ cd pandoc-1.17.0.3++Or you can fetch the development code by cloning the repository:++ git clone https://github.com/jgm/pandoc+ cd pandoc+ git submodule update --init # to fetch the templates++Note: there may be times when the development code is broken+or depends on other libraries which must be installed+separately. Unless you really know what you're doing, install+the last released version.++### Quick stack method++The easiest way to build pandoc from source is to use [stack]:++1. Install [stack].++2. Change to the pandoc source directory and issue the following commands:++ stack setup+ stack install --test++ `stack setup` will automatically download the ghc compiler+ if you don't have it. `stack install` will install the+ `pandoc` executable into `~/.local/bin`, which you should+ add to your `PATH`. This process will take a while, and+ will consume a considerable amount of disk space.++### Quick cabal method++1. Install the [Haskell platform]. This will give you [GHC] and+ the [cabal-install] build tool. Note that pandoc requires+ GHC >= 7.8.++2. Update your package database:++ cabal update++3. Use `cabal` to install pandoc and its dependencies:++ cabal install pandoc --enable-tests++ This procedure will install the released version of pandoc,+ which will be downloaded automatically from HackageDB.++ If you want to install a modified or development version+ of pandoc instead, switch to the source directory and do+ as above, but without the 'pandoc':++ cabal install++ Note: If you obtained the source from the git repository (rather+ than a release tarball), you'll need to do++ git submodule update --init++ to fetch the contents of `data/templates` before `cabal install`.++4. Make sure the `$CABALDIR/bin` directory is in your path. You should+ now be able to run `pandoc`:++ pandoc --help++ [Not sure where `$CABALDIR` is?](http://www.haskell.org/haskellwiki/Cabal-Install#The_cabal-install_configuration_file)++5. If you want to process citations with pandoc, you will also need to+ install a separate package, `pandoc-citeproc`. This can be installed+ using cabal:++ cabal install pandoc-citeproc++ By default `pandoc-citeproc` uses the "i;unicode-casemap" method+ to sort bibliography entries (RFC 5051). If you would like to+ use the locale-sensitive unicode collation algorithm instead,+ specify the `unicode_collation` flag:++ cabal install pandoc-citeproc -funicode_collation++ Note that this requires the `text-icu` library, which in turn+ depends on the C library `icu4c`. Installation directions+ vary by platform. Here is how it might work on OSX with homebrew:++ brew install icu4c+ cabal install --extra-lib-dirs=/usr/local/Cellar/icu4c/51.1/lib \+ --extra-include-dirs=/usr/local/Cellar/icu4c/51.1/include \+ -funicode_collation text-icu pandoc-citeproc++6. The `pandoc.1` man page will be installed automatically. cabal shows+ you where it is installed: you may need to set your `MANPATH`+ accordingly. If `MANUAL.txt` has been modified, the man page can be+ rebuilt: `make man/pandoc.1`.++ The `pandoc-citeproc.1` man page will also be installed automatically.+++### Custom cabal method++This is a step-by-step procedure that offers maximal control+over the build and installation. Most users should use the+quick install, but this information may be of use to packagers.+For more details, see the [Cabal User's Guide]. These instructions+assume that the pandoc source directory is your working directory.++1. Install dependencies: in addition to the [Haskell platform],+ you will need a number of additional libraries. You can install+ them all with++ cabal update+ cabal install --only-dependencies++2. Configure:++ cabal configure --prefix=DIR --bindir=DIR --libdir=DIR \+ --datadir=DIR --libsubdir=DIR --datasubdir=DIR --docdir=DIR \+ --htmldir=DIR --program-prefix=PREFIX --program-suffix=SUFFIX \+ --mandir=DIR --flags=FLAGSPEC --enable-tests++ All of the options have sensible defaults that can be overridden+ as needed.++ `FLAGSPEC` is a list of Cabal configuration flags, optionally+ preceded by a `-` (to force the flag to `false`), and separated+ by spaces. Pandoc's flags include:++ - `embed_data_files`: embed all data files into the binary (default no).+ This is helpful if you want to create a relocatable binary.+ Note: if this option is selected, you need to install the+ `hsb2hs` preprocessor: `cabal install hsb2hs` (version 0.3.1 or+ higher is required).++ - `https`: enable support for downloading resources over https+ (using the `http-client` and `http-client-tls` libraries).++3. Build:++ cabal build+ cabal test++4. Build API documentation:++ cabal haddock --html-location=URL --hyperlink-source++5. Copy the files:++ cabal copy --destdir=PATH++ The default destdir is `/`.++6. Register pandoc as a GHC package:++ cabal register++ Package managers may want to use the `--gen-script` option to+ generate a script that can be run to register the package at+ install time.++### Creating a relocatable binary++It is possible to compile pandoc such that the data files+pandoc uses are embedded in the binary. The resulting binary+can be run from any directory and is completely self-contained.+With cabal, add `-fembed_data_files` to the `cabal configure`+or `cabal install` commands.++With stack, use `--flag pandoc:embed_data_files`.++++### Running tests++Pandoc comes with an automated test suite.+To run with cabal, `cabal test`; to run with stack, `stack+test`.++To run particular tests (pattern-matching on their names), use+the `-t` option:++ cabal test --test-options='-t markdown'++If you add a new feature to pandoc, please add tests as well, following+the pattern of the existing tests. The test suite code is in+`tests/test-pandoc.hs`. If you are adding a new reader or writer, it is+probably easiest to add some data files to the `tests` directory, and+modify `tests/Tests/Old.hs`. Otherwise, it is better to modify the module+under the `tests/Tests` hierarchy corresponding to the pandoc module you+are changing.++### Running benchmarks++To build and run the benchmarks:++ cabal configure --enable-benchmarks && cabal build+ cabal bench++or with stack:++ stack bench++To use a smaller sample size so the benchmarks run faster:++ cabal bench --benchmark-options='-s 20'++To run just the markdown benchmarks:++ cabal bench --benchmark-options='markdown'++### Building the whole pandoc ecosystem++Sometimes pandoc's development code depends on unreleased versions+of dependent libraries. You'll need to build these as well. A+maximal build method would be++ mkdir pandoc-build+ cd pandoc-build+ git clone https://github.com/jgm/pandoc-types+ git clone https://github.com/jgm/texmath+ git clone https://github.com/jgm/pandoc-citeproc+ git clone https://github.com/jgm/pandoc+ git clone https://github.com/jgm/cmark-hs+ git clone https://github.com/jgm/zip-archive+ cd pandoc+ git submodule update --init+ stack install --test --install-ghc --stack-yaml stack.full.yaml++To pull in the latest changes, after you've done this and there have been+changes in the repositories: Visit each repository in pandoc-build+(pandoc-types, texmath, pandoc-citeproc, pandoc, zip-archive, cmark-hs) and do+`git pull`. In the pandoc repo, also do `git submodule update` and `stack+install --test --stack-yaml stack.full.yaml`.+++[Arch]: https://www.archlinux.org/packages/community/x86_64/pandoc/+[Cabal User's Guide]: http://www.haskell.org/cabal/release/latest/doc/users-guide/builders.html#setup-configure-paths+[Debian]: http://packages.debian.org/lenny/pandoc+[Fedora]: https://apps.fedoraproject.org/packages/pandoc+[FreeBSD ports]: http://www.freshports.org/textproc/pandoc/+[GHC]: http://www.haskell.org/ghc/+[GPL]: http://www.gnu.org/copyleft/gpl.html+[Haskell platform]: http://hackage.haskell.org/platform/+[MacPorts]: http://trac.macports.org/browser/trunk/dports/textproc/pandoc/Portfile+[MacTeX]: https://tug.org/mactex/+[NetBSD]: http://pkgsrc.se/wip/pandoc+[NixOS]: http://nixos.org/nixos/+[Slackware]: http://www.linuxpackages.net/search_view.php?by=name&name=pandoc&ver=+[Ubuntu]: http://www.ubuntu.com+[download page]: https://github.com/jgm/pandoc/releases/latest+[gentoo]: http://packages.gentoo.org/package/app-text/pandoc+[haskell repository]: https://wiki.archlinux.org/index.php/Haskell_Package_Guidelines#.5Bhaskell.5D+[openSUSE]: https://software.opensuse.org/package/pandoc+[source tarball]: http://hackage.haskell.org/package/pandoc+[stack]: http://docs.haskellstack.org/en/stable/install_and_upgrade.html+[cabal-install]: http://hackage.haskell.org/trac/hackage/wiki/CabalInstall+[uninstaller]: https://raw.githubusercontent.com/jgm/pandoc/master/osx/uninstall-pandoc.pl
+ MANUAL.txt view
@@ -0,0 +1,4164 @@+% Pandoc User's Guide+% John MacFarlane+% October 26, 2016++Synopsis+========++`pandoc` [*options*] [*input-file*]...++Description+===========++Pandoc is a [Haskell] library for converting from one markup format to+another, and a command-line tool that uses this library. It can read+[Markdown], [CommonMark], [PHP Markdown Extra], [GitHub-Flavored Markdown],+[MultiMarkdown], and (subsets of) [Textile], [reStructuredText], [HTML],+[LaTeX], [MediaWiki markup], [TWiki markup], [Haddock markup], [OPML], [Emacs+Org mode], [DocBook], [txt2tags], [EPUB], [ODT] and [Word docx]; and it can+write plain text, [Markdown], [CommonMark], [PHP Markdown Extra],+[GitHub-Flavored Markdown], [MultiMarkdown], [reStructuredText], [XHTML],+[HTML5], [LaTeX] \(including [`beamer`] slide shows\), [ConTeXt], [RTF], [OPML],+[DocBook], [OpenDocument], [ODT], [Word docx], [GNU Texinfo], [MediaWiki+markup], [DokuWiki markup], [ZimWiki markup], [Haddock markup],+[EPUB] \(v2 or v3\), [FictionBook2], [Textile], [groff man] pages,+[Emacs Org mode], [AsciiDoc], [InDesign ICML], [TEI Simple], and [Slidy],+[Slideous], [DZSlides], [reveal.js] or [S5] HTML slide shows. It can also+produce [PDF] output on systems where LaTeX, ConTeXt, or `wkhtmltopdf` is+installed.++Pandoc's enhanced version of Markdown includes syntax for [footnotes],+[tables], flexible [ordered lists], [definition lists], [fenced code blocks],+[superscripts and subscripts], [strikeout], [metadata blocks], automatic tables of+contents, embedded LaTeX [math], [citations], and [Markdown inside HTML block+elements][Extension: `markdown_in_html_blocks`]. (These enhancements, described+further under [Pandoc's Markdown], can be disabled using the+`markdown_strict` input or output format.)++In contrast to most existing tools for converting Markdown to HTML, which+use regex substitutions, pandoc has a modular design: it consists of a+set of readers, which parse text in a given format and produce a native+representation of the document, and a set of writers, which convert+this native representation into a target format. Thus, adding an input+or output format requires only adding a reader or writer.++Because pandoc's intermediate representation of a document is less+expressive than many of the formats it converts between, one should+not expect perfect conversions between every format and every other.+Pandoc attempts to preserve the structural elements of a document, but+not formatting details such as margin size. And some document elements,+such as complex tables, may not fit into pandoc's simple document+model. While conversions from pandoc's Markdown to all formats aspire+to be perfect, conversions from formats more expressive than pandoc's+Markdown can be expected to be lossy.++[Markdown]: http://daringfireball.net/projects/markdown/+[CommonMark]: http://commonmark.org+[PHP Markdown Extra]: https://michelf.ca/projects/php-markdown/extra/+[GitHub-Flavored Markdown]: https://help.github.com/articles/github-flavored-markdown/+[MultiMarkdown]: http://fletcherpenney.net/multimarkdown/+[reStructuredText]: http://docutils.sourceforge.net/docs/ref/rst/introduction.html+[S5]: http://meyerweb.com/eric/tools/s5/+[Slidy]: http://www.w3.org/Talks/Tools/Slidy/+[Slideous]: http://goessner.net/articles/slideous/+[HTML]: http://www.w3.org/html/+[HTML5]: http://www.w3.org/TR/html5/+[XHTML]: http://www.w3.org/TR/xhtml1/+[LaTeX]: http://latex-project.org+[`beamer`]: https://ctan.org/pkg/beamer+[Beamer User's Guide]: http://ctan.math.utah.edu/ctan/tex-archive/macros/latex/contrib/beamer/doc/beameruserguide.pdf+[ConTeXt]: http://contextgarden.net/+[RTF]: http://en.wikipedia.org/wiki/Rich_Text_Format+[DocBook]: http://docbook.org+[txt2tags]: http://txt2tags.org+[EPUB]: http://idpf.org/epub+[OPML]: http://dev.opml.org/spec2.html+[OpenDocument]: http://opendocument.xml.org+[ODT]: http://en.wikipedia.org/wiki/OpenDocument+[Textile]: http://redcloth.org/textile+[MediaWiki markup]: https://www.mediawiki.org/wiki/Help:Formatting+[DokuWiki markup]: https://www.dokuwiki.org/dokuwiki+[ZimWiki markup]: http://zim-wiki.org/manual/Help/Wiki_Syntax.html+[TWiki markup]: http://twiki.org/cgi-bin/view/TWiki/TextFormattingRules+[Haddock markup]: https://www.haskell.org/haddock/doc/html/ch03s08.html+[groff man]: http://developer.apple.com/DOCUMENTATION/Darwin/Reference/ManPages/man7/groff_man.7.html+[Haskell]: https://www.haskell.org+[GNU Texinfo]: http://www.gnu.org/software/texinfo/+[Emacs Org mode]: http://orgmode.org+[AsciiDoc]: http://www.methods.co.nz/asciidoc/+[DZSlides]: http://paulrouget.com/dzslides/+[Word docx]: http://www.microsoft.com/interop/openup/openxml/default.aspx+[PDF]: https://www.adobe.com/pdf/+[reveal.js]: http://lab.hakim.se/reveal-js/+[FictionBook2]: http://www.fictionbook.org/index.php/Eng:XML_Schema_Fictionbook_2.1+[InDesign ICML]: https://www.adobe.com/content/dam/Adobe/en/devnet/indesign/cs55-docs/IDML/idml-specification.pdf+[TEI Simple]: https://github.com/TEIC/TEI-Simple++Using `pandoc`+--------------++If no *input-file* is specified, input is read from *stdin*.+Otherwise, the *input-files* are concatenated (with a blank+line between each) and used as input. Output goes to *stdout* by+default (though output to *stdout* is disabled for the `odt`, `docx`,+`epub`, and `epub3` output formats). For output to a file, use the+`-o` option:++ pandoc -o output.html input.txt++By default, pandoc produces a document fragment, not a standalone+document with a proper header and footer. To produce a standalone+document, use the `-s` or `--standalone` flag:++ pandoc -s -o output.html input.txt++For more information on how standalone documents are produced, see+[Templates], below.++Instead of a file, an absolute URI may be given. In this case+pandoc will fetch the content using HTTP:++ pandoc -f html -t markdown http://www.fsf.org++If multiple input files are given, `pandoc` will concatenate them all (with+blank lines between them) before parsing. This feature is disabled for+ binary input formats such as `EPUB`, `odt`, and `docx`.++The format of the input and output can be specified explicitly using+command-line options. The input format can be specified using the+`-r/--read` or `-f/--from` options, the output format using the+`-w/--write` or `-t/--to` options. Thus, to convert `hello.txt` from+Markdown to LaTeX, you could type:++ pandoc -f markdown -t latex hello.txt++To convert `hello.html` from HTML to Markdown:++ pandoc -f html -t markdown hello.html++Supported output formats are listed below under the `-t/--to` option.+Supported input formats are listed below under the `-f/--from` option. Note+that the `rst`, `textile`, `latex`, and `html` readers are not complete;+there are some constructs that they do not parse.++If the input or output format is not specified explicitly, `pandoc`+will attempt to guess it from the extensions of+the input and output filenames. Thus, for example,++ pandoc -o hello.tex hello.txt++will convert `hello.txt` from Markdown to LaTeX. If no output file+is specified (so that output goes to *stdout*), or if the output file's+extension is unknown, the output format will default to HTML.+If no input file is specified (so that input comes from *stdin*), or+if the input files' extensions are unknown, the input format will+be assumed to be Markdown unless explicitly specified.++Pandoc uses the UTF-8 character encoding for both input and output.+If your local character encoding is not UTF-8, you+should pipe input and output through [`iconv`]:++ iconv -t utf-8 input.txt | pandoc | iconv -f utf-8++Note that in some output formats (such as HTML, LaTeX, ConTeXt,+RTF, OPML, DocBook, and Texinfo), information about+the character encoding is included in the document header, which+will only be included if you use the `-s/--standalone` option.++[`iconv`]: http://www.gnu.org/software/libiconv/++Creating a PDF+--------------++To produce a PDF, specify an output file with a `.pdf` extension.+By default, pandoc will use LaTeX to convert it to PDF:++ pandoc test.txt -o test.pdf++Production of a PDF requires that a LaTeX engine be installed (see+`--latex-engine`, below), and assumes that the following LaTeX packages+are available: [`amsfonts`], [`amsmath`], [`lm`],+[`ifxetex`], [`ifluatex`], [`eurosym`], [`listings`] (if the+`--listings` option is used), [`fancyvrb`], [`longtable`],+[`booktabs`], [`graphicx`] and [`grffile`] (if the+document contains images), [`hyperref`], [`ulem`],+[`geometry`] (with the `geometry` variable set), [`setspace`] (with+`linestretch`), and [`babel`] (with `lang`). The use of `xelatex` or+`lualatex` as the LaTeX engine requires [`fontspec`]; `xelatex` uses+[`mathspec`], [`polyglossia`] (with `lang`), [`xecjk`], and+[`bidi`] (with the `dir` variable set). The [`upquote`] and+[`microtype`] packages are used if available, and [`csquotes`] will+be used for [smart punctuation] if added to the template or included in+any header file. The [`natbib`], [`biblatex`], [`bibtex`], and [`biber`]+packages can optionally be used for [citation rendering]. These are+included with all recent versions of [TeX Live].++Alternatively, pandoc can use ConTeXt or `wkhtmltopdf` to create a PDF.+To do this, specify an output file with a `.pdf` extension,+as before, but add `-t context` or `-t html5` to the command line.++PDF output can be controlled using [variables for LaTeX] (if+LaTeX is used) and [variables for ConTeXt] (if ConTeXt is used).+If `wkhtmltopdf` is used, then the variables `margin-left`,+`margin-right`, `margin-top`, `margin-bottom`, and `papersize`+will affect the output, as will `--css`.++[`amsfonts`]: https://ctan.org/pkg/amsfonts+[`amsmath`]: https://ctan.org/pkg/amsmath+[`lm`]: https://ctan.org/pkg/lm+[`ifxetex`]: https://ctan.org/pkg/ifxetex+[`ifluatex`]: https://ctan.org/pkg/ifluatex+[`eurosym`]: https://ctan.org/pkg/eurosym+[`listings`]: https://ctan.org/pkg/listings+[`fancyvrb`]: https://ctan.org/pkg/fancyvrb+[`longtable`]: https://ctan.org/pkg/longtable+[`booktabs`]: https://ctan.org/pkg/booktabs+[`graphicx`]: https://ctan.org/pkg/graphicx+[`grffile`]: https://ctan.org/pkg/grffile+[`geometry`]: https://ctan.org/pkg/geometry+[`setspace`]: https://ctan.org/pkg/setspace+[`xecjk`]: https://ctan.org/pkg/xecjk+[`hyperref`]: https://ctan.org/pkg/hyperref+[`ulem`]: https://ctan.org/pkg/ulem+[`babel`]: https://ctan.org/pkg/babel+[`bidi`]: https://ctan.org/pkg/bidi+[`mathspec`]: https://ctan.org/pkg/mathspec+[`polyglossia`]: https://ctan.org/pkg/polyglossia+[`fontspec`]: https://ctan.org/pkg/fontspec+[`upquote`]: https://ctan.org/pkg/upquote+[`microtype`]: https://ctan.org/pkg/microtype+[`csquotes`]: https://ctan.org/pkg/csquotes+[`natbib`]: https://ctan.org/pkg/natbib+[`biblatex`]: https://ctan.org/pkg/biblatex+[`bibtex`]: https://ctan.org/pkg/bibtex+[`biber`]: https://ctan.org/pkg/biber+[TeX Live]: http://www.tug.org/texlive/++Options+=======++General options+---------------++`-f` *FORMAT*, `-r` *FORMAT*, `--from=`*FORMAT*, `--read=`*FORMAT*++: Specify input format. *FORMAT* can be `native` (native Haskell),+ `json` (JSON version of native AST), `markdown` (pandoc's+ extended Markdown), `markdown_strict` (original unextended+ Markdown), `markdown_phpextra` (PHP Markdown Extra), `markdown_github`+ (GitHub-Flavored Markdown), `markdown_mmd` (MultiMarkdown),+ `commonmark` (CommonMark Markdown), `textile` (Textile), `rst`+ (reStructuredText), `html` (HTML), `docbook` (DocBook), `t2t`+ (txt2tags), `docx` (docx), `odt` (ODT), `epub` (EPUB), `opml` (OPML),+ `org` (Emacs Org mode), `mediawiki` (MediaWiki markup), `twiki` (TWiki+ markup), `haddock` (Haddock markup), or `latex` (LaTeX). If+ `+lhs` is appended to `markdown`, `rst`, `latex`, or `html`, the+ input will be treated as literate Haskell source: see [Literate+ Haskell support], below. Markdown+ syntax extensions can be individually enabled or disabled by+ appending `+EXTENSION` or `-EXTENSION` to the format name. So, for+ example, `markdown_strict+footnotes+definition_lists` is strict+ Markdown with footnotes and definition lists enabled, and+ `markdown-pipe_tables+hard_line_breaks` is pandoc's Markdown+ without pipe tables and with hard line breaks. See [Pandoc's+ Markdown], below, for a list of extensions and+ their names. See `--list-input-formats` and `--list-extensions`,+ below.++`-t` *FORMAT*, `-w` *FORMAT*, `--to=`*FORMAT*, `--write=`*FORMAT*++: Specify output format. *FORMAT* can be `native` (native Haskell),+ `json` (JSON version of native AST), `plain` (plain text),+ `markdown` (pandoc's extended Markdown), `markdown_strict`+ (original unextended Markdown), `markdown_phpextra` (PHP Markdown+ Extra), `markdown_github` (GitHub-Flavored Markdown), `markdown_mmd`+ (MultiMarkdown), `commonmark` (CommonMark Markdown), `rst`+ (reStructuredText), `html` (XHTML), `html5` (HTML5), `latex`+ (LaTeX), `beamer` (LaTeX beamer slide show), `context` (ConTeXt),+ `man` (groff man), `mediawiki` (MediaWiki markup),+ `dokuwiki` (DokuWiki markup), `zimwiki` (ZimWiki markup),+ `textile` (Textile), `org` (Emacs Org mode),+ `texinfo` (GNU Texinfo), `opml` (OPML), `docbook` (DocBook 4),+ `docbook5` (DocBook 5), `opendocument` (OpenDocument), `odt`+ (OpenOffice text document), `docx` (Word docx), `haddock`+ (Haddock markup), `rtf` (rich text format), `epub` (EPUB v2+ book), `epub3` (EPUB v3), `fb2` (FictionBook2 e-book),+ `asciidoc` (AsciiDoc), `icml` (InDesign ICML), `tei` (TEI+ Simple), `slidy` (Slidy HTML and javascript slide show),+ `slideous` (Slideous HTML and javascript slide show),+ `dzslides` (DZSlides HTML5 + javascript slide show),+ `revealjs` (reveal.js HTML5 + javascript slide show), `s5`+ (S5 HTML and javascript slide show), or the path of a custom+ lua writer (see [Custom writers], below). Note that `odt`,+ `epub`, and `epub3` output will not be directed to *stdout*;+ an output filename must be specified using the `-o/--output`+ option. If `+lhs` is appended to `markdown`, `rst`, `latex`,+ `beamer`, `html`, or `html5`, the output will be rendered as+ literate Haskell source: see [Literate Haskell support],+ below. Markdown syntax extensions can be individually+ enabled or disabled by appending `+EXTENSION` or+ `-EXTENSION` to the format name, as described above under `-f`.+ See `--list-output-formats` and `--list-extensions`, below.++`-o` *FILE*, `--output=`*FILE*++: Write output to *FILE* instead of *stdout*. If *FILE* is+ `-`, output will go to *stdout*. (Exception: if the output+ format is `odt`, `docx`, `epub`, or `epub3`, output to stdout is disabled.)++`--data-dir=`*DIRECTORY*++: Specify the user data directory to search for pandoc data files.+ If this option is not specified, the default user data directory+ will be used. This is, in Unix:++ $HOME/.pandoc++ in Windows XP:++ C:\Documents And Settings\USERNAME\Application Data\pandoc++ and in Windows Vista or later:++ C:\Users\USERNAME\AppData\Roaming\pandoc++ You can find the default user data directory on your system by+ looking at the output of `pandoc --version`.+ A `reference.odt`, `reference.docx`, `epub.css`, `templates`,+ `slidy`, `slideous`, or `s5` directory+ placed in this directory will override pandoc's normal defaults.++`--bash-completion`++: Generate a bash completion script. To enable bash completion+ with pandoc, add this to your `.bashrc`:++ eval "$(pandoc --bash-completion)"++`--verbose`++: Give verbose debugging output. Currently this only has an effect+ with PDF output.++`--list-input-formats`++: List supported input formats, one per line.++`--list-output-formats`++: List supported output formats, one per line.++`--list-extensions`++: List supported Markdown extensions, one per line, followed+ by a `+` or `-` indicating whether it is enabled by default+ in pandoc's Markdown.++`--list-highlight-languages`++: List supported languages for syntax highlighting, one per+ line.++`--list-highlight-styles`++: List supported styles for syntax highlighting, one per line.+ See `--highlight-style`.++`-v`, `--version`++: Print version.++`-h`, `--help`++: Show usage message.++Reader options+--------------++`-R`, `--parse-raw`++: Parse untranslatable HTML codes and LaTeX environments as raw HTML+ or LaTeX, instead of ignoring them. Affects only HTML and LaTeX+ input. Raw HTML can be printed in Markdown, reStructuredText, Emacs Org+ mode, HTML, Slidy, Slideous, DZSlides, reveal.js, and S5 output; raw LaTeX+ can be printed in Markdown, reStructuredText, Emacs Org mode, LaTeX, and+ ConTeXt output. The default is for the readers to omit untranslatable+ HTML codes and LaTeX environments. (The LaTeX reader does pass through+ untranslatable LaTeX *commands*, even if `-R` is not specified.)++`-S`, `--smart`++: Produce typographically correct output, converting straight quotes+ to curly quotes, `---` to em-dashes, `--` to en-dashes, and+ `...` to ellipses. Nonbreaking spaces are inserted after certain+ abbreviations, such as "Mr." (Note: This option is selected automatically+ when the output format is `latex` or `context`, unless `--no-tex-ligatures`+ is used. It has no effect for `latex` input.)++`--old-dashes`++: Selects the pandoc <= 1.8.2.1 behavior for parsing smart dashes: `-` before+ a numeral is an en-dash, and `--` is an em-dash. This option is selected+ automatically for `textile` input.++`--base-header-level=`*NUMBER*++: Specify the base level for headers (defaults to 1).++`--indented-code-classes=`*CLASSES*++: Specify classes to use for indented code blocks--for example,+ `perl,numberLines` or `haskell`. Multiple classes may be separated+ by spaces or commas.++`--default-image-extension=`*EXTENSION*++: Specify a default extension to use when image paths/URLs have no+ extension. This allows you to use the same source for formats that+ require different kinds of images. Currently this option only affects+ the Markdown and LaTeX readers.++`--file-scope`++: Parse each file individually before combining for multifile+ documents. This will allow footnotes in different files with the+ same identifiers to work as expected. If this option is set,+ footnotes and links will not work across files. Reading binary+ files (docx, odt, epub) implies `--file-scope`.++`--filter=`*EXECUTABLE*++: Specify an executable to be used as a filter transforming the+ pandoc AST after the input is parsed and before the output is+ written. The executable should read JSON from stdin and write+ JSON to stdout. The JSON must be formatted like pandoc's own+ JSON input and output. The name of the output format will be+ passed to the filter as the first argument. Hence,++ pandoc --filter ./caps.py -t latex++ is equivalent to++ pandoc -t json | ./caps.py latex | pandoc -f json -t latex++ The latter form may be useful for debugging filters.++ Filters may be written in any language. `Text.Pandoc.JSON`+ exports `toJSONFilter` to facilitate writing filters in Haskell.+ Those who would prefer to write filters in python can use the+ module [`pandocfilters`], installable from PyPI. There are also+ pandoc filter libraries in [PHP], [perl], and+ [javascript/node.js].++ If no directory is provided pandoc will look for executable or+ non-executable filters in the director `$DATADIR/filters`, and+ then for executable filters in the user's `PATH`. If you want to+ run a script in the working directory, preface the filename with+ `./`.++ In order of preference, pandoc will look for filters in++ 1. a specified full or relative path (executable or+ non-executable)++ 2. `$DATADIR/filters` (executable or non-executable)++ 3. `$PATH` (executable only)++`-M` *KEY*[`=`*VAL*], `--metadata=`*KEY*[`:`*VAL*]++: Set the metadata field *KEY* to the value *VAL*. A value specified+ on the command line overrides a value specified in the document.+ Values will be parsed as YAML boolean or string values. If no value is+ specified, the value will be treated as Boolean true. Like+ `--variable`, `--metadata` causes template variables to be set.+ But unlike `--variable`, `--metadata` affects the metadata of the+ underlying document (which is accessible from filters and may be+ printed in some output formats).++`--normalize`++: Normalize the document after reading: merge adjacent+ `Str` or `Emph` elements, for example, and remove repeated `Space`s.++`-p`, `--preserve-tabs`++: Preserve tabs instead of converting them to spaces (the default).+ Note that this will only affect tabs in literal code spans and code+ blocks; tabs in regular text will be treated as spaces.++`--tab-stop=`*NUMBER*++: Specify the number of spaces per tab (default is 4).++`--track-changes=accept`|`reject`|`all`++: Specifies what to do with insertions, deletions, and comments+ produced by the MS Word "Track Changes" feature. `accept` (the+ default), inserts all insertions, and ignores all+ deletions. `reject` inserts all deletions and ignores+ insertions. Both `accept` and `reject` ignore comments. `all` puts+ in insertions, deletions, and comments, wrapped in spans with+ `insertion`, `deletion`, `comment-start`, and `comment-end`+ classes, respectively. The author and time of change is+ included. `all` is useful for scripting: only accepting changes+ from a certain reviewer, say, or before a certain date. This+ option only affects the docx reader.++`--extract-media=`*DIR*++: Extract images and other media contained in a docx or epub container+ to the path *DIR*, creating it if necessary, and adjust the images+ references in the document so they point to the extracted files.+ This option only affects the docx and epub readers.++[`pandocfilters`]: https://github.com/jgm/pandocfilters+[PHP]: https://github.com/vinai/pandocfilters-php+[perl]: https://metacpan.org/pod/Pandoc::Filter+[javascript/node.js]: https://github.com/mvhenderson/pandoc-filter-node++General writer options+----------------------++`-s`, `--standalone`++: Produce output with an appropriate header and footer (e.g. a+ standalone HTML, LaTeX, TEI, or RTF file, not a fragment). This option+ is set automatically for `pdf`, `epub`, `epub3`, `fb2`, `docx`, and `odt`+ output.++`--template=`*FILE*++: Use *FILE* as a custom template for the generated document. Implies+ `--standalone`. See [Templates], below, for a description+ of template syntax. If no extension is specified, an extension+ corresponding to the writer will be added, so that `--template=special`+ looks for `special.html` for HTML output. If the template is not+ found, pandoc will search for it in the `templates` subdirectory of+ the user data directory (see `--data-dir`). If this option is not used,+ a default template appropriate for the output format will be used (see+ `-D/--print-default-template`).++`-V` *KEY*[`=`*VAL*], `--variable=`*KEY*[`:`*VAL*]++: Set the template variable *KEY* to the value *VAL* when rendering the+ document in standalone mode. This is generally only useful when the+ `--template` option is used to specify a custom template, since+ pandoc automatically sets the variables used in the default+ templates. If no *VAL* is specified, the key will be given the+ value `true`.++`-D` *FORMAT*, `--print-default-template=`*FORMAT*++: Print the system default template for an output *FORMAT*. (See `-t`+ for a list of possible *FORMAT*s.) Templates in the user data+ directory are ignored.++`--print-default-data-file=`*FILE*++: Print a system default data file. Files in the user data directory+ are ignored.++`--dpi`=*NUMBER*+: Specify the dpi (dots per inch) value for conversion from pixels+ to inch/centimeters and vice versa. The default is 96dpi.+ Technically, the correct term would be ppi (pixels per inch).++`--wrap=auto`|`none`|`preserve`++: Determine how text is wrapped in the output (the source+ code, not the rendered version). With `auto` (the default),+ pandoc will attempt to wrap lines to the column width specified by+ `--columns` (default 80). With `none`, pandoc will not wrap+ lines at all. With `preserve`, pandoc will attempt to+ preserve the wrapping from the source document (that is,+ where there are nonsemantic newlines in the source, there+ will be nonsemantic newlines in the output as well).++`--no-wrap`++: Deprecated synonym for `--wrap=none`.++`--columns=`*NUMBER*++: Specify length of lines in characters. This affects text wrapping+ in the generated source code (see `--wrap`). It also affects+ calculation of column widths for plain text tables (see [Tables] below).++`--toc`, `--table-of-contents`++: Include an automatically generated table of contents (or, in+ the case of `latex`, `context`, `docx`, and `rst`, an instruction to create+ one) in the output document. This option has no effect on `man`,+ `docbook`, `docbook5`, `slidy`, `slideous`, `s5`, or `odt` output.++`--toc-depth=`*NUMBER*++: Specify the number of section levels to include in the table+ of contents. The default is 3 (which means that level 1, 2, and 3+ headers will be listed in the contents).++`--no-highlight`++: Disables syntax highlighting for code blocks and inlines, even when+ a language attribute is given.++`--highlight-style=`*STYLE*++: Specifies the coloring style to be used in highlighted source code.+ Options are `pygments` (the default), `kate`, `monochrome`,+ `espresso`, `zenburn`, `haddock`, and `tango`. For more information+ on syntax highlighting in pandoc, see [Syntax highlighting], below.+ See also `--list-highlight-styles`.++`-H` *FILE*, `--include-in-header=`*FILE*++: Include contents of *FILE*, verbatim, at the end of the header.+ This can be used, for example, to include special+ CSS or javascript in HTML documents. This option can be used+ repeatedly to include multiple files in the header. They will be+ included in the order specified. Implies `--standalone`.++`-B` *FILE*, `--include-before-body=`*FILE*++: Include contents of *FILE*, verbatim, at the beginning of the+ document body (e.g. after the `<body>` tag in HTML, or the+ `\begin{document}` command in LaTeX). This can be used to include+ navigation bars or banners in HTML documents. This option can be+ used repeatedly to include multiple files. They will be included in+ the order specified. Implies `--standalone`.++`-A` *FILE*, `--include-after-body=`*FILE*++: Include contents of *FILE*, verbatim, at the end of the document+ body (before the `</body>` tag in HTML, or the+ `\end{document}` command in LaTeX). This option can be used+ repeatedly to include multiple files. They will be included in the+ order specified. Implies `--standalone`.++Options affecting specific writers+----------------------------------++`--self-contained`++: Produce a standalone HTML file with no external dependencies, using+ `data:` URIs to incorporate the contents of linked scripts, stylesheets,+ images, and videos. The resulting file should be "self-contained,"+ in the sense that it needs no external files and no net access to be+ displayed properly by a browser. This option works only with HTML output+ formats, including `html`, `html5`, `html+lhs`, `html5+lhs`, `s5`,+ `slidy`, `slideous`, `dzslides`, and `revealjs`. Scripts, images, and+ stylesheets at absolute URLs will be downloaded; those at relative URLs+ will be sought relative to the working directory (if the first source+ file is local) or relative to the base URL (if the first source+ file is remote). Limitation: resources that are loaded dynamically+ through JavaScript cannot be incorporated; as a result, `--self-contained`+ does not work with `--mathjax`, and some advanced features (e.g.+ zoom or speaker notes) may not work in an offline "self-contained"+ `reveal.js` slide show.++`--html-q-tags`++: Use `<q>` tags for quotes in HTML.++`--ascii`++: Use only ascii characters in output. Currently supported only+ for HTML output (which uses numerical entities instead of+ UTF-8 when this option is selected).++`--reference-links`++: Use reference-style links, rather than inline links, in writing Markdown+ or reStructuredText. By default inline links are used. The+ placement of link references is affected by the+ `--reference-location` option.++`--reference-location = block`|`section`|`document`++: Specify whether footnotes (and references, if `reference-links` is+ set) are placed at the end of the current (top-level) block, the+ current section, or the document. The default is+ `document`. Currently only affects the markdown writer.++`--atx-headers`++: Use ATX-style headers in Markdown and asciidoc output. The default is+ to use setext-style headers for levels 1-2, and then ATX headers.++`--chapters`++: Deprecated synonym for `--top-level-division=chapter`.++`--top-level-division=[section|chapter|part]`++: Treat top-level headers as the given division type in LaTeX, ConTeXt,+ DocBook, and TEI output. The hierarchy order is part, chapter, then section;+ all headers are shifted such that the top-level header becomes the specified+ type. The default is `section`. When the LaTeX document class is set to+ `report`, `book`, or `memoir` (unless the `article` option is specified),+ `chapter` is implied as the setting for this option. If `beamer` is the+ output format, specifying either `chapter` or `part` will cause top-level+ headers to become `\part{..}`, while second-level headers remain as their+ default type.++`-N`, `--number-sections`++: Number section headings in LaTeX, ConTeXt, HTML, or EPUB output.+ By default, sections are not numbered. Sections with class+ `unnumbered` will never be numbered, even if `--number-sections`+ is specified.++`--number-offset=`*NUMBER*[`,`*NUMBER*`,`*...*]++: Offset for section headings in HTML output (ignored in other+ output formats). The first number is added to the section number for+ top-level headers, the second for second-level headers, and so on.+ So, for example, if you want the first top-level header in your+ document to be numbered "6", specify `--number-offset=5`.+ If your document starts with a level-2 header which you want to+ be numbered "1.5", specify `--number-offset=1,4`.+ Offsets are 0 by default. Implies `--number-sections`.++`--no-tex-ligatures`++: Do not use the TeX ligatures for quotation marks, apostrophes,+ and dashes (`` `...' ``, ` ``..'' `, `--`, `---`) when+ writing or reading LaTeX or ConTeXt. In reading LaTeX,+ parse the characters `` ` ``, `'`, and `-` literally, rather+ than parsing ligatures for quotation marks and dashes. In+ writing LaTeX or ConTeXt, print unicode quotation mark and+ dash characters literally, rather than converting them to+ the standard ASCII TeX ligatures. Note: normally `--smart`+ is selected automatically for LaTeX and ConTeXt output, but+ it must be specified explicitly if `--no-tex-ligatures` is+ selected. If you use literal curly quotes, dashes, and+ ellipses in your source, then you may want to use+ `--no-tex-ligatures` without `--smart`.++`--listings`++: Use the [`listings`] package for LaTeX code blocks++`-i`, `--incremental`++: Make list items in slide shows display incrementally (one by one).+ The default is for lists to be displayed all at once.++`--slide-level=`*NUMBER*++: Specifies that headers with the specified level create+ slides (for `beamer`, `s5`, `slidy`, `slideous`, `dzslides`). Headers+ above this level in the hierarchy are used to divide the+ slide show into sections; headers below this level create+ subheads within a slide. The default is to set the slide level+ based on the contents of the document; see+ [Structuring the slide show].++`--section-divs`++: Wrap sections in `<div>` tags (or `<section>` tags in HTML5),+ and attach identifiers to the enclosing `<div>` (or `<section>`)+ rather than the header itself. See+ [Header identifiers], below.++`--email-obfuscation=none`|`javascript`|`references`++: Specify a method for obfuscating `mailto:` links in HTML documents.+ `none` leaves `mailto:` links as they are. `javascript` obfuscates+ them using javascript. `references` obfuscates them by printing their+ letters as decimal or hexadecimal character references. The default+ is `none`.++`--id-prefix=`*STRING*++: Specify a prefix to be added to all automatically generated identifiers+ in HTML and DocBook output, and to footnote numbers in Markdown output.+ This is useful for preventing duplicate identifiers when generating+ fragments to be included in other pages.++`-T` *STRING*, `--title-prefix=`*STRING*++: Specify *STRING* as a prefix at the beginning of the title+ that appears in the HTML header (but not in the title as it+ appears at the beginning of the HTML body). Implies+ `--standalone`.++`-c` *URL*, `--css=`*URL*++: Link to a CSS style sheet. This option can be used repeatedly to+ include multiple files. They will be included in the order specified.++`--reference-odt=`*FILE*++: Use the specified file as a style reference in producing an ODT.+ For best results, the reference ODT should be a modified version+ of an ODT produced using pandoc. The contents of the reference ODT+ are ignored, but its stylesheets are used in the new ODT. If no+ reference ODT is specified on the command line, pandoc will look+ for a file `reference.odt` in the user data directory (see+ `--data-dir`). If this is not found either, sensible defaults will be+ used.++`--reference-docx=`*FILE*++: Use the specified file as a style reference in producing a docx file.+ For best results, the reference docx should be a modified version+ of a docx file produced using pandoc. The contents of the reference docx+ are ignored, but its stylesheets and document properties (including+ margins, page size, header, and footer) are used in the new docx. If no+ reference docx is specified on the command line, pandoc will look+ for a file `reference.docx` in the user data directory (see+ `--data-dir`). If this is not found either, sensible defaults will be+ used. The following styles are used by pandoc: [paragraph]+ Normal, Body Text, First Paragraph, Compact, Title, Subtitle, Author, Date,+ Abstract, Bibliography, Heading 1, Heading 2, Heading 3, Heading 4,+ Heading 5, Heading 6, Block Text, Footnote Text, Definition Term,+ Definition, Caption, Table Caption, Image Caption, Figure,+ Figure With Caption, TOC Heading;+ [character] Default Paragraph Font, Body Text Char, Verbatim Char,+ Footnote Reference, Hyperlink; [table] Normal Table.++`--epub-stylesheet=`*FILE*++: Use the specified CSS file to style the EPUB. If no stylesheet+ is specified, pandoc will look for a file `epub.css` in the+ user data directory (see `--data-dir`). If it is not+ found there, sensible defaults will be used.++`--epub-cover-image=`*FILE*++: Use the specified image as the EPUB cover. It is recommended+ that the image be less than 1000px in width and height. Note that+ in a Markdown source document you can also specify `cover-image`+ in a YAML metadata block (see [EPUB Metadata], below).++`--epub-metadata=`*FILE*++: Look in the specified XML file for metadata for the EPUB.+ The file should contain a series of [Dublin Core elements].+ For example:++ <dc:rights>Creative Commons</dc:rights>+ <dc:language>es-AR</dc:language>++ By default, pandoc will include the following metadata elements:+ `<dc:title>` (from the document title), `<dc:creator>` (from the+ document authors), `<dc:date>` (from the document date, which should+ be in [ISO 8601 format]), `<dc:language>` (from the `lang`+ variable, or, if is not set, the locale), and `<dc:identifier+ id="BookId">` (a randomly generated UUID). Any of these may be+ overridden by elements in the metadata file.++ Note: if the source document is Markdown, a YAML metadata block+ in the document can be used instead. See below under+ [EPUB Metadata].++`--epub-embed-font=`*FILE*++: Embed the specified font in the EPUB. This option can be repeated+ to embed multiple fonts. Wildcards can also be used: for example,+ `DejaVuSans-*.ttf`. However, if you use wildcards on the command+ line, be sure to escape them or put the whole filename in single quotes,+ to prevent them from being interpreted by the shell. To use the+ embedded fonts, you will need to add declarations like the following+ to your CSS (see `--epub-stylesheet`):++ @font-face {+ font-family: DejaVuSans;+ font-style: normal;+ font-weight: normal;+ src:url("DejaVuSans-Regular.ttf");+ }+ @font-face {+ font-family: DejaVuSans;+ font-style: normal;+ font-weight: bold;+ src:url("DejaVuSans-Bold.ttf");+ }+ @font-face {+ font-family: DejaVuSans;+ font-style: italic;+ font-weight: normal;+ src:url("DejaVuSans-Oblique.ttf");+ }+ @font-face {+ font-family: DejaVuSans;+ font-style: italic;+ font-weight: bold;+ src:url("DejaVuSans-BoldOblique.ttf");+ }+ body { font-family: "DejaVuSans"; }++`--epub-chapter-level=`*NUMBER*++: Specify the header level at which to split the EPUB into separate+ "chapter" files. The default is to split into chapters at level 1+ headers. This option only affects the internal composition of the+ EPUB, not the way chapters and sections are displayed to users. Some+ readers may be slow if the chapter files are too large, so for large+ documents with few level 1 headers, one might want to use a chapter+ level of 2 or 3.++`--latex-engine=pdflatex`|`lualatex`|`xelatex`++: Use the specified LaTeX engine when producing PDF output.+ The default is `pdflatex`. If the engine is not in your PATH,+ the full path of the engine may be specified here.++`--latex-engine-opt=`*STRING*++: Use the given string as a command-line argument to the `latex-engine`.+ If used multiple times, the arguments are provided with spaces between+ them. Note that no check for duplicate options is done.++[Dublin Core elements]: http://dublincore.org/documents/dces/+[ISO 8601 format]: http://www.w3.org/TR/NOTE-datetime++Citation rendering+------------------++`--bibliography=`*FILE*++: Set the `bibliography` field in the document's metadata to *FILE*,+ overriding any value set in the metadata, and process citations+ using `pandoc-citeproc`. (This is equivalent to+ `--metadata bibliography=FILE --filter pandoc-citeproc`.)+ If `--natbib` or `--biblatex` is also supplied, `pandoc-citeproc` is not+ used, making this equivalent to `--metadata bibliography=FILE`.+ If you supply this argument multiple times, each *FILE* will be added+ to bibliography.++`--csl=`*FILE*++: Set the `csl` field in the document's metadata to *FILE*,+ overriding any value set in the metadata. (This is equivalent to+ `--metadata csl=FILE`.)+ This option is only relevant with `pandoc-citeproc`.++`--citation-abbreviations=`*FILE*++: Set the `citation-abbreviations` field in the document's metadata to+ *FILE*, overriding any value set in the metadata. (This is equivalent to+ `--metadata citation-abbreviations=FILE`.)+ This option is only relevant with `pandoc-citeproc`.++`--natbib`++: Use [`natbib`] for citations in LaTeX output. This option is not for use+ with the `pandoc-citeproc` filter or with PDF output. It is intended for+ use in producing a LaTeX file that can be processed with [`bibtex`].++`--biblatex`++: Use [`biblatex`] for citations in LaTeX output. This option is not for use+ with the `pandoc-citeproc` filter or with PDF output. It is intended for+ use in producing a LaTeX file that can be processed with [`bibtex`] or [`biber`].++Math rendering in HTML+----------------------++`-m` [*URL*], `--latexmathml`[`=`*URL*]++: Use the [LaTeXMathML] script to display embedded TeX math in HTML output.+ To insert a link to a local copy of the `LaTeXMathML.js` script,+ provide a *URL*. If no *URL* is provided, the contents of the+ script will be inserted directly into the HTML header, preserving+ portability at the price of efficiency. If you plan to use math on+ several pages, it is much better to link to a copy of the script,+ so it can be cached.++`--mathml`[`=`*URL*]++: Convert TeX math to [MathML] (in `docbook`, `docbook5`, `html` and `html5`).+ In standalone `html` output, a small javascript (or a link to such a+ script if a *URL* is supplied) will be inserted that allows the MathML to+ be viewed on some browsers.++`--jsmath`[`=`*URL*]++: Use [jsMath] to display embedded TeX math in HTML output.+ The *URL* should point to the jsMath load script (e.g.+ `jsMath/easy/load.js`); if provided, it will be linked to in+ the header of standalone HTML documents. If a *URL* is not provided,+ no link to the jsMath load script will be inserted; it is then+ up to the author to provide such a link in the HTML template.++`--mathjax`[`=`*URL*]++: Use [MathJax] to display embedded TeX math in HTML output.+ The *URL* should point to the `MathJax.js` load script.+ If a *URL* is not provided, a link to the MathJax CDN will+ be inserted.++`--gladtex`++: Enclose TeX math in `<eq>` tags in HTML output. These can then+ be processed by [gladTeX] to produce links to images of the typeset+ formulas.++`--mimetex`[`=`*URL*]++: Render TeX math using the [mimeTeX] CGI script. If *URL* is not+ specified, it is assumed that the script is at `/cgi-bin/mimetex.cgi`.++`--webtex`[`=`*URL*]++: Render TeX formulas using an external script that converts TeX+ formulas to images. The formula will be concatenated with the URL+ provided. If *URL* is not specified, the CodeCogs will be used.+ Note: the `--webtex` option will affect Markdown output+ as well as HTML, which is useful if you're targeting a+ version of Markdown without native math support.++`--katex`[`=`*URL*]++: Use [KaTeX] to display embedded TeX math in HTML output.+ The *URL* should point to the `katex.js` load script. If a *URL* is+ not provided, a link to the KaTeX CDN will be inserted.+ Note: [KaTeX] seems to work best with `html5` output.++`--katex-stylesheet=`*URL*++: The *URL* should point to the `katex.css` stylesheet. If this option is+ not specified, a link to the KaTeX CDN will be inserted. Note that this+ option does not imply `--katex`.++[MathML]: http://www.w3.org/Math/+[LaTeXMathML]: http://math.etsu.edu/LaTeXMathML/+[jsMath]: http://www.math.union.edu/~dpvc/jsmath/+[MathJax]: https://www.mathjax.org+[gladTeX]: http://ans.hsh.no/home/mgg/gladtex/+[mimeTeX]: http://www.forkosh.com/mimetex.html+[KaTeX]: https://github.com/Khan/KaTeX++Options for wrapper scripts+---------------------------++`--dump-args`++: Print information about command-line arguments to *stdout*, then exit.+ This option is intended primarily for use in wrapper scripts.+ The first line of output contains the name of the output file specified+ with the `-o` option, or `-` (for *stdout*) if no output file was+ specified. The remaining lines contain the command-line arguments,+ one per line, in the order they appear. These do not include regular+ pandoc options and their arguments, but do include any options appearing+ after a `--` separator at the end of the line.++`--ignore-args`++: Ignore command-line arguments (for use in wrapper scripts).+ Regular pandoc options are not ignored. Thus, for example,++ pandoc --ignore-args -o foo.html -s foo.txt -- -e latin1++ is equivalent to++ pandoc -o foo.html -s++Templates+=========++When the `-s/--standalone` option is used, pandoc uses a template to+add header and footer material that is needed for a self-standing+document. To see the default template that is used, just type++ pandoc -D *FORMAT*++where *FORMAT* is the name of the output format. A custom template+can be specified using the `--template` option. You can also override+the system default templates for a given output format *FORMAT*+by putting a file `templates/default.*FORMAT*` in the user data+directory (see `--data-dir`, above). *Exceptions:*++- For `odt` output, customize the `default.opendocument`+ template.+- For `pdf` output, customize the `default.latex` template+ (or the `default.beamer` template, if you use `-t beamer`,+ or the `default.context` template, if you use `-t context`).+- `docx` has no template (however, you can use+ `--reference-docx` to customize the output).++Templates contain *variables*, which allow for the inclusion of+arbitrary information at any point in the file. Variables may be set+within the document using [YAML metadata blocks][Extension:+`yaml_metadata_block`]. They may also be set at the+command line using the `-V/--variable` option: variables set in this+way override metadata fields with the same name.++Variables set by pandoc+-----------------------++Some variables are set automatically by pandoc. These vary somewhat+depending on the output format, but include metadata fields as well+as the following:++`title`, `author`, `date`+: allow identification of basic aspects of the document. Included+ in PDF metadata through LaTeX and ConTeXt. These can be set+ through a [pandoc title block][Extension: `pandoc_title_block`],+ which allows for multiple authors, or through a YAML metadata block:++ ---+ author:+ - Aristotle+ - Peter Abelard+ ...++`subtitle`+: document subtitle, included in HTML, EPUB, LaTeX, ConTeXt, and Word docx;+ renders in LaTeX only when using a document class that supports+ `\subtitle`, such as `beamer` or the [KOMA-Script] series (`scrartcl`,+ `scrreprt`, `scrbook`).[^subtitle]++`institute`+: author affiliations (in LaTeX and Beamer only). Can be a+ list, when there are multiple authors.++`abstract`+: document summary, included in LaTeX, ConTeXt, AsciiDoc, and Word docx++`keywords`+: list of keywords to be included in HTML, PDF, and AsciiDoc metadata;+ may be repeated as for `author`, above++`header-includes`+: contents specified by `-H/--include-in-header` (may have multiple+ values)++`toc`+: non-null value if `--toc/--table-of-contents` was specified++`toc-title`+: title of table of contents (works only with EPUB and docx)++`include-before`+: contents specified by `-B/--include-before-body` (may have+ multiple values)++`include-after`+: contents specified by `-A/--include-after-body` (may have+ multiple values)++`body`+: body of document++`meta-json`+: JSON representation of all of the document's metadata++[^subtitle]: To make `subtitle` work with other LaTeX+ document classes, you can add the following to `header-includes`:++ \providecommand{\subtitle}[1]{%+ \usepackage{titling}+ \posttitle{%+ \par\large#1\end{center}}+ }++Language variables+------------------++`lang`+: identifies the main language of the document,+ using a code according to [BCP 47] (e.g. `en` or `en-GB`).+ For some output formats, pandoc will convert it to an appropriate+ format stored in the additional variables `babel-lang`,+ `polyglossia-lang` (LaTeX) and `context-lang` (ConTeXt).++ Native pandoc `span`s and `div`s with the lang attribute+ (value in BCP 47) can be used to switch the language in+ that range.++`otherlangs`+: a list of other languages used in the document+ in the YAML metadata, according to [BCP 47]. For example:+ `otherlangs: [en-GB, fr]`.+ This is automatically generated from the `lang` attributes+ in all `span`s and `div`s but can be overridden.+ Currently only used by LaTeX through the generated+ `babel-otherlangs` and `polyglossia-otherlangs` variables.+ The LaTeX writer outputs polyglossia commands in the text but+ the `babel-newcommands` variable contains mappings for them+ to the corresponding babel.++`dir`+: the base direction of the document, either `rtl` (right-to-left)+ or `ltr` (left-to-right).++ For bidirectional documents, native pandoc `span`s and `div`s+ with the `dir` attribute (value `rtl` or `ltr`) can be used to+ override the base direction in some output formats.+ This may not always be necessary if the final renderer+ (e.g. the browser, when generating HTML) supports the+ [Unicode Bidirectional Algorithm].++ When using LaTeX for bidirectional documents, only the `xelatex` engine+ is fully supported (use `--latex-engine=xelatex`).++[BCP 47]: https://tools.ietf.org/html/bcp47+[Unicode Bidirectional Algorithm]: http://www.w3.org/International/articles/inline-bidi-markup/uba-basics++Variables for slides+--------------------++Variables are available for [producing slide shows with pandoc],+including all [reveal.js configuration options].++`slidy-url`+: base URL for Slidy documents (defaults to+ `http://www.w3.org/Talks/Tools/Slidy2`)++`slideous-url`+: base URL for Slideous documents (defaults to `slideous`)++`s5-url`+: base URL for S5 documents (defaults to `s5/default`)++`revealjs-url`+: base URL for reveal.js documents (defaults to `reveal.js`)++`theme`, `colortheme`, `fonttheme`, `innertheme`, `outertheme`+: themes for LaTeX [`beamer`] documents++`themeoptions`+: options for LaTeX beamer themes (a list).++`navigation`+: controls navigation symbols in `beamer` documents+ (default is `empty` for no navigation symbols; other valid values+ are `frame`, `vertical`, and `horizontal`).++`section-titles`+: enables on "title pages" for new sections in `beamer`+ documents (default = true).++`beamerarticle`+: when true, the `beamerarticle` package is loaded (for+ producing an article from beamer slides).++`colorlinks`+: add color to link text; automatically enabled if any of `linkcolor`, `citecolor`,+ `urlcolor`, or `toccolor` are set (for beamer only).++`linkcolor`, `citecolor`, `urlcolor`, `toccolor`+: color for internal links, citation links, external links, and links in table+ of contents: uses any of the [predefined LaTeX colors] (for beamer only).++[reveal.js configuration options]: https://github.com/hakimel/reveal.js#configuration++Variables for LaTeX+-------------------++LaTeX variables are used when [creating a PDF].++`papersize`+: paper size, e.g. `letter`, `A4`++`fontsize`+: font size for body text (e.g. `10pt`, `12pt`)++`documentclass`+: document class, e.g. [`article`], [`report`], [`book`], [`memoir`]++`classoption`+: option for document class, e.g. `oneside`; may be repeated+ for multiple options++`geometry`+: option for [`geometry`] package, e.g. `margin=1in`;+ may be repeated for multiple options++`margin-left`, `margin-right`, `margin-top`, `margin-bottom`+: sets margins, if `geometry` is not used (otherwise `geometry`+ overrides these)++`linestretch`+: adjusts line spacing using the [`setspace`]+ package, e.g. `1.25`, `1.5`++`fontfamily`+: font package for use with `pdflatex`:+ [TeX Live] includes many options, documented in the [LaTeX Font Catalogue].+ The default is [Latin Modern][`lm`].++`fontfamilyoptions`+: options for package used as `fontfamily`: e.g. `osf,sc` with+ `fontfamily` set to [`mathpazo`] provides Palatino with old-style+ figures and true small caps; may be repeated for multiple options++`mainfont`, `sansfont`, `monofont`, `mathfont`, `CJKmainfont`+: font families for use with `xelatex` or+ `lualatex`: take the name of any system font, using the+ [`fontspec`] package. Note that if `CJKmainfont` is used,+ the [`xecjk`] package must be available.++`mainfontoptions`, `sansfontoptions`, `monofontoptions`, `mathfontoptions`, `CJKoptions`+: options to use with `mainfont`, `sansfont`, `monofont`, `mathfont`,+ `CJKmainfont` in `xelatex` and `lualatex`. Allow for any choices+ available through [`fontspec`], such as the OpenType features+ `Numbers=OldStyle,Numbers=Proportional`. May be repeated for multiple options.++`fontenc`+: allows font encoding to be specified through `fontenc` package (with `pdflatex`);+ default is `T1` (see guide to [LaTeX font encodings])++`colorlinks`+: add color to link text; automatically enabled if any of `linkcolor`, `citecolor`,+ `urlcolor`, or `toccolor` are set++`linkcolor`, `citecolor`, `urlcolor`, `toccolor`+: color for internal links, citation links, external links, and links in table of contents:+ uses any of the [predefined LaTeX colors]++`links-as-notes`+: causes links to be printed as footnotes++`indent`+: uses document class settings for indentation (the default LaTeX template+ otherwise removes indentation and adds space between paragraphs)++`subparagraph`+: disables default behavior of LaTeX template that redefines (sub)paragraphs+ as sections, changing the appearance of nested headings in some classes++`thanks`+: specifies contents of acknowledgments footnote after document title.++`toc`+: include table of contents (can also be set using `--toc/--table-of-contents`)++`toc-depth`+: level of section to include in table of contents++`secnumdepth`+: numbering depth for sections, if sections are numbered++`lof`, `lot`+: include list of figures, list of tables++`bibliography`+: bibliography to use for resolving references++`biblio-style`+: bibliography style, when used with `--natbib` and `--biblatex`.++`biblio-title`+: bibliography title, when used with `--natbib` and `--biblatex`.++`biblatexoptions`+: list of options for biblatex.++[`article`]: https://ctan.org/pkg/article+[`report`]: https://ctan.org/pkg/report+[`book`]: https://ctan.org/pkg/book+[KOMA-Script]: https://ctan.org/pkg/koma-script+[`memoir`]: https://ctan.org/pkg/memoir+[predefined LaTeX colors]: https://en.wikibooks.org/wiki/LaTeX/Colors#Predefined_colors+[LaTeX Font Catalogue]: http://www.tug.dk/FontCatalogue/+[`mathpazo`]: https://ctan.org/pkg/mathpazo+[LaTeX font encodings]: https://ctan.org/pkg/encguide++Variables for ConTeXt+---------------------++`papersize`+: paper size, e.g. `letter`, `A4`, `landscape` (see [ConTeXt Paper Setup]);+ may be repeated for multiple options++`layout`+: options for page margins and text arrangement (see [ConTeXt Layout]);+ may be repeated for multiple options++`margin-left`, `margin-right`, `margin-top`, `margin-bottom`+: sets margins, if `layout` is not used (otherwise `layout`+ overrides these)++`fontsize`+: font size for body text (e.g. `10pt`, `12pt`)++`mainfont`, `sansfont`, `monofont`, `mathfont`+: font families: take the name of any system font (see [ConTeXt Font Switching])++`linkcolor`, `contrastcolor`+: color for links outside and inside a page, e.g. `red`, `blue` (see [ConTeXt Color])++`linkstyle`+: typeface style for links, e.g. `normal`, `bold`, `slanted`, `boldslanted`, `type`, `cap`, `small`++`indenting`+: controls indentation of paragraphs, e.g. `yes,small,next` (see [ConTeXt Indentation]);+ may be repeated for multiple options++`whitespace`+: spacing between paragraphs, e.g. `none`, `small` (using [`setupwhitespace`])++`interlinespace`+: adjusts line spacing, e.g. `4ex` (using [`setupinterlinespace`]);+ may be repeated for multiple options++`headertext`, `footertext`+: text to be placed in running header or footer (see [ConTeXt Headers and Footers]);+ may be repeated up to four times for different placement++`pagenumbering`+: page number style and location (using [`setuppagenumbering`]);+ may be repeated for multiple options++`toc`+: include table of contents (can also be set using `--toc/--table-of-contents`)++`lof`, `lot`+: include list of figures, list of tables++[ConTeXt Paper Setup]: http://wiki.contextgarden.net/PaperSetup+[ConTeXt Layout]: http://wiki.contextgarden.net/Layout+[ConTeXt Font Switching]: http://wiki.contextgarden.net/Font_Switching+[ConTeXt Color]: http://wiki.contextgarden.net/Color+[ConTeXt Headers and Footers]: http://wiki.contextgarden.net/Headers_and_Footers+[ConTeXt Indentation]: http://wiki.contextgarden.net/Indentation+[`setupwhitespace`]: http://wiki.contextgarden.net/Command/setupwhitespace+[`setupinterlinespace`]: http://wiki.contextgarden.net/Command/setupinterlinespace+[`setuppagenumbering`]: http://wiki.contextgarden.net/Command/setuppagenumbering++Variables for man pages+-----------------------++`section`+: section number in man pages++`header`+: header in man pages++`footer`+: footer in man pages++`adjusting`+: adjusts text to left (`l`), right (`r`), center (`c`),+ or both (`b`) margins++`hyphenate`+: if `true` (the default), hyphenation will be used++Using variables in templates+----------------------------++Variable names are sequences of alphanumerics, `-`, and `_`,+starting with a letter. A variable name surrounded by `$` signs+will be replaced by its value. For example, the string `$title$` in++ <title>$title$</title>++will be replaced by the document title.++To write a literal `$` in a template, use `$$`.++Templates may contain conditionals. The syntax is as follows:++ $if(variable)$+ X+ $else$+ Y+ $endif$++This will include `X` in the template if `variable` has a non-null+value; otherwise it will include `Y`. `X` and `Y` are placeholders for+any valid template text, and may include interpolated variables or other+conditionals. The `$else$` section may be omitted.++When variables can have multiple values (for example, `author` in+a multi-author document), you can use the `$for$` keyword:++ $for(author)$+ <meta name="author" content="$author$" />+ $endfor$++You can optionally specify a separator to be used between+consecutive items:++ $for(author)$$author$$sep$, $endfor$++A dot can be used to select a field of a variable that takes+an object as its value. So, for example:++ $author.name$ ($author.affiliation$)++If you use custom templates, you may need to revise them as pandoc+changes. We recommend tracking the changes in the default templates,+and modifying your custom templates accordingly. An easy way to do this+is to fork the [pandoc-templates] repository and merge in changes after each+pandoc release.++[pandoc-templates]: https://github.com/jgm/pandoc-templates++Pandoc's Markdown+=================++Pandoc understands an extended and slightly revised version of+John Gruber's [Markdown] syntax. This document explains the syntax,+noting differences from standard Markdown. Except where noted, these+differences can be suppressed by using the `markdown_strict` format instead+of `markdown`. An extensions can be enabled by adding `+EXTENSION`+to the format name and disabled by adding `-EXTENSION`. For example,+`markdown_strict+footnotes` is strict Markdown with footnotes+enabled, while `markdown-footnotes-pipe_tables` is pandoc's+Markdown without footnotes or pipe tables.++Philosophy+----------++Markdown is designed to be easy to write, and, even more importantly,+easy to read:++> A Markdown-formatted document should be publishable as-is, as plain+> text, without looking like it's been marked up with tags or formatting+> instructions.+> -- [John Gruber](http://daringfireball.net/projects/markdown/syntax#philosophy)++This principle has guided pandoc's decisions in finding syntax for+tables, footnotes, and other extensions.++There is, however, one respect in which pandoc's aims are different+from the original aims of Markdown. Whereas Markdown was originally+designed with HTML generation in mind, pandoc is designed for multiple+output formats. Thus, while pandoc allows the embedding of raw HTML,+it discourages it, and provides other, non-HTMLish ways of representing+important document elements like definition lists, tables, mathematics, and+footnotes.++Paragraphs+----------++A paragraph is one or more lines of text followed by one or more blank lines.+Newlines are treated as spaces, so you can reflow your paragraphs as you like.+If you need a hard line break, put two or more spaces at the end of a line.++#### Extension: `escaped_line_breaks` ####++A backslash followed by a newline is also a hard line break.+Note: in multiline and grid table cells, this is the only way+to create a hard line break, since trailing spaces in the cells+are ignored.++Headers+-------++There are two kinds of headers: Setext and ATX.++### Setext-style headers ###++A setext-style header is a line of text "underlined" with a row of `=` signs+(for a level one header) or `-` signs (for a level two header):++ A level-one header+ ==================++ A level-two header+ ------------------++The header text can contain inline formatting, such as emphasis (see+[Inline formatting], below).+++### ATX-style headers ###++An ATX-style header consists of one to six `#` signs and a line of+text, optionally followed by any number of `#` signs. The number of+`#` signs at the beginning of the line is the header level:++ ## A level-two header++ ### A level-three header ###++As with setext-style headers, the header text can contain formatting:++ # A level-one header with a [link](/url) and *emphasis*++#### Extension: `blank_before_header` ####++Standard Markdown syntax does not require a blank line before a header.+Pandoc does require this (except, of course, at the beginning of the+document). The reason for the requirement is that it is all too easy for a+`#` to end up at the beginning of a line by accident (perhaps through line+wrapping). Consider, for example:++ I like several of their flavors of ice cream:+ #22, for example, and #5.+++### Header identifiers ###++#### Extension: `header_attributes` ####++Headers can be assigned attributes using this syntax at the end+of the line containing the header text:++ {#identifier .class .class key=value key=value}++Thus, for example, the following headers will all be assigned the identifier+`foo`:++ # My header {#foo}++ ## My header ## {#foo}++ My other header {#foo}+ ---------------++(This syntax is compatible with [PHP Markdown Extra].)++Note that although this syntax allows assignment of classes and key/value+attributes, writers generally don't use all of this information. Identifiers,+classes, and key/value attributes are used in HTML and HTML-based formats such+as EPUB and slidy. Identifiers are used for labels and link anchors in the+LaTeX, ConTeXt, Textile, and AsciiDoc writers.++Headers with the class `unnumbered` will not be numbered, even if+`--number-sections` is specified. A single hyphen (`-`) in an attribute+context is equivalent to `.unnumbered`, and preferable in non-English+documents. So,++ # My header {-}++is just the same as++ # My header {.unnumbered}++#### Extension: `auto_identifiers` ####++A header without an explicitly specified identifier will be+automatically assigned a unique identifier based on the header text.+To derive the identifier from the header text,++ - Remove all formatting, links, etc.+ - Remove all footnotes.+ - Remove all punctuation, except underscores, hyphens, and periods.+ - Replace all spaces and newlines with hyphens.+ - Convert all alphabetic characters to lowercase.+ - Remove everything up to the first letter (identifiers may+ not begin with a number or punctuation mark).+ - If nothing is left after this, use the identifier `section`.++Thus, for example,++ Header Identifier+ ------------------------------- ----------------------------+ `Header identifiers in HTML` `header-identifiers-in-html`+ `*Dogs*?--in *my* house?` `dogs--in-my-house`+ `[HTML], [S5], or [RTF]?` `html-s5-or-rtf`+ `3. Applications` `applications`+ `33` `section`++These rules should, in most cases, allow one to determine the identifier+from the header text. The exception is when several headers have the+same text; in this case, the first will get an identifier as described+above; the second will get the same identifier with `-1` appended; the+third with `-2`; and so on.++These identifiers are used to provide link targets in the table of+contents generated by the `--toc|--table-of-contents` option. They+also make it easy to provide links from one section of a document to+another. A link to this section, for example, might look like this:++ See the section on+ [header identifiers](#header-identifiers-in-html-latex-and-context).++Note, however, that this method of providing links to sections works+only in HTML, LaTeX, and ConTeXt formats.++If the `--section-divs` option is specified, then each section will+be wrapped in a `div` (or a `section`, if `--html5` was specified),+and the identifier will be attached to the enclosing `<div>`+(or `<section>`) tag rather than the header itself. This allows entire+sections to be manipulated using javascript or treated differently in+CSS.++#### Extension: `implicit_header_references` ####++Pandoc behaves as if reference links have been defined for each header.+So, to link to a header++ # Header identifiers in HTML++you can simply write++ [Header identifiers in HTML]++or++ [Header identifiers in HTML][]++or++ [the section on header identifiers][header identifiers in+ HTML]++instead of giving the identifier explicitly:++ [Header identifiers in HTML](#header-identifiers-in-html)++If there are multiple headers with identical text, the corresponding+reference will link to the first one only, and you will need to use explicit+links to link to the others, as described above.++Like regular reference links, these references are case-insensitive.++Explicit link reference definitions always take priority over+implicit header references. So, in the following example, the+link will point to `bar`, not to `#foo`:++ # Foo++ [foo]: bar++ See [foo]++Block quotations+----------------++Markdown uses email conventions for quoting blocks of text.+A block quotation is one or more paragraphs or other block elements+(such as lists or headers), with each line preceded by a `>` character+and an optional space. (The `>` need not start at the left margin, but+it should not be indented more than three spaces.)++ > This is a block quote. This+ > paragraph has two lines.+ >+ > 1. This is a list inside a block quote.+ > 2. Second item.++A "lazy" form, which requires the `>` character only on the first+line of each block, is also allowed:++ > This is a block quote. This+ paragraph has two lines.++ > 1. This is a list inside a block quote.+ 2. Second item.++Among the block elements that can be contained in a block quote are+other block quotes. That is, block quotes can be nested:++ > This is a block quote.+ >+ > > A block quote within a block quote.++If the `>` character is followed by an optional space, that space+will be considered part of the block quote marker and not part of+the indentation of the contents. Thus, to put an indented code+block in a block quote, you need five spaces after the `>`:++ > code++#### Extension: `blank_before_blockquote` ####++Standard Markdown syntax does not require a blank line before a block+quote. Pandoc does require this (except, of course, at the beginning of the+document). The reason for the requirement is that it is all too easy for a+`>` to end up at the beginning of a line by accident (perhaps through line+wrapping). So, unless the `markdown_strict` format is used, the following does+not produce a nested block quote in pandoc:++ > This is a block quote.+ >> Nested.+++Verbatim (code) blocks+----------------------++### Indented code blocks ###++A block of text indented four spaces (or one tab) is treated as verbatim+text: that is, special characters do not trigger special formatting,+and all spaces and line breaks are preserved. For example,++ if (a > 3) {+ moveShip(5 * gravity, DOWN);+ }++The initial (four space or one tab) indentation is not considered part+of the verbatim text, and is removed in the output.++Note: blank lines in the verbatim text need not begin with four spaces.+++### Fenced code blocks ###++#### Extension: `fenced_code_blocks` ####++In addition to standard indented code blocks, pandoc supports+*fenced* code blocks. These begin with a row of three or more+tildes (`~`) and end with a row of tildes that must be at least as long as+the starting row. Everything between these lines is treated as code. No+indentation is necessary:++ ~~~~~~~+ if (a > 3) {+ moveShip(5 * gravity, DOWN);+ }+ ~~~~~~~++Like regular code blocks, fenced code blocks must be separated+from surrounding text by blank lines.++If the code itself contains a row of tildes or backticks, just use a longer+row of tildes or backticks at the start and end:++ ~~~~~~~~~~~~~~~~+ ~~~~~~~~~~+ code including tildes+ ~~~~~~~~~~+ ~~~~~~~~~~~~~~~~++#### Extension: `backtick_code_blocks` ####++Same as `fenced_code_blocks`, but uses backticks (`` ` ``) instead of tildes+(`~`).++#### Extension: `fenced_code_attributes` ####++Optionally, you may attach attributes to fenced or backtick code block using+this syntax:++ ~~~~ {#mycode .haskell .numberLines startFrom="100"}+ qsort [] = []+ qsort (x:xs) = qsort (filter (< x) xs) ++ [x] +++ qsort (filter (>= x) xs)+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~++Here `mycode` is an identifier, `haskell` and `numberLines` are classes, and+`startFrom` is an attribute with value `100`. Some output formats can use this+information to do syntax highlighting. Currently, the only output formats+that uses this information are HTML and LaTeX. If highlighting is supported+for your output format and language, then the code block above will appear+highlighted, with numbered lines. (To see which languages are supported, do+`pandoc --version`.) Otherwise, the code block above will appear as follows:++ <pre id="mycode" class="haskell numberLines" startFrom="100">+ <code>+ ...+ </code>+ </pre>++A shortcut form can also be used for specifying the language of+the code block:++ ```haskell+ qsort [] = []+ ```++This is equivalent to:++ ``` {.haskell}+ qsort [] = []+ ```++If the `fenced_code_attributes` extension is disabled, but+input contains class attribute(s) for the codeblock, the first+class attribute will be printed after the opening fence as a bare+word.++To prevent all highlighting, use the `--no-highlight` flag.+To set the highlighting style, use `--highlight-style`.+For more information on highlighting, see [Syntax highlighting],+below.++Line blocks+-----------++#### Extension: `line_blocks` ####++A line block is a sequence of lines beginning with a vertical bar (`|`)+followed by a space. The division into lines will be preserved in+the output, as will any leading spaces; otherwise, the lines will+be formatted as Markdown. This is useful for verse and addresses:++ | The limerick packs laughs anatomical+ | In space that is quite economical.+ | But the good ones I've seen+ | So seldom are clean+ | And the clean ones so seldom are comical++ | 200 Main St.+ | Berkeley, CA 94718++The lines can be hard-wrapped if needed, but the continuation+line must begin with a space.++ | The Right Honorable Most Venerable and Righteous Samuel L.+ Constable, Jr.+ | 200 Main St.+ | Berkeley, CA 94718++This syntax is borrowed from [reStructuredText].++Lists+-----++### Bullet lists ###++A bullet list is a list of bulleted list items. A bulleted list+item begins with a bullet (`*`, `+`, or `-`). Here is a simple+example:++ * one+ * two+ * three++This will produce a "compact" list. If you want a "loose" list, in which+each item is formatted as a paragraph, put spaces between the items:++ * one++ * two++ * three++The bullets need not be flush with the left margin; they may be+indented one, two, or three spaces. The bullet must be followed+by whitespace.++List items look best if subsequent lines are flush with the first+line (after the bullet):++ * here is my first+ list item.+ * and my second.++But Markdown also allows a "lazy" format:++ * here is my first+ list item.+ * and my second.++### The four-space rule ###++A list item may contain multiple paragraphs and other block-level+content. However, subsequent paragraphs must be preceded by a blank line+and indented four spaces or a tab. The list will look better if the first+paragraph is aligned with the rest:++ * First paragraph.++ Continued.++ * Second paragraph. With a code block, which must be indented+ eight spaces:++ { code }++List items may include other lists. In this case the preceding blank+line is optional. The nested list must be indented four spaces or+one tab:++ * fruits+ + apples+ - macintosh+ - red delicious+ + pears+ + peaches+ * vegetables+ + broccoli+ + chard++As noted above, Markdown allows you to write list items "lazily," instead of+indenting continuation lines. However, if there are multiple paragraphs or+other blocks in a list item, the first line of each must be indented.++ + A lazy, lazy, list+ item.++ + Another one; this looks+ bad but is legal.++ Second paragraph of second+ list item.++**Note:** Although the four-space rule for continuation paragraphs+comes from the official [Markdown syntax guide], the reference implementation,+`Markdown.pl`, does not follow it. So pandoc will give different results than+`Markdown.pl` when authors have indented continuation paragraphs fewer than+four spaces.++The [Markdown syntax guide] is not explicit whether the four-space+rule applies to *all* block-level content in a list item; it only+mentions paragraphs and code blocks. But it implies that the rule+applies to all block-level content (including nested lists), and+pandoc interprets it that way.++ [Markdown syntax guide]:+ http://daringfireball.net/projects/markdown/syntax#list++### Ordered lists ###++Ordered lists work just like bulleted lists, except that the items+begin with enumerators rather than bullets.++In standard Markdown, enumerators are decimal numbers followed+by a period and a space. The numbers themselves are ignored, so+there is no difference between this list:++ 1. one+ 2. two+ 3. three++and this one:++ 5. one+ 7. two+ 1. three++#### Extension: `fancy_lists` ####++Unlike standard Markdown, pandoc allows ordered list items to be marked+with uppercase and lowercase letters and roman numerals, in addition to+arabic numerals. List markers may be enclosed in parentheses or followed by a+single right-parentheses or period. They must be separated from the+text that follows by at least one space, and, if the list marker is a+capital letter with a period, by at least two spaces.[^2]++[^2]: The point of this rule is to ensure that normal paragraphs+ starting with people's initials, like++ B. Russell was an English philosopher.++ do not get treated as list items.++ This rule will not prevent++ (C) 2007 Joe Smith++ from being interpreted as a list item. In this case, a backslash+ escape can be used:++ (C\) 2007 Joe Smith++The `fancy_lists` extension also allows '`#`' to be used as an+ordered list marker in place of a numeral:++ #. one+ #. two++#### Extension: `startnum` ####++Pandoc also pays attention to the type of list marker used, and to the+starting number, and both of these are preserved where possible in the+output format. Thus, the following yields a list with numbers followed+by a single parenthesis, starting with 9, and a sublist with lowercase+roman numerals:++ 9) Ninth+ 10) Tenth+ 11) Eleventh+ i. subone+ ii. subtwo+ iii. subthree++Pandoc will start a new list each time a different type of list+marker is used. So, the following will create three lists:++ (2) Two+ (5) Three+ 1. Four+ * Five++If default list markers are desired, use `#.`:++ #. one+ #. two+ #. three+++### Definition lists ###++#### Extension: `definition_lists` ####++Pandoc supports definition lists, using the syntax of+[PHP Markdown Extra] with some extensions.[^3]++ Term 1++ : Definition 1++ Term 2 with *inline markup*++ : Definition 2++ { some code, part of Definition 2 }++ Third paragraph of definition 2.++Each term must fit on one line, which may optionally be followed by+a blank line, and must be followed by one or more definitions.+A definition begins with a colon or tilde, which may be indented one+or two spaces.++A term may have multiple definitions, and each definition may consist of one or+more block elements (paragraph, code block, list, etc.), each indented four+spaces or one tab stop. The body of the definition (including the first line,+aside from the colon or tilde) should be indented four spaces. However,+as with other Markdown lists, you can "lazily" omit indentation except+at the beginning of a paragraph or other block element:++ Term 1++ : Definition+ with lazy continuation.++ Second paragraph of the definition.++If you leave space before the definition (as in the example above),+the text of the definition will be treated as a paragraph. In some+output formats, this will mean greater spacing between term/definition+pairs. For a more compact definition list, omit the space before the+definition:++ Term 1+ ~ Definition 1++ Term 2+ ~ Definition 2a+ ~ Definition 2b++Note that space between items in a definition list is required.+(A variant that loosens this requirement, but disallows "lazy"+hard wrapping, can be activated with `compact_definition_lists`: see+[Non-pandoc extensions], below.)++[^3]: I have been influenced by the suggestions of [David Wheeler](http://www.justatheory.com/computers/markup/modest-markdown-proposal.html).++### Numbered example lists ###++#### Extension: `example_lists` ####++The special list marker `@` can be used for sequentially numbered+examples. The first list item with a `@` marker will be numbered '1',+the next '2', and so on, throughout the document. The numbered examples+need not occur in a single list; each new list using `@` will take up+where the last stopped. So, for example:++ (@) My first example will be numbered (1).+ (@) My second example will be numbered (2).++ Explanation of examples.++ (@) My third example will be numbered (3).++Numbered examples can be labeled and referred to elsewhere in the+document:++ (@good) This is a good example.++ As (@good) illustrates, ...++The label can be any string of alphanumeric characters, underscores,+or hyphens.+++### Compact and loose lists ###++Pandoc behaves differently from `Markdown.pl` on some "edge+cases" involving lists. Consider this source:++ + First+ + Second:+ - Fee+ - Fie+ - Foe++ + Third++Pandoc transforms this into a "compact list" (with no `<p>` tags around+"First", "Second", or "Third"), while Markdown puts `<p>` tags around+"Second" and "Third" (but not "First"), because of the blank space+around "Third". Pandoc follows a simple rule: if the text is followed by+a blank line, it is treated as a paragraph. Since "Second" is followed+by a list, and not a blank line, it isn't treated as a paragraph. The+fact that the list is followed by a blank line is irrelevant. (Note:+Pandoc works this way even when the `markdown_strict` format is specified. This+behavior is consistent with the official Markdown syntax description,+even though it is different from that of `Markdown.pl`.)+++### Ending a list ###++What if you want to put an indented code block after a list?++ - item one+ - item two++ { my code block }++Trouble! Here pandoc (like other Markdown implementations) will treat+`{ my code block }` as the second paragraph of item two, and not as+a code block.++To "cut off" the list after item two, you can insert some non-indented+content, like an HTML comment, which won't produce visible output in+any format:++ - item one+ - item two++ <!-- end of list -->++ { my code block }++You can use the same trick if you want two consecutive lists instead+of one big list:++ 1. one+ 2. two+ 3. three++ <!-- -->++ 1. uno+ 2. dos+ 3. tres++Horizontal rules+----------------++A line containing a row of three or more `*`, `-`, or `_` characters+(optionally separated by spaces) produces a horizontal rule:++ * * * *++ ---------------+++Tables+------++Four kinds of tables may be used. The first three kinds presuppose the use of+a fixed-width font, such as Courier. The fourth kind can be used with+proportionally spaced fonts, as it does not require lining up columns.++#### Extension: `table_captions` ####++A caption may optionally be provided with all 4 kinds of tables (as+illustrated in the examples below). A caption is a paragraph beginning+with the string `Table:` (or just `:`), which will be stripped off.+It may appear either before or after the table.++#### Extension: `simple_tables` ####++Simple tables look like this:++ Right Left Center Default+ ------- ------ ---------- -------+ 12 12 12 12+ 123 123 123 123+ 1 1 1 1++ Table: Demonstration of simple table syntax.++The headers and table rows must each fit on one line. Column+alignments are determined by the position of the header text relative+to the dashed line below it:[^4]++ - If the dashed line is flush with the header text on the right side+ but extends beyond it on the left, the column is right-aligned.+ - If the dashed line is flush with the header text on the left side+ but extends beyond it on the right, the column is left-aligned.+ - If the dashed line extends beyond the header text on both sides,+ the column is centered.+ - If the dashed line is flush with the header text on both sides,+ the default alignment is used (in most cases, this will be left).++[^4]: This scheme is due to Michel Fortin, who proposed it on the+ [Markdown discussion list](http://six.pairlist.net/pipermail/markdown-discuss/2005-March/001097.html).++The table must end with a blank line, or a line of dashes followed by+a blank line.++The column headers may be omitted, provided a dashed line is used+to end the table. For example:++ ------- ------ ---------- -------+ 12 12 12 12+ 123 123 123 123+ 1 1 1 1+ ------- ------ ---------- -------++When headers are omitted, column alignments are determined on the basis+of the first line of the table body. So, in the tables above, the columns+would be right, left, center, and right aligned, respectively.++#### Extension: `multiline_tables` ####++Multiline tables allow headers and table rows to span multiple lines+of text (but cells that span multiple columns or rows of the table are+not supported). Here is an example:++ -------------------------------------------------------------+ Centered Default Right Left+ Header Aligned Aligned Aligned+ ----------- ------- --------------- -------------------------+ First row 12.0 Example of a row that+ spans multiple lines.++ Second row 5.0 Here's another one. Note+ the blank line between+ rows.+ -------------------------------------------------------------++ Table: Here's the caption. It, too, may span+ multiple lines.++These work like simple tables, but with the following differences:++ - They must begin with a row of dashes, before the header text+ (unless the headers are omitted).+ - They must end with a row of dashes, then a blank line.+ - The rows must be separated by blank lines.++In multiline tables, the table parser pays attention to the widths of+the columns, and the writers try to reproduce these relative widths in+the output. So, if you find that one of the columns is too narrow in the+output, try widening it in the Markdown source.++Headers may be omitted in multiline tables as well as simple tables:++ ----------- ------- --------------- -------------------------+ First row 12.0 Example of a row that+ spans multiple lines.++ Second row 5.0 Here's another one. Note+ the blank line between+ rows.+ ----------- ------- --------------- -------------------------++ : Here's a multiline table without headers.++It is possible for a multiline table to have just one row, but the row+should be followed by a blank line (and then the row of dashes that ends+the table), or the table may be interpreted as a simple table.++#### Extension: `grid_tables` ####++Grid tables look like this:++ : Sample grid table.++ +---------------+---------------+--------------------++ | Fruit | Price | Advantages |+ +===============+===============+====================++ | Bananas | $1.34 | - built-in wrapper |+ | | | - bright color |+ +---------------+---------------+--------------------++ | Oranges | $2.10 | - cures scurvy |+ | | | - tasty |+ +---------------+---------------+--------------------+++The row of `=`s separates the header from the table body, and can be+omitted for a headerless table. The cells of grid tables may contain+arbitrary block elements (multiple paragraphs, code blocks, lists,+etc.). Alignments are not supported, nor are cells that span multiple+columns or rows. Grid tables can be created easily using [Emacs table mode].++[Emacs table mode]: http://table.sourceforge.net/++#### Extension: `pipe_tables` ####++Pipe tables look like this:++ | Right | Left | Default | Center |+ |------:|:-----|---------|:------:|+ | 12 | 12 | 12 | 12 |+ | 123 | 123 | 123 | 123 |+ | 1 | 1 | 1 | 1 |++ : Demonstration of pipe table syntax.++The syntax is identical to [PHP Markdown Extra tables]. The beginning and+ending pipe characters are optional, but pipes are required between all+columns. The colons indicate column alignment as shown. The header+cannot be omitted. To simulate a headerless table, include a header+with blank cells.++Since the pipes indicate column boundaries, columns need not be vertically+aligned, as they are in the above example. So, this is a perfectly+legal (though ugly) pipe table:++ fruit| price+ -----|-----:+ apple|2.05+ pear|1.37+ orange|3.09++The cells of pipe tables cannot contain block elements like paragraphs+and lists, and cannot span multiple lines. If a pipe table contains a+row whose printable content is wider than the column width (see+`--columns`), then the cell contents will wrap, with the+relative cell widths determined by the widths of the separator+lines.++Note: pandoc also recognizes pipe tables of the following+form, as can be produced by Emacs' orgtbl-mode:++ | One | Two |+ |-----+-------|+ | my | table |+ | is | nice |++The difference is that `+` is used instead of `|`. Other orgtbl features+are not supported. In particular, to get non-default column alignment,+you'll need to add colons as above.++[PHP Markdown Extra tables]: https://michelf.ca/projects/php-markdown/extra/#table++Metadata blocks+---------------++#### Extension: `pandoc_title_block` ####++If the file begins with a title block++ % title+ % author(s) (separated by semicolons)+ % date++it will be parsed as bibliographic information, not regular text. (It+will be used, for example, in the title of standalone LaTeX or HTML+output.) The block may contain just a title, a title and an author,+or all three elements. If you want to include an author but no+title, or a title and a date but no author, you need a blank line:++ %+ % Author++ % My title+ %+ % June 15, 2006++The title may occupy multiple lines, but continuation lines must+begin with leading space, thus:++ % My title+ on multiple lines++If a document has multiple authors, the authors may be put on+separate lines with leading space, or separated by semicolons, or+both. So, all of the following are equivalent:++ % Author One+ Author Two++ % Author One; Author Two++ % Author One;+ Author Two++The date must fit on one line.++All three metadata fields may contain standard inline formatting+(italics, links, footnotes, etc.).++Title blocks will always be parsed, but they will affect the output only+when the `--standalone` (`-s`) option is chosen. In HTML output, titles+will appear twice: once in the document head -- this is the title that+will appear at the top of the window in a browser -- and once at the+beginning of the document body. The title in the document head can have+an optional prefix attached (`--title-prefix` or `-T` option). The title+in the body appears as an H1 element with class "title", so it can be+suppressed or reformatted with CSS. If a title prefix is specified with+`-T` and no title block appears in the document, the title prefix will+be used by itself as the HTML title.++The man page writer extracts a title, man page section number, and+other header and footer information from the title line. The title+is assumed to be the first word on the title line, which may optionally+end with a (single-digit) section number in parentheses. (There should+be no space between the title and the parentheses.) Anything after+this is assumed to be additional footer and header text. A single pipe+character (`|`) should be used to separate the footer text from the header+text. Thus,++ % PANDOC(1)++will yield a man page with the title `PANDOC` and section 1.++ % PANDOC(1) Pandoc User Manuals++will also have "Pandoc User Manuals" in the footer.++ % PANDOC(1) Pandoc User Manuals | Version 4.0++will also have "Version 4.0" in the header.++#### Extension: `yaml_metadata_block` ####++A YAML metadata block is a valid YAML object, delimited by a line of three+hyphens (`---`) at the top and a line of three hyphens (`---`) or three dots+(`...`) at the bottom. A YAML metadata block may occur anywhere in the+document, but if it is not at the beginning, it must be preceded by a blank+line. (Note that, because of the way pandoc concatenates input files when+several are provided, you may also keep the metadata in a separate YAML file+and pass it to pandoc as an argument, along with your Markdown files:++ pandoc chap1.md chap2.md chap3.md metadata.yaml -s -o book.html++Just be sure that the YAML file begins with `---` and ends with `---` or+`...`.)++Metadata will be taken from the fields of the YAML object and added to any+existing document metadata. Metadata can contain lists and objects (nested+arbitrarily), but all string scalars will be interpreted as Markdown. Fields+with names ending in an underscore will be ignored by pandoc. (They may be+given a role by external processors.)++A document may contain multiple metadata blocks. The metadata fields will+be combined through a *left-biased union*: if two metadata blocks attempt+to set the same field, the value from the first block will be taken.++When pandoc is used with `-t markdown` to create a Markdown document,+a YAML metadata block will be produced only if the `-s/--standalone`+option is used. All of the metadata will appear in a single block+at the beginning of the document.++Note that YAML escaping rules must be followed. Thus, for example,+if a title contains a colon, it must be quoted. The pipe character+(`|`) can be used to begin an indented block that will be interpreted+literally, without need for escaping. This form is necessary+when the field contains blank lines:++ ---+ title: 'This is the title: it contains a colon'+ author:+ - Author One+ - Author Two+ tags: [nothing, nothingness]+ abstract: |+ This is the abstract.++ It consists of two paragraphs.+ ...++Template variables will be set automatically from the metadata. Thus, for+example, in writing HTML, the variable `abstract` will be set to the HTML+equivalent of the Markdown in the `abstract` field:++ <p>This is the abstract.</p>+ <p>It consists of two paragraphs.</p>++Variables can contain arbitrary YAML structures, but the template must match+this structure. The `author` variable in the default templates expects a+simple list or string, but can be changed to support more complicated+structures. The following combination, for example, would add an affiliation+to the author if one is given:++ ---+ title: The document title+ author:+ - name: Author One+ affiliation: University of Somewhere+ - name: Author Two+ affiliation: University of Nowhere+ ...++To use the structured authors in the example above, you would need a custom+template:++ $for(author)$+ $if(author.name)$+ $author.name$$if(author.affiliation)$ ($author.affiliation$)$endif$+ $else$+ $author$+ $endif$+ $endfor$+++Backslash escapes+-----------------++#### Extension: `all_symbols_escapable` ####++Except inside a code block or inline code, any punctuation or space+character preceded by a backslash will be treated literally, even if it+would normally indicate formatting. Thus, for example, if one writes++ *\*hello\**++one will get++ <em>*hello*</em>++instead of++ <strong>hello</strong>++This rule is easier to remember than standard Markdown's rule,+which allows only the following characters to be backslash-escaped:++ \`*_{}[]()>#+-.!++(However, if the `markdown_strict` format is used, the standard Markdown rule+will be used.)++A backslash-escaped space is parsed as a nonbreaking space. It will+appear in TeX output as `~` and in HTML and XML as `\ ` or+`\ `.++A backslash-escaped newline (i.e. a backslash occurring at the end of+a line) is parsed as a hard line break. It will appear in TeX output as+`\\` and in HTML as `<br />`. This is a nice alternative to+Markdown's "invisible" way of indicating hard line breaks using+two trailing spaces on a line.++Backslash escapes do not work in verbatim contexts.++Smart punctuation+-----------------++#### Extension ####++If the `--smart` option is specified, pandoc will produce typographically+correct output, converting straight quotes to curly quotes, `---` to+em-dashes, `--` to en-dashes, and `...` to ellipses. Nonbreaking spaces+are inserted after certain abbreviations, such as "Mr."++Note: if your LaTeX template or any included header file call for the+[`csquotes`] package, pandoc will detect this automatically and use+`\enquote{...}` for quoted text.++Inline formatting+-----------------++### Emphasis ###++To *emphasize* some text, surround it with `*`s or `_`, like this:++ This text is _emphasized with underscores_, and this+ is *emphasized with asterisks*.++Double `*` or `_` produces **strong emphasis**:++ This is **strong emphasis** and __with underscores__.++A `*` or `_` character surrounded by spaces, or backslash-escaped,+will not trigger emphasis:++ This is * not emphasized *, and \*neither is this\*.++#### Extension: `intraword_underscores` ####++Because `_` is sometimes used inside words and identifiers,+pandoc does not interpret a `_` surrounded by alphanumeric+characters as an emphasis marker. If you want to emphasize+just part of a word, use `*`:++ feas*ible*, not feas*able*.+++### Strikeout ###++#### Extension: `strikeout` ####++To strikeout a section of text with a horizontal line, begin and end it+with `~~`. Thus, for example,++ This ~~is deleted text.~~+++### Superscripts and subscripts ###++#### Extension: `superscript`, `subscript` ####++Superscripts may be written by surrounding the superscripted text by `^`+characters; subscripts may be written by surrounding the subscripted+text by `~` characters. Thus, for example,++ H~2~O is a liquid. 2^10^ is 1024.++If the superscripted or subscripted text contains spaces, these spaces+must be escaped with backslashes. (This is to prevent accidental+superscripting and subscripting through the ordinary use of `~` and `^`.)+Thus, if you want the letter P with 'a cat' in subscripts, use+`P~a\ cat~`, not `P~a cat~`.+++### Verbatim ###++To make a short span of text verbatim, put it inside backticks:++ What is the difference between `>>=` and `>>`?++If the verbatim text includes a backtick, use double backticks:++ Here is a literal backtick `` ` ``.++(The spaces after the opening backticks and before the closing+backticks will be ignored.)++The general rule is that a verbatim span starts with a string+of consecutive backticks (optionally followed by a space)+and ends with a string of the same number of backticks (optionally+preceded by a space).++Note that backslash-escapes (and other Markdown constructs) do not+work in verbatim contexts:++ This is a backslash followed by an asterisk: `\*`.++#### Extension: `inline_code_attributes` ####++Attributes can be attached to verbatim text, just as with+[fenced code blocks]:++ `<$>`{.haskell}++### Small caps ###++To write small caps, you can use an HTML span tag:++ <span style="font-variant:small-caps;">Small caps</span>++(The semicolon is optional and there may be space after the+colon.) This will work in all output formats that support small caps.++Math+----++#### Extension: `tex_math_dollars` ####++Anything between two `$` characters will be treated as TeX math. The+opening `$` must have a non-space character immediately to its right,+while the closing `$` must have a non-space character immediately to its+left, and must not be followed immediately by a digit. Thus,+`$20,000 and $30,000` won't parse as math. If for some reason+you need to enclose text in literal `$` characters, backslash-escape+them and they won't be treated as math delimiters.++TeX math will be printed in all output formats. How it is rendered+depends on the output format:++Markdown, LaTeX, Emacs Org mode, ConTeXt, ZimWiki+ ~ It will appear verbatim between `$` characters.++reStructuredText+ ~ It will be rendered using an [interpreted text role `:math:`].++AsciiDoc+ ~ It will be rendered as `latexmath:[...]`.++Texinfo+ ~ It will be rendered inside a `@math` command.++groff man+ ~ It will be rendered verbatim without `$`'s.++MediaWiki, DokuWiki+ ~ It will be rendered inside `<math>` tags.++Textile+ ~ It will be rendered inside `<span class="math">` tags.++RTF, OpenDocument, ODT+ ~ It will be rendered, if possible, using unicode characters,+ and will otherwise appear verbatim.++DocBook+ ~ If the `--mathml` flag is used, it will be rendered using MathML+ in an `inlineequation` or `informalequation` tag. Otherwise it+ will be rendered, if possible, using unicode characters.++Docx+ ~ It will be rendered using OMML math markup.++FictionBook2+ ~ If the `--webtex` option is used, formulas are rendered as images+ using CodeCogs or other compatible web service, downloaded+ and embedded in the e-book. Otherwise, they will appear verbatim.++HTML, Slidy, DZSlides, S5, EPUB+ ~ The way math is rendered in HTML will depend on the+ command-line options selected:++ 1. The default is to render TeX math as far as possible using unicode+ characters, as with RTF, DocBook, and OpenDocument output. Formulas+ are put inside a `span` with `class="math"`, so that they may be+ styled differently from the surrounding text if needed.++ 2. If the `--latexmathml` option is used, TeX math will be displayed+ between `$` or `$$` characters and put in `<span>` tags with class `LaTeX`.+ The [LaTeXMathML] script will be used to render it as formulas.+ (This trick does not work in all browsers, but it works in Firefox.+ In browsers that do not support LaTeXMathML, TeX math will appear+ verbatim between `$` characters.)++ 3. If the `--jsmath` option is used, TeX math will be put inside+ `<span>` tags (for inline math) or `<div>` tags (for display math)+ with class `math`. The [jsMath] script will be used to render+ it.++ 4. If the `--mimetex` option is used, the [mimeTeX] CGI script will+ be called to generate images for each TeX formula. This should+ work in all browsers. The `--mimetex` option takes an optional URL+ as argument. If no URL is specified, it will be assumed that the+ mimeTeX CGI script is at `/cgi-bin/mimetex.cgi`.++ 5. If the `--gladtex` option is used, TeX formulas will be enclosed+ in `<eq>` tags in the HTML output. The resulting `htex` file may then+ be processed by [gladTeX], which will produce image files for each+ formula and an HTML file with links to these images. So, the+ procedure is:++ pandoc -s --gladtex myfile.txt -o myfile.htex+ gladtex -d myfile-images myfile.htex+ # produces myfile.html and images in myfile-images++ 6. If the `--webtex` option is used, TeX formulas will be converted+ to `<img>` tags that link to an external script that converts+ formulas to images. The formula will be URL-encoded and concatenated+ with the URL provided. If no URL is specified, the CodeCogs+ will be used (`https://latex.codecogs.com/png.latex?`).++ 7. If the `--mathjax` option is used, TeX math will be displayed+ between `\(...\)` (for inline math) or `\[...\]` (for display+ math) and put in `<span>` tags with class `math`.+ The [MathJax] script will be used to render it as formulas.++[interpreted text role `:math:`]: http://docutils.sourceforge.net/docs/ref/rst/roles.html#math++Raw HTML+--------++#### Extension: `raw_html` ####++Markdown allows you to insert raw HTML (or DocBook) anywhere in a document+(except verbatim contexts, where `<`, `>`, and `&` are interpreted+literally). (Technically this is not an extension, since standard+Markdown allows it, but it has been made an extension so that it can+be disabled if desired.)++The raw HTML is passed through unchanged in HTML, S5, Slidy, Slideous,+DZSlides, EPUB, Markdown, Emacs Org mode, and Textile output, and suppressed+in other formats.++#### Extension: `markdown_in_html_blocks` ####++Standard Markdown allows you to include HTML "blocks": blocks+of HTML between balanced tags that are separated from the surrounding text+with blank lines, and start and end at the left margin. Within+these blocks, everything is interpreted as HTML, not Markdown;+so (for example), `*` does not signify emphasis.++Pandoc behaves this way when the `markdown_strict` format is used; but+by default, pandoc interprets material between HTML block tags as Markdown.+Thus, for example, pandoc will turn++ <table>+ <tr>+ <td>*one*</td>+ <td>[a link](http://google.com)</td>+ </tr>+ </table>++into++ <table>+ <tr>+ <td><em>one</em></td>+ <td><a href="http://google.com">a link</a></td>+ </tr>+ </table>++whereas `Markdown.pl` will preserve it as is.++There is one exception to this rule: text between `<script>` and+`<style>` tags is not interpreted as Markdown.++This departure from standard Markdown should make it easier to mix+Markdown with HTML block elements. For example, one can surround+a block of Markdown text with `<div>` tags without preventing it+from being interpreted as Markdown.++#### Extension: `native_divs` ####++Use native pandoc `Div` blocks for content inside `<div>` tags.+For the most part this should give the same output as+`markdown_in_html_blocks`, but it makes it easier to write pandoc+filters to manipulate groups of blocks.++#### Extension: `native_spans` ####++Use native pandoc `Span` blocks for content inside `<span>` tags.+For the most part this should give the same output as `raw_html`,+but it makes it easier to write pandoc filters to manipulate groups+of inlines.++Raw TeX+-------++#### Extension: `raw_tex` ####++In addition to raw HTML, pandoc allows raw LaTeX, TeX, and ConTeXt to be+included in a document. Inline TeX commands will be preserved and passed+unchanged to the LaTeX and ConTeXt writers. Thus, for example, you can use+LaTeX to include BibTeX citations:++ This result was proved in \cite{jones.1967}.++Note that in LaTeX environments, like++ \begin{tabular}{|l|l|}\hline+ Age & Frequency \\ \hline+ 18--25 & 15 \\+ 26--35 & 33 \\+ 36--45 & 22 \\ \hline+ \end{tabular}++the material between the begin and end tags will be interpreted as raw+LaTeX, not as Markdown.++Inline LaTeX is ignored in output formats other than Markdown, LaTeX,+Emacs Org mode, and ConTeXt.++LaTeX macros+------------++#### Extension: `latex_macros` ####++For output formats other than LaTeX, pandoc will parse LaTeX `\newcommand` and+`\renewcommand` definitions and apply the resulting macros to all LaTeX+math. So, for example, the following will work in all output formats,+not just LaTeX:++ \newcommand{\tuple}[1]{\langle #1 \rangle}++ $\tuple{a, b, c}$++In LaTeX output, the `\newcommand` definition will simply be passed+unchanged to the output.+++Links+-----++Markdown allows links to be specified in several ways.++### Automatic links ###++If you enclose a URL or email address in pointy brackets, it+will become a link:++ <http://google.com>+ <sam@green.eggs.ham>++### Inline links ###++An inline link consists of the link text in square brackets,+followed by the URL in parentheses. (Optionally, the URL can+be followed by a link title, in quotes.)++ This is an [inline link](/url), and here's [one with+ a title](http://fsf.org "click here for a good time!").++There can be no space between the bracketed part and the parenthesized part.+The link text can contain formatting (such as emphasis), but the title cannot.++Email addresses in inline links are not autodetected, so they have to be+prefixed with `mailto`:++ [Write me!](mailto:sam@green.eggs.ham)++### Reference links ###++An *explicit* reference link has two parts, the link itself and the link+definition, which may occur elsewhere in the document (either+before or after the link).++The link consists of link text in square brackets, followed by a label in+square brackets. (There can be space between the two.) The link definition+consists of the bracketed label, followed by a colon and a space, followed by+the URL, and optionally (after a space) a link title either in quotes or in+parentheses. The label must not be parseable as a citation (assuming+the `citations` extension is enabled): citations take precedence over+link labels.++Here are some examples:++ [my label 1]: /foo/bar.html "My title, optional"+ [my label 2]: /foo+ [my label 3]: http://fsf.org (The free software foundation)+ [my label 4]: /bar#special 'A title in single quotes'++The URL may optionally be surrounded by angle brackets:++ [my label 5]: <http://foo.bar.baz>++The title may go on the next line:++ [my label 3]: http://fsf.org+ "The free software foundation"++Note that link labels are not case sensitive. So, this will work:++ Here is [my link][FOO]++ [Foo]: /bar/baz++In an *implicit* reference link, the second pair of brackets is+empty:++ See [my website][].++ [my website]: http://foo.bar.baz++Note: In `Markdown.pl` and most other Markdown implementations,+reference link definitions cannot occur in nested constructions+such as list items or block quotes. Pandoc lifts this arbitrary+seeming restriction. So the following is fine in pandoc, though+not in most other implementations:++ > My block [quote].+ >+ > [quote]: /foo++#### Extension: `shortcut_reference_links` ####++In a *shortcut* reference link, the second pair of brackets may+be omitted entirely:++ See [my website].++ [my website]: http://foo.bar.baz++### Internal links ###++To link to another section of the same document, use the automatically+generated identifier (see [Header identifiers]). For example:++ See the [Introduction](#introduction).++or++ See the [Introduction].++ [Introduction]: #introduction++Internal links are currently supported for HTML formats (including+HTML slide shows and EPUB), LaTeX, and ConTeXt.++Images+------++A link immediately preceded by a `!` will be treated as an image.+The link text will be used as the image's alt text:++ ++ ![movie reel]++ [movie reel]: movie.gif++#### Extension: `implicit_figures` ####++An image occurring by itself in a paragraph will be rendered as+a figure with a caption.[^5] (In LaTeX, a figure environment will be+used; in HTML, the image will be placed in a `div` with class+`figure`, together with a caption in a `p` with class `caption`.)+The image's alt text will be used as the caption.++ ++[^5]: This feature is not yet implemented for RTF, OpenDocument, or+ ODT. In those formats, you'll just get an image in a paragraph by+ itself, with no caption.++If you just want a regular inline image, just make sure it is not+the only thing in the paragraph. One way to do this is to insert a+nonbreaking space after the image:++ \ ++#### Extension: `link_attributes` ####++Attributes can be set on links and images:++ An inline {#id .class width=30 height=20px}+ and a reference ![image][ref] with attributes.++ [ref]: foo.jpg "optional title" {#id .class key=val key2="val 2"}++(This syntax is compatible with [PHP Markdown Extra] when only `#id`+and `.class` are used.)++For HTML and EPUB, all attributes except `width` and `height` (but+including `srcset` and `sizes`) are passed through as is. The other+writers ignore attributes that are not supported by their output+format.++The `width` and `height` attributes on images are treated specially. When+used without a unit, the unit is assumed to be pixels. However, any of+the following unit identifiers can be used: `px`, `cm`, `mm`, `in`, `inch`+and `%`. There must not be any spaces between the number and the unit.+For example:++```+{ width=50% }+```++- Dimensions are converted to inches for output in page-based formats like+ LaTeX. Dimensions are converted to pixels for output in HTML-like+ formats. Use the `--dpi` option to specify the number of pixels per+ inch. The default is 96dpi.+- The `%` unit is generally relative to some available space.+ For example the above example will render to+ `<img href="file.jpg" style="width: 50%;" />` (HTML),+ `\includegraphics[width=0.5\textwidth]{file.jpg}` (LaTeX), or+ `\externalfigure[file.jpg][width=0.5\textwidth]` (ConTeXt).+- Some output formats have a notion of a class+ ([ConTeXt](http://wiki.contextgarden.net/Using_Graphics#Multiple_Image_Settings))+ or a unique identifier (LaTeX `\caption`), or both (HTML).+- When no `width` or `height` attributes are specified, the fallback+ is to look at the image resolution and the dpi metadata embedded in+ the image file.++Spans+-----++#### Extension: `bracketed_spans` ####++A bracketed sequence of inlines, as one would use to begin+a link, will be treated as a span with attributes if it is+followed immediately by attributes:++ [This is *some text*]{.class key="val"}++Footnotes+---------++#### Extension: `footnotes` ####++Pandoc's Markdown allows footnotes, using the following syntax:++ Here is a footnote reference,[^1] and another.[^longnote]++ [^1]: Here is the footnote.++ [^longnote]: Here's one with multiple blocks.++ Subsequent paragraphs are indented to show that they+ belong to the previous footnote.++ { some.code }++ The whole paragraph can be indented, or just the first+ line. In this way, multi-paragraph footnotes work like+ multi-paragraph list items.++ This paragraph won't be part of the note, because it+ isn't indented.++The identifiers in footnote references may not contain spaces, tabs,+or newlines. These identifiers are used only to correlate the+footnote reference with the note itself; in the output, footnotes+will be numbered sequentially.++The footnotes themselves need not be placed at the end of the+document. They may appear anywhere except inside other block elements+(lists, block quotes, tables, etc.).++#### Extension: `inline_notes` ####++Inline footnotes are also allowed (though, unlike regular notes,+they cannot contain multiple paragraphs). The syntax is as follows:++ Here is an inline note.^[Inlines notes are easier to write, since+ you don't have to pick an identifier and move down to type the+ note.]++Inline and regular footnotes may be mixed freely.+++Citations+---------++#### Extension: `citations` ####++Using an external filter, `pandoc-citeproc`, pandoc can automatically generate+citations and a bibliography in a number of styles. Basic usage is++ pandoc --filter pandoc-citeproc myinput.txt++In order to use this feature, you will need to specify a bibliography file+using the `bibliography` metadata field in a YAML metadata section, or+`--bibliography` command line argument. You can supply multiple `--bibliography`+arguments or set `bibliography` metadata field to YAML array, if you want to+use multiple bibliography files. The bibliography may have any of these+formats:++ Format File extension+ ------------ --------------+ BibLaTeX .bib+ BibTeX .bibtex+ Copac .copac+ CSL JSON .json+ CSL YAML .yaml+ EndNote .enl+ EndNote XML .xml+ ISI .wos+ MEDLINE .medline+ MODS .mods+ RIS .ris++Note that `.bib` can be used with both BibTeX and BibLaTeX files;+use `.bibtex` to force BibTeX.++Note that `pandoc-citeproc --bib2json` and `pandoc-citeproc --bib2yaml`+can produce `.json` and `.yaml` files from any of the supported formats.++In-field markup: In BibTeX and BibLaTeX databases, pandoc-citeproc parses+a subset of LaTeX markup; in CSL YAML databases, pandoc Markdown; and in CSL JSON databases, an [HTML-like markup][CSL markup specs]:++`<i>...</i>`+: italics++`<b>...</b>`+: bold++`<span style="font-variant:small-caps;">...</span>` or `<sc>...</sc>`+: small capitals++`<sub>...</sub>`+: subscript++`<sup>...</sup>`+: superscript++`<span class="nocase">...</span>`+: prevent a phrase from being capitalized as title case++`pandoc-citeproc -j` and `-y` interconvert the CSL JSON+and CSL YAML formats as far as possible.++As an alternative to specifying a bibliography file using `--bibliography`+or the YAML metadata field `bibliography`, you can include+the citation data directly in the `references` field of the+document's YAML metadata. The field should contain an array of+YAML-encoded references, for example:++ ---+ references:+ - type: article-journal+ id: WatsonCrick1953+ author:+ - family: Watson+ given: J. D.+ - family: Crick+ given: F. H. C.+ issued:+ date-parts:+ - - 1953+ - 4+ - 25+ title: 'Molecular structure of nucleic acids: a structure for deoxyribose+ nucleic acid'+ title-short: Molecular structure of nucleic acids+ container-title: Nature+ volume: 171+ issue: 4356+ page: 737-738+ DOI: 10.1038/171737a0+ URL: http://www.nature.com/nature/journal/v171/n4356/abs/171737a0.html+ language: en-GB+ ...++(`pandoc-citeproc --bib2yaml` can produce these from a bibliography file in one+of the supported formats.)++Citations and references can be formatted using any style supported by the+[Citation Style Language], listed in the [Zotero Style Repository].+These files are specified using the `--csl` option or the `csl` metadata field.+By default, `pandoc-citeproc` will use the [Chicago Manual of Style] author-date+format. The CSL project provides further information on [finding and editing styles].++To make your citations hyperlinks to the corresponding bibliography+entries, add `link-citations: true` to your YAML metadata.++Citations go inside square brackets and are separated by semicolons.+Each citation must have a key, composed of '@' + the citation+identifier from the database, and may optionally have a prefix,+a locator, and a suffix. The citation key must begin with a letter, digit,+or `_`, and may contain alphanumerics, `_`, and internal punctuation+characters (`:.#$%&-+?<>~/`). Here are some examples:++ Blah blah [see @doe99, pp. 33-35; also @smith04, chap. 1].++ Blah blah [@doe99, pp. 33-35, 38-39 and *passim*].++ Blah blah [@smith04; @doe99].++`pandoc-citeproc` detects locator terms in the [CSL locale files].+Either abbreviated or unabbreviated forms are accepted. In the `en-US`+locale, locator terms can be written in either singular or plural forms,+as `book`, `bk.`/`bks.`; `chapter`, `chap.`/`chaps.`; `column`,+`col.`/`cols.`; `figure`, `fig.`/`figs.`; `folio`, `fol.`/`fols.`;+`number`, `no.`/`nos.`; `line`, `l.`/`ll.`; `note`, `n.`/`nn.`; `opus`,+`op.`/`opp.`; `page`, `p.`/`pp.`; `paragraph`, `para.`/`paras.`; `part`,+`pt.`/`pts.`; `section`, `sec.`/`secs.`; `sub verbo`, `s.v.`/`s.vv.`;+`verse`, `v.`/`vv.`; `volume`, `vol.`/`vols.`; `¶`/`¶¶`; `§`/`§§`. If no+locator term is used, "page" is assumed.++A minus sign (`-`) before the `@` will suppress mention of+the author in the citation. This can be useful when the+author is already mentioned in the text:++ Smith says blah [-@smith04].++You can also write an in-text citation, as follows:++ @smith04 says blah.++ @smith04 [p. 33] says blah.++If the style calls for a list of works cited, it will be placed+at the end of the document. Normally, you will want to end your+document with an appropriate header:++ last paragraph...++ # References++The bibliography will be inserted after this header. Note that+the `unnumbered` class will be added to this header, so that the+section will not be numbered.++If you want to include items in the bibliography without actually+citing them in the body text, you can define a dummy `nocite` metadata+field and put the citations there:++ ---+ nocite: |+ @item1, @item2+ ...++ @item3++In this example, the document will contain a citation for `item3`+only, but the bibliography will contain entries for `item1`, `item2`, and+`item3`.++For LaTeX or PDF output, you can also use [`natbib`] or [`biblatex`]+to render bibliography. In order to do so, specify bibliography files as+outlined above, and add `--natbib` or `--biblatex` argument to `pandoc`+invocation. Bear in mind that bibliography files have to be in respective+format (either BibTeX or BibLaTeX).++For more information, see the [pandoc-citeproc man page].++[CSL markup specs]: http://docs.citationstyles.org/en/1.0/release-notes.html#rich-text-markup-within-fields+[Chicago Manual of Style]: http://chicagomanualofstyle.org+[Citation Style Language]: http://citationstyles.org+[Zotero Style Repository]: https://www.zotero.org/styles+[finding and editing styles]: http://citationstyles.org/styles/+[CSL locale files]: https://github.com/citation-style-language/locales+[pandoc-citeproc man page]: https://github.com/jgm/pandoc-citeproc/blob/master/man/pandoc-citeproc.1.md++Non-pandoc extensions+---------------------++The following Markdown syntax extensions are not enabled by default+in pandoc, but may be enabled by adding `+EXTENSION` to the format+name, where `EXTENSION` is the name of the extension. Thus, for+example, `markdown+hard_line_breaks` is Markdown with hard line breaks.++#### Extension: `angle_brackets_escapable` ####++Allow `<` and `>` to be backslash-escaped, as they can be in+GitHub flavored Markdown but not original Markdown. This is+implied by pandoc's default `all_symbols_escapable`.++#### Extension: `lists_without_preceding_blankline` ####++Allow a list to occur right after a paragraph, with no intervening+blank space.++#### Extension: `hard_line_breaks` ####++Causes all newlines within a paragraph to be interpreted as hard line+breaks instead of spaces.++#### Extension: `ignore_line_breaks` ####++Causes newlines within a paragraph to be ignored, rather than being+treated as spaces or as hard line breaks. This option is intended for+use with East Asian languages where spaces are not used between words,+but text is divided into lines for readability.++#### Extension: `east_asian_line_breaks` ####++Causes newlines within a paragraph to be ignored, rather than+being treated as spaces or as hard line breaks, when they occur+between two East Asian wide characters. This is a better choice+than `ignore_line_breaks` for texts that include a mix of East+Asian wide characters and other characters.++##### Extension: `emoji` ####++Parses textual emojis like `:smile:` as Unicode emoticons.++#### Extension: `tex_math_single_backslash` ####++Causes anything between `\(` and `\)` to be interpreted as inline+TeX math, and anything between `\[` and `\]` to be interpreted+as display TeX math. Note: a drawback of this extension is that+it precludes escaping `(` and `[`.++#### Extension: `tex_math_double_backslash` ####++Causes anything between `\\(` and `\\)` to be interpreted as inline+TeX math, and anything between `\\[` and `\\]` to be interpreted+as display TeX math.++#### Extension: `markdown_attribute` ####++By default, pandoc interprets material inside block-level tags as Markdown.+This extension changes the behavior so that Markdown is only parsed+inside block-level tags if the tags have the attribute `markdown=1`.++#### Extension: `mmd_title_block` ####++Enables a [MultiMarkdown] style title block at the top of+the document, for example:++ Title: My title+ Author: John Doe+ Date: September 1, 2008+ Comment: This is a sample mmd title block, with+ a field spanning multiple lines.++See the MultiMarkdown documentation for details. If `pandoc_title_block` or+`yaml_metadata_block` is enabled, it will take precedence over+`mmd_title_block`.++#### Extension: `abbreviations` ####++Parses PHP Markdown Extra abbreviation keys, like++ *[HTML]: Hypertext Markup Language++Note that the pandoc document model does not support+abbreviations, so if this extension is enabled, abbreviation keys are+simply skipped (as opposed to being parsed as paragraphs).++#### Extension: `autolink_bare_uris` ####++Makes all absolute URIs into links, even when not surrounded by+pointy braces `<...>`.++#### Extension: `ascii_identifiers` ####++Causes the identifiers produced by `auto_identifiers` to be pure ASCII.+Accents are stripped off of accented latin letters, and non-latin+letters are omitted.++#### Extension: `mmd_link_attributes` ####++Parses multimarkdown style key-value attributes on link+and image references. This extension should not be confused with the+[`link_attributes`](#extension-link_attributes) extension.++ This is a reference ![image][ref] with multimarkdown attributes.++ [ref]: http://path.to/image "Image title" width=20px height=30px+ id=myId class="myClass1 myClass2"++#### Extension: `mmd_header_identifiers` ####++Parses multimarkdown style header identifiers (in square brackets,+after the header but before any trailing `#`s in an ATX header).++#### Extension: `compact_definition_lists` ####++Activates the definition list syntax of pandoc 1.12.x and earlier.+This syntax differs from the one described above under [Definition lists]+in several respects:++ - No blank line is required between consecutive items of the+ definition list.+ - To get a "tight" or "compact" list, omit space between consecutive+ items; the space between a term and its definition does not affect+ anything.+ - Lazy wrapping of paragraphs is not allowed: the entire definition must+ be indented four spaces.[^6]++[^6]: To see why laziness is incompatible with relaxing the requirement+ of a blank line between items, consider the following example:++ bar+ : definition+ foo+ : definition++ Is this a single list item with two definitions of "bar," the first of+ which is lazily wrapped, or two list items? To remove the ambiguity+ we must either disallow lazy wrapping or require a blank line between+ list items.++Markdown variants+-----------------++In addition to pandoc's extended Markdown, the following Markdown+variants are supported:++`markdown_phpextra` (PHP Markdown Extra)+: `footnotes`, `pipe_tables`, `raw_html`, `markdown_attribute`,+ `fenced_code_blocks`, `definition_lists`, `intraword_underscores`,+ `header_attributes`, `link_attributes`, `abbreviations`,+ `shortcut_reference_links`.++`markdown_github` (GitHub-Flavored Markdown)+: `pipe_tables`, `raw_html`, `fenced_code_blocks`, `auto_identifiers`,+ `ascii_identifiers`, `backtick_code_blocks`, `autolink_bare_uris`,+ `intraword_underscores`, `strikeout`, `hard_line_breaks`, `emoji`,+ `shortcut_reference_links`, `angle_brackets_escapable`.++`markdown_mmd` (MultiMarkdown)+: `pipe_tables`, `raw_html`, `markdown_attribute`, `mmd_link_attributes`,+ `tex_math_double_backslash`, `intraword_underscores`,+ `mmd_title_block`, `footnotes`, `definition_lists`,+ `all_symbols_escapable`, `implicit_header_references`,+ `auto_identifiers`, `mmd_header_identifiers`,+ `shortcut_reference_links`.++`markdown_strict` (Markdown.pl)+: `raw_html`++Extensions with formats other than Markdown+-------------------------------------------++Some of the extensions discussed above can be used with formats+other than Markdown:++* `auto_identifiers` can be used with `latex`, `rst`, `mediawiki`,+ and `textile` input (and is used by default).++* `tex_math_dollars`, `tex_math_single_backslash`, and+ `tex_math_double_backslash` can be used with `html` input.+ (This is handy for reading web pages formatted using MathJax,+ for example.)++Producing slide shows with pandoc+=================================++You can use pandoc to produce an HTML + javascript slide presentation+that can be viewed via a web browser. There are five ways to do this,+using [S5], [DZSlides], [Slidy], [Slideous], or [reveal.js].+You can also produce a PDF slide show using LaTeX [`beamer`].++Here's the Markdown source for a simple slide show, `habits.txt`:++ % Habits+ % John Doe+ % March 22, 2005++ # In the morning++ ## Getting up++ - Turn off alarm+ - Get out of bed++ ## Breakfast++ - Eat eggs+ - Drink coffee++ # In the evening++ ## Dinner++ - Eat spaghetti+ - Drink wine++ ------------------++ ++ ## Going to sleep++ - Get in bed+ - Count sheep++To produce an HTML/javascript slide show, simply type++ pandoc -t FORMAT -s habits.txt -o habits.html++where `FORMAT` is either `s5`, `slidy`, `slideous`, `dzslides`, or `revealjs`.++For Slidy, Slideous, reveal.js, and S5, the file produced by pandoc with the+`-s/--standalone` option embeds a link to javascripts and CSS files, which are+assumed to be available at the relative path `s5/default` (for S5), `slideous`+(for Slideous), `reveal.js` (for reveal.js), or at the Slidy website at+`w3.org` (for Slidy). (These paths can be changed by setting the `slidy-url`,+`slideous-url`, `revealjs-url`, or `s5-url` variables; see [Variables for slides],+above.) For DZSlides, the (relatively short) javascript and css are included in+the file by default.++With all HTML slide formats, the `--self-contained` option can be used to+produce a single file that contains all of the data necessary to display the+slide show, including linked scripts, stylesheets, images, and videos.++To produce a PDF slide show using beamer, type++ pandoc -t beamer habits.txt -o habits.pdf++Note that a reveal.js slide show can also be converted to a PDF+by printing it to a file from the browser.++Structuring the slide show+--------------------------++By default, the *slide level* is the highest header level in+the hierarchy that is followed immediately by content, and not another+header, somewhere in the document. In the example above, level 1 headers+are always followed by level 2 headers, which are followed by content,+so 2 is the slide level. This default can be overridden using+the `--slide-level` option.++The document is carved up into slides according to the following+rules:++ * A horizontal rule always starts a new slide.++ * A header at the slide level always starts a new slide.++ * Headers *below* the slide level in the hierarchy create+ headers *within* a slide.++ * Headers *above* the slide level in the hierarchy create+ "title slides," which just contain the section title+ and help to break the slide show into sections.++ * A title page is constructed automatically from the document's title+ block, if present. (In the case of beamer, this can be disabled+ by commenting out some lines in the default template.)++These rules are designed to support many different styles of slide show. If+you don't care about structuring your slides into sections and subsections,+you can just use level 1 headers for all each slide. (In that case, level 1+will be the slide level.) But you can also structure the slide show into+sections, as in the example above.++Note: in reveal.js slide shows, if slide level is 2, a two-dimensional+layout will be produced, with level 1 headers building horizontally+and level 2 headers building vertically. It is not recommended that+you use deeper nesting of section levels with reveal.js.++Incremental lists+-----------------++By default, these writers produce lists that display "all at once."+If you want your lists to display incrementally (one item at a time),+use the `-i` option. If you want a particular list to depart from the+default (that is, to display incrementally without the `-i` option and+all at once with the `-i` option), put it in a block quote:++ > - Eat spaghetti+ > - Drink wine++In this way incremental and nonincremental lists can be mixed in+a single document.++Inserting pauses+----------------++You can add "pauses" within a slide by including a paragraph containing+three dots, separated by spaces:++ # Slide with a pause++ content before the pause++ . . .++ content after the pause++Styling the slides+------------------++You can change the style of HTML slides by putting customized CSS files+in `$DATADIR/s5/default` (for S5), `$DATADIR/slidy` (for Slidy),+or `$DATADIR/slideous` (for Slideous),+where `$DATADIR` is the user data directory (see `--data-dir`, above).+The originals may be found in pandoc's system data directory (generally+`$CABALDIR/pandoc-VERSION/s5/default`). Pandoc will look there for any+files it does not find in the user data directory.++For dzslides, the CSS is included in the HTML file itself, and may+be modified there.++All [reveal.js configuration options] can be set through variables.+For example, themes can be used by setting the `theme` variable:++ -V theme=moon++Or you can specify a custom stylesheet using the `--css` option.++To style beamer slides, you can specify a `theme`, `colortheme`,+`fonttheme`, `innertheme`, and `outertheme`, using the `-V` option:++ pandoc -t beamer habits.txt -V theme:Warsaw -o habits.pdf++Note that header attributes will turn into slide attributes+(on a `<div>` or `<section>`) in HTML slide formats, allowing you+to style individual slides. In beamer, the only header attribute+that affects slides is the `allowframebreaks` class, which sets the+`allowframebreaks` option, causing multiple slides to be created+if the content overfills the frame. This is recommended especially for+bibliographies:++ # References {.allowframebreaks}++Speaker notes+-------------++reveal.js has good support for speaker notes. You can add notes to your+Markdown document thus:++ <div class="notes">+ This is my note.++ - It can contain Markdown+ - like this list++ </div>++To show the notes window, press `s` while viewing the presentation.+Notes are not yet supported for other slide formats, but the notes+will not appear on the slides themselves.++Frame attributes in beamer+--------------------------++Sometimes it is necessary to add the LaTeX `[fragile]` option to+a frame in beamer (for example, when using the `minted` environment).+This can be forced by adding the `fragile` class to the header+introducing the slide:++ # Fragile slide {.fragile}++All of the other frame attributes described in Section 8.1 of+the [Beamer User's Guide] may also be used: `allowdisplaybreaks`,+`allowframebreaks`, `b`, `c`, `t`, `environment`, `label`, `plain`,+`shrink`.++Creating EPUBs with pandoc+==========================++EPUB Metadata+-------------++EPUB metadata may be specified using the `--epub-metadata` option, but+if the source document is Markdown, it is better to use a [YAML metadata+block][Extension: `yaml_metadata_block`]. Here is an example:++ ---+ title:+ - type: main+ text: My Book+ - type: subtitle+ text: An investigation of metadata+ creator:+ - role: author+ text: John Smith+ - role: editor+ text: Sarah Jones+ identifier:+ - scheme: DOI+ text: doi:10.234234.234/33+ publisher: My Press+ rights: © 2007 John Smith, CC BY-NC+ ...++The following fields are recognized:++`identifier`+ ~ Either a string value or an object with fields `text` and+ `scheme`. Valid values for `scheme` are `ISBN-10`,+ `GTIN-13`, `UPC`, `ISMN-10`, `DOI`, `LCCN`, `GTIN-14`,+ `ISBN-13`, `Legal deposit number`, `URN`, `OCLC`,+ `ISMN-13`, `ISBN-A`, `JP`, `OLCC`.++`title`+ ~ Either a string value, or an object with fields `file-as` and+ `type`, or a list of such objects. Valid values for `type` are+ `main`, `subtitle`, `short`, `collection`, `edition`, `extended`.++`creator`+ ~ Either a string value, or an object with fields `role`, `file-as`,+ and `text`, or a list of such objects. Valid values for `role` are+ [MARC relators], but+ pandoc will attempt to translate the human-readable versions+ (like "author" and "editor") to the appropriate marc relators.++`contributor`+ ~ Same format as `creator`.++`date`+ ~ A string value in `YYYY-MM-DD` format. (Only the year is necessary.)+ Pandoc will attempt to convert other common date formats.++`lang` (or legacy: `language`)+ ~ A string value in [BCP 47] format. Pandoc will default to the local+ language if nothing is specified.++`subject`+ ~ A string value or a list of such values.++`description`+ ~ A string value.++`type`+ ~ A string value.++`format`+ ~ A string value.++`relation`+ ~ A string value.++`coverage`+ ~ A string value.++`rights`+ ~ A string value.++`cover-image`+ ~ A string value (path to cover image).++`stylesheet`+ ~ A string value (path to CSS stylesheet).++`page-progression-direction`+ ~ Either `ltr` or `rtl`. Specifies the `page-progression-direction`+ attribute for the [`spine` element].++[MARC relators]: http://loc.gov/marc/relators/relaterm.html+[`spine` element]: http://idpf.org/epub/301/spec/epub-publications.html#sec-spine-elem++Linked media+------------++By default, pandoc will download linked media (including audio and+video) and include it in the EPUB container, yielding a completely+self-contained EPUB. If you want to link to external media resources+instead, use raw HTML in your source and add `data-external="1"` to the tag+with the `src` attribute. For example:++ <audio controls="1">+ <source src="http://example.com/music/toccata.mp3"+ data-external="1" type="audio/mpeg">+ </source>+ </audio>++Literate Haskell support+========================++If you append `+lhs` (or `+literate_haskell`) to an appropriate input or output+format (`markdown`, `markdown_strict`, `rst`, or `latex` for input or output;+`beamer`, `html` or `html5` for output only), pandoc will treat the document as+literate Haskell source. This means that++ - In Markdown input, "bird track" sections will be parsed as Haskell+ code rather than block quotations. Text between `\begin{code}`+ and `\end{code}` will also be treated as Haskell code. For+ ATX-style headers the character '=' will be used instead of '#'.++ - In Markdown output, code blocks with classes `haskell` and `literate`+ will be rendered using bird tracks, and block quotations will be+ indented one space, so they will not be treated as Haskell code.+ In addition, headers will be rendered setext-style (with underlines)+ rather than ATX-style (with '#' characters). (This is because ghc+ treats '#' characters in column 1 as introducing line numbers.)++ - In restructured text input, "bird track" sections will be parsed+ as Haskell code.++ - In restructured text output, code blocks with class `haskell` will+ be rendered using bird tracks.++ - In LaTeX input, text in `code` environments will be parsed as+ Haskell code.++ - In LaTeX output, code blocks with class `haskell` will be rendered+ inside `code` environments.++ - In HTML output, code blocks with class `haskell` will be rendered+ with class `literatehaskell` and bird tracks.++Examples:++ pandoc -f markdown+lhs -t html++reads literate Haskell source formatted with Markdown conventions and writes+ordinary HTML (without bird tracks).++ pandoc -f markdown+lhs -t html+lhs++writes HTML with the Haskell code in bird tracks, so it can be copied+and pasted as literate Haskell source.++Syntax highlighting+===================++Pandoc will automatically highlight syntax in [fenced code blocks] that+are marked with a language name. The Haskell library [highlighting-kate] is used for+highlighting, which works in HTML, Docx, and LaTeX/PDF output.+The color scheme can be selected using the `--highlight-style` option.+The default color scheme is `pygments`, which imitates the default color+scheme used by the Python library pygments, but pygments is not actually+used to do the highlighting.++To see a list of language names that pandoc will recognize, type+`pandoc --version`.++To disable highlighting, use the `--no-highlight` option.++[highlighting-kate]: https://github.com/jgm/highlighting-kate++Custom Styles in Docx Output+============================++By default, pandoc's docx output applies a predefined set of styles for+blocks such as paragraphs and block quotes, and uses largely default+formatting (italics, bold) for inlines. This will work for most+purposes, especially alongside a `reference.docx` file. However, if you+need to apply your own styles to blocks, or match a preexisting set of+styles, pandoc allows you to define custom styles for blocks and text+using `div`s and `span`s, respecitively.++If you define a `div` or `span` with the attribute `custom-style`,+pandoc will apply your specified style to the contained elements. So,+for example,++ <span custom-style="Emphatically">Get out,</span> he said.++would produce a docx file with "Get out," styled with character+style `Emphatically`. Similarly,++ Dickinson starts the poem simply:++ <div custom-style="Poetry">+ | A Bird came down the Walk---+ | He did not know I saw---+ </div>++would style the two contained lines with the `Poetry` paragraph style.++If the styles are not yet in your reference.docx, they will be defined+in the output file as inheriting from normal text. If they are already+defined, pandoc will not alter the definition.++This feature allows for greatest customization in conjunction with+[pandoc filters]. If you want all paragraphs after block quotes to be+indented, you can write a filter to apply the styles necessary. If you+want all italics to be transformed to the `Emphasis` character style+(perhaps to change their color), you can write a filter which will+transform all italicized inlines to inlines within an `Emphasis`+custom-style `span`.++[pandoc filters]: http://pandoc.org/scripting.html++Custom writers+==============++Pandoc can be extended with custom writers written in [lua]. (Pandoc+includes a lua interpreter, so lua need not be installed separately.)++To use a custom writer, simply specify the path to the lua script+in place of the output format. For example:++ pandoc -t data/sample.lua++Creating a custom writer requires writing a lua function for each+possible element in a pandoc document. To get a documented example+which you can modify according to your needs, do++ pandoc --print-default-data-file sample.lua++[lua]: http://www.lua.org++Authors+=======++© 2006-2016 John MacFarlane (jgm@berkeley.edu). Released under the+[GPL], version 2 or greater. This software carries no warranty of+any kind. (See COPYRIGHT for full copyright and warranty notices.)++Contributors include+Arata Mizuki,+Aaron Wolen,+Albert Krewinkel,+Alex Ivkin,+Alex Vong,+Alexander Kondratskiy,+Alexander Sulfrian,+Alexander V Vershilov,+Alfred Wechselberger,+Andreas Lööw,+Andrew Dunning,+Antoine Latter,+Arata Mizuki,+Arlo O'Keeffe,+Artyom Kazak,+B. Scott Michel,+Ben Gamari,+Beni Cherniavsky-Paskin,+Benoit Schweblin,+Bjorn Buckwalter,+Bradley Kuhn,+Brent Yorgey,+Bryan O'Sullivan,+Caleb McDaniel,+Calvin Beck,+Carlos Sosa,+Chris Black,+Christian Conkle,+Christoffer Ackelman,+Christoffer Sawicki,+Clare Macrae,+Clint Adams,+Conal Elliott,+Craig S. Bosma,+Daniel Bergey,+Daniel T. Staal,+Daniele D'Orazio,+David Lazar,+David Röthlisberger,+Denis Laxalde,+Douglas Calvert,+Emanuel Evans,+Emily Eisenberg,+Eric Kow,+Eric Seidel,+Felix Yan,+Florian Eitel,+François Gannaz,+Freiric Barral,+Freirich Raabe,+Frerich Raabe,+Fyodor Sheremetyev,+Gabor Pali,+Gavin Beatty,+Gottfried Haider,+Greg Maslov,+Greg Rundlett,+Grégory Bataille,+Gwern Branwen,+Hans-Peter Deifel,+Henrik Tramberend,+Henry de Valence,+Hubert Plociniczak,+Ilya V. Portnov,+Ivo Clarysse,+J. Lewis Muir,+Jaime Marquínez Ferrándiz,+Jakob Voß,+James Aspnes,+Jamie F. Olson,+Jan Larres,+Jan Schulz,+Jason Ronallo,+Jeff Arnold,+Jeff Runningen,+Jens Petersen,+Jesse Rosenthal,+Joe Hillenbrand,+John MacFarlane,+Jonas Smedegaard,+Jonathan Daugherty,+Jose Luis Duran,+Josef Svenningsson,+Julien Cretel,+Juliusz Gonera,+Justin Bogner,+Jérémy Bobbio,+Kelsey Hightower,+Kolen Cheung,+KolenCheung,+Konstantin Zudov,+Kristof Bastiaensen,+Lars-Dominik Braun,+Luke Plant,+Mark Szepieniec,+Mark Wright,+Martin Linn,+Masayoshi Takahashi,+Matej Kollar,+Mathias Schenner,+Mathieu Duponchelle,+Matthew Eddey,+Matthew Pickering,+Matthias C. M. Troffaes,+Mauro Bieg,+Max Bolingbroke,+Max Rydahl Andersen,+Merijn Verstraaten,+Michael Beaumont,+Michael Chladek,+Michael Snoyman,+Michael Thompson,+MinRK,+Morton Fox,+Nathan Gass,+Neil Mayhew,+Nick Bart,+Nicolas Kaiser,+Nikolay Yakimov,+Oliver Matthews,+Ophir Lifshitz,+Pablo Rodríguez,+Paul Rivier,+Paulo Tanimoto,+Peter Wang,+Philippe Ombredanne,+Phillip Alday,+Prayag Verma,+Puneeth Chaganti,+Ralf Stephan,+Raniere Silva,+Recai Oktaş,+RyanGlScott,+Scott Morrison,+Sergei Trofimovich,+Sergey Astanin,+Shahbaz Youssefi,+Shaun Attfield,+Sidarth Kapur,+Sidharth Kapur,+Simon Hengel,+Sumit Sahrawat,+Thomas Hodgson,+Thomas Weißschuh,+Tim Lin,+Timothy Humphries,+Tiziano Müller,+Todd Sifleet,+Tom Leese,+Uli Köhler,+Václav Zeman,+Viktor Kronvall,+Vincent,+Václav Zeman,+Waldir Pimenta,+Wikiwide,+Xavier Olive,+csforste,+infinity0x,+nkalvi,+qerub,+robabla,+roblabla,+rodja.trappe,+rski,+shreevatsa.public,+takahashim,+thsutton.++[GPL]: http://www.gnu.org/copyleft/gpl.html "GNU General Public License"
− README
@@ -1,4007 +0,0 @@-% Pandoc User's Guide-% John MacFarlane-% July 17, 2016--Synopsis-========--`pandoc` [*options*] [*input-file*]...--Description-===========--Pandoc is a [Haskell] library for converting from one markup format to-another, and a command-line tool that uses this library. It can read-[Markdown], [CommonMark], [PHP Markdown Extra], [GitHub-Flavored Markdown],-[MultiMarkdown], and (subsets of) [Textile], [reStructuredText], [HTML],-[LaTeX], [MediaWiki markup], [TWiki markup], [Haddock markup], [OPML], [Emacs-Org mode], [DocBook], [txt2tags], [EPUB], [ODT] and [Word docx]; and it can-write plain text, [Markdown], [CommonMark], [PHP Markdown Extra],-[GitHub-Flavored Markdown], [MultiMarkdown], [reStructuredText], [XHTML],-[HTML5], [LaTeX] (including [`beamer`] slide shows), [ConTeXt], [RTF], [OPML],-[DocBook], [OpenDocument], [ODT], [Word docx], [GNU Texinfo], [MediaWiki-markup], [DokuWiki markup], [ZimWiki markup], [Haddock markup],-[EPUB] (v2 or v3), [FictionBook2], [Textile], [groff man] pages,-[Emacs Org mode], [AsciiDoc], [InDesign ICML], [TEI Simple], and [Slidy],-[Slideous], [DZSlides], [reveal.js] or [S5] HTML slide shows. It can also-produce [PDF] output on systems where LaTeX, ConTeXt, or `wkhtmltopdf` is-installed.--Pandoc's enhanced version of Markdown includes syntax for [footnotes],-[tables], flexible [ordered lists], [definition lists], [fenced code blocks],-[superscripts and subscripts], [strikeout], [metadata blocks], automatic tables of-contents, embedded LaTeX [math], [citations], and [Markdown inside HTML block-elements][Extension: `markdown_in_html_blocks`]. (These enhancements, described below under-[Pandoc's Markdown], can be disabled using the-`markdown_strict` input or output format.)--In contrast to most existing tools for converting Markdown to HTML, which-use regex substitutions, pandoc has a modular design: it consists of a-set of readers, which parse text in a given format and produce a native-representation of the document, and a set of writers, which convert-this native representation into a target format. Thus, adding an input-or output format requires only adding a reader or writer.--Because pandoc's intermediate representation of a document is less-expressive than many of the formats it converts between, one should-not expect perfect conversions between every format and every other.-Pandoc attempts to preserve the structural elements of a document, but-not formatting details such as margin size. And some document elements,-such as complex tables, may not fit into pandoc's simple document-model. While conversions from pandoc's Markdown to all formats aspire-to be perfect, conversions from formats more expressive than pandoc's-Markdown can be expected to be lossy.--[Markdown]: http://daringfireball.net/projects/markdown/-[CommonMark]: http://commonmark.org-[PHP Markdown Extra]: https://michelf.ca/projects/php-markdown/extra/-[GitHub-Flavored Markdown]: https://help.github.com/articles/github-flavored-markdown/-[MultiMarkdown]: http://fletcherpenney.net/multimarkdown/-[reStructuredText]: http://docutils.sourceforge.net/docs/ref/rst/introduction.html-[S5]: http://meyerweb.com/eric/tools/s5/-[Slidy]: http://www.w3.org/Talks/Tools/Slidy/-[Slideous]: http://goessner.net/articles/slideous/-[HTML]: http://www.w3.org/html/-[HTML5]: http://www.w3.org/TR/html5/-[XHTML]: http://www.w3.org/TR/xhtml1/-[LaTeX]: http://latex-project.org-[`beamer`]: https://ctan.org/pkg/beamer-[Beamer User's Guide]: http://ctan.math.utah.edu/ctan/tex-archive/macros/latex/contrib/beamer/doc/beameruserguide.pdf-[ConTeXt]: http://contextgarden.net/-[RTF]: http://en.wikipedia.org/wiki/Rich_Text_Format-[DocBook]: http://docbook.org-[txt2tags]: http://txt2tags.org-[EPUB]: http://idpf.org/epub-[OPML]: http://dev.opml.org/spec2.html-[OpenDocument]: http://opendocument.xml.org-[ODT]: http://en.wikipedia.org/wiki/OpenDocument-[Textile]: http://redcloth.org/textile-[MediaWiki markup]: https://www.mediawiki.org/wiki/Help:Formatting-[DokuWiki markup]: https://www.dokuwiki.org/dokuwiki-[ZimWiki markup]: http://zim-wiki.org/manual/Help/Wiki_Syntax.html-[TWiki markup]: http://twiki.org/cgi-bin/view/TWiki/TextFormattingRules-[Haddock markup]: https://www.haskell.org/haddock/doc/html/ch03s08.html-[groff man]: http://developer.apple.com/DOCUMENTATION/Darwin/Reference/ManPages/man7/groff_man.7.html-[Haskell]: https://www.haskell.org-[GNU Texinfo]: http://www.gnu.org/software/texinfo/-[Emacs Org mode]: http://orgmode.org-[AsciiDoc]: http://www.methods.co.nz/asciidoc/-[DZSlides]: http://paulrouget.com/dzslides/-[Word docx]: http://www.microsoft.com/interop/openup/openxml/default.aspx-[PDF]: https://www.adobe.com/pdf/-[reveal.js]: http://lab.hakim.se/reveal-js/-[FictionBook2]: http://www.fictionbook.org/index.php/Eng:XML_Schema_Fictionbook_2.1-[InDesign ICML]: https://www.adobe.com/content/dam/Adobe/en/devnet/indesign/cs55-docs/IDML/idml-specification.pdf-[TEI Simple]: https://github.com/TEIC/TEI-Simple--Using `pandoc`-----------------If no *input-file* is specified, input is read from *stdin*.-Otherwise, the *input-files* are concatenated (with a blank-line between each) and used as input. Output goes to *stdout* by-default (though output to *stdout* is disabled for the `odt`, `docx`,-`epub`, and `epub3` output formats). For output to a file, use the-`-o` option:-- pandoc -o output.html input.txt--By default, pandoc produces a document fragment, not a standalone-document with a proper header and footer. To produce a standalone-document, use the `-s` or `--standalone` flag:-- pandoc -s -o output.html input.txt--For more information on how standalone documents are produced, see-[Templates], below.--Instead of a file, an absolute URI may be given. In this case-pandoc will fetch the content using HTTP:-- pandoc -f html -t markdown http://www.fsf.org--If multiple input files are given, `pandoc` will concatenate them all (with-blank lines between them) before parsing. This feature is disabled for- binary input formats such as `EPUB`, `odt`, and `docx`.--The format of the input and output can be specified explicitly using-command-line options. The input format can be specified using the-`-r/--read` or `-f/--from` options, the output format using the-`-w/--write` or `-t/--to` options. Thus, to convert `hello.txt` from-Markdown to LaTeX, you could type:-- pandoc -f markdown -t latex hello.txt--To convert `hello.html` from HTML to Markdown:-- pandoc -f html -t markdown hello.html--Supported output formats are listed below under the `-t/--to` option.-Supported input formats are listed below under the `-f/--from` option. Note-that the `rst`, `textile`, `latex`, and `html` readers are not complete;-there are some constructs that they do not parse.--If the input or output format is not specified explicitly, `pandoc`-will attempt to guess it from the extensions of-the input and output filenames. Thus, for example,-- pandoc -o hello.tex hello.txt--will convert `hello.txt` from Markdown to LaTeX. If no output file-is specified (so that output goes to *stdout*), or if the output file's-extension is unknown, the output format will default to HTML.-If no input file is specified (so that input comes from *stdin*), or-if the input files' extensions are unknown, the input format will-be assumed to be Markdown unless explicitly specified.--Pandoc uses the UTF-8 character encoding for both input and output.-If your local character encoding is not UTF-8, you-should pipe input and output through [`iconv`]:-- iconv -t utf-8 input.txt | pandoc | iconv -f utf-8--Note that in some output formats (such as HTML, LaTeX, ConTeXt,-RTF, OPML, DocBook, and Texinfo), information about-the character encoding is included in the document header, which-will only be included if you use the `-s/--standalone` option.--[`iconv`]: http://www.gnu.org/software/libiconv/--Creating a PDF-----------------To produce a PDF, specify an output file with a `.pdf` extension.-By default, pandoc will use LaTeX to convert it to PDF:-- pandoc test.txt -o test.pdf--Production of a PDF requires that a LaTeX engine be installed (see-`--latex-engine`, below), and assumes that the following LaTeX packages-are available: [`amsfonts`], [`amsmath`], [`lm`],-[`ifxetex`], [`ifluatex`], [`eurosym`], [`listings`] (if the-`--listings` option is used), [`fancyvrb`], [`longtable`],-[`booktabs`], [`graphicx`] and [`grffile`] (if the-document contains images), [`hyperref`], [`ulem`],-[`geometry`] (with the `geometry` variable set), [`setspace`] (with-`linestretch`), and [`babel`] (with `lang`). The use of `xelatex` or-`lualatex` as the LaTeX engine requires [`fontspec`]; `xelatex` uses-[`mathspec`], [`polyglossia`] (with `lang`), [`xecjk`], and-[`bidi`] (with the `dir` variable set). The [`upquote`] and-[`microtype`] packages are used if available, and [`csquotes`] will-be used for [smart punctuation] if added to the template or included in-any header file. The [`natbib`], [`biblatex`], [`bibtex`], and [`biber`]-packages can optionally be used for [citation rendering]. These are-included with all recent versions of [TeX Live].--Alternatively, pandoc can use ConTeXt or `wkhtmltopdf` to create a PDF.-To do this, specify an output file with a `.pdf` extension,-as before, but add `-t context` or `-t html5` to the command line.--PDF output can be controlled using [variables for LaTeX] (if-LaTeX is used) and [variables for ConTeXt] (if ConTeXt is used).-If `wkhtmltopdf` is used, then the variables `margin-left`,-`margin-right`, `margin-top`, `margin-bottom`, and `papersize`-will affect the output, as will `--css`.--[`amsfonts`]: https://ctan.org/pkg/amsfonts-[`amsmath`]: https://ctan.org/pkg/amsmath-[`lm`]: https://ctan.org/pkg/lm-[`ifxetex`]: https://ctan.org/pkg/ifxetex-[`ifluatex`]: https://ctan.org/pkg/ifluatex-[`eurosym`]: https://ctan.org/pkg/eurosym-[`listings`]: https://ctan.org/pkg/listings-[`fancyvrb`]: https://ctan.org/pkg/fancyvrb-[`longtable`]: https://ctan.org/pkg/longtable-[`booktabs`]: https://ctan.org/pkg/booktabs-[`graphicx`]: https://ctan.org/pkg/graphicx-[`grffile`]: https://ctan.org/pkg/grffile-[`geometry`]: https://ctan.org/pkg/geometry-[`setspace`]: https://ctan.org/pkg/setspace-[`xecjk`]: https://ctan.org/pkg/xecjk-[`hyperref`]: https://ctan.org/pkg/hyperref-[`ulem`]: https://ctan.org/pkg/ulem-[`babel`]: https://ctan.org/pkg/babel-[`bidi`]: https://ctan.org/pkg/bidi-[`mathspec`]: https://ctan.org/pkg/mathspec-[`polyglossia`]: https://ctan.org/pkg/polyglossia-[`fontspec`]: https://ctan.org/pkg/fontspec-[`upquote`]: https://ctan.org/pkg/upquote-[`microtype`]: https://ctan.org/pkg/microtype-[`csquotes`]: https://ctan.org/pkg/csquotes-[`natbib`]: https://ctan.org/pkg/natbib-[`biblatex`]: https://ctan.org/pkg/biblatex-[`bibtex`]: https://ctan.org/pkg/bibtex-[`biber`]: https://ctan.org/pkg/biber-[TeX Live]: http://www.tug.org/texlive/--Options-=======--General options------------------`-f` *FORMAT*, `-r` *FORMAT*, `--from=`*FORMAT*, `--read=`*FORMAT*--: Specify input format. *FORMAT* can be `native` (native Haskell),- `json` (JSON version of native AST), `markdown` (pandoc's- extended Markdown), `markdown_strict` (original unextended- Markdown), `markdown_phpextra` (PHP Markdown Extra), `markdown_github`- (GitHub-Flavored Markdown), `markdown_mmd` (MultiMarkdown),- `commonmark` (CommonMark Markdown), `textile` (Textile), `rst`- (reStructuredText), `html` (HTML), `docbook` (DocBook), `t2t`- (txt2tags), `docx` (docx), `odt` (ODT), `epub` (EPUB), `opml` (OPML),- `org` (Emacs Org mode), `mediawiki` (MediaWiki markup), `twiki` (TWiki- markup), `haddock` (Haddock markup), or `latex` (LaTeX). If- `+lhs` is appended to `markdown`, `rst`, `latex`, or `html`, the- input will be treated as literate Haskell source: see [Literate- Haskell support], below. Markdown- syntax extensions can be individually enabled or disabled by- appending `+EXTENSION` or `-EXTENSION` to the format name. So, for- example, `markdown_strict+footnotes+definition_lists` is strict- Markdown with footnotes and definition lists enabled, and- `markdown-pipe_tables+hard_line_breaks` is pandoc's Markdown- without pipe tables and with hard line breaks. See [Pandoc's- Markdown], below, for a list of extensions and- their names.--`-t` *FORMAT*, `-w` *FORMAT*, `--to=`*FORMAT*, `--write=`*FORMAT*--: Specify output format. *FORMAT* can be `native` (native Haskell),- `json` (JSON version of native AST), `plain` (plain text),- `markdown` (pandoc's extended Markdown), `markdown_strict`- (original unextended Markdown), `markdown_phpextra` (PHP Markdown- Extra), `markdown_github` (GitHub-Flavored Markdown), `markdown_mmd`- (MultiMarkdown), `commonmark` (CommonMark Markdown), `rst`- (reStructuredText), `html` (XHTML), `html5` (HTML5), `latex`- (LaTeX), `beamer` (LaTeX beamer slide show), `context` (ConTeXt),- `man` (groff man), `mediawiki` (MediaWiki markup),- `dokuwiki` (DokuWiki markup), `zimwiki` (ZimWiki markup),- `textile` (Textile), `org` (Emacs Org mode),- `texinfo` (GNU Texinfo), `opml` (OPML), `docbook` (DocBook 4),- `docbook5` (DocBook 5), `opendocument` (OpenDocument), `odt`- (OpenOffice text document), `docx` (Word docx), `haddock`- (Haddock markup), `rtf` (rich text format), `epub` (EPUB v2- book), `epub3` (EPUB v3), `fb2` (FictionBook2 e-book),- `asciidoc` (AsciiDoc), `icml` (InDesign ICML), `tei` (TEI- Simple), `slidy` (Slidy HTML and javascript slide show),- `slideous` (Slideous HTML and javascript slide show),- `dzslides` (DZSlides HTML5 + javascript slide show),- `revealjs` (reveal.js HTML5 + javascript slide show), `s5`- (S5 HTML and javascript slide show), or the path of a custom- lua writer (see [Custom writers], below). Note that `odt`,- `epub`, and `epub3` output will not be directed to *stdout*;- an output filename must be specified using the `-o/--output`- option. If `+lhs` is appended to `markdown`, `rst`, `latex`,- `beamer`, `html`, or `html5`, the output will be rendered as- literate Haskell source: see [Literate Haskell support],- below. Markdown syntax extensions can be individually- enabled or disabled by appending `+EXTENSION` or- `-EXTENSION` to the format name, as described above under `-f`.--`-o` *FILE*, `--output=`*FILE*--: Write output to *FILE* instead of *stdout*. If *FILE* is- `-`, output will go to *stdout*. (Exception: if the output- format is `odt`, `docx`, `epub`, or `epub3`, output to stdout is disabled.)--`--data-dir=`*DIRECTORY*--: Specify the user data directory to search for pandoc data files.- If this option is not specified, the default user data directory- will be used. This is, in Unix:-- $HOME/.pandoc-- in Windows XP:-- C:\Documents And Settings\USERNAME\Application Data\pandoc-- and in Windows Vista or later:-- C:\Users\USERNAME\AppData\Roaming\pandoc-- You can find the default user data directory on your system by- looking at the output of `pandoc --version`.- A `reference.odt`, `reference.docx`, `epub.css`, `templates`,- `slidy`, `slideous`, or `s5` directory- placed in this directory will override pandoc's normal defaults.--`--bash-completion`--: Generate a bash completion script. To enable bash completion- with pandoc, add this to your `.bashrc`:-- eval "$(pandoc --bash-completion)"--`--verbose`--: Give verbose debugging output. Currently this only has an effect- with PDF output.--`-v`, `--version`--: Print version.--`-h`, `--help`--: Show usage message.--Reader options-----------------`-R`, `--parse-raw`--: Parse untranslatable HTML codes and LaTeX environments as raw HTML- or LaTeX, instead of ignoring them. Affects only HTML and LaTeX- input. Raw HTML can be printed in Markdown, reStructuredText, Emacs Org- mode, HTML, Slidy, Slideous, DZSlides, reveal.js, and S5 output; raw LaTeX- can be printed in Markdown, reStructuredText, Emacs Org mode, LaTeX, and- ConTeXt output. The default is for the readers to omit untranslatable- HTML codes and LaTeX environments. (The LaTeX reader does pass through- untranslatable LaTeX *commands*, even if `-R` is not specified.)--`-S`, `--smart`--: Produce typographically correct output, converting straight quotes- to curly quotes, `---` to em-dashes, `--` to en-dashes, and- `...` to ellipses. Nonbreaking spaces are inserted after certain- abbreviations, such as "Mr." (Note: This option is selected automatically- when the output format is `latex` or `context`, unless `--no-tex-ligatures`- is used. It has no effect for `latex` input.)--`--old-dashes`--: Selects the pandoc <= 1.8.2.1 behavior for parsing smart dashes: `-` before- a numeral is an en-dash, and `--` is an em-dash. This option is selected- automatically for `textile` input.--`--base-header-level=`*NUMBER*--: Specify the base level for headers (defaults to 1).--`--indented-code-classes=`*CLASSES*--: Specify classes to use for indented code blocks--for example,- `perl,numberLines` or `haskell`. Multiple classes may be separated- by spaces or commas.--`--default-image-extension=`*EXTENSION*--: Specify a default extension to use when image paths/URLs have no- extension. This allows you to use the same source for formats that- require different kinds of images. Currently this option only affects- the Markdown and LaTeX readers.--`--file-scope`--: Parse each file individually before combining for multifile- documents. This will allow footnotes in different files with the- same identifiers to work as expected. If this option is set,- footnotes and links will not work across files. Reading binary- files (docx, odt, epub) implies `--file-scope`.--`--filter=`*EXECUTABLE*--: Specify an executable to be used as a filter transforming the- pandoc AST after the input is parsed and before the output is- written. The executable should read JSON from stdin and write- JSON to stdout. The JSON must be formatted like pandoc's own- JSON input and output. The name of the output format will be- passed to the filter as the first argument. Hence,-- pandoc --filter ./caps.py -t latex-- is equivalent to-- pandoc -t json | ./caps.py latex | pandoc -f json -t latex-- The latter form may be useful for debugging filters.-- Filters may be written in any language. `Text.Pandoc.JSON`- exports `toJSONFilter` to facilitate writing filters in Haskell.- Those who would prefer to write filters in python can use the- module [`pandocfilters`], installable from PyPI. There are also- pandoc filter libraries in [PHP], [perl], and [javascript/node.js].-- Note that the *EXECUTABLE* will be sought in the user's- `PATH`, and not in the working directory, if no directory is- provided. If you want to run a script in the working directory,- preface the filename with `./`.--`-M` *KEY*[`=`*VAL*], `--metadata=`*KEY*[`:`*VAL*]--: Set the metadata field *KEY* to the value *VAL*. A value specified- on the command line overrides a value specified in the document.- Values will be parsed as YAML boolean or string values. If no value is- specified, the value will be treated as Boolean true. Like- `--variable`, `--metadata` causes template variables to be set.- But unlike `--variable`, `--metadata` affects the metadata of the- underlying document (which is accessible from filters and may be- printed in some output formats).--`--normalize`--: Normalize the document after reading: merge adjacent- `Str` or `Emph` elements, for example, and remove repeated `Space`s.--`-p`, `--preserve-tabs`--: Preserve tabs instead of converting them to spaces (the default).- Note that this will only affect tabs in literal code spans and code- blocks; tabs in regular text will be treated as spaces.--`--tab-stop=`*NUMBER*--: Specify the number of spaces per tab (default is 4).--`--track-changes=accept`|`reject`|`all`--: Specifies what to do with insertions, deletions, and comments- produced by the MS Word "Track Changes" feature. `accept` (the- default), inserts all insertions, and ignores all- deletions. `reject` inserts all deletions and ignores- insertions. Both `accept` and `reject` ignore comments. `all` puts- in insertions, deletions, and comments, wrapped in spans with- `insertion`, `deletion`, `comment-start`, and `comment-end`- classes, respectively. The author and time of change is- included. `all` is useful for scripting: only accepting changes- from a certain reviewer, say, or before a certain date. This- option only affects the docx reader.--`--extract-media=`*DIR*--: Extract images and other media contained in a docx or epub container- to the path *DIR*, creating it if necessary, and adjust the images- references in the document so they point to the extracted files.- This option only affects the docx and epub readers.--[`pandocfilters`]: https://github.com/jgm/pandocfilters-[PHP]: https://github.com/vinai/pandocfilters-php-[perl]: https://metacpan.org/pod/Pandoc::Filter-[javascript/node.js]: https://github.com/mvhenderson/pandoc-filter-node--General writer options-------------------------`-s`, `--standalone`--: Produce output with an appropriate header and footer (e.g. a- standalone HTML, LaTeX, TEI, or RTF file, not a fragment). This option- is set automatically for `pdf`, `epub`, `epub3`, `fb2`, `docx`, and `odt`- output.--`--template=`*FILE*--: Use *FILE* as a custom template for the generated document. Implies- `--standalone`. See [Templates], below, for a description- of template syntax. If no extension is specified, an extension- corresponding to the writer will be added, so that `--template=special`- looks for `special.html` for HTML output. If the template is not- found, pandoc will search for it in the `templates` subdirectory of- the user data directory (see `--data-dir`). If this option is not used,- a default template appropriate for the output format will be used (see- `-D/--print-default-template`).--`-V` *KEY*[`=`*VAL*], `--variable=`*KEY*[`:`*VAL*]--: Set the template variable *KEY* to the value *VAL* when rendering the- document in standalone mode. This is generally only useful when the- `--template` option is used to specify a custom template, since- pandoc automatically sets the variables used in the default- templates. If no *VAL* is specified, the key will be given the- value `true`.--`-D` *FORMAT*, `--print-default-template=`*FORMAT*--: Print the system default template for an output *FORMAT*. (See `-t`- for a list of possible *FORMAT*s.) Templates in the user data- directory are ignored.--`--print-default-data-file=`*FILE*--: Print a system default data file. Files in the user data directory- are ignored.--`--dpi`=*NUMBER*-: Specify the dpi (dots per inch) value for conversion from pixels- to inch/centimeters and vice versa. The default is 96dpi.- Technically, the correct term would be ppi (pixels per inch).--`--wrap=[auto|none|preserve]`--: Determine how text is wrapped in the output (the source- code, not the rendered version). With `auto` (the default),- pandoc will attempt to wrap lines to the column width specified by- `--columns` (default 80). With `none`, pandoc will not wrap- lines at all. With `preserve`, pandoc will attempt to- preserve the wrapping from the source document (that is,- where there are nonsemantic newlines in the source, there- will be nonsemantic newlines in the output as well).--`--no-wrap`--: Deprecated synonym for `--wrap=none`.--`--columns=`*NUMBER*--: Specify length of lines in characters. This affects text wrapping- in the generated source code (see `--wrap`). It also affects- calculation of column widths for plain text tables (see [Tables] below).--`--toc`, `--table-of-contents`--: Include an automatically generated table of contents (or, in- the case of `latex`, `context`, `docx`, and `rst`, an instruction to create- one) in the output document. This option has no effect on `man`,- `docbook`, `docbook5`, `slidy`, `slideous`, `s5`, or `odt` output.--`--toc-depth=`*NUMBER*--: Specify the number of section levels to include in the table- of contents. The default is 3 (which means that level 1, 2, and 3- headers will be listed in the contents).--`--no-highlight`--: Disables syntax highlighting for code blocks and inlines, even when- a language attribute is given.--`--highlight-style=`*STYLE*--: Specifies the coloring style to be used in highlighted source code.- Options are `pygments` (the default), `kate`, `monochrome`,- `espresso`, `zenburn`, `haddock`, and `tango`. For more information- on syntax highlighting in pandoc, see [Syntax highlighting], below.--`-H` *FILE*, `--include-in-header=`*FILE*--: Include contents of *FILE*, verbatim, at the end of the header.- This can be used, for example, to include special- CSS or javascript in HTML documents. This option can be used- repeatedly to include multiple files in the header. They will be- included in the order specified. Implies `--standalone`.--`-B` *FILE*, `--include-before-body=`*FILE*--: Include contents of *FILE*, verbatim, at the beginning of the- document body (e.g. after the `<body>` tag in HTML, or the- `\begin{document}` command in LaTeX). This can be used to include- navigation bars or banners in HTML documents. This option can be- used repeatedly to include multiple files. They will be included in- the order specified. Implies `--standalone`.--`-A` *FILE*, `--include-after-body=`*FILE*--: Include contents of *FILE*, verbatim, at the end of the document- body (before the `</body>` tag in HTML, or the- `\end{document}` command in LaTeX). This option can be used- repeatedly to include multiple files. They will be included in the- order specified. Implies `--standalone`.--Options affecting specific writers-------------------------------------`--self-contained`--: Produce a standalone HTML file with no external dependencies, using- `data:` URIs to incorporate the contents of linked scripts, stylesheets,- images, and videos. The resulting file should be "self-contained,"- in the sense that it needs no external files and no net access to be- displayed properly by a browser. This option works only with HTML output- formats, including `html`, `html5`, `html+lhs`, `html5+lhs`, `s5`,- `slidy`, `slideous`, `dzslides`, and `revealjs`. Scripts, images, and- stylesheets at absolute URLs will be downloaded; those at relative URLs- will be sought relative to the working directory (if the first source- file is local) or relative to the base URL (if the first source- file is remote). Limitation: resources that are loaded dynamically- through JavaScript cannot be incorporated; as a result, `--self-contained`- does not work with `--mathjax`, and some advanced features (e.g.- zoom or speaker notes) may not work in an offline "self-contained"- `reveal.js` slide show.--`--html-q-tags`--: Use `<q>` tags for quotes in HTML.--`--ascii`--: Use only ascii characters in output. Currently supported only- for HTML output (which uses numerical entities instead of- UTF-8 when this option is selected).--`--reference-links`--: Use reference-style links, rather than inline links, in writing Markdown- or reStructuredText. By default inline links are used.--`--atx-headers`--: Use ATX-style headers in Markdown and asciidoc output. The default is- to use setext-style headers for levels 1-2, and then ATX headers.--`--chapters`--: Treat top-level headers as chapters in LaTeX, ConTeXt, and DocBook- output. When the LaTeX document class is set to `report`, `book`,- or `memoir` (unless the `article` option is specified), this- option is implied. If `beamer` is the output format, top-level- headers will become `\part{..}`.--`-N`, `--number-sections`--: Number section headings in LaTeX, ConTeXt, HTML, or EPUB output.- By default, sections are not numbered. Sections with class- `unnumbered` will never be numbered, even if `--number-sections`- is specified.--`--number-offset=`*NUMBER*[`,`*NUMBER*`,`*...*]--: Offset for section headings in HTML output (ignored in other- output formats). The first number is added to the section number for- top-level headers, the second for second-level headers, and so on.- So, for example, if you want the first top-level header in your- document to be numbered "6", specify `--number-offset=5`.- If your document starts with a level-2 header which you want to- be numbered "1.5", specify `--number-offset=1,4`.- Offsets are 0 by default. Implies `--number-sections`.--`--no-tex-ligatures`--: Do not use the TeX ligatures for quotation marks, apostrophes,- and dashes (`` `...' ``, ` ``..'' `, `--`, `---`) when- writing or reading LaTeX or ConTeXt. In reading LaTeX,- parse the characters `` ` ``, `'`, and `-` literally, rather- than parsing ligatures for quotation marks and dashes. In- writing LaTeX or ConTeXt, print unicode quotation mark and- dash characters literally, rather than converting them to- the standard ASCII TeX ligatures. Note: normally `--smart`- is selected automatically for LaTeX and ConTeXt output, but- it must be specified explicitly if `--no-tex-ligatures` is- selected. If you use literal curly quotes, dashes, and- ellipses in your source, then you may want to use- `--no-tex-ligatures` without `--smart`.--`--listings`--: Use the [`listings`] package for LaTeX code blocks--`-i`, `--incremental`--: Make list items in slide shows display incrementally (one by one).- The default is for lists to be displayed all at once.--`--slide-level=`*NUMBER*--: Specifies that headers with the specified level create- slides (for `beamer`, `s5`, `slidy`, `slideous`, `dzslides`). Headers- above this level in the hierarchy are used to divide the- slide show into sections; headers below this level create- subheads within a slide. The default is to set the slide level- based on the contents of the document; see- [Structuring the slide show].--`--section-divs`--: Wrap sections in `<div>` tags (or `<section>` tags in HTML5),- and attach identifiers to the enclosing `<div>` (or `<section>`)- rather than the header itself. See- [Header identifiers], below.--`--email-obfuscation=none`|`javascript`|`references`--: Specify a method for obfuscating `mailto:` links in HTML documents.- `none` leaves `mailto:` links as they are. `javascript` obfuscates- them using javascript. `references` obfuscates them by printing their- letters as decimal or hexadecimal character references. The default- is `none`.--`--id-prefix=`*STRING*--: Specify a prefix to be added to all automatically generated identifiers- in HTML and DocBook output, and to footnote numbers in Markdown output.- This is useful for preventing duplicate identifiers when generating- fragments to be included in other pages.--`-T` *STRING*, `--title-prefix=`*STRING*--: Specify *STRING* as a prefix at the beginning of the title- that appears in the HTML header (but not in the title as it- appears at the beginning of the HTML body). Implies- `--standalone`.--`-c` *URL*, `--css=`*URL*--: Link to a CSS style sheet. This option can be used repeatedly to- include multiple files. They will be included in the order specified.--`--reference-odt=`*FILE*--: Use the specified file as a style reference in producing an ODT.- For best results, the reference ODT should be a modified version- of an ODT produced using pandoc. The contents of the reference ODT- are ignored, but its stylesheets are used in the new ODT. If no- reference ODT is specified on the command line, pandoc will look- for a file `reference.odt` in the user data directory (see- `--data-dir`). If this is not found either, sensible defaults will be- used.--`--reference-docx=`*FILE*--: Use the specified file as a style reference in producing a docx file.- For best results, the reference docx should be a modified version- of a docx file produced using pandoc. The contents of the reference docx- are ignored, but its stylesheets and document properties (including- margins, page size, header, and footer) are used in the new docx. If no- reference docx is specified on the command line, pandoc will look- for a file `reference.docx` in the user data directory (see- `--data-dir`). If this is not found either, sensible defaults will be- used. The following styles are used by pandoc: [paragraph]- Normal, Body Text, First Paragraph, Compact, Title, Subtitle, Author, Date,- Abstract, Bibliography, Heading 1, Heading 2, Heading 3, Heading 4,- Heading 5, Heading 6, Block Text, Footnote Text, Definition Term,- Definition, Caption, Table Caption, Image Caption, Figure,- Figure With Caption, TOC Heading;- [character] Default Paragraph Font, Body Text Char, Verbatim Char,- Footnote Reference, Hyperlink; [table] Normal Table.--`--epub-stylesheet=`*FILE*--: Use the specified CSS file to style the EPUB. If no stylesheet- is specified, pandoc will look for a file `epub.css` in the- user data directory (see `--data-dir`). If it is not- found there, sensible defaults will be used.--`--epub-cover-image=`*FILE*--: Use the specified image as the EPUB cover. It is recommended- that the image be less than 1000px in width and height. Note that- in a Markdown source document you can also specify `cover-image`- in a YAML metadata block (see [EPUB Metadata], below).--`--epub-metadata=`*FILE*--: Look in the specified XML file for metadata for the EPUB.- The file should contain a series of [Dublin Core elements].- For example:-- <dc:rights>Creative Commons</dc:rights>- <dc:language>es-AR</dc:language>-- By default, pandoc will include the following metadata elements:- `<dc:title>` (from the document title), `<dc:creator>` (from the- document authors), `<dc:date>` (from the document date, which should- be in [ISO 8601 format]), `<dc:language>` (from the `lang`- variable, or, if is not set, the locale), and `<dc:identifier- id="BookId">` (a randomly generated UUID). Any of these may be- overridden by elements in the metadata file.-- Note: if the source document is Markdown, a YAML metadata block- in the document can be used instead. See below under- [EPUB Metadata].--`--epub-embed-font=`*FILE*--: Embed the specified font in the EPUB. This option can be repeated- to embed multiple fonts. Wildcards can also be used: for example,- `DejaVuSans-*.ttf`. However, if you use wildcards on the command- line, be sure to escape them or put the whole filename in single quotes,- to prevent them from being interpreted by the shell. To use the- embedded fonts, you will need to add declarations like the following- to your CSS (see `--epub-stylesheet`):-- @font-face {- font-family: DejaVuSans;- font-style: normal;- font-weight: normal;- src:url("DejaVuSans-Regular.ttf");- }- @font-face {- font-family: DejaVuSans;- font-style: normal;- font-weight: bold;- src:url("DejaVuSans-Bold.ttf");- }- @font-face {- font-family: DejaVuSans;- font-style: italic;- font-weight: normal;- src:url("DejaVuSans-Oblique.ttf");- }- @font-face {- font-family: DejaVuSans;- font-style: italic;- font-weight: bold;- src:url("DejaVuSans-BoldOblique.ttf");- }- body { font-family: "DejaVuSans"; }--`--epub-chapter-level=`*NUMBER*--: Specify the header level at which to split the EPUB into separate- "chapter" files. The default is to split into chapters at level 1- headers. This option only affects the internal composition of the- EPUB, not the way chapters and sections are displayed to users. Some- readers may be slow if the chapter files are too large, so for large- documents with few level 1 headers, one might want to use a chapter- level of 2 or 3.--`--latex-engine=pdflatex`|`lualatex`|`xelatex`--: Use the specified LaTeX engine when producing PDF output.- The default is `pdflatex`. If the engine is not in your PATH,- the full path of the engine may be specified here.--`--latex-engine-opt=`*STRING*--: Use the given string as a command-line argument to the `latex-engine`.- If used multiple times, the arguments are provided with spaces between- them. Note that no check for duplicate options is done.--[Dublin Core elements]: http://dublincore.org/documents/dces/-[ISO 8601 format]: http://www.w3.org/TR/NOTE-datetime--Citation rendering---------------------`--bibliography=`*FILE*--: Set the `bibliography` field in the document's metadata to *FILE*,- overriding any value set in the metadata, and process citations- using `pandoc-citeproc`. (This is equivalent to- `--metadata bibliography=FILE --filter pandoc-citeproc`.)- If `--natbib` or `--biblatex` is also supplied, `pandoc-citeproc` is not- used, making this equivalent to `--metadata bibliography=FILE`.- If you supply this argument multiple times, each *FILE* will be added- to bibliography.--`--csl=`*FILE*--: Set the `csl` field in the document's metadata to *FILE*,- overriding any value set in the metadata. (This is equivalent to- `--metadata csl=FILE`.)- This option is only relevant with `pandoc-citeproc`.--`--citation-abbreviations=`*FILE*--: Set the `citation-abbreviations` field in the document's metadata to- *FILE*, overriding any value set in the metadata. (This is equivalent to- `--metadata citation-abbreviations=FILE`.)- This option is only relevant with `pandoc-citeproc`.--`--natbib`--: Use [`natbib`] for citations in LaTeX output. This option is not for use- with the `pandoc-citeproc` filter or with PDF output. It is intended for- use in producing a LaTeX file that can be processed with [`bibtex`].--`--biblatex`--: Use [`biblatex`] for citations in LaTeX output. This option is not for use- with the `pandoc-citeproc` filter or with PDF output. It is intended for- use in producing a LaTeX file that can be processed with [`bibtex`] or [`biber`].--Math rendering in HTML-------------------------`-m` [*URL*], `--latexmathml`[`=`*URL*]--: Use the [LaTeXMathML] script to display embedded TeX math in HTML output.- To insert a link to a local copy of the `LaTeXMathML.js` script,- provide a *URL*. If no *URL* is provided, the contents of the- script will be inserted directly into the HTML header, preserving- portability at the price of efficiency. If you plan to use math on- several pages, it is much better to link to a copy of the script,- so it can be cached.--`--mathml`[`=`*URL*]--: Convert TeX math to [MathML] (in `docbook`, `docbook5`, `html` and `html5`).- In standalone `html` output, a small javascript (or a link to such a- script if a *URL* is supplied) will be inserted that allows the MathML to- be viewed on some browsers.--`--jsmath`[`=`*URL*]--: Use [jsMath] to display embedded TeX math in HTML output.- The *URL* should point to the jsMath load script (e.g.- `jsMath/easy/load.js`); if provided, it will be linked to in- the header of standalone HTML documents. If a *URL* is not provided,- no link to the jsMath load script will be inserted; it is then- up to the author to provide such a link in the HTML template.--`--mathjax`[`=`*URL*]--: Use [MathJax] to display embedded TeX math in HTML output.- The *URL* should point to the `MathJax.js` load script.- If a *URL* is not provided, a link to the MathJax CDN will- be inserted.--`--gladtex`--: Enclose TeX math in `<eq>` tags in HTML output. These can then- be processed by [gladTeX] to produce links to images of the typeset- formulas.--`--mimetex`[`=`*URL*]--: Render TeX math using the [mimeTeX] CGI script. If *URL* is not- specified, it is assumed that the script is at `/cgi-bin/mimetex.cgi`.--`--webtex`[`=`*URL*]--: Render TeX formulas using an external script that converts TeX- formulas to images. The formula will be concatenated with the URL- provided. If *URL* is not specified, the Google Chart API will be used.- Note: the `--webtex` option will affect Markdown output- as well as HTML.--`--katex`[`=`*URL*]--: Use [KaTeX] to display embedded TeX math in HTML output.- The *URL* should point to the `katex.js` load script. If a *URL* is- not provided, a link to the KaTeX CDN will be inserted.--`--katex-stylesheet=`*URL*--: The *URL* should point to the `katex.css` stylesheet. If this option is- not specified, a link to the KaTeX CDN will be inserted. Note that this- option does not imply `--katex`.--[MathML]: http://www.w3.org/Math/-[LaTeXMathML]: http://math.etsu.edu/LaTeXMathML/-[jsMath]: http://www.math.union.edu/~dpvc/jsmath/-[MathJax]: https://www.mathjax.org-[gladTeX]: http://ans.hsh.no/home/mgg/gladtex/-[mimeTeX]: http://www.forkosh.com/mimetex.html-[KaTeX]: https://github.com/Khan/KaTeX--Options for wrapper scripts------------------------------`--dump-args`--: Print information about command-line arguments to *stdout*, then exit.- This option is intended primarily for use in wrapper scripts.- The first line of output contains the name of the output file specified- with the `-o` option, or `-` (for *stdout*) if no output file was- specified. The remaining lines contain the command-line arguments,- one per line, in the order they appear. These do not include regular- pandoc options and their arguments, but do include any options appearing- after a `--` separator at the end of the line.--`--ignore-args`--: Ignore command-line arguments (for use in wrapper scripts).- Regular pandoc options are not ignored. Thus, for example,-- pandoc --ignore-args -o foo.html -s foo.txt -- -e latin1-- is equivalent to-- pandoc -o foo.html -s--Templates-=========--When the `-s/--standalone` option is used, pandoc uses a template to-add header and footer material that is needed for a self-standing-document. To see the default template that is used, just type-- pandoc -D *FORMAT*--where *FORMAT* is the name of the output format. A custom template-can be specified using the `--template` option. You can also override-the system default templates for a given output format *FORMAT*-by putting a file `templates/default.*FORMAT*` in the user data-directory (see `--data-dir`, above). *Exceptions:*--- For `odt` output, customize the `default.opendocument`- template.-- For `pdf` output, customize the `default.latex` template- (or the `default.beamer` template, if you use `-t beamer`,- or the `default.context` template, if you use `-t context`).-- `docx` has no template (however, you can use- `--reference-docx` to customize the output).--Templates contain *variables*, which allow for the inclusion of-arbitrary information at any point in the file. Variables may be set-within the document using [YAML metadata blocks][Extension:-`yaml_metadata_block`]. They may also be set at the-command line using the `-V/--variable` option: variables set in this-way override metadata fields with the same name.--Variables set by pandoc--------------------------Some variables are set automatically by pandoc. These vary somewhat-depending on the output format, but include metadata fields as well-as the following:--`title`, `author`, `date`-: allow identification of basic aspects of the document. Included- in PDF metadata through LaTeX and ConTeXt. These can be set- through a [pandoc title block][Extension: `pandoc_title_block`],- which allows for multiple authors, or through a YAML metadata block:-- ---- author:- - Aristotle- - Peter Abelard- ...--`subtitle`-: document subtitle, included in HTML, EPUB, LaTeX, ConTeXt, and Word docx;- renders in LaTeX only when using a document class that supports- `\subtitle`, such as `beamer` or the [KOMA-Script] series (`scrartcl`,- `scrreprt`, `scrbook`).[^subtitle]--`institute`-: author affiliations (in LaTeX and Beamer only). Can be a- list, when there are multiple authors.--`abstract`-: document summary, included in LaTeX, ConTeXt, AsciiDoc, and Word docx--`keywords`-: list of keywords to be included in HTML, PDF, and AsciiDoc metadata;- may be repeated as for `author`, above--`header-includes`-: contents specified by `-H/--include-in-header` (may have multiple- values)--`toc`-: non-null value if `--toc/--table-of-contents` was specified--`toc-title`-: title of table of contents (works only with EPUB and docx)--`include-before`-: contents specified by `-B/--include-before-body` (may have- multiple values)--`include-after`-: contents specified by `-A/--include-after-body` (may have- multiple values)--`body`-: body of document--`meta-json`-: JSON representation of all of the document's metadata--[^subtitle]: To make `subtitle` work with other LaTeX- document classes, you can add the following to `header-includes`:-- \providecommand{\subtitle}[1]{%- \usepackage{titling}- \posttitle{%- \par\large#1\end{center}}- }--Language variables---------------------`lang`-: identifies the main language of the document,- using a code according to [BCP 47] (e.g. `en` or `en-GB`).- For some output formats, pandoc will convert it to an appropriate- format stored in the additional variables `babel-lang`,- `polyglossia-lang` (LaTeX) and `context-lang` (ConTeXt).-- Native pandoc `span`s and `div`s with the lang attribute- (value in BCP 47) can be used to switch the language in- that range.--`otherlangs`-: a list of other languages used in the document- in the YAML metadata, according to [BCP 47]. For example:- `otherlangs: [en-GB, fr]`.- This is automatically generated from the `lang` attributes- in all `span`s and `div`s but can be overridden.- Currently only used by LaTeX through the generated- `babel-otherlangs` and `polyglossia-otherlangs` variables.- The LaTeX writer outputs polyglossia commands in the text but- the `babel-newcommands` variable contains mappings for them- to the corresponding babel.--`dir`-: the base direction of the document, either `rtl` (right-to-left)- or `ltr` (left-to-right).-- For bidirectional documents, native pandoc `span`s and `div`s- with the `dir` attribute (value `rtl` or `ltr`) can be used to- override the base direction in some output formats.- This may not always be necessary if the final renderer- (e.g. the browser, when generating HTML) supports the- [Unicode Bidirectional Algorithm].-- When using LaTeX for bidirectional documents, only the `xelatex` engine- is fully supported (use `--latex-engine=xelatex`).--[BCP 47]: https://tools.ietf.org/html/bcp47-[Unicode Bidirectional Algorithm]: http://www.w3.org/International/articles/inline-bidi-markup/uba-basics--Variables for slides-----------------------Variables are available for [producing slide shows with pandoc],-including all [reveal.js configuration options].--`slidy-url`-: base URL for Slidy documents (defaults to- `http://www.w3.org/Talks/Tools/Slidy2`)--`slideous-url`-: base URL for Slideous documents (defaults to `slideous`)--`s5-url`-: base URL for S5 documents (defaults to `s5/default`)--`revealjs-url`-: base URL for reveal.js documents (defaults to `reveal.js`)--`theme`, `colortheme`, `fonttheme`, `innertheme`, `outertheme`-: themes for LaTeX [`beamer`] documents--`navigation`-: controls navigation symbols in `beamer` documents- (default is `empty` for no navigation symbols; other valid values- are `frame`, `vertical`, and `horizontal`).--`section-titles`-: enables on "title pages" for new sections in `beamer`- documents (default = true).--[reveal.js configuration options]: https://github.com/hakimel/reveal.js#configuration--Variables for LaTeX----------------------LaTeX variables are used when [creating a PDF].--`papersize`-: paper size, e.g. `letter`, `A4`--`fontsize`-: font size for body text (e.g. `10pt`, `12pt`)--`documentclass`-: document class, e.g. [`article`], [`report`], [`book`], [`memoir`]--`classoption`-: option for document class, e.g. `oneside`; may be repeated- for multiple options--`geometry`-: option for [`geometry`] package, e.g. `margin=1in`;- may be repeated for multiple options--`margin-left`, `margin-right`, `margin-top`, `margin-bottom`-: sets margins, if `geometry` is not used (otherwise `geometry`- overrides these)--`linestretch`-: adjusts line spacing using the [`setspace`]- package, e.g. `1.25`, `1.5`--`fontfamily`-: font package for use with `pdflatex`:- [TeX Live] includes many options, documented in the [LaTeX Font Catalogue].- The default is [Latin Modern][`lm`].--`fontfamilyoptions`-: options for package used as `fontfamily`: e.g. `osf,sc` with- `fontfamily` set to [`mathpazo`] provides Palatino with old-style- figures and true small caps; may be repeated for multiple options--`mainfont`, `sansfont`, `monofont`, `mathfont`, `CJKmainfont`-: font families for use with `xelatex` or- `lualatex`: take the name of any system font, using the- [`fontspec`] package. Note that if `CJKmainfont` is used,- the [`xecjk`] package must be available.--`mainfontoptions`, `sansfontoptions`, `monofontoptions`, `mathfontoptions`, `CJKoptions`-: options to use with `mainfont`, `sansfont`, `monofont`, `mathfont`,- `CJKmainfont` in `xelatex` and `lualatex`. Allow for any choices- available through [`fontspec`], such as the OpenType features- `Numbers=OldStyle,Numbers=Proportional`. May be repeated for multiple options.--`fontenc`-: allows font encoding to be specified through `fontenc` package (with `pdflatex`);- default is `T1` (see guide to [LaTeX font encodings])--`colorlinks`-: add color to link text; automatically enabled if any of `linkcolor`, `citecolor`,- `urlcolor`, or `toccolor` are set--`linkcolor`, `citecolor`, `urlcolor`, `toccolor`-: color for internal links, citation links, external links, and links in table of contents:- uses any of the [predefined LaTeX colors]--`links-as-notes`-: causes links to be printed as footnotes--`indent`-: uses document class settings for indentation (the default LaTeX template- otherwise removes indentation and adds space between paragraphs)--`subparagraph`-: disables default behavior of LaTeX template that redefines (sub)paragraphs- as sections, changing the appearance of nested headings in some classes--`thanks`-: specifies contents of acknowledgments footnote after document title.--`toc`-: include table of contents (can also be set using `--toc/--table-of-contents`)--`toc-depth`-: level of section to include in table of contents--`secnumdepth`-: numbering depth for sections, if sections are numbered--`lof`, `lot`-: include list of figures, list of tables--`bibliography`-: bibliography to use for resolving references--`biblio-style`-: bibliography style, when used with `--natbib` and- `--biblatex`.--`biblatexoptions`-: list of options for biblatex.--[`article`]: https://ctan.org/pkg/article-[`report`]: https://ctan.org/pkg/report-[`book`]: https://ctan.org/pkg/book-[KOMA-Script]: https://ctan.org/pkg/koma-script-[`memoir`]: https://ctan.org/pkg/memoir-[predefined LaTeX colors]: https://en.wikibooks.org/wiki/LaTeX/Colors#Predefined_colors-[LaTeX Font Catalogue]: http://www.tug.dk/FontCatalogue/-[`mathpazo`]: https://ctan.org/pkg/mathpazo-[LaTeX font encodings]: https://ctan.org/pkg/encguide--Variables for ConTeXt------------------------`papersize`-: paper size, e.g. `letter`, `A4`, `landscape` (see [ConTeXt Paper Setup]);- may be repeated for multiple options--`layout`-: options for page margins and text arrangement (see [ConTeXt Layout]);- may be repeated for multiple options--`margin-left`, `margin-right`, `margin-top`, `margin-bottom`-: sets margins, if `layout` is not used (otherwise `layout`- overrides these)--`fontsize`-: font size for body text (e.g. `10pt`, `12pt`)--`mainfont`, `sansfont`, `monofont`, `mathfont`-: font families: take the name of any system font (see [ConTeXt Font Switching])--`linkcolor`, `contrastcolor`-: color for links outside and inside a page, e.g. `red`, `blue` (see [ConTeXt Color])--`linkstyle`-: typeface style for links, e.g. `normal`, `bold`, `slanted`, `boldslanted`, `type`, `cap`, `small`--`indenting`-: controls indentation of paragraphs, e.g. `yes,small,next` (see [ConTeXt Indentation]);- may be repeated for multiple options--`whitespace`-: spacing between paragraphs, e.g. `none`, `small` (using [`setupwhitespace`])--`interlinespace`-: adjusts line spacing, e.g. `4ex` (using [`setupinterlinespace`]);- may be repeated for multiple options--`headertext`, `footertext`-: text to be placed in running header or footer (see [ConTeXt Headers and Footers]);- may be repeated up to four times for different placement--`pagenumbering`-: page number style and location (using [`setuppagenumbering`]);- may be repeated for multiple options--`toc`-: include table of contents (can also be set using `--toc/--table-of-contents`)--`lof`, `lot`-: include list of figures, list of tables--[ConTeXt Paper Setup]: http://wiki.contextgarden.net/PaperSetup-[ConTeXt Layout]: http://wiki.contextgarden.net/Layout-[ConTeXt Font Switching]: http://wiki.contextgarden.net/Font_Switching-[ConTeXt Color]: http://wiki.contextgarden.net/Color-[ConTeXt Headers and Footers]: http://wiki.contextgarden.net/Headers_and_Footers-[ConTeXt Indentation]: http://wiki.contextgarden.net/Indentation-[`setupwhitespace`]: http://wiki.contextgarden.net/Command/setupwhitespace-[`setupinterlinespace`]: http://wiki.contextgarden.net/Command/setupinterlinespace-[`setuppagenumbering`]: http://wiki.contextgarden.net/Command/setuppagenumbering--Variables for man pages--------------------------`section`-: section number in man pages--`header`-: header in man pages--`footer`-: footer in man pages--`adjusting`-: adjusts text to left (`l`), right (`r`), center (`c`),- or both (`b`) margins--`hyphenate`-: if `true` (the default), hyphenation will be used--Using variables in templates-------------------------------Variable names are sequences of alphanumerics, `-`, and `_`,-starting with a letter. A variable name surrounded by `$` signs-will be replaced by its value. For example, the string `$title$` in-- <title>$title$</title>--will be replaced by the document title.--To write a literal `$` in a template, use `$$`.--Templates may contain conditionals. The syntax is as follows:-- $if(variable)$- X- $else$- Y- $endif$--This will include `X` in the template if `variable` has a non-null-value; otherwise it will include `Y`. `X` and `Y` are placeholders for-any valid template text, and may include interpolated variables or other-conditionals. The `$else$` section may be omitted.--When variables can have multiple values (for example, `author` in-a multi-author document), you can use the `$for$` keyword:-- $for(author)$- <meta name="author" content="$author$" />- $endfor$--You can optionally specify a separator to be used between-consecutive items:-- $for(author)$$author$$sep$, $endfor$--A dot can be used to select a field of a variable that takes-an object as its value. So, for example:-- $author.name$ ($author.affiliation$)--If you use custom templates, you may need to revise them as pandoc-changes. We recommend tracking the changes in the default templates,-and modifying your custom templates accordingly. An easy way to do this-is to fork the [pandoc-templates] repository and merge in changes after each-pandoc release.--[pandoc-templates]: https://github.com/jgm/pandoc-templates--Pandoc's Markdown-=================--Pandoc understands an extended and slightly revised version of-John Gruber's [Markdown] syntax. This document explains the syntax,-noting differences from standard Markdown. Except where noted, these-differences can be suppressed by using the `markdown_strict` format instead-of `markdown`. An extensions can be enabled by adding `+EXTENSION`-to the format name and disabled by adding `-EXTENSION`. For example,-`markdown_strict+footnotes` is strict Markdown with footnotes-enabled, while `markdown-footnotes-pipe_tables` is pandoc's-Markdown without footnotes or pipe tables.--Philosophy-------------Markdown is designed to be easy to write, and, even more importantly,-easy to read:--> A Markdown-formatted document should be publishable as-is, as plain-> text, without looking like it's been marked up with tags or formatting-> instructions.-> -- [John Gruber](http://daringfireball.net/projects/markdown/syntax#philosophy)--This principle has guided pandoc's decisions in finding syntax for-tables, footnotes, and other extensions.--There is, however, one respect in which pandoc's aims are different-from the original aims of Markdown. Whereas Markdown was originally-designed with HTML generation in mind, pandoc is designed for multiple-output formats. Thus, while pandoc allows the embedding of raw HTML,-it discourages it, and provides other, non-HTMLish ways of representing-important document elements like definition lists, tables, mathematics, and-footnotes.--Paragraphs-------------A paragraph is one or more lines of text followed by one or more blank lines.-Newlines are treated as spaces, so you can reflow your paragraphs as you like.-If you need a hard line break, put two or more spaces at the end of a line.--#### Extension: `escaped_line_breaks` ####--A backslash followed by a newline is also a hard line break.-Note: in multiline and grid table cells, this is the only way-to create a hard line break, since trailing spaces in the cells-are ignored.--Headers----------There are two kinds of headers: Setext and ATX.--### Setext-style headers ###--A setext-style header is a line of text "underlined" with a row of `=` signs-(for a level one header) or `-` signs (for a level two header):-- A level-one header- ==================-- A level-two header- --------------------The header text can contain inline formatting, such as emphasis (see-[Inline formatting], below).---### ATX-style headers ###--An ATX-style header consists of one to six `#` signs and a line of-text, optionally followed by any number of `#` signs. The number of-`#` signs at the beginning of the line is the header level:-- ## A level-two header-- ### A level-three header ###--As with setext-style headers, the header text can contain formatting:-- # A level-one header with a [link](/url) and *emphasis*--#### Extension: `blank_before_header` ####--Standard Markdown syntax does not require a blank line before a header.-Pandoc does require this (except, of course, at the beginning of the-document). The reason for the requirement is that it is all too easy for a-`#` to end up at the beginning of a line by accident (perhaps through line-wrapping). Consider, for example:-- I like several of their flavors of ice cream:- #22, for example, and #5.---### Header identifiers ###--#### Extension: `header_attributes` ####--Headers can be assigned attributes using this syntax at the end-of the line containing the header text:-- {#identifier .class .class key=value key=value}--Thus, for example, the following headers will all be assigned the identifier-`foo`:-- # My header {#foo}-- ## My header ## {#foo}-- My other header {#foo}- -----------------(This syntax is compatible with [PHP Markdown Extra].)--Note that although this syntax allows assignment of classes and key/value-attributes, writers generally don't use all of this information. Identifiers,-classes, and key/value attributes are used in HTML and HTML-based formats such-as EPUB and slidy. Identifiers are used for labels and link anchors in the-LaTeX, ConTeXt, Textile, and AsciiDoc writers.--Headers with the class `unnumbered` will not be numbered, even if-`--number-sections` is specified. A single hyphen (`-`) in an attribute-context is equivalent to `.unnumbered`, and preferable in non-English-documents. So,-- # My header {-}--is just the same as-- # My header {.unnumbered}--#### Extension: `auto_identifiers` ####--A header without an explicitly specified identifier will be-automatically assigned a unique identifier based on the header text.-To derive the identifier from the header text,-- - Remove all formatting, links, etc.- - Remove all footnotes.- - Remove all punctuation, except underscores, hyphens, and periods.- - Replace all spaces and newlines with hyphens.- - Convert all alphabetic characters to lowercase.- - Remove everything up to the first letter (identifiers may- not begin with a number or punctuation mark).- - If nothing is left after this, use the identifier `section`.--Thus, for example,-- Header Identifier- ------------------------------- ----------------------------- `Header identifiers in HTML` `header-identifiers-in-html`- `*Dogs*?--in *my* house?` `dogs--in-my-house`- `[HTML], [S5], or [RTF]?` `html-s5-or-rtf`- `3. Applications` `applications`- `33` `section`--These rules should, in most cases, allow one to determine the identifier-from the header text. The exception is when several headers have the-same text; in this case, the first will get an identifier as described-above; the second will get the same identifier with `-1` appended; the-third with `-2`; and so on.--These identifiers are used to provide link targets in the table of-contents generated by the `--toc|--table-of-contents` option. They-also make it easy to provide links from one section of a document to-another. A link to this section, for example, might look like this:-- See the section on- [header identifiers](#header-identifiers-in-html-latex-and-context).--Note, however, that this method of providing links to sections works-only in HTML, LaTeX, and ConTeXt formats.--If the `--section-divs` option is specified, then each section will-be wrapped in a `div` (or a `section`, if `--html5` was specified),-and the identifier will be attached to the enclosing `<div>`-(or `<section>`) tag rather than the header itself. This allows entire-sections to be manipulated using javascript or treated differently in-CSS.--#### Extension: `implicit_header_references` ####--Pandoc behaves as if reference links have been defined for each header.-So, to link to a header-- # Header identifiers in HTML--you can simply write-- [Header identifiers in HTML]--or-- [Header identifiers in HTML][]--or-- [the section on header identifiers][header identifiers in- HTML]--instead of giving the identifier explicitly:-- [Header identifiers in HTML](#header-identifiers-in-html)--If there are multiple headers with identical text, the corresponding-reference will link to the first one only, and you will need to use explicit-links to link to the others, as described above.--Like regular reference links, these references are case-insensitive.--Explicit link reference definitions always take priority over-implicit header references. So, in the following example, the-link will point to `bar`, not to `#foo`:-- # Foo-- [foo]: bar-- See [foo]--Block quotations-------------------Markdown uses email conventions for quoting blocks of text.-A block quotation is one or more paragraphs or other block elements-(such as lists or headers), with each line preceded by a `>` character-and an optional space. (The `>` need not start at the left margin, but-it should not be indented more than three spaces.)-- > This is a block quote. This- > paragraph has two lines.- >- > 1. This is a list inside a block quote.- > 2. Second item.--A "lazy" form, which requires the `>` character only on the first-line of each block, is also allowed:-- > This is a block quote. This- paragraph has two lines.-- > 1. This is a list inside a block quote.- 2. Second item.--Among the block elements that can be contained in a block quote are-other block quotes. That is, block quotes can be nested:-- > This is a block quote.- >- > > A block quote within a block quote.--If the `>` character is followed by an optional space, that space-will be considered part of the block quote marker and not part of-the indentation of the contents. Thus, to put an indented code-block in a block quote, you need five spaces after the `>`:-- > code--#### Extension: `blank_before_blockquote` ####--Standard Markdown syntax does not require a blank line before a block-quote. Pandoc does require this (except, of course, at the beginning of the-document). The reason for the requirement is that it is all too easy for a-`>` to end up at the beginning of a line by accident (perhaps through line-wrapping). So, unless the `markdown_strict` format is used, the following does-not produce a nested block quote in pandoc:-- > This is a block quote.- >> Nested.---Verbatim (code) blocks-------------------------### Indented code blocks ###--A block of text indented four spaces (or one tab) is treated as verbatim-text: that is, special characters do not trigger special formatting,-and all spaces and line breaks are preserved. For example,-- if (a > 3) {- moveShip(5 * gravity, DOWN);- }--The initial (four space or one tab) indentation is not considered part-of the verbatim text, and is removed in the output.--Note: blank lines in the verbatim text need not begin with four spaces.---### Fenced code blocks ###--#### Extension: `fenced_code_blocks` ####--In addition to standard indented code blocks, pandoc supports-*fenced* code blocks. These begin with a row of three or more-tildes (`~`) and end with a row of tildes that must be at least as long as-the starting row. Everything between these lines is treated as code. No-indentation is necessary:-- ~~~~~~~- if (a > 3) {- moveShip(5 * gravity, DOWN);- }- ~~~~~~~--Like regular code blocks, fenced code blocks must be separated-from surrounding text by blank lines.--If the code itself contains a row of tildes or backticks, just use a longer-row of tildes or backticks at the start and end:-- ~~~~~~~~~~~~~~~~- ~~~~~~~~~~- code including tildes- ~~~~~~~~~~- ~~~~~~~~~~~~~~~~--#### Extension: `backtick_code_blocks` ####--Same as `fenced_code_blocks`, but uses backticks (`` ` ``) instead of tildes-(`~`).--#### Extension: `fenced_code_attributes` ####--Optionally, you may attach attributes to fenced or backtick code block using-this syntax:-- ~~~~ {#mycode .haskell .numberLines startFrom="100"}- qsort [] = []- qsort (x:xs) = qsort (filter (< x) xs) ++ [x] ++- qsort (filter (>= x) xs)- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--Here `mycode` is an identifier, `haskell` and `numberLines` are classes, and-`startFrom` is an attribute with value `100`. Some output formats can use this-information to do syntax highlighting. Currently, the only output formats-that uses this information are HTML and LaTeX. If highlighting is supported-for your output format and language, then the code block above will appear-highlighted, with numbered lines. (To see which languages are supported, do-`pandoc --version`.) Otherwise, the code block above will appear as follows:-- <pre id="mycode" class="haskell numberLines" startFrom="100">- <code>- ...- </code>- </pre>--A shortcut form can also be used for specifying the language of-the code block:-- ```haskell- qsort [] = []- ```--This is equivalent to:-- ``` {.haskell}- qsort [] = []- ```--If the `fenced_code_attributes` extension is disabled, but-input contains class attribute(s) for the codeblock, the first-class attribute will be printed after the opening fence as a bare-word.--To prevent all highlighting, use the `--no-highlight` flag.-To set the highlighting style, use `--highlight-style`.-For more information on highlighting, see [Syntax highlighting],-below.--Line blocks--------------#### Extension: `line_blocks` ####--A line block is a sequence of lines beginning with a vertical bar (`|`)-followed by a space. The division into lines will be preserved in-the output, as will any leading spaces; otherwise, the lines will-be formatted as Markdown. This is useful for verse and addresses:-- | The limerick packs laughs anatomical- | In space that is quite economical.- | But the good ones I've seen- | So seldom are clean- | And the clean ones so seldom are comical-- | 200 Main St.- | Berkeley, CA 94718--The lines can be hard-wrapped if needed, but the continuation-line must begin with a space.-- | The Right Honorable Most Venerable and Righteous Samuel L.- Constable, Jr.- | 200 Main St.- | Berkeley, CA 94718--This syntax is borrowed from [reStructuredText].--Lists--------### Bullet lists ###--A bullet list is a list of bulleted list items. A bulleted list-item begins with a bullet (`*`, `+`, or `-`). Here is a simple-example:-- * one- * two- * three--This will produce a "compact" list. If you want a "loose" list, in which-each item is formatted as a paragraph, put spaces between the items:-- * one-- * two-- * three--The bullets need not be flush with the left margin; they may be-indented one, two, or three spaces. The bullet must be followed-by whitespace.--List items look best if subsequent lines are flush with the first-line (after the bullet):-- * here is my first- list item.- * and my second.--But Markdown also allows a "lazy" format:-- * here is my first- list item.- * and my second.--### The four-space rule ###--A list item may contain multiple paragraphs and other block-level-content. However, subsequent paragraphs must be preceded by a blank line-and indented four spaces or a tab. The list will look better if the first-paragraph is aligned with the rest:-- * First paragraph.-- Continued.-- * Second paragraph. With a code block, which must be indented- eight spaces:-- { code }--List items may include other lists. In this case the preceding blank-line is optional. The nested list must be indented four spaces or-one tab:-- * fruits- + apples- - macintosh- - red delicious- + pears- + peaches- * vegetables- + broccoli- + chard--As noted above, Markdown allows you to write list items "lazily," instead of-indenting continuation lines. However, if there are multiple paragraphs or-other blocks in a list item, the first line of each must be indented.-- + A lazy, lazy, list- item.-- + Another one; this looks- bad but is legal.-- Second paragraph of second- list item.--**Note:** Although the four-space rule for continuation paragraphs-comes from the official [Markdown syntax guide], the reference implementation,-`Markdown.pl`, does not follow it. So pandoc will give different results than-`Markdown.pl` when authors have indented continuation paragraphs fewer than-four spaces.--The [Markdown syntax guide] is not explicit whether the four-space-rule applies to *all* block-level content in a list item; it only-mentions paragraphs and code blocks. But it implies that the rule-applies to all block-level content (including nested lists), and-pandoc interprets it that way.-- [Markdown syntax guide]:- http://daringfireball.net/projects/markdown/syntax#list--### Ordered lists ###--Ordered lists work just like bulleted lists, except that the items-begin with enumerators rather than bullets.--In standard Markdown, enumerators are decimal numbers followed-by a period and a space. The numbers themselves are ignored, so-there is no difference between this list:-- 1. one- 2. two- 3. three--and this one:-- 5. one- 7. two- 1. three--#### Extension: `fancy_lists` ####--Unlike standard Markdown, pandoc allows ordered list items to be marked-with uppercase and lowercase letters and roman numerals, in addition to-arabic numerals. List markers may be enclosed in parentheses or followed by a-single right-parentheses or period. They must be separated from the-text that follows by at least one space, and, if the list marker is a-capital letter with a period, by at least two spaces.[^2]--[^2]: The point of this rule is to ensure that normal paragraphs- starting with people's initials, like-- B. Russell was an English philosopher.-- do not get treated as list items.-- This rule will not prevent-- (C) 2007 Joe Smith-- from being interpreted as a list item. In this case, a backslash- escape can be used:-- (C\) 2007 Joe Smith--The `fancy_lists` extension also allows '`#`' to be used as an-ordered list marker in place of a numeral:-- #. one- #. two--#### Extension: `startnum` ####--Pandoc also pays attention to the type of list marker used, and to the-starting number, and both of these are preserved where possible in the-output format. Thus, the following yields a list with numbers followed-by a single parenthesis, starting with 9, and a sublist with lowercase-roman numerals:-- 9) Ninth- 10) Tenth- 11) Eleventh- i. subone- ii. subtwo- iii. subthree--Pandoc will start a new list each time a different type of list-marker is used. So, the following will create three lists:-- (2) Two- (5) Three- 1. Four- * Five--If default list markers are desired, use `#.`:-- #. one- #. two- #. three---### Definition lists ###--#### Extension: `definition_lists` ####--Pandoc supports definition lists, using the syntax of-[PHP Markdown Extra] with some extensions.[^3]-- Term 1-- : Definition 1-- Term 2 with *inline markup*-- : Definition 2-- { some code, part of Definition 2 }-- Third paragraph of definition 2.--Each term must fit on one line, which may optionally be followed by-a blank line, and must be followed by one or more definitions.-A definition begins with a colon or tilde, which may be indented one-or two spaces.--A term may have multiple definitions, and each definition may consist of one or-more block elements (paragraph, code block, list, etc.), each indented four-spaces or one tab stop. The body of the definition (including the first line,-aside from the colon or tilde) should be indented four spaces. However,-as with other Markdown lists, you can "lazily" omit indentation except-at the beginning of a paragraph or other block element:-- Term 1-- : Definition- with lazy continuation.-- Second paragraph of the definition.--If you leave space before the definition (as in the example above),-the text of the definition will be treated as a paragraph. In some-output formats, this will mean greater spacing between term/definition-pairs. For a more compact definition list, omit the space before the-definition:-- Term 1- ~ Definition 1-- Term 2- ~ Definition 2a- ~ Definition 2b--Note that space between items in a definition list is required.-(A variant that loosens this requirement, but disallows "lazy"-hard wrapping, can be activated with `compact_definition_lists`: see-[Non-pandoc extensions], below.)--[^3]: I have been influenced by the suggestions of [David Wheeler](http://www.justatheory.com/computers/markup/modest-markdown-proposal.html).--### Numbered example lists ###--#### Extension: `example_lists` ####--The special list marker `@` can be used for sequentially numbered-examples. The first list item with a `@` marker will be numbered '1',-the next '2', and so on, throughout the document. The numbered examples-need not occur in a single list; each new list using `@` will take up-where the last stopped. So, for example:-- (@) My first example will be numbered (1).- (@) My second example will be numbered (2).-- Explanation of examples.-- (@) My third example will be numbered (3).--Numbered examples can be labeled and referred to elsewhere in the-document:-- (@good) This is a good example.-- As (@good) illustrates, ...--The label can be any string of alphanumeric characters, underscores,-or hyphens.---### Compact and loose lists ###--Pandoc behaves differently from `Markdown.pl` on some "edge-cases" involving lists. Consider this source:-- + First- + Second:- - Fee- - Fie- - Foe-- + Third--Pandoc transforms this into a "compact list" (with no `<p>` tags around-"First", "Second", or "Third"), while Markdown puts `<p>` tags around-"Second" and "Third" (but not "First"), because of the blank space-around "Third". Pandoc follows a simple rule: if the text is followed by-a blank line, it is treated as a paragraph. Since "Second" is followed-by a list, and not a blank line, it isn't treated as a paragraph. The-fact that the list is followed by a blank line is irrelevant. (Note:-Pandoc works this way even when the `markdown_strict` format is specified. This-behavior is consistent with the official Markdown syntax description,-even though it is different from that of `Markdown.pl`.)---### Ending a list ###--What if you want to put an indented code block after a list?-- - item one- - item two-- { my code block }--Trouble! Here pandoc (like other Markdown implementations) will treat-`{ my code block }` as the second paragraph of item two, and not as-a code block.--To "cut off" the list after item two, you can insert some non-indented-content, like an HTML comment, which won't produce visible output in-any format:-- - item one- - item two-- <!-- end of list -->-- { my code block }--You can use the same trick if you want two consecutive lists instead-of one big list:-- 1. one- 2. two- 3. three-- <!-- -->-- 1. uno- 2. dos- 3. tres--Horizontal rules-------------------A line containing a row of three or more `*`, `-`, or `_` characters-(optionally separated by spaces) produces a horizontal rule:-- * * * *-- ------------------Tables---------Four kinds of tables may be used. The first three kinds presuppose the use of-a fixed-width font, such as Courier. The fourth kind can be used with-proportionally spaced fonts, as it does not require lining up columns.--#### Extension: `table_captions` ####--A caption may optionally be provided with all 4 kinds of tables (as-illustrated in the examples below). A caption is a paragraph beginning-with the string `Table:` (or just `:`), which will be stripped off.-It may appear either before or after the table.--#### Extension: `simple_tables` ####--Simple tables look like this:-- Right Left Center Default- ------- ------ ---------- -------- 12 12 12 12- 123 123 123 123- 1 1 1 1-- Table: Demonstration of simple table syntax.--The headers and table rows must each fit on one line. Column-alignments are determined by the position of the header text relative-to the dashed line below it:[^4]-- - If the dashed line is flush with the header text on the right side- but extends beyond it on the left, the column is right-aligned.- - If the dashed line is flush with the header text on the left side- but extends beyond it on the right, the column is left-aligned.- - If the dashed line extends beyond the header text on both sides,- the column is centered.- - If the dashed line is flush with the header text on both sides,- the default alignment is used (in most cases, this will be left).--[^4]: This scheme is due to Michel Fortin, who proposed it on the- [Markdown discussion list](http://six.pairlist.net/pipermail/markdown-discuss/2005-March/001097.html).--The table must end with a blank line, or a line of dashes followed by-a blank line.--The column headers may be omitted, provided a dashed line is used-to end the table. For example:-- ------- ------ ---------- -------- 12 12 12 12- 123 123 123 123- 1 1 1 1- ------- ------ ---------- ---------When headers are omitted, column alignments are determined on the basis-of the first line of the table body. So, in the tables above, the columns-would be right, left, center, and right aligned, respectively.--#### Extension: `multiline_tables` ####--Multiline tables allow headers and table rows to span multiple lines-of text (but cells that span multiple columns or rows of the table are-not supported). Here is an example:-- -------------------------------------------------------------- Centered Default Right Left- Header Aligned Aligned Aligned- ----------- ------- --------------- -------------------------- First row 12.0 Example of a row that- spans multiple lines.-- Second row 5.0 Here's another one. Note- the blank line between- rows.- --------------------------------------------------------------- Table: Here's the caption. It, too, may span- multiple lines.--These work like simple tables, but with the following differences:-- - They must begin with a row of dashes, before the header text- (unless the headers are omitted).- - They must end with a row of dashes, then a blank line.- - The rows must be separated by blank lines.--In multiline tables, the table parser pays attention to the widths of-the columns, and the writers try to reproduce these relative widths in-the output. So, if you find that one of the columns is too narrow in the-output, try widening it in the Markdown source.--Headers may be omitted in multiline tables as well as simple tables:-- ----------- ------- --------------- -------------------------- First row 12.0 Example of a row that- spans multiple lines.-- Second row 5.0 Here's another one. Note- the blank line between- rows.- ----------- ------- --------------- --------------------------- : Here's a multiline table without headers.--It is possible for a multiline table to have just one row, but the row-should be followed by a blank line (and then the row of dashes that ends-the table), or the table may be interpreted as a simple table.--#### Extension: `grid_tables` ####--Grid tables look like this:-- : Sample grid table.-- +---------------+---------------+--------------------+- | Fruit | Price | Advantages |- +===============+===============+====================+- | Bananas | $1.34 | - built-in wrapper |- | | | - bright color |- +---------------+---------------+--------------------+- | Oranges | $2.10 | - cures scurvy |- | | | - tasty |- +---------------+---------------+--------------------+--The row of `=`s separates the header from the table body, and can be-omitted for a headerless table. The cells of grid tables may contain-arbitrary block elements (multiple paragraphs, code blocks, lists,-etc.). Alignments are not supported, nor are cells that span multiple-columns or rows. Grid tables can be created easily using [Emacs table mode].--[Emacs table mode]: http://table.sourceforge.net/--#### Extension: `pipe_tables` ####--Pipe tables look like this:-- | Right | Left | Default | Center |- |------:|:-----|---------|:------:|- | 12 | 12 | 12 | 12 |- | 123 | 123 | 123 | 123 |- | 1 | 1 | 1 | 1 |-- : Demonstration of pipe table syntax.--The syntax is identical to [PHP Markdown Extra tables]. The beginning and-ending pipe characters are optional, but pipes are required between all-columns. The colons indicate column alignment as shown. The header-cannot be omitted. To simulate a headerless table, include a header-with blank cells.--Since the pipes indicate column boundaries, columns need not be vertically-aligned, as they are in the above example. So, this is a perfectly-legal (though ugly) pipe table:-- fruit| price- -----|-----:- apple|2.05- pear|1.37- orange|3.09--The cells of pipe tables cannot contain block elements like paragraphs-and lists, and cannot span multiple lines. If a pipe table contains a-row whose printable content is wider than the column width (see-`--columns`), then the cell contents will wrap, with the-relative cell widths determined by the widths of the separator-lines.--Note: pandoc also recognizes pipe tables of the following-form, as can be produced by Emacs' orgtbl-mode:-- | One | Two |- |-----+-------|- | my | table |- | is | nice |--The difference is that `+` is used instead of `|`. Other orgtbl features-are not supported. In particular, to get non-default column alignment,-you'll need to add colons as above.--[PHP Markdown Extra tables]: https://michelf.ca/projects/php-markdown/extra/#table--Metadata blocks------------------#### Extension: `pandoc_title_block` ####--If the file begins with a title block-- % title- % author(s) (separated by semicolons)- % date--it will be parsed as bibliographic information, not regular text. (It-will be used, for example, in the title of standalone LaTeX or HTML-output.) The block may contain just a title, a title and an author,-or all three elements. If you want to include an author but no-title, or a title and a date but no author, you need a blank line:-- %- % Author-- % My title- %- % June 15, 2006--The title may occupy multiple lines, but continuation lines must-begin with leading space, thus:-- % My title- on multiple lines--If a document has multiple authors, the authors may be put on-separate lines with leading space, or separated by semicolons, or-both. So, all of the following are equivalent:-- % Author One- Author Two-- % Author One; Author Two-- % Author One;- Author Two--The date must fit on one line.--All three metadata fields may contain standard inline formatting-(italics, links, footnotes, etc.).--Title blocks will always be parsed, but they will affect the output only-when the `--standalone` (`-s`) option is chosen. In HTML output, titles-will appear twice: once in the document head -- this is the title that-will appear at the top of the window in a browser -- and once at the-beginning of the document body. The title in the document head can have-an optional prefix attached (`--title-prefix` or `-T` option). The title-in the body appears as an H1 element with class "title", so it can be-suppressed or reformatted with CSS. If a title prefix is specified with-`-T` and no title block appears in the document, the title prefix will-be used by itself as the HTML title.--The man page writer extracts a title, man page section number, and-other header and footer information from the title line. The title-is assumed to be the first word on the title line, which may optionally-end with a (single-digit) section number in parentheses. (There should-be no space between the title and the parentheses.) Anything after-this is assumed to be additional footer and header text. A single pipe-character (`|`) should be used to separate the footer text from the header-text. Thus,-- % PANDOC(1)--will yield a man page with the title `PANDOC` and section 1.-- % PANDOC(1) Pandoc User Manuals--will also have "Pandoc User Manuals" in the footer.-- % PANDOC(1) Pandoc User Manuals | Version 4.0--will also have "Version 4.0" in the header.--#### Extension: `yaml_metadata_block` ####--A YAML metadata block is a valid YAML object, delimited by a line of three-hyphens (`---`) at the top and a line of three hyphens (`---`) or three dots-(`...`) at the bottom. A YAML metadata block may occur anywhere in the-document, but if it is not at the beginning, it must be preceded by a blank-line. (Note that, because of the way pandoc concatenates input files when-several are provided, you may also keep the metadata in a separate YAML file-and pass it to pandoc as an argument, along with your Markdown files:-- pandoc chap1.md chap2.md chap3.md metadata.yaml -s -o book.html--Just be sure that the YAML file begins with `---` and ends with `---` or-`...`.)--Metadata will be taken from the fields of the YAML object and added to any-existing document metadata. Metadata can contain lists and objects (nested-arbitrarily), but all string scalars will be interpreted as Markdown. Fields-with names ending in an underscore will be ignored by pandoc. (They may be-given a role by external processors.)--A document may contain multiple metadata blocks. The metadata fields will-be combined through a *left-biased union*: if two metadata blocks attempt-to set the same field, the value from the first block will be taken.--When pandoc is used with `-t markdown` to create a Markdown document,-a YAML metadata block will be produced only if the `-s/--standalone`-option is used. All of the metadata will appear in a single block-at the beginning of the document.--Note that YAML escaping rules must be followed. Thus, for example,-if a title contains a colon, it must be quoted. The pipe character-(`|`) can be used to begin an indented block that will be interpreted-literally, without need for escaping. This form is necessary-when the field contains blank lines:-- ---- title: 'This is the title: it contains a colon'- author:- - name: Author One- affiliation: University of Somewhere- - name: Author Two- affiliation: University of Nowhere- tags: [nothing, nothingness]- abstract: |- This is the abstract.-- It consists of two paragraphs.- ...--Template variables will be set automatically from the metadata. Thus, for-example, in writing HTML, the variable `abstract` will be set to the HTML-equivalent of the Markdown in the `abstract` field:-- <p>This is the abstract.</p>- <p>It consists of two paragraphs.</p>--Note: The `author` variable in the default templates expects a simple list or-string. To use the structured authors in the example, you would need a-custom template. For example:-- $for(author)$- $if(author.name)$- $author.name$$if(author.affiliation)$ ($author.affiliation$)$endif$- $else$- $author$- $endif$- $endfor$---Backslash escapes--------------------#### Extension: `all_symbols_escapable` ####--Except inside a code block or inline code, any punctuation or space-character preceded by a backslash will be treated literally, even if it-would normally indicate formatting. Thus, for example, if one writes-- *\*hello\**--one will get-- <em>*hello*</em>--instead of-- <strong>hello</strong>--This rule is easier to remember than standard Markdown's rule,-which allows only the following characters to be backslash-escaped:-- \`*_{}[]()>#+-.!--(However, if the `markdown_strict` format is used, the standard Markdown rule-will be used.)--A backslash-escaped space is parsed as a nonbreaking space. It will-appear in TeX output as `~` and in HTML and XML as `\ ` or-`\ `.--A backslash-escaped newline (i.e. a backslash occurring at the end of-a line) is parsed as a hard line break. It will appear in TeX output as-`\\` and in HTML as `<br />`. This is a nice alternative to-Markdown's "invisible" way of indicating hard line breaks using-two trailing spaces on a line.--Backslash escapes do not work in verbatim contexts.--Smart punctuation--------------------#### Extension ####--If the `--smart` option is specified, pandoc will produce typographically-correct output, converting straight quotes to curly quotes, `---` to-em-dashes, `--` to en-dashes, and `...` to ellipses. Nonbreaking spaces-are inserted after certain abbreviations, such as "Mr."--Note: if your LaTeX template or any included header file call for the-[`csquotes`] package, pandoc will detect this automatically and use-`\enquote{...}` for quoted text.--Inline formatting--------------------### Emphasis ###--To *emphasize* some text, surround it with `*`s or `_`, like this:-- This text is _emphasized with underscores_, and this- is *emphasized with asterisks*.--Double `*` or `_` produces **strong emphasis**:-- This is **strong emphasis** and __with underscores__.--A `*` or `_` character surrounded by spaces, or backslash-escaped,-will not trigger emphasis:-- This is * not emphasized *, and \*neither is this\*.--#### Extension: `intraword_underscores` ####--Because `_` is sometimes used inside words and identifiers,-pandoc does not interpret a `_` surrounded by alphanumeric-characters as an emphasis marker. If you want to emphasize-just part of a word, use `*`:-- feas*ible*, not feas*able*.---### Strikeout ###--#### Extension: `strikeout` ####--To strikeout a section of text with a horizontal line, begin and end it-with `~~`. Thus, for example,-- This ~~is deleted text.~~---### Superscripts and subscripts ###--#### Extension: `superscript`, `subscript` ####--Superscripts may be written by surrounding the superscripted text by `^`-characters; subscripts may be written by surrounding the subscripted-text by `~` characters. Thus, for example,-- H~2~O is a liquid. 2^10^ is 1024.--If the superscripted or subscripted text contains spaces, these spaces-must be escaped with backslashes. (This is to prevent accidental-superscripting and subscripting through the ordinary use of `~` and `^`.)-Thus, if you want the letter P with 'a cat' in subscripts, use-`P~a\ cat~`, not `P~a cat~`.---### Verbatim ###--To make a short span of text verbatim, put it inside backticks:-- What is the difference between `>>=` and `>>`?--If the verbatim text includes a backtick, use double backticks:-- Here is a literal backtick `` ` ``.--(The spaces after the opening backticks and before the closing-backticks will be ignored.)--The general rule is that a verbatim span starts with a string-of consecutive backticks (optionally followed by a space)-and ends with a string of the same number of backticks (optionally-preceded by a space).--Note that backslash-escapes (and other Markdown constructs) do not-work in verbatim contexts:-- This is a backslash followed by an asterisk: `\*`.--#### Extension: `inline_code_attributes` ####--Attributes can be attached to verbatim text, just as with-[fenced code blocks]:-- `<$>`{.haskell}--### Small caps ###--To write small caps, you can use an HTML span tag:-- <span style="font-variant:small-caps;">Small caps</span>--(The semicolon is optional and there may be space after the-colon.) This will work in all output formats that support small caps.--Math-------#### Extension: `tex_math_dollars` ####--Anything between two `$` characters will be treated as TeX math. The-opening `$` must have a non-space character immediately to its right,-while the closing `$` must have a non-space character immediately to its-left, and must not be followed immediately by a digit. Thus,-`$20,000 and $30,000` won't parse as math. If for some reason-you need to enclose text in literal `$` characters, backslash-escape-them and they won't be treated as math delimiters.--TeX math will be printed in all output formats. How it is rendered-depends on the output format:--Markdown, LaTeX, Emacs Org mode, ConTeXt, ZimWiki- ~ It will appear verbatim between `$` characters.--reStructuredText- ~ It will be rendered using an [interpreted text role `:math:`].--AsciiDoc- ~ It will be rendered as `latexmath:[...]`.--Texinfo- ~ It will be rendered inside a `@math` command.--groff man- ~ It will be rendered verbatim without `$`'s.--MediaWiki, DokuWiki- ~ It will be rendered inside `<math>` tags.--Textile- ~ It will be rendered inside `<span class="math">` tags.--RTF, OpenDocument, ODT- ~ It will be rendered, if possible, using unicode characters,- and will otherwise appear verbatim.--DocBook- ~ If the `--mathml` flag is used, it will be rendered using MathML- in an `inlineequation` or `informalequation` tag. Otherwise it- will be rendered, if possible, using unicode characters.--Docx- ~ It will be rendered using OMML math markup.--FictionBook2- ~ If the `--webtex` option is used, formulas are rendered as images- using Google Charts or other compatible web service, downloaded- and embedded in the e-book. Otherwise, they will appear verbatim.--HTML, Slidy, DZSlides, S5, EPUB- ~ The way math is rendered in HTML will depend on the- command-line options selected:-- 1. The default is to render TeX math as far as possible using unicode- characters, as with RTF, DocBook, and OpenDocument output. Formulas- are put inside a `span` with `class="math"`, so that they may be- styled differently from the surrounding text if needed.-- 2. If the `--latexmathml` option is used, TeX math will be displayed- between `$` or `$$` characters and put in `<span>` tags with class `LaTeX`.- The [LaTeXMathML] script will be used to render it as formulas.- (This trick does not work in all browsers, but it works in Firefox.- In browsers that do not support LaTeXMathML, TeX math will appear- verbatim between `$` characters.)-- 3. If the `--jsmath` option is used, TeX math will be put inside- `<span>` tags (for inline math) or `<div>` tags (for display math)- with class `math`. The [jsMath] script will be used to render- it.-- 4. If the `--mimetex` option is used, the [mimeTeX] CGI script will- be called to generate images for each TeX formula. This should- work in all browsers. The `--mimetex` option takes an optional URL- as argument. If no URL is specified, it will be assumed that the- mimeTeX CGI script is at `/cgi-bin/mimetex.cgi`.-- 5. If the `--gladtex` option is used, TeX formulas will be enclosed- in `<eq>` tags in the HTML output. The resulting `htex` file may then- be processed by [gladTeX], which will produce image files for each- formula and an HTML file with links to these images. So, the- procedure is:-- pandoc -s --gladtex myfile.txt -o myfile.htex- gladtex -d myfile-images myfile.htex- # produces myfile.html and images in myfile-images-- 6. If the `--webtex` option is used, TeX formulas will be converted- to `<img>` tags that link to an external script that converts- formulas to images. The formula will be URL-encoded and concatenated- with the URL provided. If no URL is specified, the Google Chart- API will be used (`http://chart.apis.google.com/chart?cht=tx&chl=`).-- 7. If the `--mathjax` option is used, TeX math will be displayed- between `\(...\)` (for inline math) or `\[...\]` (for display- math) and put in `<span>` tags with class `math`.- The [MathJax] script will be used to render it as formulas.--[interpreted text role `:math:`]: http://docutils.sourceforge.net/docs/ref/rst/roles.html#math--Raw HTML-----------#### Extension: `raw_html` ####--Markdown allows you to insert raw HTML (or DocBook) anywhere in a document-(except verbatim contexts, where `<`, `>`, and `&` are interpreted-literally). (Technically this is not an extension, since standard-Markdown allows it, but it has been made an extension so that it can-be disabled if desired.)--The raw HTML is passed through unchanged in HTML, S5, Slidy, Slideous,-DZSlides, EPUB, Markdown, Emacs Org mode, and Textile output, and suppressed-in other formats.--#### Extension: `markdown_in_html_blocks` ####--Standard Markdown allows you to include HTML "blocks": blocks-of HTML between balanced tags that are separated from the surrounding text-with blank lines, and start and end at the left margin. Within-these blocks, everything is interpreted as HTML, not Markdown;-so (for example), `*` does not signify emphasis.--Pandoc behaves this way when the `markdown_strict` format is used; but-by default, pandoc interprets material between HTML block tags as Markdown.-Thus, for example, pandoc will turn-- <table>- <tr>- <td>*one*</td>- <td>[a link](http://google.com)</td>- </tr>- </table>--into-- <table>- <tr>- <td><em>one</em></td>- <td><a href="http://google.com">a link</a></td>- </tr>- </table>--whereas `Markdown.pl` will preserve it as is.--There is one exception to this rule: text between `<script>` and-`<style>` tags is not interpreted as Markdown.--This departure from standard Markdown should make it easier to mix-Markdown with HTML block elements. For example, one can surround-a block of Markdown text with `<div>` tags without preventing it-from being interpreted as Markdown.--#### Extension: `native_divs` ####--Use native pandoc `Div` blocks for content inside `<div>` tags.-For the most part this should give the same output as-`markdown_in_html_blocks`, but it makes it easier to write pandoc-filters to manipulate groups of blocks.--#### Extension: `native_spans` ####--Use native pandoc `Span` blocks for content inside `<span>` tags.-For the most part this should give the same output as `raw_html`,-but it makes it easier to write pandoc filters to manipulate groups-of inlines.--Raw TeX----------#### Extension: `raw_tex` ####--In addition to raw HTML, pandoc allows raw LaTeX, TeX, and ConTeXt to be-included in a document. Inline TeX commands will be preserved and passed-unchanged to the LaTeX and ConTeXt writers. Thus, for example, you can use-LaTeX to include BibTeX citations:-- This result was proved in \cite{jones.1967}.--Note that in LaTeX environments, like-- \begin{tabular}{|l|l|}\hline- Age & Frequency \\ \hline- 18--25 & 15 \\- 26--35 & 33 \\- 36--45 & 22 \\ \hline- \end{tabular}--the material between the begin and end tags will be interpreted as raw-LaTeX, not as Markdown.--Inline LaTeX is ignored in output formats other than Markdown, LaTeX,-Emacs Org mode, and ConTeXt.--LaTeX macros---------------#### Extension: `latex_macros` ####--For output formats other than LaTeX, pandoc will parse LaTeX `\newcommand` and-`\renewcommand` definitions and apply the resulting macros to all LaTeX-math. So, for example, the following will work in all output formats,-not just LaTeX:-- \newcommand{\tuple}[1]{\langle #1 \rangle}-- $\tuple{a, b, c}$--In LaTeX output, the `\newcommand` definition will simply be passed-unchanged to the output.---Links--------Markdown allows links to be specified in several ways.--### Automatic links ###--If you enclose a URL or email address in pointy brackets, it-will become a link:-- <http://google.com>- <sam@green.eggs.ham>--### Inline links ###--An inline link consists of the link text in square brackets,-followed by the URL in parentheses. (Optionally, the URL can-be followed by a link title, in quotes.)-- This is an [inline link](/url), and here's [one with- a title](http://fsf.org "click here for a good time!").--There can be no space between the bracketed part and the parenthesized part.-The link text can contain formatting (such as emphasis), but the title cannot.--Email addresses in inline links are not autodetected, so they have to be-prefixed with `mailto`:-- [Write me!](mailto:sam@green.eggs.ham)--### Reference links ###--An *explicit* reference link has two parts, the link itself and the link-definition, which may occur elsewhere in the document (either-before or after the link).--The link consists of link text in square brackets, followed by a label in-square brackets. (There can be space between the two.) The link definition-consists of the bracketed label, followed by a colon and a space, followed by-the URL, and optionally (after a space) a link title either in quotes or in-parentheses. The label must not be parseable as a citation (assuming-the `citations` extension is enabled): citations take precedence over-link labels.--Here are some examples:-- [my label 1]: /foo/bar.html "My title, optional"- [my label 2]: /foo- [my label 3]: http://fsf.org (The free software foundation)- [my label 4]: /bar#special 'A title in single quotes'--The URL may optionally be surrounded by angle brackets:-- [my label 5]: <http://foo.bar.baz>--The title may go on the next line:-- [my label 3]: http://fsf.org- "The free software foundation"--Note that link labels are not case sensitive. So, this will work:-- Here is [my link][FOO]-- [Foo]: /bar/baz--In an *implicit* reference link, the second pair of brackets is-empty:-- See [my website][].-- [my website]: http://foo.bar.baz--Note: In `Markdown.pl` and most other Markdown implementations,-reference link definitions cannot occur in nested constructions-such as list items or block quotes. Pandoc lifts this arbitrary-seeming restriction. So the following is fine in pandoc, though-not in most other implementations:-- > My block [quote].- >- > [quote]: /foo--#### Extension: `shortcut_reference_links` ####--In a *shortcut* reference link, the second pair of brackets may-be omitted entirely:-- See [my website].-- [my website]: http://foo.bar.baz--### Internal links ###--To link to another section of the same document, use the automatically-generated identifier (see [Header identifiers]). For example:-- See the [Introduction](#introduction).--or-- See the [Introduction].-- [Introduction]: #introduction--Internal links are currently supported for HTML formats (including-HTML slide shows and EPUB), LaTeX, and ConTeXt.--Images---------A link immediately preceded by a `!` will be treated as an image.-The link text will be used as the image's alt text:-- -- ![movie reel]-- [movie reel]: movie.gif--#### Extension: `implicit_figures` ####--An image occurring by itself in a paragraph will be rendered as-a figure with a caption.[^5] (In LaTeX, a figure environment will be-used; in HTML, the image will be placed in a `div` with class-`figure`, together with a caption in a `p` with class `caption`.)-The image's alt text will be used as the caption.-- --[^5]: This feature is not yet implemented for RTF, OpenDocument, or- ODT. In those formats, you'll just get an image in a paragraph by- itself, with no caption.--If you just want a regular inline image, just make sure it is not-the only thing in the paragraph. One way to do this is to insert a-nonbreaking space after the image:-- \ --#### Extension: `link_attributes` ####--Attributes can be set on links and images:-- An inline {#id .class width=30 height=20px}- and a reference ![image][ref] with attributes.-- [ref]: foo.jpg "optional title" {#id .class key=val key2="val 2"}--(This syntax is compatible with [PHP Markdown Extra] when only `#id`-and `.class` are used.)--For HTML and EPUB, all attributes except `width` and `height` (but-including `srcset` and `sizes`) are passed through as is. The other-writers ignore attributes that are not supported by their output-format.--The `width` and `height` attributes on images are treated specially. When-used without a unit, the unit is assumed to be pixels. However, any of-the following unit identifiers can be used: `px`, `cm`, `mm`, `in`, `inch`-and `%`. There must not be any spaces between the number and the unit.-For example:--```-{ width=50% }-```--- Dimensions are converted to inches for output in page-based formats like- LaTeX. Dimensions are converted to pixels for output in HTML-like- formats. Use the `--dpi` option to specify the number of pixels per- inch. The default is 96dpi.-- The `%` unit is generally relative to some available space.- For example the above example will render to- `<img href="file.jpg" style="width: 50%;" />` (HTML),- `\includegraphics[width=0.5\textwidth]{file.jpg}` (LaTeX), or- `\externalfigure[file.jpg][width=0.5\textwidth]` (ConTeXt).-- Some output formats have a notion of a class- ([ConTeXt](http://wiki.contextgarden.net/Using_Graphics#Multiple_Image_Settings))- or a unique identifier (LaTeX `\caption`), or both (HTML).-- When no `width` or `height` attributes are specified, the fallback- is to look at the image resolution and the dpi metadata embedded in- the image file.---Footnotes------------#### Extension: `footnotes` ####--Pandoc's Markdown allows footnotes, using the following syntax:-- Here is a footnote reference,[^1] and another.[^longnote]-- [^1]: Here is the footnote.-- [^longnote]: Here's one with multiple blocks.-- Subsequent paragraphs are indented to show that they- belong to the previous footnote.-- { some.code }-- The whole paragraph can be indented, or just the first- line. In this way, multi-paragraph footnotes work like- multi-paragraph list items.-- This paragraph won't be part of the note, because it- isn't indented.--The identifiers in footnote references may not contain spaces, tabs,-or newlines. These identifiers are used only to correlate the-footnote reference with the note itself; in the output, footnotes-will be numbered sequentially.--The footnotes themselves need not be placed at the end of the-document. They may appear anywhere except inside other block elements-(lists, block quotes, tables, etc.).--#### Extension: `inline_notes` ####--Inline footnotes are also allowed (though, unlike regular notes,-they cannot contain multiple paragraphs). The syntax is as follows:-- Here is an inline note.^[Inlines notes are easier to write, since- you don't have to pick an identifier and move down to type the- note.]--Inline and regular footnotes may be mixed freely.---Citations------------#### Extension: `citations` ####--Using an external filter, `pandoc-citeproc`, pandoc can automatically generate-citations and a bibliography in a number of styles. Basic usage is-- pandoc --filter pandoc-citeproc myinput.txt--In order to use this feature, you will need to specify a bibliography file-using the `bibliography` metadata field in a YAML metadata section, or-`--bibliography` command line argument. You can supply multiple `--bibliography`-arguments or set `bibliography` metadata field to YAML array, if you want to-use multiple bibliography files. The bibliography may have any of these-formats:-- Format File extension- ------------ --------------- BibLaTeX .bib- BibTeX .bibtex- Copac .copac- CSL JSON .json- CSL YAML .yaml- EndNote .enl- EndNote XML .xml- ISI .wos- MEDLINE .medline- MODS .mods- RIS .ris--Note that `.bib` can be used with both BibTeX and BibLaTeX files;-use `.bibtex` to force BibTeX.--Note that `pandoc-citeproc --bib2json` and `pandoc-citeproc --bib2yaml`-can produce `.json` and `.yaml` files from any of the supported formats.--In-field markup: In BibTeX and BibLaTeX databases, pandoc-citeproc parses-a subset of LaTeX markup; in CSL YAML databases, pandoc Markdown; and in CSL JSON databases, an [HTML-like markup][CSL markup specs]:--`<i>...</i>`-: italics--`<b>...</b>`-: bold--`<span style="font-variant:small-caps;">...</span>` or `<sc>...</sc>`-: small capitals--`<sub>...</sub>`-: subscript--`<sup>...</sup>`-: superscript--`<span class="nocase">...</span>`-: prevent a phrase from being capitalized as title case--`pandoc-citeproc -j` and `-y` interconvert the CSL JSON-and CSL YAML formats as far as possible.--As an alternative to specifying a bibliography file using `--bibliography`-or the YAML metadata field `bibliography`, you can include-the citation data directly in the `references` field of the-document's YAML metadata. The field should contain an array of-YAML-encoded references, for example:-- ---- references:- - type: article-journal- id: WatsonCrick1953- author:- - family: Watson- given: J. D.- - family: Crick- given: F. H. C.- issued:- date-parts:- - - 1953- - 4- - 25- title: 'Molecular structure of nucleic acids: a structure for deoxyribose- nucleic acid'- title-short: Molecular structure of nucleic acids- container-title: Nature- volume: 171- issue: 4356- page: 737-738- DOI: 10.1038/171737a0- URL: http://www.nature.com/nature/journal/v171/n4356/abs/171737a0.html- language: en-GB- ...--(`pandoc-citeproc --bib2yaml` can produce these from a bibliography file in one-of the supported formats.)--Citations and references can be formatted using any style supported by the-[Citation Style Language], listed in the [Zotero Style Repository].-These files are specified using the `--csl` option or the `csl` metadata field.-By default, `pandoc-citeproc` will use the [Chicago Manual of Style] author-date-format. The CSL project provides further information on [finding and editing styles].--To make your citations hyperlinks to the corresponding bibliography-entries, add `link-citations: true` to your YAML metadata.--Citations go inside square brackets and are separated by semicolons.-Each citation must have a key, composed of '@' + the citation-identifier from the database, and may optionally have a prefix,-a locator, and a suffix. The citation key must begin with a letter, digit,-or `_`, and may contain alphanumerics, `_`, and internal punctuation-characters (`:.#$%&-+?<>~/`). Here are some examples:-- Blah blah [see @doe99, pp. 33-35; also @smith04, chap. 1].-- Blah blah [@doe99, pp. 33-35, 38-39 and *passim*].-- Blah blah [@smith04; @doe99].--`pandoc-citeproc` detects locator terms in the [CSL locale files].-Either abbreviated or unabbreviated forms are accepted. In the `en-US`-locale, locator terms can be written in either singular or plural forms,-as `book`, `bk.`/`bks.`; `chapter`, `chap.`/`chaps.`; `column`,-`col.`/`cols.`; `figure`, `fig.`/`figs.`; `folio`, `fol.`/`fols.`;-`number`, `no.`/`nos.`; `line`, `l.`/`ll.`; `note`, `n.`/`nn.`; `opus`,-`op.`/`opp.`; `page`, `p.`/`pp.`; `paragraph`, `para.`/`paras.`; `part`,-`pt.`/`pts.`; `section`, `sec.`/`secs.`; `sub verbo`, `s.v.`/`s.vv.`;-`verse`, `v.`/`vv.`; `volume`, `vol.`/`vols.`; `¶`/`¶¶`; `§`/`§§`. If no-locator term is used, "page" is assumed.--A minus sign (`-`) before the `@` will suppress mention of-the author in the citation. This can be useful when the-author is already mentioned in the text:-- Smith says blah [-@smith04].--You can also write an in-text citation, as follows:-- @smith04 says blah.-- @smith04 [p. 33] says blah.--If the style calls for a list of works cited, it will be placed-at the end of the document. Normally, you will want to end your-document with an appropriate header:-- last paragraph...-- # References--The bibliography will be inserted after this header. Note that-the `unnumbered` class will be added to this header, so that the-section will not be numbered.--If you want to include items in the bibliography without actually-citing them in the body text, you can define a dummy `nocite` metadata-field and put the citations there:-- ---- nocite: |- @item1, @item2- ...-- @item3--In this example, the document will contain a citation for `item3`-only, but the bibliography will contain entries for `item1`, `item2`, and-`item3`.--For LaTeX or PDF output, you can also use [`natbib`] or [`biblatex`]-to render bibliography. In order to do so, specify bibliography files as-outlined above, and add `--natbib` or `--biblatex` argument to `pandoc`-invocation. Bear in mind that bibliography files have to be in respective-format (either BibTeX or BibLaTeX).--For more information, see the [pandoc-citeproc man page].--[CSL markup specs]: http://docs.citationstyles.org/en/1.0/release-notes.html#rich-text-markup-within-fields-[Chicago Manual of Style]: http://chicagomanualofstyle.org-[Citation Style Language]: http://citationstyles.org-[Zotero Style Repository]: https://www.zotero.org/styles-[finding and editing styles]: http://citationstyles.org/styles/-[CSL locale files]: https://github.com/citation-style-language/locales-[pandoc-citeproc man page]: https://github.com/jgm/pandoc-citeproc/blob/master/man/pandoc-citeproc.1.md--Non-pandoc extensions------------------------The following Markdown syntax extensions are not enabled by default-in pandoc, but may be enabled by adding `+EXTENSION` to the format-name, where `EXTENSION` is the name of the extension. Thus, for-example, `markdown+hard_line_breaks` is Markdown with hard line breaks.--#### Extension: `lists_without_preceding_blankline` ####--Allow a list to occur right after a paragraph, with no intervening-blank space.--#### Extension: `hard_line_breaks` ####--Causes all newlines within a paragraph to be interpreted as hard line-breaks instead of spaces.--#### Extension: `ignore_line_breaks` ####--Causes newlines within a paragraph to be ignored, rather than being-treated as spaces or as hard line breaks. This option is intended for-use with East Asian languages where spaces are not used between words,-but text is divided into lines for readability.--#### Extension: `east_asian_line_breaks` ####--Causes newlines within a paragraph to be ignored, rather than-being treated as spaces or as hard line breaks, when they occur-between two East Asian wide characters. This is a better choice-than `ignore_line_breaks` for texts that include a mix of East-Asian wide characters and other characters.--##### Extension: `emoji` ####--Parses textual emojis like `:smile:` as Unicode emoticons.--#### Extension: `tex_math_single_backslash` ####--Causes anything between `\(` and `\)` to be interpreted as inline-TeX math, and anything between `\[` and `\]` to be interpreted-as display TeX math. Note: a drawback of this extension is that-it precludes escaping `(` and `[`.--#### Extension: `tex_math_double_backslash` ####--Causes anything between `\\(` and `\\)` to be interpreted as inline-TeX math, and anything between `\\[` and `\\]` to be interpreted-as display TeX math.--#### Extension: `markdown_attribute` ####--By default, pandoc interprets material inside block-level tags as Markdown.-This extension changes the behavior so that Markdown is only parsed-inside block-level tags if the tags have the attribute `markdown=1`.--#### Extension: `mmd_title_block` ####--Enables a [MultiMarkdown] style title block at the top of-the document, for example:-- Title: My title- Author: John Doe- Date: September 1, 2008- Comment: This is a sample mmd title block, with- a field spanning multiple lines.--See the MultiMarkdown documentation for details. If `pandoc_title_block` or-`yaml_metadata_block` is enabled, it will take precedence over-`mmd_title_block`.--#### Extension: `abbreviations` ####--Parses PHP Markdown Extra abbreviation keys, like-- *[HTML]: Hypertext Markup Language--Note that the pandoc document model does not support-abbreviations, so if this extension is enabled, abbreviation keys are-simply skipped (as opposed to being parsed as paragraphs).--#### Extension: `autolink_bare_uris` ####--Makes all absolute URIs into links, even when not surrounded by-pointy braces `<...>`.--#### Extension: `ascii_identifiers` ####--Causes the identifiers produced by `auto_identifiers` to be pure ASCII.-Accents are stripped off of accented latin letters, and non-latin-letters are omitted.--#### Extension: `mmd_link_attributes` ####--Parses multimarkdown style key-value attributes on link-and image references. This extension should not be confused with the-[`link_attributes`](#extension-link_attributes) extension.-- This is a reference ![image][ref] with multimarkdown attributes.-- [ref]: http://path.to/image "Image title" width=20px height=30px- id=myId class="myClass1 myClass2"--#### Extension: `mmd_header_identifiers` ####--Parses multimarkdown style header identifiers (in square brackets,-after the header but before any trailing `#`s in an ATX header).--#### Extension: `compact_definition_lists` ####--Activates the definition list syntax of pandoc 1.12.x and earlier.-This syntax differs from the one described above under [Definition lists]-in several respects:-- - No blank line is required between consecutive items of the- definition list.- - To get a "tight" or "compact" list, omit space between consecutive- items; the space between a term and its definition does not affect- anything.- - Lazy wrapping of paragraphs is not allowed: the entire definition must- be indented four spaces.[^6]--[^6]: To see why laziness is incompatible with relaxing the requirement- of a blank line between items, consider the following example:-- bar- : definition- foo- : definition-- Is this a single list item with two definitions of "bar," the first of- which is lazily wrapped, or two list items? To remove the ambiguity- we must either disallow lazy wrapping or require a blank line between- list items.--Markdown variants--------------------In addition to pandoc's extended Markdown, the following Markdown-variants are supported:--`markdown_phpextra` (PHP Markdown Extra)-: `footnotes`, `pipe_tables`, `raw_html`, `markdown_attribute`,- `fenced_code_blocks`, `definition_lists`, `intraword_underscores`,- `header_attributes`, `link_attributes`, `abbreviations`,- `shortcut_reference_links`.--`markdown_github` (GitHub-Flavored Markdown)-: `pipe_tables`, `raw_html`, `fenced_code_blocks`, `auto_identifiers`,- `ascii_identifiers`, `backtick_code_blocks`, `autolink_bare_uris`,- `intraword_underscores`, `strikeout`, `hard_line_breaks`, `emoji`,- `shortcut_reference_links`.--`markdown_mmd` (MultiMarkdown)-: `pipe_tables`, `raw_html`, `markdown_attribute`, `mmd_link_attributes`,- `raw_tex`, `tex_math_double_backslash`, `intraword_underscores`,- `mmd_title_block`, `footnotes`, `definition_lists`,- `all_symbols_escapable`, `implicit_header_references`,- `auto_identifiers`, `mmd_header_identifiers`,- `shortcut_reference_links`.--`markdown_strict` (Markdown.pl)-: `raw_html`--Extensions with formats other than Markdown----------------------------------------------Some of the extensions discussed above can be used with formats-other than Markdown:--* `auto_identifiers` can be used with `latex`, `rst`, `mediawiki`,- and `textile` input (and is used by default).--* `tex_math_dollars`, `tex_math_single_backslash`, and- `tex_math_double_backslash` can be used with `html` input.- (This is handy for reading web pages formatted using MathJax,- for example.)--Producing slide shows with pandoc-=================================--You can use pandoc to produce an HTML + javascript slide presentation-that can be viewed via a web browser. There are five ways to do this,-using [S5], [DZSlides], [Slidy], [Slideous], or [reveal.js].-You can also produce a PDF slide show using LaTeX [`beamer`].--Here's the Markdown source for a simple slide show, `habits.txt`:-- % Habits- % John Doe- % March 22, 2005-- # In the morning-- ## Getting up-- - Turn off alarm- - Get out of bed-- ## Breakfast-- - Eat eggs- - Drink coffee-- # In the evening-- ## Dinner-- - Eat spaghetti- - Drink wine-- -------------------- -- ## Going to sleep-- - Get in bed- - Count sheep--To produce an HTML/javascript slide show, simply type-- pandoc -t FORMAT -s habits.txt -o habits.html--where `FORMAT` is either `s5`, `slidy`, `slideous`, `dzslides`, or `revealjs`.--For Slidy, Slideous, reveal.js, and S5, the file produced by pandoc with the-`-s/--standalone` option embeds a link to javascripts and CSS files, which are-assumed to be available at the relative path `s5/default` (for S5), `slideous`-(for Slideous), `reveal.js` (for reveal.js), or at the Slidy website at-`w3.org` (for Slidy). (These paths can be changed by setting the `slidy-url`,-`slideous-url`, `revealjs-url`, or `s5-url` variables; see [Variables for slides],-above.) For DZSlides, the (relatively short) javascript and css are included in-the file by default.--With all HTML slide formats, the `--self-contained` option can be used to-produce a single file that contains all of the data necessary to display the-slide show, including linked scripts, stylesheets, images, and videos.--To produce a PDF slide show using beamer, type-- pandoc -t beamer habits.txt -o habits.pdf--Note that a reveal.js slide show can also be converted to a PDF-by printing it to a file from the browser.--Structuring the slide show-----------------------------By default, the *slide level* is the highest header level in-the hierarchy that is followed immediately by content, and not another-header, somewhere in the document. In the example above, level 1 headers-are always followed by level 2 headers, which are followed by content,-so 2 is the slide level. This default can be overridden using-the `--slide-level` option.--The document is carved up into slides according to the following-rules:-- * A horizontal rule always starts a new slide.-- * A header at the slide level always starts a new slide.-- * Headers *below* the slide level in the hierarchy create- headers *within* a slide.-- * Headers *above* the slide level in the hierarchy create- "title slides," which just contain the section title- and help to break the slide show into sections.-- * A title page is constructed automatically from the document's title- block, if present. (In the case of beamer, this can be disabled- by commenting out some lines in the default template.)--These rules are designed to support many different styles of slide show. If-you don't care about structuring your slides into sections and subsections,-you can just use level 1 headers for all each slide. (In that case, level 1-will be the slide level.) But you can also structure the slide show into-sections, as in the example above.--Note: in reveal.js slide shows, if slide level is 2, a two-dimensional-layout will be produced, with level 1 headers building horizontally-and level 2 headers building vertically. It is not recommended that-you use deeper nesting of section levels with reveal.js.--Incremental lists--------------------By default, these writers produce lists that display "all at once."-If you want your lists to display incrementally (one item at a time),-use the `-i` option. If you want a particular list to depart from the-default (that is, to display incrementally without the `-i` option and-all at once with the `-i` option), put it in a block quote:-- > - Eat spaghetti- > - Drink wine--In this way incremental and nonincremental lists can be mixed in-a single document.--Inserting pauses-------------------You can add "pauses" within a slide by including a paragraph containing-three dots, separated by spaces:-- # Slide with a pause-- content before the pause-- . . .-- content after the pause--Styling the slides---------------------You can change the style of HTML slides by putting customized CSS files-in `$DATADIR/s5/default` (for S5), `$DATADIR/slidy` (for Slidy),-or `$DATADIR/slideous` (for Slideous),-where `$DATADIR` is the user data directory (see `--data-dir`, above).-The originals may be found in pandoc's system data directory (generally-`$CABALDIR/pandoc-VERSION/s5/default`). Pandoc will look there for any-files it does not find in the user data directory.--For dzslides, the CSS is included in the HTML file itself, and may-be modified there.--All [reveal.js configuration options] can be set through variables.-For example, themes can be used by setting the `theme` variable:-- -V theme=moon--Or you can specify a custom stylesheet using the `--css` option.--To style beamer slides, you can specify a `theme`, `colortheme`,-`fonttheme`, `innertheme`, and `outertheme`, using the `-V` option:-- pandoc -t beamer habits.txt -V theme:Warsaw -o habits.pdf--Note that header attributes will turn into slide attributes-(on a `<div>` or `<section>`) in HTML slide formats, allowing you-to style individual slides. In beamer, the only header attribute-that affects slides is the `allowframebreaks` class, which sets the-`allowframebreaks` option, causing multiple slides to be created-if the content overfills the frame. This is recommended especially for-bibliographies:-- # References {.allowframebreaks}--Speaker notes----------------reveal.js has good support for speaker notes. You can add notes to your-Markdown document thus:-- <div class="notes">- This is my note.-- - It can contain Markdown- - like this list-- </div>--To show the notes window, press `s` while viewing the presentation.-Notes are not yet supported for other slide formats, but the notes-will not appear on the slides themselves.--Frame attributes in beamer-----------------------------Sometimes it is necessary to add the LaTeX `[fragile]` option to-a frame in beamer (for example, when using the `minted` environment).-This can be forced by adding the `fragile` class to the header-introducing the slide:-- # Fragile slide {.fragile}--All of the other frame attributes described in Section 8.1 of-the [Beamer User's Guide] may also be used: `allowdisplaybreaks`,-`allowframebreaks`, `b`, `c`, `t`, `environment`, `label`, `plain`,-`shrink`.--Creating EPUBs with pandoc-==========================--EPUB Metadata----------------EPUB metadata may be specified using the `--epub-metadata` option, but-if the source document is Markdown, it is better to use a [YAML metadata-block][Extension: `yaml_metadata_block`]. Here is an example:-- ---- title:- - type: main- text: My Book- - type: subtitle- text: An investigation of metadata- creator:- - role: author- text: John Smith- - role: editor- text: Sarah Jones- identifier:- - scheme: DOI- text: doi:10.234234.234/33- publisher: My Press- rights: © 2007 John Smith, CC BY-NC- ...--The following fields are recognized:--`identifier`- ~ Either a string value or an object with fields `text` and- `scheme`. Valid values for `scheme` are `ISBN-10`,- `GTIN-13`, `UPC`, `ISMN-10`, `DOI`, `LCCN`, `GTIN-14`,- `ISBN-13`, `Legal deposit number`, `URN`, `OCLC`,- `ISMN-13`, `ISBN-A`, `JP`, `OLCC`.--`title`- ~ Either a string value, or an object with fields `file-as` and- `type`, or a list of such objects. Valid values for `type` are- `main`, `subtitle`, `short`, `collection`, `edition`, `extended`.--`creator`- ~ Either a string value, or an object with fields `role`, `file-as`,- and `text`, or a list of such objects. Valid values for `role` are- [MARC relators], but- pandoc will attempt to translate the human-readable versions- (like "author" and "editor") to the appropriate marc relators.--`contributor`- ~ Same format as `creator`.--`date`- ~ A string value in `YYYY-MM-DD` format. (Only the year is necessary.)- Pandoc will attempt to convert other common date formats.--`lang` (or legacy: `language`)- ~ A string value in [BCP 47] format. Pandoc will default to the local- language if nothing is specified.--`subject`- ~ A string value or a list of such values.--`description`- ~ A string value.--`type`- ~ A string value.--`format`- ~ A string value.--`relation`- ~ A string value.--`coverage`- ~ A string value.--`rights`- ~ A string value.--`cover-image`- ~ A string value (path to cover image).--`stylesheet`- ~ A string value (path to CSS stylesheet).--`page-progression-direction`- ~ Either `ltr` or `rtl`. Specifies the `page-progression-direction`- attribute for the [`spine` element].--[MARC relators]: http://loc.gov/marc/relators/relaterm.html-[`spine` element]: http://idpf.org/epub/301/spec/epub-publications.html#sec-spine-elem--Linked media---------------By default, pandoc will download linked media (including audio and-video) and include it in the EPUB container, yielding a completely-self-contained EPUB. If you want to link to external media resources-instead, use raw HTML in your source and add `data-external="1"` to the tag-with the `src` attribute. For example:-- <audio controls="1">- <source src="http://example.com/music/toccata.mp3"- data-external="1" type="audio/mpeg">- </source>- </audio>--Literate Haskell support-========================--If you append `+lhs` (or `+literate_haskell`) to an appropriate input or output-format (`markdown`, `markdown_strict`, `rst`, or `latex` for input or output;-`beamer`, `html` or `html5` for output only), pandoc will treat the document as-literate Haskell source. This means that-- - In Markdown input, "bird track" sections will be parsed as Haskell- code rather than block quotations. Text between `\begin{code}`- and `\end{code}` will also be treated as Haskell code. For- ATX-style headers the character '=' will be used instead of '#'.-- - In Markdown output, code blocks with classes `haskell` and `literate`- will be rendered using bird tracks, and block quotations will be- indented one space, so they will not be treated as Haskell code.- In addition, headers will be rendered setext-style (with underlines)- rather than ATX-style (with '#' characters). (This is because ghc- treats '#' characters in column 1 as introducing line numbers.)-- - In restructured text input, "bird track" sections will be parsed- as Haskell code.-- - In restructured text output, code blocks with class `haskell` will- be rendered using bird tracks.-- - In LaTeX input, text in `code` environments will be parsed as- Haskell code.-- - In LaTeX output, code blocks with class `haskell` will be rendered- inside `code` environments.-- - In HTML output, code blocks with class `haskell` will be rendered- with class `literatehaskell` and bird tracks.--Examples:-- pandoc -f markdown+lhs -t html--reads literate Haskell source formatted with Markdown conventions and writes-ordinary HTML (without bird tracks).-- pandoc -f markdown+lhs -t html+lhs--writes HTML with the Haskell code in bird tracks, so it can be copied-and pasted as literate Haskell source.--Syntax highlighting-===================--Pandoc will automatically highlight syntax in [fenced code blocks] that-are marked with a language name. The Haskell library [highlighting-kate] is used for-highlighting, which works in HTML, Docx, and LaTeX/PDF output.-The color scheme can be selected using the `--highlight-style` option.-The default color scheme is `pygments`, which imitates the default color-scheme used by the Python library pygments, but pygments is not actually-used to do the highlighting.--To see a list of language names that pandoc will recognize, type-`pandoc --version`.--To disable highlighting, use the `--no-highlight` option.--[highlighting-kate]: https://github.com/jgm/highlighting-kate--Custom writers-==============--Pandoc can be extended with custom writers written in [lua]. (Pandoc-includes a lua interpreter, so lua need not be installed separately.)--To use a custom writer, simply specify the path to the lua script-in place of the output format. For example:-- pandoc -t data/sample.lua--Creating a custom writer requires writing a lua function for each-possible element in a pandoc document. To get a documented example-which you can modify according to your needs, do-- pandoc --print-default-data-file sample.lua--[lua]: http://www.lua.org--Authors-=======--© 2006-2015 John MacFarlane (jgm@berkeley.edu). Released under the-[GPL], version 2 or greater. This software carries no warranty of-any kind. (See COPYRIGHT for full copyright and warranty notices.)--Contributors include-Aaron Wolen,-Albert Krewinkel,-Alex Vong,-Alexander Kondratskiy,-Alexander Sulfrian,-Alexander V Vershilov,-Alfred Wechselberger,-Andreas Lööw,-Andrew Dunning,-Antoine Latter,-Arata Mizuki,-Arlo O'Keeffe,-Artyom Kazak,-Ben Gamari,-Beni Cherniavsky-Paskin,-Benoit Schweblin,-Bjorn Buckwalter,-Bradley Kuhn,-Brent Yorgey,-Bryan O'Sullivan,-B. Scott Michel,-Caleb McDaniel,-Calvin Beck,-Carlos Sosa,-Chris Black,-Christian Conkle,-Christoffer Ackelman,-Christoffer Sawicki,-Clare Macrae,-Clint Adams,-Conal Elliott,-Craig S. Bosma,-csforste,-Daniel Bergey,-Daniel T. Staal,-David Lazar,-David Röthlisberger,-Denis Laxalde,-Douglas Calvert,-Douglas F. Calvert,-Emanuel Evans,-Emily Eisenberg,-Eric Kow,-Eric Seidel,-Florian Eitel,-François Gannaz,-Freiric Barral,-Freirich Raabe,-Fyodor Sheremetyev,-Gabor Pali,-Gavin Beatty,-Gottfried Haider,-Greg Maslov,-Grégory Bataille,-Greg Rundlett,-gwern,-Gwern Branwen,-Hans-Peter Deifel,-Henrik Tramberend,-Henry de Valence,-ickc,-Ilya V. Portnov,-infinity0x,-Ivo Clarysse,-Jaime Marquínez Ferrándiz,-James Aspnes,-Jamie F. Olson,-Jan Larres,-Jan Schulz,-Jason Ronallo,-Jeff Arnold,-Jeff Runningen,-Jens Petersen,-Jérémy Bobbio,-Jesse Rosenthal,-J. Lewis Muir,-Joe Hillenbrand,-John MacFarlane,-Jonas Smedegaard,-Jonathan Daugherty,-Josef Svenningsson,-Jose Luis Duran,-Julien Cretel,-Juliusz Gonera,-Justin Bogner,-Kelsey Hightower,-Kolen Cheung,-Konstantin Zudov,-Kristof Bastiaensen,-Lars-Dominik Braun,-Luke Plant,-Mark Szepieniec,-Mark Wright,-Martin Linn,-Masayoshi Takahashi,-Matej Kollar,-Mathias Schenner,-Mathieu Duponchelle,-Matthew Eddey,-Matthew Pickering,-Matthias C. M. Troffaes,-Mauro Bieg,-Max Bolingbroke,-Max Rydahl Andersen,-Merijn Verstraaten,-Michael Beaumont,-Michael Chladek,-Michael Snoyman,-Michael Thompson,-MinRK,-Nathan Gass,-Neil Mayhew,-Nick Bart,-Nicolas Kaiser,-Nikolay Yakimov,-nkalvi,-Ophir Lifshitz,-Pablo Rodríguez,-Paulo Tanimoto,-Paul Rivier,-Peter Wang,-Philippe Ombredanne,-Phillip Alday,-Prayag Verma,-Puneeth Chaganti,-qerub,-Ralf Stephan,-Raniere Silva,-Recai Oktaş,-robabla,-rodja.trappe,-rski,-RyanGlScott,-Scott Morrison,-Sergei Trofimovich,-Sergey Astanin,-Shahbaz Youssefi,-Shaun Attfield,-Sidarth Kapur,-shreevatsa.public,-Simon Hengel,-Sumit Sahrawat,-takahashim,-thsutton,-Tim Lin,-Timothy Humphries,-Tiziano Müller,-Thomas Hodgson,-Todd Sifleet,-Tom Leese,-Uli Köhler,-Václav Zeman,-Viktor Kronvall,-Vincent,-Wikiwide, and-Xavier Olive.--[GPL]: http://www.gnu.org/copyleft/gpl.html "GNU General Public License"
+ README.md view
@@ -0,0 +1,144 @@+Pandoc+======++[](https://www.gnu.org/licenses/gpl.html)+[](http://hackage.haskell.org/package/pandoc)+[](http://stackage.org/lts/package/pandoc)+[](https://github.com/jgm/pandoc/releases)+[](https://travis-ci.org/jgm/pandoc)+[](https://ci.appveyor.com/project/jgm/pandoc)+++The universal markup converter+------------------------------++Pandoc is a [Haskell] library for converting from one markup format to+another, and a command-line tool that uses this library. It can read+[Markdown], [CommonMark], [PHP Markdown Extra], [GitHub-Flavored Markdown],+[MultiMarkdown], and (subsets of) [Textile], [reStructuredText], [HTML],+[LaTeX], [MediaWiki markup], [TWiki markup], [Haddock markup], [OPML], [Emacs+Org mode], [DocBook], [txt2tags], [EPUB], [ODT] and [Word docx]; and it can+write plain text, [Markdown], [CommonMark], [PHP Markdown Extra],+[GitHub-Flavored Markdown], [MultiMarkdown], [reStructuredText], [XHTML],+[HTML5], [LaTeX] \(including [`beamer`] slide shows\), [ConTeXt], [RTF], [OPML],+[DocBook], [OpenDocument], [ODT], [Word docx], [GNU Texinfo], [MediaWiki+markup], [DokuWiki markup], [ZimWiki markup], [Haddock markup],+[EPUB] \(v2 or v3\), [FictionBook2], [Textile], [groff man] pages,+[Emacs Org mode], [AsciiDoc], [InDesign ICML], [TEI Simple], and [Slidy],+[Slideous], [DZSlides], [reveal.js] or [S5] HTML slide shows. It can also+produce [PDF] output on systems where LaTeX, ConTeXt, or `wkhtmltopdf` is+installed.++Pandoc's enhanced version of Markdown includes syntax for [footnotes],+[tables], flexible [ordered lists], [definition lists], [fenced code blocks],+[superscripts and subscripts], [strikeout], [metadata blocks], automatic tables of+contents, embedded LaTeX [math], [citations], and [Markdown inside HTML block+elements]. (These enhancements, described+further under [Pandoc's Markdown], can be disabled using the+`markdown_strict` input or output format.)++In contrast to most existing tools for converting Markdown to HTML, which+use regex substitutions, pandoc has a modular design: it consists of a+set of readers, which parse text in a given format and produce a native+representation of the document, and a set of writers, which convert+this native representation into a target format. Thus, adding an input+or output format requires only adding a reader or writer.++Because pandoc's intermediate representation of a document is less+expressive than many of the formats it converts between, one should+not expect perfect conversions between every format and every other.+Pandoc attempts to preserve the structural elements of a document, but+not formatting details such as margin size. And some document elements,+such as complex tables, may not fit into pandoc's simple document+model. While conversions from pandoc's Markdown to all formats aspire+to be perfect, conversions from formats more expressive than pandoc's+Markdown can be expected to be lossy.++[Markdown]: http://daringfireball.net/projects/markdown/+[CommonMark]: http://commonmark.org+[PHP Markdown Extra]: https://michelf.ca/projects/php-markdown/extra/+[GitHub-Flavored Markdown]: https://help.github.com/articles/github-flavored-markdown/+[MultiMarkdown]: http://fletcherpenney.net/multimarkdown/+[reStructuredText]: http://docutils.sourceforge.net/docs/ref/rst/introduction.html+[S5]: http://meyerweb.com/eric/tools/s5/+[Slidy]: http://www.w3.org/Talks/Tools/Slidy/+[Slideous]: http://goessner.net/articles/slideous/+[HTML]: http://www.w3.org/html/+[HTML5]: http://www.w3.org/TR/html5/+[XHTML]: http://www.w3.org/TR/xhtml1/+[LaTeX]: http://latex-project.org+[`beamer`]: https://ctan.org/pkg/beamer+[Beamer User's Guide]: http://ctan.math.utah.edu/ctan/tex-archive/macros/latex/contrib/beamer/doc/beameruserguide.pdf+[ConTeXt]: http://contextgarden.net/+[RTF]: http://en.wikipedia.org/wiki/Rich_Text_Format+[DocBook]: http://docbook.org+[txt2tags]: http://txt2tags.org+[EPUB]: http://idpf.org/epub+[OPML]: http://dev.opml.org/spec2.html+[OpenDocument]: http://opendocument.xml.org+[ODT]: http://en.wikipedia.org/wiki/OpenDocument+[Textile]: http://redcloth.org/textile+[MediaWiki markup]: https://www.mediawiki.org/wiki/Help:Formatting+[DokuWiki markup]: https://www.dokuwiki.org/dokuwiki+[ZimWiki markup]: http://zim-wiki.org/manual/Help/Wiki_Syntax.html+[TWiki markup]: http://twiki.org/cgi-bin/view/TWiki/TextFormattingRules+[Haddock markup]: https://www.haskell.org/haddock/doc/html/ch03s08.html+[groff man]: http://developer.apple.com/DOCUMENTATION/Darwin/Reference/ManPages/man7/groff_man.7.html+[Haskell]: https://www.haskell.org+[GNU Texinfo]: http://www.gnu.org/software/texinfo/+[Emacs Org mode]: http://orgmode.org+[AsciiDoc]: http://www.methods.co.nz/asciidoc/+[DZSlides]: http://paulrouget.com/dzslides/+[Word docx]: http://www.microsoft.com/interop/openup/openxml/default.aspx+[PDF]: https://www.adobe.com/pdf/+[reveal.js]: http://lab.hakim.se/reveal-js/+[FictionBook2]: http://www.fictionbook.org/index.php/Eng:XML_Schema_Fictionbook_2.1+[InDesign ICML]: https://www.adobe.com/content/dam/Adobe/en/devnet/indesign/cs55-docs/IDML/idml-specification.pdf+[TEI Simple]: https://github.com/TEIC/TEI-Simple+++++[footnotes]: http://pandoc.org/MANUAL.html#footnotes+[tables]: http://pandoc.org/MANUAL.html#tables+[ordered lists]: http://pandoc.org/MANUAL.html#ordered-lists+[definition lists]: http://pandoc.org/MANUAL.html#definition-lists+[fenced code blocks]: http://pandoc.org/MANUAL.html#fenced-code-blocks+[superscripts and subscripts]: http://pandoc.org/MANUAL.html#superscripts-and-subscripts+[strikeout]: http://pandoc.org/MANUAL.html#strikeout+[metadata blocks]: http://pandoc.org/MANUAL.html#metadata-blocks+[math]: http://pandoc.org/MANUAL.html#math+[citations]: http://pandoc.org/MANUAL.html#citations+[Markdown inside HTML block elements]: http://pandoc.org/MANUAL.html#extension-markdown_in_html_blocks+[Pandoc's Markdown]: http://pandoc.org/MANUAL.html#pandocs-markdown++Installing+----------++Here's [how to install pandoc](INSTALL.md).++Documentation+-------------++Pandoc's website contains a full [User's Guide](https://pandoc.org/MANUAL.html).+It is also available [here](MANUAL.txt) as pandoc-flavored Markdown.+The website also contains some [examples of the use of+pandoc](https://pandoc.org/demos.html) and a limited [online+demo](https://pandoc.org/try).++Contributing+------------++Pull requests, bug reports, and feature requests are welcome. Please make+sure to read [the contributor guidelines](CONTRIBUTING.md) before opening a+new issue.+++License+-------++© 2006-2016 John MacFarlane (jgm@berkeley.edu). Released under the+[GPL], version 2 or greater. This software carries no warranty of+any kind. (See COPYRIGHT for full copyright and warranty notices.)++[GPL]: http://www.gnu.org/copyleft/gpl.html "GNU General Public License"
Setup.hs view
@@ -18,18 +18,14 @@ import Distribution.Simple import Distribution.Simple.PreProcess-import Distribution.Simple.Setup (ConfigFlags(..))+import Distribution.Simple.Setup (ConfigFlags(..), CopyFlags(..), fromFlag) import Distribution.PackageDescription (PackageDescription(..), FlagName(..)) import Distribution.Simple.Utils ( rawSystemExitCode, findProgramVersion ) import System.Exit-import Distribution.Verbosity ( Verbosity ) import Distribution.Simple.Utils (info, notice, installOrdinaryFiles)-import Distribution.Simple.Setup import Distribution.Simple.Program (simpleProgram, Program(..)) import Distribution.Simple.LocalBuildInfo-import Data.Version import Control.Monad (when)-import qualified Control.Exception as E main :: IO () main = defaultMainWithHooks $ simpleUserHooks {
changelog view
@@ -1,3 +1,431 @@+pandoc (1.18)++ * Added `--list-input-formats`, `--list-output-formats`,+ `--list-extensions`, `--list-highlight-languages`, and+ `--list-highlight-styles` (#3173). Removed list of highlighting+ languages from `--version` output. Removed list of input and output+ formats from default `--help` output.++ * Added `--reference-location=block|section|document` option+ (Jesse Rosenthal). This determines whether Markdown link references+ and footnotes are placed at the end of the document, the end of the+ section, or the end of the top-level block.++ * Added `--top-level-division=section|chapter|part` (Albert Krewinkel).+ This determines what a level-1 header corresponds to in LaTeX,+ ConTeXt, DocBook, and TEI output. The default is `section`.+ The `--chapters` option has been deprecated in favor of+ `--top-level-division=chapter`.++ * Added `LineBlock` constructor for `Block` (Albert Krewinkel). This+ is now used in parsing RST and Markdown line blocks, DocBook+ `linegroup`/`line` combinations, and Org-mode `VERSE` blocks.+ Previously `Para` blocks with hard linebreaks were used. `LineBlock`s+ are handled specially in the following ouput formats: AsciiDoc+ (as `[verse]` blocks), ConTeXt (`\startlines`/`\endlines`),+ HTML (`div` with a style), Markdown (line blocks if `line_blocks`+ is enabled), Org-mode (`VERSE` blocks), RST (line blocks). In+ other output formats, a paragraph with hard linebreaks is emitted.++ * Allow binary formats to be written to stdout (but not to tty) (#2677).+ Only works on posix, since we use the unix library to check whether+ output is to tty. On Windows, pandoc works as before and always requires+ an output file parameter for binary formats.++ * Changed JSON output format (Jesse Rosenthal). Previously we used+ generically generated JSON, but this was subject to change depending+ on the version of aeson pandoc was compiled with. To ensure stability,+ we switched to using manually written ToJSON and FromJSON+ instances, and encoding the API version. **Note:** pandoc filter+ libraries will need to be revised to handle the format change.+ Here is a summary of the essential changes:++ + The toplevel JSON format is now `{"pandoc-api-version" :+ [MAJ, MIN, REV], "meta" : META, "blocks": BLOCKS}`+ instead of `[{"unMeta": META}, [BLOCKS]]`.+ Decoding fails if the major and minor version numbers don't+ match.+ + Leaf nodes no longer have an empty array for their "c" value.+ Thus, for example, a `Space` is encoded as `{"t":"Space"}`+ rather than `{"t":"Space","c":[]}` as before.++ * Removed `tests/Tests/Arbitrary.hs` and added a `Text.Pandoc.Arbitrary`+ module to pandoc-types (Jesse Rosenthal). This makes it easier+ to use QuickCheck with pandoc types outside of pandoc itself.++ * Add `bracketed_spans` Markdown extension, enabled by default+ in pandoc `markdown`. This allows you to create a native span+ using this syntax: `[Here is my span]{#id .class key="val"}`.++ * Added `angle_brackets_escapable` Markdown extension (#2846).+ This is needed because github flavored Markdown has a slightly+ different set of escapable symbols than original Markdown;+ it includes angle brackets.++ * Export `Text.Pandoc.Error` in `Text.Pandoc` [API change].++ * Print highlighting-kate version in `--version`.++ * `Text.Pandoc.Options`:++ + `Extension` has new constructors `Ext_brackted_spans` and+ `Ext_angle_brackets_escapable` [API change].+ + Added `ReferenceLocation` type [API change] (Jesse Rosenthal).+ + Added `writerReferenceLocation` field to `WriterOptions` (Jesse+ Rosenthal).++ * `--filter`: we now check `$DATADIR/filters` for filters before+ looking in the path (#3127, Jesse Rosenthal, thanks to Jakob+ Voß for the idea). Filters placed in this directory need not+ be executable; if the extension is `.hs`, `.php`, `.pl`, `.js`,+ or `.rb`, pandoc will run the right interpreter.++ * For `--webtex`, replace deprecated Google Chart API by CodeCogs as+ default (Kolen Cheung).++ * Removed `raw_tex` extension from `markdown_mmd` defaults (Kolen Cheung).++ * Execute .js filters with node (Jakob Voß).++ * Textile reader:++ + Support `bc..` extended code blocks (#3037). Also, remove trailing+ newline in code blocks (consistently with Markdown reader).+ + Improve table parsing. We now handle cell and row attributes, mostly+ by skipping them. However, alignments are now handled properly.+ Since in pandoc alignment is per-column, not per-cell, we+ try to devine column alignments from cell alignments.+ Table captions are also now parsed, and textile indicators+ for thead and tfoot no longer cause parse failure. (However,+ a row designated as tfoot will just be a regular row in pandoc.)+ + Improve definition list parsing. We now allow multiple terms+ (which we concatenate with linebreaks). An exponential parsing+ bug (#3020) is also fixed.+ + Disallow empty URL in explicit link (#3036).++ * RST reader:++ + Use Div instead of BlockQuote for admonitions (#3031).+ The Div has class `admonition` and (if relevant) one of the+ following: `attention`, `caution`, `danger`, `error`, `hint`,+ `important`, `note`, `tip`, `warning`. **Note:** This will change+ the rendering of some RST documents! The word ("Warning", "Attention",+ etc.) is no longer added; that must be done with CSS or a filter.+ + A Div is now used for `sidebar` as well.+ + Skip whitespace before note (Jesse Rosenthal, #3163). RST requires a+ space before a footnote marker. We discard those spaces so that footnotes+ will be adjacent to the text that comes before it. This is in line with+ what rst2latex does.+ + Allow empty lines when parsing line blocks (Albert Krewinkel).++ * Markdown reader:++ + Allow empty lines when parsing line blocks (Albert Krewinkel).+ + Allow attributes on autolinks (#3183, Daniele D'Orazio).++ * LaTeX reader:++ + More robust parsing of unknown environments (#3026).+ We no longer fail on things like `^` inside options for tikz.+ + Be more forgiving of non-standard characters, e.g. `^` outside of math.+ Some custom environments give these a meaning, so we should try not to+ fall over when we encounter them.+ + Drop duplicate `*` in bibtexKeyChars (Albert Krewinkel)++ * MediaWiki reader:++ + Fix for unquoted attribute values in mediawiki tables (#3053).+ Previously an unquoted attribute value in a table row+ could cause parsing problems.+ + Improved treatment of verbatim constructions (#3055).+ Previously these yielded strings of alternating Code and Space+ elements; we now incorporate the spaces into the Code. Emphasis+ etc. is still possible inside these.+ + Properly interpret XML tags in pre environments (#3042). They are meant+ to be interpreted as literal text.++ * EPUB reader: don't add root path to data: URIs (#3150).+ Thanks to @lep for the bug report and patch.++ * Org reader (Albert Krewinkel):++ + Preserve indentation of verse lines (#3064). Leading spaces in verse+ lines are converted to non-breaking spaces, so indentation is preserved.+ + Ensure image sources are proper links. Image sources as those in plain+ images, image links, or figures, must be proper URIs or relative file+ paths to be recognized as images. This restriction is now enforced+ for all image sources. This also fixes the reader's usage of uncleaned+ image sources, leading to `file:` prefixes not being deleted from+ figure images. Thanks to @bsag for noticing this bug.+ + Trim verse lines properly (Albert Krewinkel).+ + Extract meta parsing code to module. Parsing of meta-data is well+ separable from other block parsing tasks. Moving into new module to+ get small files and clearly arranged code.+ + Read markup only for special meta keys. Most meta-keys should be read+ as normal string values, only a few are interpreted as marked-up text.+ + Allow multiple, comma-separated authors. Multiple authors can be+ specified in the `#+AUTHOR` meta line if they are given as a+ comma-separated list.+ + Give precedence to later meta lines. The last meta-line of any given+ type is the significant line. Previously the value of the first line+ was kept, even if more lines of the same type were encounterd.+ + Read LaTeX_header as header-includes. LaTeX-specific header commands+ can be defined in `#+LaTeX_header` lines. They are parsed as+ format-specific inlines to ensure that they will only show up in LaTeX+ output.+ + Set documentclass meta from LaTeX_class.+ + Set classoption meta from LaTeX_class_options.+ + Read HTML_head as header-includes. HTML-specific head content can be+ defined in `#+HTML_head` lines. They are parsed as format-specific+ inlines to ensure that they will only show up in HTML output.+ + Respect `author` export option. The `author` option controls whether+ the author should be included in the final markup. Setting+ `#+OPTIONS: author:nil` will drop the author from the final meta-data+ output.+ + Respect `email` export option. The `email` option controls whether the+ email meta-field should be included in the final markup. Setting+ `#+OPTIONS: email:nil` will drop the email field from the final+ meta-data output.+ + Respect `creator` export option. The `creator` option controls whether+ the creator meta-field should be included in the final markup. Setting+ `#+OPTIONS: creator:nil` will drop the creator field from the final+ meta-data output. Org-mode recognizes the special value `comment` for+ this field, causing the creator to be included in a comment. This is+ difficult to translate to Pandoc internals and is hence interpreted the+ same as other truish values (i.e. the meta field is kept if it's+ present).+ + Respect unnumbered header property (#3095). Sections the `unnumbered`+ property should, as the name implies, be excluded from the automatic+ numbering of section provided by some output formats. The Pandoc+ convention for this is to add an "unnumbered" class to the header. The+ reader treats properties as key-value pairs per default, so a special+ case is added to translate the above property to a class instead.+ + Allow figure with empty caption (Albert Krewinkel, #3161).+ A `#+CAPTION` attribute before an image is enough to turn an image into+ a figure. This wasn't the case because the `parseFromString` function,+ which processes the caption value, would fail on empty values. Adding+ a newline character to the caption value fixes this.++ * Docx reader:++ + Use XML convenience functions (Jesse Rosenthal).+ The functions `isElem` and `elemName` (defined in Docx/Util.hs) make+ the code a lot cleaner than the original XML.Light functions, but they+ had been used inconsistently. This puts them in wherever applicable.+ + Handle anchor spans with content in headers. Previously, we would only+ be able to figure out internal links to a header in a docx if the+ anchor span was empty. We change that to read the inlines out of the+ first anchor span in a header.+ + Let headers use exisiting id. Previously we always generated an id for+ headers (since they wouldn't bring one from Docx). Now we let it use an+ existing one if possible. This should allow us to recurs through anchor+ spans.+ + Use all anchor spans for header ids. Previously we only used the first+ anchor span to affect header ids. This allows us to use all the anchor+ spans in a header, whether they're nested or not (#3088).+ + Test for nested anchor spans in header. This ensures that anchor spans+ in header with content (or with other anchor spans inside) will resolve+ to links to a header id properly.++ * ODT reader (Hubert Plociniczak)++ + Include list's starting value. Previously the starting value of+ the lists' items has been hardcoded to 1. In reality ODT's list+ style definition can provide a new starting value in one of its+ attributes.+ + Infer caption from the text following the image.+ Frame can contain other frames with the text boxes.+ + Add `fig:` to title for Image with a caption (as expected+ by pandoc's writers).+ + Basic support for images in ODT documents.+ + Don't duplicate text for anchors (#3143). When creating an anchor+ element we were adding its representation as well as the original+ content, leading to text duplication.++ * DocBook writer:++ + Include an anchor element when a div or span has an id (#3102).+ Note that DocBook does not have a class attribute, but at least this+ provides an anchor for internal links.++ * LaTeX writer:++ + Don't use * for unnumbered paragraph, subparagraph. The starred+ variants don't exist. This helps with part of #3058...it gets rid of+ the spurious `*`s. But we still have numbers on the 4th and 5th level+ headers.+ + Properly escape backticks in verbatim (#3121, Jesse Rosenthal).+ Otherwise they can cause unintended ligatures like `` ?` ``.+ + Handle NARRAOW NO-BREAK SPACE into LaTeX (Vaclav Zeman) as `\,`.+ + Don't include `[htbp]` placement for figures (#3103, Václav Haisman).+ This allows figure placement defaults to be changed by the user+ in the template.++ * TEI writer: remove heuristic to detect book template (Albert Krewinkel).+ TEI doesn't have `<book>` elements but only generic `<divN>` division+ elements. Checking the template for a trailing `</book>` is nonsensical.++ * MediaWiki writer: transform filename with underscores in images (#3052).+ `foo bar.jpg` becomes `foo_bar.jpg`. This was already done+ for internal links, but it also needs to happen for images.++ * ICML writer: replace partial function (!!) in table handling (#3175,+ Mauro Bieg).++ * Man writer: allow section numbers that are not a single digit (#3089).++ * AsciiDoc writer: avoid unnecessary use of "unconstrained" emphasis+ (#3068). In AsciiDoc, you must use a special form of emphasis+ (double `__`) for intraword emphasis. Pandoc was previously using+ this more than necessary.++ * EPUB writer: use stringify instead of plain writer for metadata+ (#3066). This means that underscores won't be used for emphasis,+ or CAPS for bold. The metadata fields will just have unadorned+ text.++ * Docx Writer:++ + Implement user-defined styles (Jesse Rosenthal). Divs and Spans+ with a `custom-style` key in the attributes will apply the corresponding+ key to the contained blocks or inlines.+ + Add ReaderT env to the docx writer (Jesse Rosenthal).+ + Clean up and streamline RTL behavior (Jesse Rosenthal, #3140).+ You can set `dir: rtl` in YAML metadata, or use `-M dir=rtl`+ on the command line. For finer-grained control, you can set+ the `dir` attribute in Div or Span elements.++ * Org writer (Albert Krewinkel):++ + Remove blank line after figure caption. Org-mode only treats an image+ as a figure if it is directly preceded by a caption.+ + Ensure blank line after figure. An Org-mode figure should be surrounded+ by blank lines. The figure would be recognized regardless, but images+ in the following line would unintentionally be treated as figures as+ well.+ + Ensure link targets are paths or URLs. Org-mode treats links as+ document internal searches unless the link target looks like a URL or+ file path, either relative or absolute. This change ensures that this+ is always the case.+ + Translate language identifiers. Pandoc and Org-mode use different+ programming language identifiers. An additional translation between+ those identifiers is added to avoid unexpected behavior. This fixes a+ problem where language specific source code would sometimes be output+ as example code.+ + Drop space before footnote markers (Albert Krewinkel, #3162).+ The writer no longer adds an extra space before footnote markers.++ * Markdown writer:++ + Don't emit HTML for tables unless `raw_html` extension is set (#3154).+ Emit `[TABLE]` if no suitable table formats are enabled and raw HTML+ is disabled.+ + Check for the `raw_html` extension before emiting a raw HTML block.+ + Abstract out note/ref function (Jesse Rosenthal).+ + Add ReaderT monad for environment variables (Jesse Rosenthal).++ * HTML, EPUB, slidy, revealjs templates: Use `<p>` instead of `<h1>` for+ subtitle, author, date (#3119). Note that, as a result of this change,+ authors may need to update CSS.++ * revealjs template: Added `notes-server` option+ (jgm/pandoc-templates#212, Yoan Blanc).++ * Beamer template:++ + Restore whitespace between paragraphs. This was+ a regression in the last release (jgm/pandoc-templates#207).+ + Added `themeoptions` variable (Carsten Gips).+ + Added `beamerarticle` variable. This causes the `beamerarticle`+ package to be loaded in beamer, to produce an article from beamer+ slides. (Carsten Gips)+ + Added support for `fontfamilies` structured variable+ (Artem Klevtsov).+ + Added hypersetup options (Jake Zimmerman).++ * LaTeX template:++ + Added dummy definition for `\institute`.+ This isn't a standard command, and we want to avoid a crash when+ `institute` is used with the default template.+ + Define default figure placement (Václav Haisman), since pandoc+ no longer includes `[htbp]` for figures. Users with custom templates+ will want to add this. See #3103.+ + Use footnote package to fix notes in tables (jgm/pandoc-templates#208,+ Václav Haisman).++ * Moved template compiling/rendering code to a separate library.+ `doctemplates`. This allows the pandoc templating system to be+ used independently.++ * Text.Pandoc.Error: Fix out of index error in `handleError`+ (Matthew Pickering). The fix is to not try to show the exact line when+ it would cause an out-of-bounds error as a result of included files.++ * Text.Pandoc.Shared: Add `linesToBlock` function (Albert Krewinkel).++ * Text.Pandoc.Parsing.emailAddress: tighten up parsing of email+ addresses. Technically `**@user` is a valid email address, but if we+ allow things like this, we get bad results in markdown flavors+ that autolink raw email addresses (see #2940). So we exclude a few+ valid email addresses in order to avoid these more common bad cases.++ * Text.Pandoc.PDF: Don't crash with nonexistent image (#3100). Instead,+ emit the alt text, emphasized. This accords with what the ODT writer+ currently does. The user will still get a warning about a nonexistent+ image.++ * Fix example in API documentation (#3176, Thomas Weißschuh).++ * Tell where to get tarball in INSTALL (#3062).++ * Rename README to MANUAL.txt and add GitHub-friendly README.md+ (Albert Krewinkel, Kolen Cheung).++ * Replace COPYING with Markdown version COPYING.md from GNU (Kolen Cheung).++ * MANUAL.txt:++ + Put note on structured vars in separate paragraph (#2148, Albert+ Krewinkel). Make it clearer that structured author variables require a+ custom template+ + Note that `--katex` works best with `html5` (#3077).+ + Fix the LaTeX and EPUB links in manual (Morton Fox).+ + Document `biblio-title` variable.++ * Improve spacing of footnotes in `--help` output (Waldir Pimenta).++ * Update KaTeX to v0.6.0 (Kolen Cheung).++ * Allow latest dependencies.++ * Use texmath 0.8.6.6 (#3040).++ * Allow http-client 0.4.30, which is the version in stackage lts.+ Previously we required 0.5.+ Remove CPP conditionals for earlier versions.++ * Remove support for GHC < 7.8 (Jesse Rosenthal).++ + Remove Compat.Monoid.+ + Remove an inline monad compatibility macro.+ + Remove Text.Pandoc.Compat.Except.+ + Remove directory compat.+ + Change constraint on mtl.+ + Remove unnecessary CPP condition in UTF8.+ + Bump base lower bound to 4.7.+ + Remove 7.6 build from .travis.yaml.+ + Bump supported ghc version in CONTRIBUTING.md.+ + Add note about GHC version support to INSTALL.+ + Remove GHC 7.6 from list of tested versions (Albert Krewinkel).+ + Remove TagSoup compat.+ + Add EOL note to time compat module. Because time 1.4 is a boot library+ for GHC 7.8, we will support the compatibility module as long as we+ support 7.8. But we should be clear about when we will no longer need+ it.+ + Remove blaze-html CPP conditional.+ + Remove unnecessary CPP in custom Prelude.+ pandoc (1.17.2) * Added Zim Wiki writer, template and tests. `zimwiki` is now@@ -26,14 +454,16 @@ wrapped in a `#+BEGIN`...`#+END` block. - The old behavior for Divs with more complex attributes is kept. - * HTML writer: Better support for raw LaTeX environments (#2758).- Previously we just passed all raw TeX through when MathJax- was used for HTML math. This passed through too much.- With this patch, only raw LaTeX environments that MathJax- can handle get passed through.- This patch also causes raw LaTeX environments to be treated- as math, when possible, with MathML and WebTeX output.+ * HTML writer: + + Better support for raw LaTeX environments (#2758).+ Previously we just passed all raw TeX through when MathJax was used for+ HTML math. This passed through too much. With this patch, only raw+ LaTeX environments that MathJax can handle get passed through.+ This patch also causes raw LaTeX environments to be treated+ as math, when possible, with MathML and WebTeX output.+ + In slide shows, don't change slide title to level 1 header (#2221).+ * Markdown writer: use raw HTML for simple, pipe tables with linebreaks (#2993). Markdown line breaks involve a newline, and simple and pipe tables can't contain one.@@ -243,6 +673,9 @@ * make_oxs_package.sh - use OSX env variable. + * Replaced INSTALL with INSTALL.md, incorporating INSTALL and the+ old installing page from website.+ * Added `winpkg` target to Makefile. This downloads the windows package from appveyor and signs it using the key. @@ -339,6 +772,7 @@ * Markdown reader: + + Added bracket syntax for native spans (#168). + Fix pandoc title blocks with lines ending in 2 spaces (#2799). + Added `-s` to markdown-reader-more test.
data/sample.lua view
@@ -206,6 +206,11 @@ return "<hr/>" end +function LineBlock(ls)+ return '<div style="white-space: pre-line;">' .. table.concat(ls, '\n') ..+ '</div>'+end+ function CodeBlock(s, attr) -- If code block has class 'dot', pipe the contents through dot -- and base64, and include the base64-encoded png as a data: URL.
data/templates/default.beamer view
@@ -24,6 +24,9 @@ \usepackage{fontspec} \fi \defaultfontfeatures{Ligatures=TeX,Scale=MatchLowercase}+$for(fontfamilies)$+ \newfontfamily{$fontfamilies.name$}[$fontfamilies.options$]{$fontfamilies.font$}+$endfor$ $if(euro)$ \newcommand{\euro}{€} $endif$@@ -45,7 +48,7 @@ $endif$ \fi $if(theme)$-\usetheme{$theme$}+\usetheme[$for(themeoptions)$$themeoptions$$sep$,$endfor$]{$theme$} $endif$ $if(colortheme)$ \usecolortheme{$colortheme$}@@ -94,6 +97,25 @@ \addbibresource{$bibliography$} $endfor$ $endif$+\hypersetup{+$if(title-meta)$+ pdftitle={$title-meta$},+$endif$+$if(author-meta)$+ pdfauthor={$author-meta$},+$endif$+$if(keywords)$+ pdfkeywords={$for(keywords)$$keywords$$sep$; $endfor$},+$endif$+$if(colorlinks)$+ colorlinks=true,+ linkcolor=$if(linkcolor)$$linkcolor$$else$Maroon$endif$,+ citecolor=$if(citecolor)$$citecolor$$else$Blue$endif$,+ urlcolor=$if(urlcolor)$$urlcolor$$else$Blue$endif$,+$else$+ pdfborder={0 0 0},+$endif$+ breaklinks=true} $if(listings)$ \usepackage{listings} $endif$@@ -161,6 +183,8 @@ % avoid problems with \sout in headers with hyperref: \pdfstringdefDisableCommands{\renewcommand{\sout}{}} $endif$+\setlength{\parindent}{0pt}+\setlength{\parskip}{6pt plus 2pt minus 1pt} \setlength{\emergencystretch}{3em} % prevent overfull lines \providecommand{\tightlist}{% \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
data/templates/default.epub view
@@ -28,13 +28,13 @@ $endif$ $endfor$ $if(subtitle)$- <h1 class="subtitle">$subtitle$</h1>+ <p class="subtitle">$subtitle$</p> $endif$ $for(author)$- <h2 class="author">$author$</h2>+ <p class="author">$author$</p> $endfor$ $for(creator)$- <h2 class="$creator.role$">$creator.text$</h2>+ <p class="$creator.role$">$creator.text$</p> $endfor$ $if(publisher)$ <p class="publisher">$publisher$</p>
data/templates/default.epub3 view
@@ -33,13 +33,13 @@ $endif$ $endfor$ $if(subtitle)$- <h1 class="subtitle">$subtitle$</h1>+ <p class="subtitle">$subtitle$</p> $endif$ $for(author)$- <h2 class="author">$author$</h2>+ <p class="author">$author$</p> $endfor$ $for(creator)$- <h2 class="$creator.role$">$creator.text$</h2>+ <p class="$creator.role$">$creator.text$</p> $endfor$ $if(publisher)$ <p class="publisher">$publisher$</p>
data/templates/default.html5 view
@@ -44,13 +44,13 @@ <header> <h1 class="title">$title$</h1> $if(subtitle)$-<h1 class="subtitle">$subtitle$</h1>+<p class="subtitle">$subtitle$</p> $endif$ $for(author)$-<h2 class="author">$author$</h2>+<p class="author">$author$</p> $endfor$ $if(date)$-<h3 class="date">$date$</h3>+<p class="date">$date$</p> $endif$ </header> $endif$
data/templates/default.latex view
@@ -1,4 +1,7 @@ \documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$babel-lang$,$endif$$if(papersize)$$papersize$paper,$endif$$for(classoption)$$classoption$$sep$,$endfor$]{$documentclass$}+$if(beamerarticle)$+\usepackage{beamerarticle} % needs to be loaded first+$endif$ $if(fontfamily)$ \usepackage[$for(fontfamilyoptions)$$fontfamilyoptions$$sep$,$endfor$]{$fontfamily$} $else$@@ -120,6 +123,8 @@ $endif$ $if(tables)$ \usepackage{longtable,booktabs}+% Fix footnotes in tables (requires footnote package)+\IfFileExists{footnote.sty}{\usepackage{footnote}\makesavenoteenv{long table}}{} $endif$ $if(graphics)$ \usepackage{graphicx,grffile}@@ -187,6 +192,12 @@ \newenvironment{LTR}{\beginL}{\endL} \fi $endif$++% set default figure placement to htbp+\makeatletter+\def\fps@figure{htbp}+\makeatother+ $for(header-includes)$ $header-includes$ $endfor$@@ -202,6 +213,7 @@ \author{$for(author)$$author$$sep$ \and $endfor$} $endif$ $if(institute)$+\providecommand{\institute}[1]{} \institute{$for(institute)$$institute$$sep$ \and $endfor$} $endif$ \date{$date$}
data/templates/default.revealjs view
@@ -63,13 +63,13 @@ <section> <h1 class="title">$title$</h1> $if(subtitle)$- <h1 class="subtitle">$subtitle$</h1>+ <p class="subtitle">$subtitle$</p> $endif$ $for(author)$- <h2 class="author">$author$</h2>+ <p class="author">$author$</p> $endfor$ $if(date)$- <h3 class="date">$date$</h3>+ <p class="date">$date$</p> $endif$ </section> $endif$@@ -228,6 +228,10 @@ dependencies: [ { src: '$revealjs-url$/lib/js/classList.js', condition: function() { return !document.body.classList; } }, { src: '$revealjs-url$/plugin/zoom-js/zoom.js', async: true },+ $if(notes-server)$+ { src: '$revealjs-url$/socket.io/socker.io.js', async: true },+ { src: '$revealjs-url$/plugin/notes-server/client.js', async: true },+ $endif$ { src: '$revealjs-url$/plugin/notes/notes.js', async: true } ] });
data/templates/default.slidy view
@@ -51,7 +51,7 @@ <div class="slide titlepage"> <h1 class="title">$title$</h1> $if(subtitle)$- <h1 class="subtitle">$subtitle$</h1>+ <p class="subtitle">$subtitle$</p> $endif$ $if(author)$ <p class="author">
man/pandoc.1 view
@@ -1,5 +1,5 @@ .\"t-.TH PANDOC 1 "June 4, 2016" "pandoc 1.17.2"+.TH PANDOC 1 "October 26, 2016" "pandoc 1.18" .SH NAME pandoc - general markup converter .SH SYNOPSIS@@ -28,8 +28,8 @@ superscripts and subscripts, strikeout, metadata blocks, automatic tables of contents, embedded LaTeX math, citations, and Markdown inside HTML block elements.-(These enhancements, described below under Pandoc\[aq]s Markdown, can be-disabled using the \f[C]markdown_strict\f[] input or output format.)+(These enhancements, described further under Pandoc\[aq]s Markdown, can+be disabled using the \f[C]markdown_strict\f[] input or output format.) .PP In contrast to most existing tools for converting Markdown to HTML, which use regex substitutions, pandoc has a modular design: it consists@@ -231,6 +231,8 @@ without pipe tables and with hard line breaks. See Pandoc\[aq]s Markdown, below, for a list of extensions and their names.+See \f[C]\-\-list\-input\-formats\f[] and \f[C]\-\-list\-extensions\f[],+below. .RS .RE .TP@@ -271,6 +273,8 @@ Markdown syntax extensions can be individually enabled or disabled by appending \f[C]+EXTENSION\f[] or \f[C]\-EXTENSION\f[] to the format name, as described above under \f[C]\-f\f[].+See \f[C]\-\-list\-output\-formats\f[] and+\f[C]\-\-list\-extensions\f[], below. .RS .RE .TP@@ -338,6 +342,34 @@ .RS .RE .TP+.B \f[C]\-\-list\-input\-formats\f[]+List supported input formats, one per line.+.RS+.RE+.TP+.B \f[C]\-\-list\-output\-formats\f[]+List supported output formats, one per line.+.RS+.RE+.TP+.B \f[C]\-\-list\-extensions\f[]+List supported Markdown extensions, one per line, followed by a+\f[C]+\f[] or \f[C]\-\f[] indicating whether it is enabled by default in+pandoc\[aq]s Markdown.+.RS+.RE+.TP+.B \f[C]\-\-list\-highlight\-languages\f[]+List supported languages for syntax highlighting, one per line.+.RS+.RE+.TP+.B \f[C]\-\-list\-highlight\-styles\f[]+List supported styles for syntax highlighting, one per line.+See \f[C]\-\-highlight\-style\f[].+.RS+.RE+.TP .B \f[C]\-v\f[], \f[C]\-\-version\f[] Print version. .RS@@ -448,11 +480,19 @@ There are also pandoc filter libraries in PHP, perl, and javascript/node.js. .PP-Note that the \f[I]EXECUTABLE\f[] will be sought in the user\[aq]s-\f[C]PATH\f[], and not in the working directory, if no directory is-provided.+If no directory is provided pandoc will look for executable or+non\-executable filters in the director \f[C]$DATADIR/filters\f[], and+then for executable filters in the user\[aq]s \f[C]PATH\f[]. If you want to run a script in the working directory, preface the filename with \f[C]\&./\f[].+.PP+In order of preference, pandoc will look for filters in+.IP "1." 3+a specified full or relative path (executable or non\-executable)+.IP "2." 3+\f[C]$DATADIR/filters\f[] (executable or non\-executable)+.IP "3." 3+\f[C]$PATH\f[] (executable only) .RE .TP .B \f[C]\-M\f[] \f[I]KEY\f[][\f[C]=\f[]\f[I]VAL\f[]], \f[C]\-\-metadata=\f[]\f[I]KEY\f[][\f[C]:\f[]\f[I]VAL\f[]]@@ -571,7 +611,7 @@ .RS .RE .TP-.B \f[C]\-\-wrap=[auto|none|preserve]\f[]+.B \f[C]\-\-wrap=auto\f[]|\f[C]none\f[]|\f[C]preserve\f[] Determine how text is wrapped in the output (the source code, not the rendered version). With \f[C]auto\f[] (the default), pandoc will attempt to wrap lines to@@ -629,6 +669,7 @@ \f[C]haddock\f[], and \f[C]tango\f[]. For more information on syntax highlighting in pandoc, see Syntax highlighting, below.+See also \f[C]\-\-list\-highlight\-styles\f[]. .RS .RE .TP@@ -706,9 +747,20 @@ Use reference\-style links, rather than inline links, in writing Markdown or reStructuredText. By default inline links are used.+The placement of link references is affected by the+\f[C]\-\-reference\-location\f[] option. .RS .RE .TP+.B \f[C]\-\-reference\-location\ =\ block\f[]|\f[C]section\f[]|\f[C]document\f[]+Specify whether footnotes (and references, if \f[C]reference\-links\f[]+is set) are placed at the end of the current (top\-level) block, the+current section, or the document.+The default is \f[C]document\f[].+Currently only affects the markdown writer.+.RS+.RE+.TP .B \f[C]\-\-atx\-headers\f[] Use ATX\-style headers in Markdown and asciidoc output. The default is to use setext\-style headers for levels 1\-2, and then@@ -717,13 +769,23 @@ .RE .TP .B \f[C]\-\-chapters\f[]-Treat top\-level headers as chapters in LaTeX, ConTeXt, and DocBook-output.+Deprecated synonym for \f[C]\-\-top\-level\-division=chapter\f[].+.RS+.RE+.TP+.B \f[C]\-\-top\-level\-division=[section|chapter|part]\f[]+Treat top\-level headers as the given division type in LaTeX, ConTeXt,+DocBook, and TEI output.+The hierarchy order is part, chapter, then section; all headers are+shifted such that the top\-level header becomes the specified type.+The default is \f[C]section\f[]. When the LaTeX document class is set to \f[C]report\f[], \f[C]book\f[], or \f[C]memoir\f[] (unless the \f[C]article\f[] option is specified),-this option is implied.-If \f[C]beamer\f[] is the output format, top\-level headers will become-\f[C]\\part{..}\f[].+\f[C]chapter\f[] is implied as the setting for this option.+If \f[C]beamer\f[] is the output format, specifying either+\f[C]chapter\f[] or \f[C]part\f[] will cause top\-level headers to+become \f[C]\\part{..}\f[], while second\-level headers remain as their+default type. .RS .RE .TP@@ -1092,9 +1154,10 @@ Render TeX formulas using an external script that converts TeX formulas to images. The formula will be concatenated with the URL provided.-If \f[I]URL\f[] is not specified, the Google Chart API will be used.+If \f[I]URL\f[] is not specified, the CodeCogs will be used. Note: the \f[C]\-\-webtex\f[] option will affect Markdown output as well-as HTML.+as HTML, which is useful if you\[aq]re targeting a version of Markdown+without native math support. .RS .RE .TP@@ -1103,6 +1166,7 @@ The \f[I]URL\f[] should point to the \f[C]katex.js\f[] load script. If a \f[I]URL\f[] is not provided, a link to the KaTeX CDN will be inserted.+Note: KaTeX seems to work best with \f[C]html5\f[] output. .RS .RE .TP@@ -1353,6 +1417,11 @@ .RS .RE .TP+.B \f[C]themeoptions\f[]+options for LaTeX beamer themes (a list).+.RS+.RE+.TP .B \f[C]navigation\f[] controls navigation symbols in \f[C]beamer\f[] documents (default is \f[C]empty\f[] for no navigation symbols; other valid values are@@ -1365,6 +1434,26 @@ (default = true). .RS .RE+.TP+.B \f[C]beamerarticle\f[]+when true, the \f[C]beamerarticle\f[] package is loaded (for producing+an article from beamer slides).+.RS+.RE+.TP+.B \f[C]colorlinks\f[]+add color to link text; automatically enabled if any of+\f[C]linkcolor\f[], \f[C]citecolor\f[], \f[C]urlcolor\f[], or+\f[C]toccolor\f[] are set (for beamer only).+.RS+.RE+.TP+.B \f[C]linkcolor\f[], \f[C]citecolor\f[], \f[C]urlcolor\f[], \f[C]toccolor\f[]+color for internal links, citation links, external links, and links in+table of contents: uses any of the predefined LaTeX colors (for beamer+only).+.RS+.RE .SS Variables for LaTeX .PP LaTeX variables are used when creating a PDF.@@ -1519,6 +1608,12 @@ .RS .RE .TP+.B \f[C]biblio\-title\f[]+bibliography title, when used with \f[C]\-\-natbib\f[] and+\f[C]\-\-biblatex\f[].+.RS+.RE+.TP .B \f[C]biblatexoptions\f[] list of options for biblatex. .RS@@ -3039,10 +3134,8 @@ \-\-\- title:\ \ \[aq]This\ is\ the\ title:\ it\ contains\ a\ colon\[aq] author:-\-\ name:\ Author\ One-\ \ affiliation:\ University\ of\ Somewhere-\-\ name:\ Author\ Two-\ \ affiliation:\ University\ of\ Nowhere+\-\ Author\ One+\-\ Author\ Two tags:\ [nothing,\ nothingness] abstract:\ | \ \ This\ is\ the\ abstract.@@ -3064,14 +3157,32 @@ \f[] .fi .PP-Note: The \f[C]author\f[] variable in the default templates expects a-simple list or string.-To use the structured authors in the example, you would need a custom-template.-For example:+Variables can contain arbitrary YAML structures, but the template must+match this structure.+The \f[C]author\f[] variable in the default templates expects a simple+list or string, but can be changed to support more complicated+structures.+The following combination, for example, would add an affiliation to the+author if one is given: .IP .nf \f[C]+\-\-\-+title:\ The\ document\ title+author:+\-\ name:\ Author\ One+\ \ affiliation:\ University\ of\ Somewhere+\-\ name:\ Author\ Two+\ \ affiliation:\ University\ of\ Nowhere+\&...+\f[]+.fi+.PP+To use the structured authors in the example above, you would need a+custom template:+.IP+.nf+\f[C] $for(author)$ $if(author.name)$ $author.name$$if(author.affiliation)$\ ($author.affiliation$)$endif$@@ -3348,8 +3459,8 @@ .TP .B FictionBook2 If the \f[C]\-\-webtex\f[] option is used, formulas are rendered as-images using Google Charts or other compatible web service, downloaded-and embedded in the e\-book.+images using CodeCogs or other compatible web service, downloaded and+embedded in the e\-book. Otherwise, they will appear verbatim. .RS .RE@@ -3405,8 +3516,8 @@ converted to \f[C]<img>\f[] tags that link to an external script that converts formulas to images. The formula will be URL\-encoded and concatenated with the URL provided.-If no URL is specified, the Google Chart API will be used-(\f[C]http://chart.apis.google.com/chart?cht=tx&chl=\f[]).+If no URL is specified, the CodeCogs will be used+(\f[C]https://latex.codecogs.com/png.latex?\f[]). .IP "7." 3 If the \f[C]\-\-mathjax\f[] option is used, TeX math will be displayed between \f[C]\\(...\\)\f[] (for inline math) or \f[C]\\[...\\]\f[] (for@@ -3787,6 +3898,18 @@ When no \f[C]width\f[] or \f[C]height\f[] attributes are specified, the fallback is to look at the image resolution and the dpi metadata embedded in the image file.+.SS Spans+.SS Extension: \f[C]bracketed_spans\f[]+.PP+A bracketed sequence of inlines, as one would use to begin a link, will+be treated as a span with attributes if it is followed immediately by+attributes:+.IP+.nf+\f[C]+[This\ is\ *some\ text*]{.class\ key="val"}+\f[]+.fi .SS Footnotes .SS Extension: \f[C]footnotes\f[] .PP@@ -4130,6 +4253,11 @@ name, where \f[C]EXTENSION\f[] is the name of the extension. Thus, for example, \f[C]markdown+hard_line_breaks\f[] is Markdown with hard line breaks.+.SS Extension: \f[C]angle_brackets_escapable\f[]+.PP+Allow \f[C]<\f[] and \f[C]>\f[] to be backslash\-escaped, as they can be+in GitHub flavored Markdown but not original Markdown.+This is implied by pandoc\[aq]s default \f[C]all_symbols_escapable\f[]. .SS Extension: \f[C]lists_without_preceding_blankline\f[] .PP Allow a list to occur right after a paragraph, with no intervening blank@@ -4269,15 +4397,15 @@ \f[C]backtick_code_blocks\f[], \f[C]autolink_bare_uris\f[], \f[C]intraword_underscores\f[], \f[C]strikeout\f[], \f[C]hard_line_breaks\f[], \f[C]emoji\f[],-\f[C]shortcut_reference_links\f[].+\f[C]shortcut_reference_links\f[], \f[C]angle_brackets_escapable\f[]. .RS .RE .TP .B \f[C]markdown_mmd\f[] (MultiMarkdown) \f[C]pipe_tables\f[], \f[C]raw_html\f[], \f[C]markdown_attribute\f[],-\f[C]mmd_link_attributes\f[], \f[C]raw_tex\f[],-\f[C]tex_math_double_backslash\f[], \f[C]intraword_underscores\f[],-\f[C]mmd_title_block\f[], \f[C]footnotes\f[], \f[C]definition_lists\f[],+\f[C]mmd_link_attributes\f[], \f[C]tex_math_double_backslash\f[],+\f[C]intraword_underscores\f[], \f[C]mmd_title_block\f[],+\f[C]footnotes\f[], \f[C]definition_lists\f[], \f[C]all_symbols_escapable\f[], \f[C]implicit_header_references\f[], \f[C]auto_identifiers\f[], \f[C]mmd_header_identifiers\f[], \f[C]shortcut_reference_links\f[].@@ -4772,6 +4900,58 @@ \f[C]pandoc\ \-\-version\f[]. .PP To disable highlighting, use the \f[C]\-\-no\-highlight\f[] option.+.SH CUSTOM STYLES IN DOCX OUTPUT+.PP+By default, pandoc\[aq]s docx output applies a predefined set of styles+for blocks such as paragraphs and block quotes, and uses largely default+formatting (italics, bold) for inlines.+This will work for most purposes, especially alongside a+\f[C]reference.docx\f[] file.+However, if you need to apply your own styles to blocks, or match a+preexisting set of styles, pandoc allows you to define custom styles for+blocks and text using \f[C]div\f[]s and \f[C]span\f[]s, respecitively.+.PP+If you define a \f[C]div\f[] or \f[C]span\f[] with the attribute+\f[C]custom\-style\f[], pandoc will apply your specified style to the+contained elements.+So, for example,+.IP+.nf+\f[C]+<span\ custom\-style="Emphatically">Get\ out,</span>\ he\ said.+\f[]+.fi+.PP+would produce a docx file with "Get out," styled with character style+\f[C]Emphatically\f[].+Similarly,+.IP+.nf+\f[C]+Dickinson\ starts\ the\ poem\ simply:++<div\ custom\-style="Poetry">+|\ A\ Bird\ came\ down\ the\ Walk\-\-\-+|\ He\ did\ not\ know\ I\ saw\-\-\-+</div>+\f[]+.fi+.PP+would style the two contained lines with the \f[C]Poetry\f[] paragraph+style.+.PP+If the styles are not yet in your reference.docx, they will be defined+in the output file as inheriting from normal text.+If they are already defined, pandoc will not alter the definition.+.PP+This feature allows for greatest customization in conjunction with+pandoc filters.+If you want all paragraphs after block quotes to be indented, you can+write a filter to apply the styles necessary.+If you want all italics to be transformed to the \f[C]Emphasis\f[]+character style (perhaps to change their color), you can write a filter+which will transform all italicized inlines to inlines within an+\f[C]Emphasis\f[] custom\-style \f[C]span\f[]. .SH CUSTOM WRITERS .PP Pandoc can be extended with custom writers written in lua.@@ -4800,35 +4980,35 @@ .fi .SH AUTHORS .PP-© 2006\-2015 John MacFarlane (jgm\@berkeley.edu).+© 2006\-2016 John MacFarlane (jgm\@berkeley.edu). Released under the GPL, version 2 or greater. This software carries no warranty of any kind. (See COPYRIGHT for full copyright and warranty notices.) .PP-Contributors include Aaron Wolen, Albert Krewinkel, Alex Vong, Alexander-Kondratskiy, Alexander Sulfrian, Alexander V Vershilov, Alfred-Wechselberger, Andreas Lööw, Andrew Dunning, Antoine Latter, Arata-Mizuki, Arlo O\[aq]Keeffe, Artyom Kazak, Ben Gamari, Beni-Cherniavsky\-Paskin, Benoit Schweblin, Bjorn Buckwalter, Bradley Kuhn,-Brent Yorgey, Bryan O\[aq]Sullivan, B.-Scott Michel, Caleb McDaniel, Calvin Beck, Carlos Sosa, Chris Black,-Christian Conkle, Christoffer Ackelman, Christoffer Sawicki, Clare-Macrae, Clint Adams, Conal Elliott, Craig S.-Bosma, csforste, Daniel Bergey, Daniel T.-Staal, David Lazar, David Röthlisberger, Denis Laxalde, Douglas Calvert,-Douglas F.-Calvert, Emanuel Evans, Emily Eisenberg, Eric Kow, Eric Seidel, Florian-Eitel, François Gannaz, Freiric Barral, Freirich Raabe, Fyodor-Sheremetyev, Gabor Pali, Gavin Beatty, Gottfried Haider, Greg Maslov,-Grégory Bataille, Greg Rundlett, gwern, Gwern Branwen, Hans\-Peter-Deifel, Henrik Tramberend, Henry de Valence, ickc, Ilya V.-Portnov, infinity0x, Ivo Clarysse, Jaime Marquínez Ferrándiz, James-Aspnes, Jamie F.+Contributors include Arata Mizuki, Aaron Wolen, Albert Krewinkel, Alex+Ivkin, Alex Vong, Alexander Kondratskiy, Alexander Sulfrian, Alexander V+Vershilov, Alfred Wechselberger, Andreas Lööw, Andrew Dunning, Antoine+Latter, Arata Mizuki, Arlo O\[aq]Keeffe, Artyom Kazak, B.+Scott Michel, Ben Gamari, Beni Cherniavsky\-Paskin, Benoit Schweblin,+Bjorn Buckwalter, Bradley Kuhn, Brent Yorgey, Bryan O\[aq]Sullivan,+Caleb McDaniel, Calvin Beck, Carlos Sosa, Chris Black, Christian Conkle,+Christoffer Ackelman, Christoffer Sawicki, Clare Macrae, Clint Adams,+Conal Elliott, Craig S.+Bosma, Daniel Bergey, Daniel T.+Staal, Daniele D\[aq]Orazio, David Lazar, David Röthlisberger, Denis+Laxalde, Douglas Calvert, Emanuel Evans, Emily Eisenberg, Eric Kow, Eric+Seidel, Felix Yan, Florian Eitel, François Gannaz, Freiric Barral,+Freirich Raabe, Frerich Raabe, Fyodor Sheremetyev, Gabor Pali, Gavin+Beatty, Gottfried Haider, Greg Maslov, Greg Rundlett, Grégory Bataille,+Gwern Branwen, Hans\-Peter Deifel, Henrik Tramberend, Henry de Valence,+Hubert Plociniczak, Ilya V.+Portnov, Ivo Clarysse, J.+Lewis Muir, Jaime Marquínez Ferrándiz, Jakob Voß, James Aspnes, Jamie F. Olson, Jan Larres, Jan Schulz, Jason Ronallo, Jeff Arnold, Jeff-Runningen, Jens Petersen, Jérémy Bobbio, Jesse Rosenthal, J.-Lewis Muir, Joe Hillenbrand, John MacFarlane, Jonas Smedegaard, Jonathan-Daugherty, Josef Svenningsson, Jose Luis Duran, Julien Cretel, Juliusz-Gonera, Justin Bogner, Kelsey Hightower, Kolen Cheung, Konstantin Zudov,+Runningen, Jens Petersen, Jesse Rosenthal, Joe Hillenbrand, John+MacFarlane, Jonas Smedegaard, Jonathan Daugherty, Jose Luis Duran, Josef+Svenningsson, Julien Cretel, Juliusz Gonera, Justin Bogner, Jérémy+Bobbio, Kelsey Hightower, Kolen Cheung, KolenCheung, Konstantin Zudov, Kristof Bastiaensen, Lars\-Dominik Braun, Luke Plant, Mark Szepieniec, Mark Wright, Martin Linn, Masayoshi Takahashi, Matej Kollar, Mathias Schenner, Mathieu Duponchelle, Matthew Eddey, Matthew Pickering,@@ -4836,16 +5016,18 @@ M. Troffaes, Mauro Bieg, Max Bolingbroke, Max Rydahl Andersen, Merijn Verstraaten, Michael Beaumont, Michael Chladek, Michael Snoyman, Michael-Thompson, MinRK, Nathan Gass, Neil Mayhew, Nick Bart, Nicolas Kaiser,-Nikolay Yakimov, nkalvi, Ophir Lifshitz, Pablo Rodríguez, Paulo-Tanimoto, Paul Rivier, Peter Wang, Philippe Ombredanne, Phillip Alday,-Prayag Verma, Puneeth Chaganti, qerub, Ralf Stephan, Raniere Silva,-Recai Oktaş, robabla, rodja.trappe, rski, RyanGlScott, Scott Morrison,-Sergei Trofimovich, Sergey Astanin, Shahbaz Youssefi, Shaun Attfield,-Sidarth Kapur, shreevatsa.public, Simon Hengel, Sumit Sahrawat,-takahashim, thsutton, Tim Lin, Timothy Humphries, Tiziano Müller, Thomas-Hodgson, Todd Sifleet, Tom Leese, Uli Köhler, Václav Zeman, Viktor-Kronvall, Vincent, Wikiwide, and Xavier Olive.+Thompson, MinRK, Morton Fox, Nathan Gass, Neil Mayhew, Nick Bart,+Nicolas Kaiser, Nikolay Yakimov, Oliver Matthews, Ophir Lifshitz, Pablo+Rodríguez, Paul Rivier, Paulo Tanimoto, Peter Wang, Philippe Ombredanne,+Phillip Alday, Prayag Verma, Puneeth Chaganti, Ralf Stephan, Raniere+Silva, Recai Oktaş, RyanGlScott, Scott Morrison, Sergei Trofimovich,+Sergey Astanin, Shahbaz Youssefi, Shaun Attfield, Sidarth Kapur,+Sidharth Kapur, Simon Hengel, Sumit Sahrawat, Thomas Hodgson, Thomas+Weißschuh, Tim Lin, Timothy Humphries, Tiziano Müller, Todd Sifleet, Tom+Leese, Uli Köhler, Václav Zeman, Viktor Kronvall, Vincent, Václav Zeman,+Waldir Pimenta, Wikiwide, Xavier Olive, csforste, infinity0x, nkalvi,+qerub, robabla, roblabla, rodja.trappe, rski, shreevatsa.public,+takahashim, thsutton. .PP The Pandoc source code and all documentation may be downloaded from <http://pandoc.org>.
pandoc.cabal view
@@ -1,9 +1,9 @@ Name: pandoc-Version: 1.17.2+Version: 1.18 Cabal-Version: >= 1.10 Build-Type: Custom License: GPL-License-File: COPYING+License-File: COPYING.md Copyright: (c) 2006-2016 John MacFarlane Author: John MacFarlane <jgm@berkeley.edu> Maintainer: John MacFarlane <jgm@berkeley.edu>@@ -11,7 +11,7 @@ Stability: alpha Homepage: http://pandoc.org Category: Text-Tested-With: GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.2, GHC == 8.0.1+Tested-With: GHC == 7.8.4, GHC == 7.10.2, GHC == 8.0.1 Synopsis: Conversion between markup formats Description: Pandoc is a Haskell library for converting from one markup format to another, and a command-line tool that uses@@ -105,10 +105,10 @@ -- bash completion template data/bash_completion.tpl -- documentation- README, COPYRIGHT+ MANUAL.txt, COPYRIGHT Extra-Source-Files: -- documentation- INSTALL, BUGS, CONTRIBUTING.md, changelog+ INSTALL.md, BUGS, README.md, CONTRIBUTING.md, changelog man/pandoc.1 -- stack build plan stack.yaml@@ -205,8 +205,8 @@ tests/lhs-test.html+lhs tests/lhs-test.fragment.html+lhs tests/pipe-tables.txt- tests/dokuwiki_external_images.dokuwiki- tests/dokuwiki_external_images.native+ tests/dokuwiki_external_images.dokuwiki+ tests/dokuwiki_external_images.native tests/dokuwiki_multiblock_table.dokuwiki tests/dokuwiki_multiblock_table.native tests/fb2/*.markdown@@ -249,13 +249,13 @@ Default: False Library- Build-Depends: base >= 4.2 && <5,+ Build-Depends: base >= 4.7 && <5, syb >= 0.1 && < 0.7, containers >= 0.1 && < 0.6, unordered-containers >= 0.2 && < 0.3, array >= 0.3 && < 0.6, parsec >= 3.1 && < 3.2,- mtl >= 1.1 && < 2.3,+ mtl >= 2.2 && < 2.3, filepath >= 1.1 && < 1.5, process >= 1 && < 1.5, directory >= 1 && < 1.3,@@ -263,12 +263,12 @@ text >= 0.11 && < 1.3, zip-archive >= 0.2.3.4 && < 0.4, HTTP >= 4000.0.5 && < 4000.4,- texmath >= 0.8.6.4 && < 0.9,+ texmath >= 0.8.6.5 && < 0.9, xml >= 1.3.12 && < 1.4, random >= 1 && < 1.2, extensible-exceptions >= 0.1 && < 0.2,- pandoc-types >= 1.16 && < 1.17,- aeson >= 0.7 && < 0.12,+ pandoc-types >= 1.17 && < 1.18,+ aeson >= 0.7 && < 1.1, tagsoup >= 0.13.7 && < 0.15, base64-bytestring >= 0.1 && < 1.1, zlib >= 0.5 && < 0.7,@@ -289,6 +289,7 @@ JuicyPixels >= 3.1.6.1 && < 3.3, filemanip >= 0.3 && < 0.4, cmark >= 0.5 && < 0.6,+ doctemplates >= 0.1 && < 0.2, ghc-prim >= 0.2 if flag(old-locale) Build-Depends: old-locale >= 1 && < 1.1,@@ -300,8 +301,8 @@ else Build-Depends: network >= 2 && < 2.6 if flag(https)- Build-Depends: http-client >= 0.5 && < 0.6,- http-client-tls >= 0.3 && < 0.4,+ Build-Depends: http-client >= 0.4.30 && < 0.6,+ http-client-tls >= 0.2.4 && < 0.4, http-types >= 0.8 && < 0.10 cpp-options: -DHTTP_CLIENT if flag(embed_data_files)@@ -401,6 +402,7 @@ Text.Pandoc.Readers.Org.Blocks, Text.Pandoc.Readers.Org.ExportSettings, Text.Pandoc.Readers.Org.Inlines,+ Text.Pandoc.Readers.Org.Meta, Text.Pandoc.Readers.Org.ParserState, Text.Pandoc.Readers.Org.Parsing, Text.Pandoc.Readers.Org.Shared,@@ -414,25 +416,21 @@ Text.Pandoc.Slides, Text.Pandoc.Highlighting, Text.Pandoc.Compat.Time,- Text.Pandoc.Compat.Except,- Text.Pandoc.Compat.TagSoupEntity,- Text.Pandoc.Compat.Directory,- Text.Pandoc.Compat.Monoid, Paths_pandoc Buildable: True Executable pandoc Build-Depends: pandoc,- pandoc-types >= 1.16 && < 1.17,+ pandoc-types >= 1.17 && < 1.18, base >= 4.2 && <5,- directory >= 1 && < 1.3,+ directory >= 1.2 && < 1.3, filepath >= 1.1 && < 1.5, text >= 0.11 && < 1.3, bytestring >= 0.9 && < 0.11, extensible-exceptions >= 0.1 && < 0.2, highlighting-kate >= 0.6.2 && < 0.7,- aeson >= 0.7.0.5 && < 0.12,+ aeson >= 0.7.0.5 && < 1.1, yaml >= 0.8.8.2 && < 0.9, containers >= 0.1 && < 0.6, HTTP >= 4000.0.5 && < 4000.4@@ -444,6 +442,9 @@ Ghc-Prof-Options: -fprof-auto-exported -rtsopts -with-rtsopts=-K16m if os(windows) Cpp-options: -D_WINDOWS+ else+ Build-Depends: unix >= 2.4 && < 2.8+ Default-Language: Haskell98 Other-Extensions: PatternGuards, OverloadedStrings, ScopedTypeVariables, GeneralizedNewtypeDeriving,@@ -481,7 +482,7 @@ Build-Depends: base >= 4.2 && < 5, syb >= 0.1 && < 0.7, pandoc,- pandoc-types >= 1.16 && < 1.17,+ pandoc-types >= 1.17 && < 1.18, bytestring >= 0.9 && < 0.11, text >= 0.11 && < 1.3, directory >= 1 && < 1.3,@@ -493,14 +494,13 @@ test-framework-hunit >= 0.2 && < 0.4, test-framework-quickcheck2 >= 0.2.9 && < 0.4, QuickCheck >= 2.4 && < 2.10,- HUnit >= 1.2 && < 1.4,+ HUnit >= 1.2 && < 1.6, containers >= 0.1 && < 0.6, ansi-terminal >= 0.5 && < 0.7, executable-path >= 0.0 && < 0.1, zip-archive >= 0.2.3.4 && < 0.4 Other-Modules: Tests.Old Tests.Helpers- Tests.Arbitrary Tests.Shared Tests.Walk Tests.Readers.LaTeX
pandoc.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE CPP, TupleSections, ScopedTypeVariables #-}+{-# LANGUAGE CPP, TupleSections, ScopedTypeVariables, PatternGuards #-} {- Copyright (C) 2006-2016 John MacFarlane <jgm@berkeley.edu> @@ -48,8 +48,9 @@ import System.Exit ( ExitCode (..), exitSuccess ) import System.FilePath import System.Console.GetOpt+import qualified Data.Set as Set import Data.Char ( toLower, toUpper )-import Data.List ( delete, intercalate, isPrefixOf, isSuffixOf, sort )+import Data.List ( intercalate, isPrefixOf, isSuffixOf, sort ) import System.Directory ( getAppUserDataDirectory, findExecutable, doesFileExist, Permissions(..), getPermissions ) import System.IO ( stdout, stderr )@@ -72,7 +73,10 @@ import Text.Pandoc.Readers.Txt2Tags (getT2TMeta) import Paths_pandoc (getDataDir) import Text.Printf (printf)-import Text.Pandoc.Error+#ifndef _WINDOWS+import System.Posix.Terminal (queryTerminal)+import System.Posix.IO (stdOutput)+#endif type Transform = Pandoc -> Pandoc @@ -87,11 +91,8 @@ compileInfo :: String compileInfo =- "\nCompiled with texmath " ++- VERSION_texmath ++ ", highlighting-kate " ++ VERSION_highlighting_kate ++- ".\nSyntax highlighting is supported for the following languages:\n " ++- wrapWords 4 78- [map toLower l | l <- languages, l /= "Alert" && l /= "Alert_indent"]+ "\nCompiled with pandoc-types " ++ VERSION_pandoc_types ++ ", texmath " +++ VERSION_texmath ++ ", highlighting-kate " ++ VERSION_highlighting_kate -- | Converts a list of strings into a single string with the items printed as -- comma separated words in lines with a maximum line length.@@ -139,6 +140,7 @@ ".pl" -> ("perl", f:args') ".rb" -> ("ruby", f:args') ".php" -> ("php", f:args')+ ".js" -> ("node", f:args') _ -> (f, args') else err 85 $ "Filter " ++ f ++ " not found" when (f' /= f) $ do@@ -157,6 +159,16 @@ filterException e = err 83 $ "Error running filter " ++ f ++ "\n" ++ show e +highlightingStyles :: [(String, Style)]+highlightingStyles =+ [("pygments", pygments),+ ("tango", tango),+ ("espresso", espresso),+ ("zenburn", zenburn),+ ("kate", kate),+ ("monochrome", monochrome),+ ("haddock", haddock)]+ -- | Data structure for command line options. data Opt = Opt { optTabStop :: Int -- ^ Number of spaces per tab@@ -182,7 +194,7 @@ , optHtmlQTags :: Bool -- ^ Use <q> tags in HTML , optHighlight :: Bool -- ^ Highlight source code , optHighlightStyle :: Style -- ^ Style to use for highlighted code- , optChapters :: Bool -- ^ Use chapter for top-level sects+ , optTopLevelDivision :: Division -- ^ Type of the top-level divisions , optHTMLMathMethod :: HTMLMathMethod -- ^ Method to print HTML math , optReferenceODT :: Maybe FilePath -- ^ Path of reference.odt , optReferenceDocx :: Maybe FilePath -- ^ Path of reference.docx@@ -195,6 +207,7 @@ , optIgnoreArgs :: Bool -- ^ Ignore command-line arguments , optVerbose :: Bool -- ^ Verbose diagnostic output , optReferenceLinks :: Bool -- ^ Use reference links in writing markdown, rst+ , optReferenceLocation :: ReferenceLocation -- ^ location for footnotes and link references in markdown output , optDpi :: Int -- ^ Dpi , optWrapText :: WrapOption -- ^ Options for wrapping text , optColumns :: Int -- ^ Line length in characters@@ -246,7 +259,7 @@ , optHtmlQTags = False , optHighlight = True , optHighlightStyle = pygments- , optChapters = False+ , optTopLevelDivision = Section , optHTMLMathMethod = PlainMath , optReferenceODT = Nothing , optReferenceDocx = Nothing@@ -259,6 +272,7 @@ , optIgnoreArgs = False , optVerbose = False , optReferenceLinks = False+ , optReferenceLocation = EndOfDocument , optDpi = 96 , optWrapText = WrapAuto , optColumns = 72@@ -514,17 +528,9 @@ , Option "" ["highlight-style"] (ReqArg (\arg opt -> do- newStyle <- case map toLower arg of- "pygments" -> return pygments- "tango" -> return tango- "espresso" -> return espresso- "zenburn" -> return zenburn- "kate" -> return kate- "monochrome" -> return monochrome- "haddock" -> return haddock- _ -> err 39 $- "Unknown style :" ++ arg- return opt{ optHighlightStyle = newStyle })+ case lookup (map toLower arg) highlightingStyles of+ Just s -> return opt{ optHighlightStyle = s }+ Nothing -> err 39 $ "Unknown style: " ++ arg) "STYLE") "" -- "Style for highlighted code" @@ -583,6 +589,19 @@ (\opt -> return opt { optReferenceLinks = True } )) "" -- "Use reference links in parsing HTML" + , Option "" ["reference-location"]+ (ReqArg+ (\arg opt -> do+ action <- case arg of+ "block" -> return EndOfBlock+ "section" -> return EndOfSection+ "document" -> return EndOfDocument+ _ -> err 6+ ("Unknown option for reference-location: " ++ arg)+ return opt { optReferenceLocation = action })+ "block|section|document")+ "" -- "Accepting or reject MS Word track-changes.""+ , Option "" ["atx-headers"] (NoArg (\opt -> return opt { optSetextHeaders = False } ))@@ -590,9 +609,19 @@ , Option "" ["chapters"] (NoArg- (\opt -> return opt { optChapters = True }))+ (\opt -> do warn $ "--chapters is deprecated. " +++ "Use --top-level-division=chapter instead."+ return opt { optTopLevelDivision = Chapter })) "" -- "Use chapter for top-level sections in LaTeX, DocBook" + , Option "" ["top-level-division"]+ (ReqArg+ (\arg opt -> case safeRead (uppercaseFirstLetter arg) of+ Just dvsn -> return opt { optTopLevelDivision = dvsn }+ _ -> err 76 "could not parse top-level division")+ "[section|chapter|part]")+ "" -- "Use top-level division type in LaTeX, ConTeXt, DocBook"+ , Option "N" ["number-sections"] (NoArg (\opt -> return opt { optNumberSections = True }))@@ -822,7 +851,7 @@ , Option "" ["webtex"] (OptArg (\arg opt -> do- let url' = fromMaybe "http://chart.apis.google.com/chart?cht=tx&chl=" arg+ let url' = fromMaybe "https://latex.codecogs.com/png.latex?" arg return opt { optHTMLMathMethod = WebTeX url' }) "URL") "" -- "Use web service for HTML math"@@ -845,7 +874,7 @@ (\arg opt -> return opt { optKaTeXJS =- arg <|> Just "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.js"})+ arg <|> Just "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.js"}) "URL") "" -- Use KaTeX for HTML Math @@ -892,11 +921,56 @@ let allopts = unwords (concatMap optnames options) UTF8.hPutStrLn stdout $ printf tpl allopts (unwords (map fst readers))- (unwords ("pdf": map fst writers))+ (unwords (map fst writers)) ddir exitSuccess )) "" -- "Print bash completion script" + , Option "" ["list-input-formats"]+ (NoArg+ (\_ -> do+ let readers'names = sort (map fst readers)+ mapM_ (UTF8.hPutStrLn stdout) readers'names+ exitSuccess ))+ ""++ , Option "" ["list-output-formats"]+ (NoArg+ (\_ -> do+ let writers'names = sort (map fst writers)+ mapM_ (UTF8.hPutStrLn stdout) writers'names+ exitSuccess ))+ ""++ , Option "" ["list-extensions"]+ (NoArg+ (\_ -> do+ let showExt x = drop 4 (show x) +++ if x `Set.member` pandocExtensions+ then " +"+ else " -"+ mapM_ (UTF8.hPutStrLn stdout . showExt)+ ([minBound..maxBound] :: [Extension])+ exitSuccess ))+ ""++ , Option "" ["list-highlight-languages"]+ (NoArg+ (\_ -> do+ let langs = [map toLower l | l <- languages,+ l /= "Alert" && l /= "Alert_indent"]+ mapM_ (UTF8.hPutStrLn stdout) langs+ exitSuccess ))+ ""++ , Option "" ["list-highlight-styles"]+ (NoArg+ (\_ -> do+ mapM_ (UTF8.hPutStrLn stdout) $+ map fst highlightingStyles+ exitSuccess ))+ ""+ , Option "v" ["version"] (NoArg (\_ -> do@@ -935,17 +1009,7 @@ -- Returns usage message usageMessage :: String -> [OptDescr (Opt -> IO Opt)] -> String-usageMessage programName = usageInfo- (programName ++ " [OPTIONS] [FILES]" ++ "\nInput formats: " ++- wrapWords 16 78 readers'names ++- '\n' : replicate 16 ' ' ++- "[ *only Pandoc's JSON version of native AST]" ++ "\nOutput formats: " ++- wrapWords 16 78 writers'names ++- '\n' : replicate 16 ' ' ++- "[**for pdf output, use latex or beamer and -o FILENAME.pdf]\nOptions:")- where- writers'names = sort $ "json*" : "pdf**" : delete "json" (map fst writers)- readers'names = sort $ "json*" : delete "json" (map fst readers)+usageMessage programName = usageInfo (programName ++ " [OPTIONS] [FILES]") -- Determine default reader based on source file extensions defaultReaderName :: String -> [FilePath] -> String@@ -1042,10 +1106,25 @@ applyTransforms :: [Transform] -> Pandoc -> IO Pandoc applyTransforms transforms d = return $ foldr ($) d transforms -applyFilters :: [FilePath] -> [String] -> Pandoc -> IO Pandoc-applyFilters filters args d =- foldrM ($) d $ map (flip externalFilter args) filters+ -- First we check to see if a filter is a path. If it isn't, we+ -- check to see whether it's in `userdir/filters`. If not, we leave+ -- it unchanged.+expandFilterPath :: Maybe FilePath -> FilePath -> IO FilePath+expandFilterPath mbDatadir fp+ | '/' `elem` fp = return fp+ | Just datadir <- mbDatadir = do+ let filterPath = (datadir </> "filters" </> fp)+ filterPathExists <- doesFileExist filterPath+ if filterPathExists+ then return filterPath+ else return fp+ | otherwise = return fp +applyFilters :: Maybe FilePath -> [FilePath] -> [String] -> Pandoc -> IO Pandoc+applyFilters mbDatadir filters args d = do+ expandedFilters <- mapM (expandFilterPath mbDatadir) filters+ foldrM ($) d $ map (flip externalFilter args) expandedFilters+ uppercaseFirstLetter :: String -> String uppercaseFirstLetter (c:cs) = toUpper c : cs uppercaseFirstLetter [] = []@@ -1091,7 +1170,7 @@ , optHtmlQTags = htmlQTags , optHighlight = highlight , optHighlightStyle = highlightStyle- , optChapters = chapters+ , optTopLevelDivision = topLevelDivision , optHTMLMathMethod = mathMethod' , optReferenceODT = referenceODT , optReferenceDocx = referenceDocx@@ -1104,6 +1183,7 @@ , optIgnoreArgs = ignoreArgs , optVerbose = verbose , optReferenceLinks = referenceLinks+ , optReferenceLocation = referenceLocation , optDpi = dpi , optWrapText = wrap , optColumns = columns@@ -1134,7 +1214,7 @@ mapM_ (UTF8.hPutStrLn stdout) args exitSuccess - let csscdn = "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.css"+ let csscdn = "https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.css" let mathMethod = case (katexJS, katexStylesheet) of (Nothing, _) -> mathMethod'@@ -1280,7 +1360,12 @@ , readerFileScope = fileScope } - when (not (isTextFormat format) && outputFile == "-") $+#ifdef _WINDOWS+ let istty = True+#else+ istty <- queryTerminal stdOutput+#endif+ when (istty && not (isTextFormat format) && outputFile == "-") $ err 5 $ "Cannot write " ++ format ++ " output to stdout.\n" ++ "Specify an output file using the -o option." @@ -1344,6 +1429,7 @@ writerNumberOffset = numberFrom, writerSectionDivs = sectionDivs, writerReferenceLinks = referenceLinks,+ writerReferenceLocation = referenceLocation, writerDpi = dpi, writerWrapText = wrap, writerColumns = columns,@@ -1353,7 +1439,7 @@ writerUserDataDir = datadir, writerHtml5 = html5, writerHtmlQTags = htmlQTags,- writerChapters = chapters,+ writerTopLevelDivision = topLevelDivision, writerListings = listings, writerBeamer = False, writerSlideLevel = slideLevel,@@ -1377,10 +1463,11 @@ doc' <- (maybe return (extractMedia media) mbExtractMedia >=> adjustMetadata metadata >=> applyTransforms transforms >=>- applyFilters filters' [format]) doc+ applyFilters datadir filters' [format]) doc - let writeBinary :: B.ByteString -> IO ()- writeBinary = B.writeFile (UTF8.encodePath outputFile)+ let writeFnBinary :: FilePath -> B.ByteString -> IO ()+ writeFnBinary "-" = B.putStr+ writeFnBinary f = B.writeFile (UTF8.encodePath f) let writerFn :: FilePath -> String -> IO () writerFn "-" = UTF8.putStr@@ -1388,7 +1475,7 @@ case writer of IOStringWriter f -> f writerOptions doc' >>= writerFn outputFile- IOByteStringWriter f -> f writerOptions doc' >>= writeBinary+ IOByteStringWriter f -> f writerOptions doc' >>= writeFnBinary outputFile PureStringWriter f | pdfOutput -> do -- make sure writer is latex or beamer or context or html5@@ -1408,7 +1495,7 @@ res <- makePDF pdfprog f writerOptions doc' case res of- Right pdf -> writeBinary pdf+ Right pdf -> writeFnBinary outputFile pdf Left err' -> do B.hPutStr stderr err' B.hPut stderr $ B.pack [10]
prelude/Prelude.hs view
@@ -19,12 +19,8 @@ #if MIN_VERSION_base(4,8,0) import "base" Prelude as P-#elif MIN_VERSION_base(4,6,0)-import "base" Prelude as P-import Control.Applicative-import Data.Monoid #else-import "base" Prelude as P hiding (catch)+import "base" Prelude as P import Control.Applicative import Data.Monoid #endif
src/Text/Pandoc.hs view
@@ -37,12 +37,11 @@ > module Main where > import Text.Pandoc-> import Text.Pandoc.Error (handleError) > > markdownToRST :: String -> String-> markdownToRST = handleError .+> markdownToRST = > writeRST def {writerReferenceLinks = True} .-> readMarkdown def+> handleError . readMarkdown def > > main = getContents >>= putStrLn . markdownToRST @@ -60,6 +59,8 @@ , module Text.Pandoc.Generic -- * Options , module Text.Pandoc.Options+ -- * Error handling+ , module Text.Pandoc.Error -- * Lists of readers and writers , readers , writers
− src/Text/Pandoc/Compat/Directory.hs
@@ -1,21 +0,0 @@-{-# LANGUAGE CPP #-}-module Text.Pandoc.Compat.Directory ( getModificationTime )- where--#if MIN_VERSION_directory(1,2,0)-import System.Directory---#else-import qualified System.Directory as S-import Data.Time.Clock (UTCTime)-import Data.Time.Clock.POSIX-import System.Time--getModificationTime :: FilePath -> IO UTCTime-getModificationTime fp = convert `fmap` S.getModificationTime fp- where- convert (TOD x _) = posixSecondsToUTCTime (realToFrac x)--#endif-
− src/Text/Pandoc/Compat/Except.hs
@@ -1,37 +0,0 @@-{-# LANGUAGE CPP #-}-module Text.Pandoc.Compat.Except ( ExceptT- , Except- , Error(..)- , runExceptT- , runExcept- , MonadError- , throwError- , catchError )- where--#if MIN_VERSION_mtl(2,2,1)-import Control.Monad.Except--class Error a where- noMsg :: a- strMsg :: String -> a-- noMsg = strMsg ""- strMsg _ = noMsg--#else-import Control.Monad.Error-import Control.Monad.Identity (Identity, runIdentity)--type ExceptT = ErrorT--type Except s a = ErrorT s Identity a--runExceptT :: ExceptT e m a -> m (Either e a)-runExceptT = runErrorT--runExcept :: ExceptT e Identity a -> Either e a-runExcept = runIdentity . runExceptT-#endif--
− src/Text/Pandoc/Compat/Monoid.hs
@@ -1,17 +0,0 @@-{-# LANGUAGE CPP #-}-module Text.Pandoc.Compat.Monoid ( (<>) )- where--#if MIN_VERSION_base(4,5,0)-import Data.Monoid ((<>))--#else-import Data.Monoid--infixr 6 <>----- | An infix synonym for 'mappend'.-(<>) :: Monoid m => m -> m -> m-(<>) = mappend-{-# INLINE (<>) #-}-#endif
− src/Text/Pandoc/Compat/TagSoupEntity.hs
@@ -1,15 +0,0 @@-{-# LANGUAGE CPP #-}-module Text.Pandoc.Compat.TagSoupEntity (lookupEntity- ) where--import qualified Text.HTML.TagSoup.Entity as TE--lookupEntity :: String -> Maybe Char-#if MIN_VERSION_tagsoup(0,13,0)-lookupEntity = str2chr . TE.lookupEntity- where str2chr :: Maybe String -> Maybe Char- str2chr (Just [c]) = Just c- str2chr _ = Nothing-#else-lookupEntity = TE.lookupEntity-#endif
src/Text/Pandoc/Compat/Time.hs view
@@ -1,4 +1,16 @@ {-# LANGUAGE CPP #-}++{-+This compatibility module is needed because, in time 1.5, the+`defaultTimeLocale` function was moved from System.Locale (in the+old-locale library) into Data.Time.++We support both behaviors because time 1.4 is a boot library for GHC+7.8. time 1.5 is a boot library for GHC 7.10.++When support is dropped for GHC 7.8, this module may be obsoleted.+-}+ #if MIN_VERSION_time(1,5,0) module Text.Pandoc.Compat.Time ( module Data.Time
src/Text/Pandoc/Data.hsb view
@@ -12,4 +12,4 @@ (Posix.joinPath (splitDirectories fp), contents)) dataFiles' dataFiles' :: [(FilePath, B.ByteString)]-dataFiles' = ("README", %blob "README") : %blobs "data"+dataFiles' = ("MANUAL.txt", %blob "MANUAL.txt") : %blobs "data"
src/Text/Pandoc/Error.hs view
@@ -33,7 +33,6 @@ import Text.Parsec.Error import Text.Parsec.Pos hiding (Line)-import Text.Pandoc.Compat.Except import GHC.Generics (Generic) import Data.Generics (Typeable) import Control.Exception (Exception)@@ -48,10 +47,6 @@ instance Exception PandocError -instance Error PandocError where- strMsg = ParseFailure-- -- | An unsafe method to handle `PandocError`s. handleError :: Either PandocError a -> a handleError (Right r) = r@@ -62,8 +57,12 @@ let errPos = errorPos err' errLine = sourceLine errPos errColumn = sourceColumn errPos- theline = (lines input ++ [""]) !! (errLine - 1)- in error $ "\nError at " ++ show err' ++ "\n" ++- theline ++ "\n" ++ replicate (errColumn - 1) ' ' ++- "^"+ ls = lines input ++ [""]+ errorInFile = if length ls > errLine - 1+ then concat ["\n", (ls !! (errLine - 1))+ ,"\n", replicate (errColumn - 1) ' '+ ,"^"]+ else ""+ in error $ "\nError at " ++ show err'+ ++ errorInFile
src/Text/Pandoc/ImageSize.hs view
@@ -59,8 +59,7 @@ import Text.Pandoc.Definition import Text.Pandoc.Options import qualified Data.Map as M-import Text.Pandoc.Compat.Except-import Control.Monad.Trans+import Control.Monad.Except import Data.Maybe (fromMaybe) -- quick and dirty functions to get image sizes
src/Text/Pandoc/Options.hs view
@@ -43,8 +43,10 @@ , HTMLSlideVariant (..) , EPUBVersion (..) , WrapOption (..)+ , Division (..) , WriterOptions (..) , TrackChanges (..)+ , ReferenceLocation (..) , def , isEnabled ) where@@ -84,6 +86,7 @@ | Ext_markdown_in_html_blocks -- ^ Interpret as markdown inside HTML blocks | Ext_native_divs -- ^ Use Div blocks for contents of <div> tags | Ext_native_spans -- ^ Use Span inlines for contents of <span>+ | Ext_bracketed_spans -- ^ Bracketed spans with attributes | Ext_markdown_attribute -- ^ Interpret text inside HTML as markdown -- iff container has attribute 'markdown' | Ext_escaped_line_breaks -- ^ Treat a backslash at EOL as linebreak@@ -98,6 +101,7 @@ -- space between items, and disallow laziness | Ext_example_lists -- ^ Markdown-style numbered examples | Ext_all_symbols_escapable -- ^ Make all non-alphanumerics escapable+ | Ext_angle_brackets_escapable -- ^ Make < and > escapable | Ext_intraword_underscores -- ^ Treat underscore inside word as literal | Ext_blank_before_blockquote -- ^ Require blank line before a blockquote | Ext_blank_before_header -- ^ Require blank line before a header@@ -145,6 +149,7 @@ , Ext_markdown_in_html_blocks , Ext_native_divs , Ext_native_spans+ , Ext_bracketed_spans , Ext_escaped_line_breaks , Ext_fancy_lists , Ext_startnum@@ -200,7 +205,8 @@ githubMarkdownExtensions :: Set Extension githubMarkdownExtensions = Set.fromList- [ Ext_pipe_tables+ [ Ext_angle_brackets_escapable+ , Ext_pipe_tables , Ext_raw_html , Ext_fenced_code_blocks , Ext_auto_identifiers@@ -221,7 +227,9 @@ , Ext_raw_html , Ext_markdown_attribute , Ext_mmd_link_attributes- , Ext_raw_tex+ -- , Ext_raw_tex+ -- Note: MMD's raw TeX syntax requires raw TeX to be+ -- enclosed in HTML comment , Ext_tex_math_double_backslash , Ext_intraword_underscores , Ext_mmd_title_block@@ -332,6 +340,18 @@ | WrapPreserve -- ^ Preserve wrapping of input source deriving (Show, Read, Eq, Data, Typeable, Generic) +-- | Options defining the type of top-level headers.+data Division = Part -- ^ Top-level headers become parts+ | Chapter -- ^ Top-level headers become chapters+ | Section -- ^ Top-level headers become sections+ deriving (Show, Read, Eq, Ord, Data, Typeable, Generic)++-- | Locations for footnotes and references in markdown output+data ReferenceLocation = EndOfBlock -- ^ End of block+ | EndOfSection -- ^ prior to next section header (or end of document)+ | EndOfDocument -- ^ at end of document+ deriving (Show, Read, Eq, Data, Typeable, Generic)+ -- | Options for writers data WriterOptions = WriterOptions { writerStandalone :: Bool -- ^ Include header and footer@@ -362,7 +382,7 @@ , writerHtmlQTags :: Bool -- ^ Use @<q>@ tags for quotes in HTML , writerBeamer :: Bool -- ^ Produce beamer LaTeX slide show , writerSlideLevel :: Maybe Int -- ^ Force header level of slides- , writerChapters :: Bool -- ^ Use "chapter" for top-level sects+ , writerTopLevelDivision :: Division -- ^ Type of top-level divisions , writerListings :: Bool -- ^ Use listings package for code , writerHighlight :: Bool -- ^ Highlight source code , writerHighlightStyle :: Style -- ^ Style to use for highlighting@@ -379,6 +399,7 @@ , writerMediaBag :: MediaBag -- ^ Media collected by docx or epub reader , writerVerbose :: Bool -- ^ Verbose debugging output , writerLaTeXArgs :: [String] -- ^ Flags to pass to latex-engine+ , writerReferenceLocation :: ReferenceLocation -- ^ Location of footnotes and references for writing markdown } deriving (Show, Data, Typeable, Generic) instance Default WriterOptions where@@ -409,7 +430,7 @@ , writerHtmlQTags = False , writerBeamer = False , writerSlideLevel = Nothing- , writerChapters = False+ , writerTopLevelDivision = Section , writerListings = False , writerHighlight = False , writerHighlightStyle = pygments@@ -426,6 +447,7 @@ , writerMediaBag = mempty , writerVerbose = False , writerLaTeXArgs = []+ , writerReferenceLocation = EndOfDocument } -- | Returns True if the given extension is enabled.
src/Text/Pandoc/PDF.hs view
@@ -34,7 +34,7 @@ import qualified Data.ByteString.Lazy as B import qualified Data.ByteString.Lazy.Char8 as BC import qualified Data.ByteString as BS-import Text.Pandoc.Compat.Monoid ((<>))+import Data.Monoid ((<>)) import System.Exit (ExitCode (..)) import System.FilePath import System.IO (stderr, stdout)@@ -131,7 +131,8 @@ return $ Image attr ils (fname,tit) _ -> do warn $ "Could not find image `" ++ src ++ "', skipping..."- return $ Image attr ils (src,tit)+ -- return alt text+ return $ Emph ils handleImage' _ _ x = return x convertImages :: FilePath -> Inline -> IO Inline
src/Text/Pandoc/Parsing.hs view
@@ -178,15 +178,15 @@ import Text.Parsec hiding (token) import Text.Parsec.Pos (newPos) import Data.Char ( toLower, toUpper, ord, chr, isAscii, isAlphaNum,- isHexDigit, isSpace )+ isHexDigit, isSpace, isPunctuation ) import Data.List ( intercalate, transpose, isSuffixOf ) import Text.Pandoc.Shared import qualified Data.Map as M import Text.TeXMath.Readers.TeX.Macros (applyMacros, Macro, parseMacroDefinitions)-import Text.Pandoc.Compat.TagSoupEntity ( lookupEntity )+import Text.HTML.TagSoup.Entity ( lookupEntity ) import Text.Pandoc.Asciify (toAsciiChar)-import Text.Pandoc.Compat.Monoid ((<>))+import Data.Monoid ((<>)) import Data.Default import qualified Data.Set as Set import Control.Monad.Reader@@ -405,9 +405,18 @@ domain = intercalate "." <$> (subdomain `sepby1` dot) dot = char '.' subdomain = many1 $ alphaNum <|> innerPunct- innerPunct = try (satisfy (\c -> isEmailPunct c || c == '@') <*- notFollowedBy space)- emailWord = many1 $ satisfy isEmailChar+ -- this excludes some valid email addresses, since an+ -- email could contain e.g. '__', but gives better results+ -- for our purposes, when combined with markdown parsing:+ innerPunct = try (satisfy (\c -> isEmailPunct c || c == '@')+ <* notFollowedBy space+ <* notFollowedBy (satisfy isPunctuation))+ -- technically an email address could begin with a symbol,+ -- but allowing this creates too many problems.+ -- See e.g. https://github.com/jgm/pandoc/issues/2940+ emailWord = do x <- satisfy isAlphaNum+ xs <- many (satisfy isEmailChar)+ return (x:xs) isEmailChar c = isAlphaNum c || isEmailPunct c isEmailPunct c = c `elem` "!\"#$%&'*+-/=?^_{|}~;" -- note: sepBy1 from parsec consumes input when sep@@ -578,8 +587,8 @@ '#':_ -> ent _ -> ent ++ ";" case lookupEntity ent' of- Just c -> return c- Nothing -> fail "entity not found"+ Just (c : _) -> return c+ _ -> fail "entity not found" -- | Parses an uppercase roman numeral and returns (UpperRoman, number). upperRoman :: Stream s m Char => ParserT s st m (ListNumberStyle, Int)@@ -718,11 +727,14 @@ continuations <- many (try $ char ' ' >> anyLine) return $ white ++ unwords (line : continuations) +blankLineBlockLine :: Stream [Char] m Char => ParserT [Char] st m Char+blankLineBlockLine = try (char '|' >> blankline)+ -- | Parses an RST-style line block and returns a list of strings. lineBlockLines :: Stream [Char] m Char => ParserT [Char] st m [String] lineBlockLines = try $ do- lines' <- many1 lineBlockLine- skipMany1 $ blankline <|> try (char '|' >> blankline)+ lines' <- many1 (lineBlockLine <|> ((:[]) <$> blankLineBlockLine))+ skipMany1 $ blankline <|> blankLineBlockLine return lines' -- | Parse a table using 'headerParser', 'rowParser',
src/Text/Pandoc/Pretty.hs view
@@ -80,7 +80,7 @@ import Data.String import Control.Monad.State import Data.Char (isSpace)-import Text.Pandoc.Compat.Monoid ((<>))+import Data.Monoid ((<>)) data RenderState a = RenderState{ output :: [a] -- ^ In reverse order@@ -125,18 +125,6 @@ -- | The empty document. empty :: Doc empty = mempty--#if MIN_VERSION_base(4,5,0)--- (<>) is defined in Data.Monoid-#else-infixr 6 <>---- | An infix synonym for 'mappend'.--- @a <> b@ is the result of concatenating @a@ with @b@.-(<>) :: Monoid m => m -> m -> m-(<>) = mappend-{-# INLINE (<>) #-}-#endif -- | Concatenate a list of 'Doc's. cat :: [Doc] -> Doc
src/Text/Pandoc/Readers/DocBook.hs view
@@ -5,7 +5,7 @@ import Text.Pandoc.Definition import Text.Pandoc.Builder import Text.XML.Light-import Text.Pandoc.Compat.TagSoupEntity (lookupEntity)+import Text.HTML.TagSoup.Entity (lookupEntity) import Data.Either (rights) import Data.Generics import Data.Char (isSpace)@@ -14,7 +14,7 @@ import Data.Maybe (fromMaybe) import Text.TeXMath (readMathML, writeTeX) import Text.Pandoc.Error (PandocError)-import Text.Pandoc.Compat.Except+import Control.Monad.Except import Data.Default import Data.Foldable (asum) @@ -564,7 +564,7 @@ go xs = xs convertEntity :: String -> String-convertEntity e = maybe (map toUpper e) (:[]) (lookupEntity e)+convertEntity e = maybe (map toUpper e) id (lookupEntity e) -- convenience function to get an attribute value, defaulting to "" attrValue :: String -> Element -> String@@ -592,8 +592,6 @@ when accepts p return mempty -- addMeta :: ToMetaValue a => String -> a -> DB () addMeta field val = modify (setMeta field val) @@ -612,7 +610,7 @@ "important","caution","note","tip","warning","qandadiv", "question","answer","abstract","itemizedlist","orderedlist", "variablelist","article","book","table","informaltable",- "informalexample",+ "informalexample", "linegroup", "screen","programlisting","example","calloutlist"] isBlockElement _ = False @@ -779,6 +777,7 @@ "informaltable" -> parseTable "informalexample" -> divWith ("", ["informalexample"], []) <$> getBlocks e+ "linegroup" -> lineBlock <$> lineItems "literallayout" -> codeBlockWithLang "screen" -> codeBlockWithLang "programlisting" -> codeBlockWithLang@@ -900,6 +899,7 @@ let ident = attrValue "id" e modify $ \st -> st{ dbSectionLevel = n - 1 } return $ headerWith (ident,[],[]) n' headerText <> b+ lineItems = mapM getInlines $ filterChildren (named "line") e metaBlock = acceptingMetadata (getBlocks e) >> return mempty getInlines :: Element -> DB Inlines@@ -916,7 +916,7 @@ parseInline :: Content -> DB Inlines parseInline (Text (CData _ s _)) = return $ text s parseInline (CRef ref) =- return $ maybe (text $ map toUpper ref) (text . (:[])) $ lookupEntity ref+ return $ maybe (text $ map toUpper ref) (text) $ lookupEntity ref parseInline (Elem e) = case qName (elName e) of "equation" -> equation displayMath
src/Text/Pandoc/Readers/Docx.hs view
@@ -1,7 +1,7 @@-{-# LANGUAGE PatternGuards, OverloadedStrings #-}+{-# LANGUAGE PatternGuards, OverloadedStrings, CPP #-} {--Copyright (C) 2014 Jesse Rosenthal <jrosenthal@jhu.edu>+Copyright (C) 2014-2016 Jesse Rosenthal <jrosenthal@jhu.edu> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -20,7 +20,7 @@ {- | Module : Text.Pandoc.Readers.Docx- Copyright : Copyright (C) 2014 Jesse Rosenthal+ Copyright : Copyright (C) 2014-2016 Jesse Rosenthal License : GNU GPL, version 2 or above Maintainer : Jesse Rosenthal <jrosenthal@jhu.edu>@@ -83,7 +83,7 @@ import Text.Pandoc.Readers.Docx.Combine import Text.Pandoc.Shared import Text.Pandoc.MediaBag (insertMedia, MediaBag)-import Data.List (delete, (\\), intersect)+import Data.List (delete, intersect) import Text.TeXMath (writeTeX) import Data.Default (Default) import qualified Data.ByteString.Lazy as B@@ -93,9 +93,12 @@ import Control.Monad.State import Data.Sequence (ViewL(..), viewl) import qualified Data.Sequence as Seq (null)+#if !(MIN_VERSION_base(4,8,0))+import Data.Traversable (traverse)+#endif import Text.Pandoc.Error-import Text.Pandoc.Compat.Except+import Control.Monad.Except readDocxWithWarnings :: ReaderOptions -> B.ByteString@@ -412,39 +415,39 @@ return $ math $ writeTeX exps isAnchorSpan :: Inline -> Bool-isAnchorSpan (Span (_, classes, kvs) ils) =+isAnchorSpan (Span (_, classes, kvs) _) = classes == ["anchor"] &&- null kvs &&- null ils+ null kvs isAnchorSpan _ = False dummyAnchors :: [String] dummyAnchors = ["_GoBack"] makeHeaderAnchor :: Blocks -> DocxContext Blocks-makeHeaderAnchor bs = case viewl $ unMany bs of- (x :< xs) -> do- x' <- (makeHeaderAnchor' x)- xs' <- (makeHeaderAnchor $ Many xs)- return $ (singleton x') <> xs'- EmptyL -> return mempty+makeHeaderAnchor bs = traverse makeHeaderAnchor' bs makeHeaderAnchor' :: Block -> DocxContext Block -- If there is an anchor already there (an anchor span in the header, -- to be exact), we rename and associate the new id with the old one.-makeHeaderAnchor' (Header n (_, classes, kvs) ils)- | (c:cs) <- filter isAnchorSpan ils- , (Span (ident, ["anchor"], _) _) <- c = do+makeHeaderAnchor' (Header n (ident, classes, kvs) ils)+ | (c:_) <- filter isAnchorSpan ils+ , (Span (anchIdent, ["anchor"], _) cIls) <- c = do hdrIDMap <- gets docxAnchorMap- let newIdent = uniqueIdent ils (Set.fromList $ M.elems hdrIDMap)- modify $ \s -> s {docxAnchorMap = M.insert ident newIdent hdrIDMap}- return $ Header n (newIdent, classes, kvs) (ils \\ (c:cs))+ let newIdent = if null ident+ then uniqueIdent ils (Set.fromList $ M.elems hdrIDMap)+ else ident+ newIls = concatMap f ils where f il | il == c = cIls+ | otherwise = [il]+ modify $ \s -> s {docxAnchorMap = M.insert anchIdent newIdent hdrIDMap}+ makeHeaderAnchor' $ Header n (newIdent, classes, kvs) newIls -- Otherwise we just give it a name, and register that name (associate -- it with itself.)-makeHeaderAnchor' (Header n (_, classes, kvs) ils) =+makeHeaderAnchor' (Header n (ident, classes, kvs) ils) = do hdrIDMap <- gets docxAnchorMap- let newIdent = uniqueIdent ils (Set.fromList $ M.elems hdrIDMap)+ let newIdent = if null ident+ then uniqueIdent ils (Set.fromList $ M.elems hdrIDMap)+ else ident modify $ \s -> s {docxAnchorMap = M.insert newIdent newIdent hdrIDMap} return $ Header n (newIdent, classes, kvs) ils makeHeaderAnchor' blk = return blk
src/Text/Pandoc/Readers/Docx/Lists.hs view
@@ -1,5 +1,5 @@ {--Copyright (C) 2014 Jesse Rosenthal <jrosenthal@jhu.edu>+Copyright (C) 2014-2016 Jesse Rosenthal <jrosenthal@jhu.edu> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -18,7 +18,7 @@ {- | Module : Text.Pandoc.Readers.Docx.Lists- Copyright : Copyright (C) 2014 Jesse Rosenthal+ Copyright : Copyright (C) 2014-2016 Jesse Rosenthal License : GNU GPL, version 2 or above Maintainer : Jesse Rosenthal <jrosenthal@jhu.edu>
src/Text/Pandoc/Readers/Docx/Parse.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE PatternGuards, ViewPatterns, FlexibleInstances #-} {--Copyright (C) 2014 Jesse Rosenthal <jrosenthal@jhu.edu>+Copyright (C) 2014-2016 Jesse Rosenthal <jrosenthal@jhu.edu> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -20,7 +20,7 @@ {- | Module : Text.Pandoc.Readers.Docx.Parse- Copyright : Copyright (C) 2014 Jesse Rosenthal+ Copyright : Copyright (C) 2014-2016 Jesse Rosenthal License : GNU GPL, version 2 or above Maintainer : Jesse Rosenthal <jrosenthal@jhu.edu>@@ -64,8 +64,8 @@ import Control.Monad.State import Control.Applicative ((<|>)) import qualified Data.Map as M-import Text.Pandoc.Compat.Except-import Text.Pandoc.Shared (safeRead)+import Control.Monad.Except+import Text.Pandoc.Shared (safeRead, filteredFilesFromArchive) import Text.TeXMath.Readers.OMML (readOMML) import Text.Pandoc.Readers.Docx.Fonts (getUnicode, Font(..)) import Text.TeXMath (Exp)@@ -86,14 +86,10 @@ data ReaderState = ReaderState { stateWarnings :: [String] } deriving Show- data DocxError = DocxError | WrongElem deriving Show -instance Error DocxError where- noMsg = WrongElem- type D = ExceptT DocxError (ReaderT ReaderEnv (State ReaderState)) runD :: D a -> ReaderEnv -> ReaderState -> (Either DocxError a, ReaderState)@@ -279,7 +275,7 @@ comments = archiveToComments archive numbering = archiveToNumbering archive rels = archiveToRelationships archive- media = archiveToMedia archive+ media = filteredFilesFromArchive archive filePathIsMedia (styles, parstyles) = archiveToStyles archive rEnv = ReaderEnv notes comments numbering rels media Nothing styles parstyles InDocument@@ -405,7 +401,6 @@ case cmts of Just c -> Comments cmts_namespaces c Nothing -> Comments cmts_namespaces M.empty- filePathToRelType :: FilePath -> Maybe DocumentLocation filePathToRelType "word/_rels/document.xml.rels" = Just InDocument@@ -427,7 +422,7 @@ , Just relElems <- (parseXMLDoc . UTF8.toStringLazy . fromEntry) entry = mapMaybe (relElemToRelationship relType) $ elChildren relElems filePathToRelationships _ _ = []- + archiveToRelationships :: Archive -> [Relationship] archiveToRelationships archive = concatMap (filePathToRelationships archive) $ filesInArchive archive@@ -438,16 +433,6 @@ in (dir == "word/media/") -getMediaPair :: Archive -> FilePath -> Maybe (FilePath, B.ByteString)-getMediaPair zf fp =- case findEntryByPath fp zf of- Just e -> Just (fp, fromEntry e)- Nothing -> Nothing--archiveToMedia :: Archive -> Media-archiveToMedia zf =- mapMaybe (getMediaPair zf) (filter filePathIsMedia (filesInArchive zf))- lookupLevel :: String -> String -> Numbering -> Maybe Level lookupLevel numId ilvl (Numbering _ numbs absNumbs) = do absNumId <- lookup numId $ map (\(Numb nid absnumid) -> (nid, absnumid)) numbs@@ -457,40 +442,33 @@ numElemToNum :: NameSpaces -> Element -> Maybe Numb-numElemToNum ns element |- qName (elName element) == "num" &&- qURI (elName element) == (lookup "w" ns) = do- numId <- findAttr (QName "numId" (lookup "w" ns) (Just "w")) element- absNumId <- findChild (QName "abstractNumId" (lookup "w" ns) (Just "w")) element- >>= findAttr (QName "val" (lookup "w" ns) (Just "w"))- return $ Numb numId absNumId+numElemToNum ns element+ | isElem ns "w" "num" element = do+ numId <- findAttr (elemName ns "w" "numId") element+ absNumId <- findChild (elemName ns "w" "abstractNumId") element+ >>= findAttr (elemName ns "w" "val")+ return $ Numb numId absNumId numElemToNum _ _ = Nothing absNumElemToAbsNum :: NameSpaces -> Element -> Maybe AbstractNumb-absNumElemToAbsNum ns element |- qName (elName element) == "abstractNum" &&- qURI (elName element) == (lookup "w" ns) = do- absNumId <- findAttr- (QName "abstractNumId" (lookup "w" ns) (Just "w"))- element- let levelElems = findChildren- (QName "lvl" (lookup "w" ns) (Just "w"))- element- levels = mapMaybe (levelElemToLevel ns) levelElems- return $ AbstractNumb absNumId levels+absNumElemToAbsNum ns element+ | isElem ns "w" "abstractNum" element = do+ absNumId <- findAttr (elemName ns "w" "abstractNumId") element+ let levelElems = findChildren (elemName ns "w" "lvl") element+ levels = mapMaybe (levelElemToLevel ns) levelElems+ return $ AbstractNumb absNumId levels absNumElemToAbsNum _ _ = Nothing levelElemToLevel :: NameSpaces -> Element -> Maybe Level-levelElemToLevel ns element |- qName (elName element) == "lvl" &&- qURI (elName element) == (lookup "w" ns) = do- ilvl <- findAttr (QName "ilvl" (lookup "w" ns) (Just "w")) element- fmt <- findChild (QName "numFmt" (lookup "w" ns) (Just "w")) element- >>= findAttr (QName "val" (lookup "w" ns) (Just "w"))- txt <- findChild (QName "lvlText" (lookup "w" ns) (Just "w")) element- >>= findAttr (QName "val" (lookup "w" ns) (Just "w"))- let start = findChild (QName "start" (lookup "w" ns) (Just "w")) element- >>= findAttr (QName "val" (lookup "w" ns) (Just "w"))+levelElemToLevel ns element+ | isElem ns "w" "lvl" element = do+ ilvl <- findAttr (elemName ns "w" "ilvl") element+ fmt <- findChild (elemName ns "w" "numFmt") element+ >>= findAttr (elemName ns "w" "val")+ txt <- findChild (elemName ns "w" "lvlText") element+ >>= findAttr (elemName ns "w" "val")+ let start = findChild (elemName ns "w" "start") element+ >>= findAttr (elemName ns "w" "val") >>= (\s -> listToMaybe (map fst (reads s :: [(Integer, String)]))) return (ilvl, fmt, txt, start) levelElemToLevel _ _ = Nothing@@ -502,12 +480,8 @@ Just entry -> do numberingElem <- (parseXMLDoc . UTF8.toStringLazy . fromEntry) entry let namespaces = elemToNameSpaces numberingElem- numElems = findChildren- (QName "num" (lookup "w" namespaces) (Just "w"))- numberingElem- absNumElems = findChildren- (QName "abstractNum" (lookup "w" namespaces) (Just "w"))- numberingElem+ numElems = findChildren (elemName namespaces "w" "num") numberingElem+ absNumElems = findChildren (elemName namespaces "w" "abstractNum") numberingElem nums = mapMaybe (numElemToNum namespaces) numElems absNums = mapMaybe (absNumElemToAbsNum namespaces) absNumElems return $ Numbering namespaces nums absNums@@ -584,13 +558,13 @@ elemToParIndentation ns element | isElem ns "w" "ind" element = Just $ ParIndentation { leftParIndent =- findAttr (QName "left" (lookup "w" ns) (Just "w")) element >>=+ findAttr (elemName ns "w" "left") element >>= stringToInteger , rightParIndent =- findAttr (QName "right" (lookup "w" ns) (Just "w")) element >>=+ findAttr (elemName ns "w" "right") element >>= stringToInteger , hangingParIndent =- findAttr (QName "hanging" (lookup "w" ns) (Just "w")) element >>=+ findAttr (elemName ns "w" "hanging") element >>= stringToInteger} elemToParIndentation _ _ = Nothing @@ -677,7 +651,7 @@ , Just drawingElem <- findChild (elemName ns "w" "drawing") element = let a_ns = "http://schemas.openxmlformats.org/drawingml/2006/main" drawing = findElement (QName "blip" (Just a_ns) (Just "a")) element- >>= findAttr (QName "embed" (lookup "r" ns) (Just "r"))+ >>= findAttr (elemName ns "r" "embed") in case drawing of Just s -> expandDrawingId s >>= (\(fp, bs) -> return $ Drawing fp bs $ elemToExtent drawingElem)@@ -755,7 +729,7 @@ , Just cmtDate <- findAttr (elemName ns "w" "date") element = do bps <- mapD (elemToBodyPart ns) (elChildren element) return $ CommentStart cmtId cmtAuthor cmtDate bps-elemToCommentStart _ _ = throwError WrongElem +elemToCommentStart _ _ = throwError WrongElem lookupFootnote :: String -> Notes -> Maybe Element lookupFootnote s (Notes _ fns _) = fns >>= (M.lookup s)
src/Text/Pandoc/Readers/Docx/StyleMap.hs view
@@ -1,4 +1,6 @@ module Text.Pandoc.Readers.Docx.StyleMap ( StyleMaps(..)+ , alterMap+ , getMap , defaultStyleMaps , getStyleMaps , getStyleId
src/Text/Pandoc/Readers/EPUB.hs view
@@ -10,14 +10,14 @@ import Text.XML.Light import Text.Pandoc.Definition hiding (Attr)-import Text.Pandoc.Walk (walk, query) import Text.Pandoc.Readers.HTML (readHtml)+import Text.Pandoc.Error+import Text.Pandoc.Walk (walk, query) import Text.Pandoc.Options ( ReaderOptions(..), readerTrace) import Text.Pandoc.Shared (escapeURI, collapseFilePath, addMetaField) import Network.URI (unEscapeString) import Text.Pandoc.MediaBag (MediaBag, insertMedia)-import Text.Pandoc.Compat.Except (MonadError, throwError, runExcept, Except)-import Text.Pandoc.Compat.Monoid ((<>))+import Control.Monad.Except (MonadError, throwError, runExcept, Except) import Text.Pandoc.MIME (MimeType) import qualified Text.Pandoc.Builder as B import Codec.Archive.Zip ( Archive (..), toArchiveOrFail, fromEntry@@ -31,12 +31,11 @@ import Data.List (isPrefixOf, isInfixOf) import Data.Maybe (mapMaybe, fromMaybe) import qualified Data.Map as M (Map, lookup, fromList, elems)+import Data.Monoid ((<>)) import Control.DeepSeq (deepseq, NFData) import Debug.Trace (trace) -import Text.Pandoc.Error- type Items = M.Map String (FilePath, MimeType) readEPUB :: ReaderOptions -> BL.ByteString -> Either PandocError (Pandoc, MediaBag)@@ -109,7 +108,9 @@ -- Remove relative paths renameImages :: FilePath -> Inline -> Inline-renameImages root (Image attr a (url, b)) = Image attr a (collapseFilePath (root </> url), b)+renameImages root img@(Image attr a (url, b))+ | "data:" `isPrefixOf` url = img+ | otherwise = Image attr a (collapseFilePath (root </> url), b) renameImages _ x = x imageToPandoc :: FilePath -> Pandoc
src/Text/Pandoc/Readers/HTML.hs view
@@ -66,7 +66,7 @@ import Network.URI (URI, parseURIReference, nonStrictRelativeTo) import Text.Pandoc.Error import Text.Pandoc.CSS (foldOrElse, pickStyleAttrProps)-import Text.Pandoc.Compat.Monoid ((<>))+import Data.Monoid ((<>)) import Text.Parsec.Error import qualified Data.Set as Set
src/Text/Pandoc/Readers/Haddock.hs view
@@ -16,7 +16,7 @@ import Text.Pandoc.Builder (Blocks, Inlines) import qualified Text.Pandoc.Builder as B-import Text.Pandoc.Compat.Monoid ((<>))+import Data.Monoid ((<>)) import Text.Pandoc.Shared (trim, splitBy) import Data.List (intersperse, stripPrefix) import Data.Maybe (fromMaybe)
src/Text/Pandoc/Readers/LaTeX.hs view
@@ -232,7 +232,7 @@ <|> (guardEnabled Ext_literate_haskell *> char '|' *> doLHSverb) <|> (str . (:[]) <$> tildeEscape) <|> (str . (:[]) <$> oneOf "[]")- <|> (str . (:[]) <$> oneOf "#&") -- TODO print warning?+ <|> (str . (:[]) <$> oneOf "#&~^'`\"[]") -- TODO print warning? -- <|> (str <$> count 1 (satisfy (\c -> c /= '\\' && c /='\n' && c /='}' && c /='{'))) -- eat random leftover characters inlines :: LP Inlines@@ -859,8 +859,14 @@ opt :: LP Inlines opt = bracketed inline +rawopt :: LP String+rawopt = do+ contents <- bracketed (many1 (noneOf "]") <|> try (string "\\]"))+ optional sp+ return $ "[" ++ contents ++ "]"+ skipopts :: LP ()-skipopts = skipMany (opt *> optional sp)+skipopts = skipMany rawopt inlineText :: LP Inlines inlineText = str <$> many1 inlineChar@@ -883,8 +889,9 @@ rawEnv :: String -> LP Blocks rawEnv name = do- let addBegin x = "\\begin{" ++ name ++ "}" ++ x parseRaw <- getOption readerParseRaw+ rawOptions <- mconcat <$> many rawopt+ let addBegin x = "\\begin{" ++ name ++ "}" ++ rawOptions ++ x if parseRaw then (rawBlock "latex" . addBegin) <$> (withRaw (env name blocks) >>= applyMacros' . snd)@@ -1275,7 +1282,7 @@ <* optional sp <* optional (char ',') <* optional sp)- where isBibtexKeyChar c = isAlphaNum c || c `elem` (".:;?!`'()/*@_+=-[]*" :: String)+ where isBibtexKeyChar c = isAlphaNum c || c `elem` (".:;?!`'()/*@_+=-[]" :: String) cites :: CitationMode -> Bool -> LP [Citation] cites mode multi = try $ do
src/Text/Pandoc/Readers/Markdown.hs view
@@ -32,7 +32,7 @@ module Text.Pandoc.Readers.Markdown ( readMarkdown, readMarkdownWithWarnings ) where -import Data.List ( transpose, sortBy, findIndex, intersperse, intercalate )+import Data.List ( transpose, sortBy, findIndex, intercalate ) import qualified Data.Map as M import Data.Scientific (coefficient, base10Exponent) import Data.Ord ( comparing )@@ -64,7 +64,7 @@ import qualified Data.Set as Set import Text.Printf (printf) import Debug.Trace (trace)-import Text.Pandoc.Compat.Monoid ((<>))+import Data.Monoid ((<>)) import Text.Pandoc.Error type MarkdownParser = Parser [Char] ParserState@@ -1106,7 +1106,7 @@ guardEnabled Ext_line_blocks lines' <- lineBlockLines >>= mapM (parseFromString (trimInlinesF . mconcat <$> many inline))- return $ B.para <$> (mconcat $ intersperse (return B.linebreak) lines')+ return $ B.lineBlock <$> sequence lines' -- -- Tables@@ -1482,6 +1482,7 @@ , strongOrEmph , note , cite+ , bracketedSpan , link , image , math@@ -1506,6 +1507,8 @@ escapedChar' = try $ do char '\\' (guardEnabled Ext_all_symbols_escapable >> satisfy (not . isAlphaNum))+ <|> (guardEnabled Ext_angle_brackets_escapable >>+ oneOf "\\`*_{}[]()>#+-.!~\"<>") <|> oneOf "\\`*_{}[]()>#+-.!~\"" escapedChar :: MarkdownParser (F Inlines)@@ -1750,6 +1753,13 @@ setState $ st{ stateAllowLinks = True } regLink B.linkWith lab <|> referenceLink B.linkWith (lab,raw) +bracketedSpan :: MarkdownParser (F Inlines)+bracketedSpan = try $ do+ guardEnabled Ext_bracketed_spans+ (lab,_) <- reference+ attr <- attributes+ return $ B.spanWith attr <$> lab+ regLink :: (Attr -> String -> String -> Inlines -> Inlines) -> F Inlines -> MarkdownParser (F Inlines) regLink constructor lab = try $ do@@ -1818,7 +1828,9 @@ -- final punctuation. for example: in `<http://hi---there>`, -- the URI parser will stop before the dashes. extra <- fromEntities <$> manyTill nonspaceChar (char '>')- return $ return $ B.link (src ++ escapeURI extra) "" (B.str $ orig ++ extra)+ attr <- option nullAttr $ try $+ guardEnabled Ext_link_attributes >> attributes+ return $ return $ B.linkWith attr (src ++ escapeURI extra) "" (B.str $ orig ++ extra) image :: MarkdownParser (F Inlines) image = try $ do
src/Text/Pandoc/Readers/MediaWiki.hs view
@@ -39,7 +39,7 @@ import Text.Pandoc.Definition import qualified Text.Pandoc.Builder as B import Text.Pandoc.Builder (Inlines, Blocks, trimInlines)-import Text.Pandoc.Compat.Monoid ((<>))+import Data.Monoid ((<>)) import Text.Pandoc.Options import Text.Pandoc.Readers.HTML ( htmlTag, isBlockTag, isCommentTag ) import Text.Pandoc.XML ( fromEntities )@@ -253,7 +253,7 @@ k <- many1 letter char '=' v <- (char '"' >> many1Till (satisfy (/='\n')) (char '"'))- <|> many1 nonspaceChar+ <|> many1 (satisfy $ \c -> not (isSpace c) && c /= '|') return (k,v) tableStart :: MWParser ()@@ -376,11 +376,17 @@ spacesStr _ = False if F.all spacesStr contents then return mempty- else return $ B.para $ walk strToCode contents+ else return $ B.para $ encode contents -strToCode :: Inline -> Inline-strToCode (Str s) = Code ("",[],[]) s-strToCode x = x+encode :: Inlines -> Inlines+encode = B.fromList . normalizeCode . B.toList . walk strToCode+ where strToCode (Str s) = Code ("",[],[]) s+ strToCode Space = Code ("",[],[]) " "+ strToCode x = x+ normalizeCode [] = []+ normalizeCode (Code a1 x : Code a2 y : zs) | a1 == a2 =+ normalizeCode $ (Code a1 (x ++ y)) : zs+ normalizeCode (x:xs) = x : normalizeCode xs header :: MWParser Blocks header = try $ do@@ -545,8 +551,8 @@ TagOpen "del" _ -> B.strikeout <$> inlinesInTags "del" TagOpen "sub" _ -> B.subscript <$> inlinesInTags "sub" TagOpen "sup" _ -> B.superscript <$> inlinesInTags "sup"- TagOpen "code" _ -> walk strToCode <$> inlinesInTags "code"- TagOpen "tt" _ -> walk strToCode <$> inlinesInTags "tt"+ TagOpen "code" _ -> encode <$> inlinesInTags "code"+ TagOpen "tt" _ -> encode <$> inlinesInTags "tt" TagOpen "hask" _ -> B.codeWith ("",["haskell"],[]) <$> charsInTags "hask" _ -> B.rawInline "html" . snd <$> htmlTag (~== tag) @@ -579,7 +585,7 @@ image = try $ do sym "[[" choice imageIdentifiers- fname <- many1 (noneOf "|]")+ fname <- addUnderscores <$> many1 (noneOf "|]") _ <- many imageOption dims <- try (char '|' *> (sepBy (many digit) (char 'x')) <* string "px") <|> return []
src/Text/Pandoc/Readers/OPML.hs view
@@ -7,11 +7,11 @@ import Text.Pandoc.Readers.HTML (readHtml) import Text.Pandoc.Readers.Markdown (readMarkdown) import Text.XML.Light-import Text.Pandoc.Compat.TagSoupEntity (lookupEntity)+import Text.HTML.TagSoup.Entity (lookupEntity) import Data.Generics import Control.Monad.State import Data.Default-import Text.Pandoc.Compat.Except+import Control.Monad.Except import Text.Pandoc.Error type OPML = ExceptT PandocError (State OPMLState)@@ -53,7 +53,7 @@ go xs = xs convertEntity :: String -> String-convertEntity e = maybe (map toUpper e) (:[]) (lookupEntity e)+convertEntity e = maybe (map toUpper e) id (lookupEntity e) -- convenience function to get an attribute value, defaulting to "" attrValue :: String -> Element -> String
src/Text/Pandoc/Readers/Odt.hs view
@@ -37,6 +37,8 @@ import qualified Data.ByteString.Lazy as B +import System.FilePath+ import Text.Pandoc.Definition import Text.Pandoc.Error import Text.Pandoc.Options@@ -48,39 +50,49 @@ import Text.Pandoc.Readers.Odt.Generic.XMLConverter import Text.Pandoc.Readers.Odt.Generic.Fallible+import Text.Pandoc.Shared (filteredFilesFromArchive) -- readOdt :: ReaderOptions -> B.ByteString -> Either PandocError (Pandoc, MediaBag)-readOdt _ bytes = case bytesToOdt bytes of- Right pandoc -> Right (pandoc , mempty)- Left err -> Left err+readOdt _ bytes = bytesToOdt bytes-- of+-- Right (pandoc, mediaBag) -> Right (pandoc , mediaBag)+-- Left err -> Left err ---bytesToOdt :: B.ByteString -> Either PandocError Pandoc+bytesToOdt :: B.ByteString -> Either PandocError (Pandoc, MediaBag) bytesToOdt bytes = case toArchiveOrFail bytes of Right archive -> archiveToOdt archive Left _ -> Left $ ParseFailure "Couldn't parse odt file." ---archiveToOdt :: Archive -> Either PandocError Pandoc+archiveToOdt :: Archive -> Either PandocError (Pandoc, MediaBag) archiveToOdt archive- | Just contentEntry <- findEntryByPath "content.xml" archive- , Just stylesEntry <- findEntryByPath "styles.xml" archive- , Just contentElem <- entryToXmlElem contentEntry- , Just stylesElem <- entryToXmlElem stylesEntry- , Right styles <- chooseMax (readStylesAt stylesElem )- (readStylesAt contentElem)- , startState <- readerState styles- , Right pandoc <- runConverter' read_body- startState- contentElem- = Right pandoc+ | Just contentEntry <- findEntryByPath "content.xml" archive+ , Just stylesEntry <- findEntryByPath "styles.xml" archive+ , Just contentElem <- entryToXmlElem contentEntry+ , Just stylesElem <- entryToXmlElem stylesEntry+ , Right styles <- chooseMax (readStylesAt stylesElem )+ (readStylesAt contentElem)+ , media <- filteredFilesFromArchive archive filePathIsOdtMedia+ , startState <- readerState styles media+ , Right pandocWithMedia <- runConverter' read_body+ startState+ contentElem + = Right pandocWithMedia+ | otherwise -- Not very detailed, but I don't think more information would be helpful = Left $ ParseFailure "Couldn't parse odt file."+ where+ filePathIsOdtMedia :: FilePath -> Bool+ filePathIsOdtMedia fp =+ let (dir, _) = splitFileName fp+ in+ (dir == "Pictures/")+ -- entryToXmlElem :: Entry -> Maybe XML.Element
src/Text/Pandoc/Readers/Odt/Arrows/State.hs view
@@ -45,8 +45,8 @@ import Control.Monad import Data.Foldable+import Data.Monoid -import Text.Pandoc.Compat.Monoid import Text.Pandoc.Readers.Odt.Arrows.Utils import Text.Pandoc.Readers.Odt.Generic.Fallible
src/Text/Pandoc/Readers/Odt/Arrows/Utils.hs view
@@ -43,10 +43,10 @@ import Control.Monad ( join, MonadPlus(..) ) import qualified Data.Foldable as F+import Data.Monoid import Text.Pandoc.Readers.Odt.Generic.Fallible import Text.Pandoc.Readers.Odt.Generic.Utils-import Text.Pandoc.Compat.Monoid and2 :: (Arrow a) => a b c -> a b c' -> a b (c,c') and2 = (&&&)
src/Text/Pandoc/Readers/Odt/ContentReader.hs view
@@ -42,6 +42,7 @@ import Control.Arrow import Control.Applicative hiding ( liftA, liftA2, liftA3 ) +import qualified Data.ByteString.Lazy as B import qualified Data.Map as M import Data.List ( find ) import Data.Maybe@@ -50,6 +51,7 @@ import Text.Pandoc.Definition import Text.Pandoc.Builder+import Text.Pandoc.MediaBag (insertMedia, MediaBag) import Text.Pandoc.Shared import Text.Pandoc.Readers.Odt.Base@@ -68,6 +70,7 @@ -------------------------------------------------------------------------------- type Anchor = String+type Media = [(FilePath, B.ByteString)] data ReaderState = ReaderState { -- | A collection of styles read somewhere else.@@ -87,14 +90,17 @@ -- | A map from internal anchor names to "pretty" ones. -- The mapping is a purely cosmetic one. , bookmarkAnchors :: M.Map Anchor Anchor-+ -- | A map of files / binary data from the archive+ , envMedia :: Media+ -- | Hold binary resources used in the document+ , odtMediaBag :: MediaBag -- , sequences -- , trackedChangeIDs } deriving ( Show ) -readerState :: Styles -> ReaderState-readerState styles = ReaderState styles [] 0 Nothing M.empty+readerState :: Styles -> Media -> ReaderState+readerState styles media = ReaderState styles [] 0 Nothing M.empty media mempty -- pushStyle' :: Style -> ReaderState -> ReaderState@@ -134,6 +140,16 @@ usedAnchors :: ReaderState -> [Anchor] usedAnchors ReaderState{..} = M.elems bookmarkAnchors +getMediaBag :: ReaderState -> MediaBag+getMediaBag ReaderState{..} = odtMediaBag++getMediaEnv :: ReaderState -> Media+getMediaEnv ReaderState{..} = envMedia++insertMedia' :: (FilePath, B.ByteString) -> ReaderState -> ReaderState+insertMedia' (fp, bs) state@ReaderState{..}+ = state { odtMediaBag = insertMedia fp Nothing bs odtMediaBag }+ -------------------------------------------------------------------------------- -- Reader type and associated tools --------------------------------------------------------------------------------@@ -190,7 +206,23 @@ getCurrentListLevel :: OdtReaderSafe _x ListLevel getCurrentListLevel = getExtraState >>^ currentListLevel +--+updateMediaWithResource :: OdtReaderSafe (FilePath, B.ByteString) (FilePath, B.ByteString)+updateMediaWithResource = keepingTheValue (+ (keepingTheValue getExtraState+ >>% insertMedia'+ )+ >>> setExtraState+ )+ >>^ fst +lookupResource :: OdtReaderSafe String (FilePath, B.ByteString)+lookupResource = proc target -> do+ state <- getExtraState -< ()+ case lookup target (getMediaEnv state) of+ Just bs -> returnV (target, bs) -<< ()+ Nothing -> returnV ("", B.empty) -< ()+ type AnchorPrefix = String -- | An adaptation of 'uniqueIdent' from "Text.Pandoc.Shared" that generates a@@ -386,7 +418,7 @@ LltNumbered -> let listNumberStyle = toListNumberStyle listItemFormat listNumberDelim = toListNumberDelim listItemPrefix listItemSuffix- in orderedListWith (1, listNumberStyle, listNumberDelim)+ in orderedListWith (listItemStart, listNumberStyle, listNumberDelim) where toListNumberStyle LinfNone = DefaultStyle toListNumberStyle LinfNumber = Decimal@@ -511,7 +543,11 @@ extractText (XML.Text cData) = succeedWith (XML.cdData cData) extractText _ = failEmpty +read_text_seq :: InlineMatcher+read_text_seq = matchingElement NsText "sequence"+ $ matchChildContent [] read_plain_text + -- specifically. I honor that, although the current implementation of '(<>)' -- for 'Inlines' in "Text.Pandoc.Builder" will collaps them agein. -- The rational is to be prepared for future modifications.@@ -559,6 +595,8 @@ , read_reference_start , read_bookmark_ref , read_reference_ref+ , read_maybe_nested_img_frame+ , read_text_seq ] read_plain_text @@ -583,6 +621,7 @@ , read_reference_start , read_bookmark_ref , read_reference_ref+ , read_maybe_nested_img_frame ] read_plain_text ) -< blocks anchor <- getHeaderAnchor -< children@@ -688,6 +727,68 @@ ] ----------------------+-- Images+----------------------++--+read_maybe_nested_img_frame :: InlineMatcher+read_maybe_nested_img_frame = matchingElement NsDraw "frame"+ $ proc blocks -> do+ img <- (findChild' NsDraw "image") -< ()+ case img of+ Just _ -> read_frame -< blocks+ Nothing -> matchChildContent' [ read_frame_text_box ] -< blocks++read_frame :: OdtReaderSafe Inlines Inlines+read_frame =+ proc blocks -> do+ w <- ( findAttr' NsSVG "width" ) -< ()+ h <- ( findAttr' NsSVG "height" ) -< ()+ titleNodes <- ( matchChildContent' [ read_frame_title ] ) -< blocks+ src <- matchChildContent' [ read_image_src ] -< blocks+ resource <- lookupResource -< src+ _ <- updateMediaWithResource -< resource+ alt <- (matchChildContent [] read_plain_text) -< blocks+ arr (uncurry4 imageWith ) -<+ (image_attributes w h, src, inlineListToIdentifier (toList titleNodes), alt)++image_attributes :: Maybe String -> Maybe String -> Attr+image_attributes x y =+ ( "", [], (dim "width" x) ++ (dim "height" y))+ where+ dim _ (Just "") = []+ dim name (Just v) = [(name, v)]+ dim _ Nothing = []++read_image_src :: (Namespace, ElementName, OdtReader Anchor Anchor)+read_image_src = matchingElement NsDraw "image"+ $ proc _ -> do+ imgSrc <- findAttr NsXLink "href" -< ()+ case imgSrc of+ Right src -> returnV src -<< ()+ Left _ -> returnV "" -< ()++read_frame_title :: InlineMatcher+read_frame_title = matchingElement NsSVG "title"+ $ (matchChildContent [] read_plain_text)++read_frame_text_box :: InlineMatcher+read_frame_text_box = matchingElement NsDraw "text-box"+ $ proc blocks -> do+ paragraphs <- (matchChildContent' [ read_paragraph ]) -< blocks+ arr read_img_with_caption -< toList paragraphs++read_img_with_caption :: [Block] -> Inlines+read_img_with_caption ((Para ((Image attr alt (src,title)) : [])) : _) =+ singleton (Image attr alt (src, 'f':'i':'g':':':title)) -- no text, default caption+read_img_with_caption ((Para ((Image attr _ (src,title)) : txt)) : _) =+ singleton (Image attr txt (src, 'f':'i':'g':':':title) ) -- override caption with the text that follows+read_img_with_caption ( (Para (_ : xs)) : ys) =+ read_img_with_caption ((Para xs) : ys)+read_img_with_caption _ =+ mempty++---------------------- -- Internal links ---------------------- @@ -713,9 +814,8 @@ >>> proc (inlines, fAnchorElem) -> do case fAnchorElem of- Right anchorElem ->- arr (anchorElem <>) -<< inlines- Left _ -> returnA -< inlines+ Right anchorElem -> returnA -< anchorElem+ Left _ -> returnA -< inlines where toAnchorElem :: Anchor -> Inlines toAnchorElem anchorID = spanWith (anchorID, [], []) mempty@@ -783,8 +883,11 @@ ] >>^ doc -read_body :: OdtReader _x Pandoc+read_body :: OdtReader _x (Pandoc, MediaBag) read_body = executeIn NsOffice "body" $ executeIn NsOffice "text"- $ liftAsSuccess read_text-+ $ liftAsSuccess+ $ proc inlines -> do+ txt <- read_text -< inlines+ state <- getExtraState -< ()+ returnA -< (txt, getMediaBag state)
src/Text/Pandoc/Readers/Odt/Generic/Fallible.hs view
@@ -41,8 +41,9 @@ import Control.Applicative import Control.Monad-import Text.Pandoc.Compat.Monoid ((<>))+ import qualified Data.Foldable as F+import Data.Monoid ((<>)) -- | Default for now. Will probably become a class at some point. type Failure = ()
src/Text/Pandoc/Readers/Odt/StyleReader.hs view
@@ -76,8 +76,9 @@ import qualified Data.Foldable as F import qualified Data.Map as M import qualified Data.Set as S-import Data.List ( unfoldr )+import Data.Char ( isDigit ) import Data.Default+import Data.List ( unfoldr ) import Data.Maybe import qualified Text.XML.Light as XML@@ -390,6 +391,7 @@ , listItemPrefix :: Maybe String , listItemSuffix :: Maybe String , listItemFormat :: ListItemNumberFormat+ , listItemStart :: Int } deriving ( Eq, Ord ) @@ -578,25 +580,31 @@ readListLevelStyle :: ListLevelType -> StyleReader _x (Int, ListLevelStyle) readListLevelStyle levelType = readAttr NsText "level" >>?! keepingTheValue- ( liftA4 toListLevelStyle- ( returnV levelType )- ( findAttr' NsStyle "num-prefix" )- ( findAttr' NsStyle "num-suffix" )- ( getAttr NsStyle "num-format" )+ ( liftA5 toListLevelStyle+ ( returnV levelType )+ ( findAttr' NsStyle "num-prefix" )+ ( findAttr' NsStyle "num-suffix" )+ ( getAttr NsStyle "num-format" )+ ( findAttr' NsText "start-value" ) ) where- toListLevelStyle _ p s LinfNone = ListLevelStyle LltBullet p s LinfNone- toListLevelStyle _ p s f@(LinfString _) = ListLevelStyle LltBullet p s f- toListLevelStyle t p s f = ListLevelStyle t p s f+ toListLevelStyle _ p s LinfNone b = ListLevelStyle LltBullet p s LinfNone (startValue b)+ toListLevelStyle _ p s f@(LinfString _) b = ListLevelStyle LltBullet p s f (startValue b)+ toListLevelStyle t p s f b = ListLevelStyle t p s f (startValue b)+ startValue (Just "") = 1+ startValue (Just v) = if all isDigit v+ then read v+ else 1+ startValue Nothing = 1 -- chooseMostSpecificListLevelStyle :: S.Set ListLevelStyle -> Maybe ListLevelStyle chooseMostSpecificListLevelStyle ls | ls == mempty = Nothing | otherwise = Just ( F.foldr1 select ls ) where- select ( ListLevelStyle t1 p1 s1 f1 )- ( ListLevelStyle t2 p2 s2 f2 )- = ListLevelStyle (select' t1 t2) (p1 <|> p2) (s1 <|> s2) (selectLinf f1 f2)+ select ( ListLevelStyle t1 p1 s1 f1 b1 )+ ( ListLevelStyle t2 p2 s2 f2 _ )+ = ListLevelStyle (select' t1 t2) (p1 <|> p2) (s1 <|> s2) (selectLinf f1 f2) b1 select' LltNumbered _ = LltNumbered select' _ LltNumbered = LltNumbered select' _ _ = LltBullet
src/Text/Pandoc/Readers/Org/Blocks.hs view
@@ -34,27 +34,25 @@ ) where import Text.Pandoc.Readers.Org.BlockStarts-import Text.Pandoc.Readers.Org.ExportSettings ( exportSettings ) import Text.Pandoc.Readers.Org.Inlines+import Text.Pandoc.Readers.Org.Meta ( metaExport, metaLine ) import Text.Pandoc.Readers.Org.ParserState import Text.Pandoc.Readers.Org.Parsing import Text.Pandoc.Readers.Org.Shared- ( isImageFilename, rundocBlockClass, toRundocAttrib- , translateLang )+ ( cleanLinkString, isImageFilename, rundocBlockClass+ , toRundocAttrib, translateLang ) import qualified Text.Pandoc.Builder as B import Text.Pandoc.Builder ( Inlines, Blocks ) import Text.Pandoc.Definition-import Text.Pandoc.Compat.Monoid ((<>)) import Text.Pandoc.Options import Text.Pandoc.Shared ( compactify', compactify'DL ) import Control.Monad ( foldM, guard, mzero, void ) import Data.Char ( isSpace, toLower, toUpper)-import Data.List ( foldl', intersperse, isPrefixOf )-import qualified Data.Map as M+import Data.List ( foldl', isPrefixOf ) import Data.Maybe ( fromMaybe, isNothing )-import Network.HTTP ( urlEncode )+import Data.Monoid ((<>)) -- -- Org headers@@ -82,6 +80,10 @@ toPropertyValue :: String -> PropertyValue toPropertyValue = PropertyValue +-- | Check whether the property value is non-nil (i.e. truish).+isNonNil :: PropertyValue -> Bool+isNonNil p = map toLower (fromValue p) `notElem` ["()", "{}", "nil"]+ -- | Key/value pairs from a PROPERTIES drawer type Properties = [(PropertyKey, PropertyValue)] @@ -202,12 +204,16 @@ toStringPair prop = (fromKey (fst prop), fromValue (snd prop)) customIdKey = toPropertyKey "custom_id" classKey = toPropertyKey "class"+ unnumberedKey = toPropertyKey "unnumbered"+ specialProperties = [customIdKey, classKey, unnumberedKey] id' = fromMaybe mempty . fmap fromValue . lookup customIdKey $ properties cls = fromMaybe mempty . fmap fromValue . lookup classKey $ properties- kvs' = map toStringPair . filter ((`notElem` [customIdKey, classKey]) . fst)+ kvs' = map toStringPair . filter ((`notElem` specialProperties) . fst) $ properties+ isUnnumbered =+ fromMaybe False . fmap isNonNil . lookup unnumberedKey $ properties in- (id', words cls, kvs')+ (id', words cls ++ (if isUnnumbered then ["unnumbered"] else []), kvs') tagTitle :: Inlines -> [Tag] -> Inlines tagTitle title tags = title <> (mconcat $ map tagToInline tags)@@ -232,8 +238,8 @@ -- | Get the meta information safed in the state. meta :: OrgParser Meta meta = do- st <- getState- return $ runF (orgStateMeta st) st+ meta' <- metaExport+ runF meta' <$> getState blocks :: OrgParser (F Blocks) blocks = mconcat <$> manyTill block (void (lookAhead headerStart) <|> eof)@@ -282,9 +288,9 @@ let kvAttrs = foldl' (appendValues "ATTR_HTML") Nothing kv let name = lookup "NAME" kv let label = lookup "LABEL" kv- caption' <- maybe (return Nothing)- (fmap Just . parseFromString inlines)- caption+ caption' <- case caption of+ Nothing -> return Nothing+ Just s -> Just <$> parseFromString inlines (s ++ "\n") kvAttrs' <- parseFromString keyValues . (++ "\n") $ fromMaybe mempty kvAttrs return $ BlockAttributes { blockAttrName = name@@ -421,8 +427,19 @@ verseBlock blockType = try $ do ignHeaders content <- rawBlockContent blockType- fmap B.para . mconcat . intersperse (pure B.linebreak)- <$> mapM (parseFromString inlines) (map (++ "\n") . lines $ content)+ fmap B.lineBlock . sequence+ <$> mapM parseVerseLine (lines content)+ where+ -- replace initial spaces with nonbreaking spaces to preserve+ -- indentation, parse the rest as normal inline+ parseVerseLine :: String -> OrgParser (F Inlines)+ parseVerseLine cs = do+ let (initialSpaces, indentedLine) = span isSpace cs+ let nbspIndent = if null initialSpaces+ then mempty+ else B.str $ map (const '\160') initialSpaces+ line <- parseFromString inlines (indentedLine ++ "\n")+ return (trimInlinesF $ pure nbspIndent <> line) -- | Read a code block and the associated results block if present. Which of -- boths blocks is included in the output is determined using the "exports"@@ -571,23 +588,33 @@ figure = try $ do figAttrs <- blockAttributes src <- skipSpaces *> selfTarget <* skipSpaces <* newline- guard . not . isNothing . blockAttrCaption $ figAttrs- guard (isImageFilename src)- let figName = fromMaybe mempty $ blockAttrName figAttrs- let figLabel = fromMaybe mempty $ blockAttrLabel figAttrs- let figCaption = fromMaybe mempty $ blockAttrCaption figAttrs- let figKeyVals = blockAttrKeyValues figAttrs- let attr = (figLabel, mempty, figKeyVals)- return $ (B.para . B.imageWith attr src (withFigPrefix figName) <$> figCaption)+ case cleanLinkString src of+ Nothing -> mzero+ Just imgSrc -> do+ guard (not . isNothing . blockAttrCaption $ figAttrs)+ guard (isImageFilename imgSrc)+ return $ figureBlock figAttrs imgSrc where+ selfTarget :: OrgParser String+ selfTarget = try $ char '[' *> linkTarget <* char ']'++ figureBlock :: BlockAttributes -> String -> (F Blocks)+ figureBlock figAttrs imgSrc =+ let+ figName = fromMaybe mempty $ blockAttrName figAttrs+ figLabel = fromMaybe mempty $ blockAttrLabel figAttrs+ figCaption = fromMaybe mempty $ blockAttrCaption figAttrs+ figKeyVals = blockAttrKeyValues figAttrs+ attr = (figLabel, mempty, figKeyVals)+ in+ B.para . B.imageWith attr imgSrc (withFigPrefix figName) <$> figCaption+ withFigPrefix :: String -> String withFigPrefix cs = if "fig:" `isPrefixOf` cs then cs else "fig:" ++ cs - selfTarget :: OrgParser String- selfTarget = try $ char '[' *> linkTarget <* char ']' -- -- Examples@@ -612,68 +639,10 @@ specialLine :: OrgParser (F Blocks) specialLine = fmap return . try $ metaLine <|> commentLine --- The order, in which blocks are tried, makes sure that we're not looking at--- the beginning of a block, so we don't need to check for it-metaLine :: OrgParser Blocks-metaLine = mempty <$ metaLineStart <* (optionLine <|> declarationLine)- commentLine :: OrgParser Blocks commentLine = commentLineStart *> anyLine *> pure mempty -declarationLine :: OrgParser ()-declarationLine = try $ do- key <- metaKey- value <- metaInlines- updateState $ \st ->- let meta' = B.setMeta key <$> value <*> pure nullMeta- in st { orgStateMeta = orgStateMeta st <> meta' } -metaInlines :: OrgParser (F MetaValue)-metaInlines = fmap (MetaInlines . B.toList) <$> inlinesTillNewline--metaKey :: OrgParser String-metaKey = map toLower <$> many1 (noneOf ": \n\r")- <* char ':'- <* skipSpaces--optionLine :: OrgParser ()-optionLine = try $ do- key <- metaKey- case key of- "link" -> parseLinkFormat >>= uncurry addLinkFormat- "options" -> exportSettings- _ -> mzero--addLinkFormat :: String- -> (String -> String)- -> OrgParser ()-addLinkFormat key formatter = updateState $ \s ->- let fs = orgStateLinkFormatters s- in s{ orgStateLinkFormatters = M.insert key formatter fs }--parseLinkFormat :: OrgParser ((String, String -> String))-parseLinkFormat = try $ do- linkType <- (:) <$> letter <*> many (alphaNum <|> oneOf "-_") <* skipSpaces- linkSubst <- parseFormat- return (linkType, linkSubst)---- | An ad-hoc, single-argument-only implementation of a printf-style format--- parser.-parseFormat :: OrgParser (String -> String)-parseFormat = try $ do- replacePlain <|> replaceUrl <|> justAppend- where- -- inefficient, but who cares- replacePlain = try $ (\x -> concat . flip intersperse x)- <$> sequence [tillSpecifier 's', rest]- replaceUrl = try $ (\x -> concat . flip intersperse x . urlEncode)- <$> sequence [tillSpecifier 'h', rest]- justAppend = try $ (++) <$> rest-- rest = manyTill anyChar (eof <|> () <$ oneOf "\n\r")- tillSpecifier c = manyTill (noneOf "\n\r") (try $ string ('%':c:""))-- -- -- Tables --@@ -848,9 +817,6 @@ *> notFollowedBy (inList *> (() <$ orderedListStart <|> bulletListStart)) *> return (B.para <$> ils)) <|> (return (B.plain <$> ils))--inlinesTillNewline :: OrgParser (F Inlines)-inlinesTillNewline = trimInlinesF . mconcat <$> manyTill inline newline --
src/Text/Pandoc/Readers/Org/ExportSettings.hs view
@@ -54,13 +54,15 @@ , ignoredSetting "<" , ignoredSetting "\\n" , archivedTreeSetting "arch" (\val es -> es { exportArchivedTrees = val })- , ignoredSetting "author"+ , booleanSetting "author" (\val es -> es { exportWithAuthor = val }) , ignoredSetting "c"- , ignoredSetting "creator"+ -- org-mode allows the special value `comment` for creator, which we'll+ -- interpret as true as it doesn't make sense in the context of Pandoc.+ , booleanSetting "creator" (\val es -> es { exportWithCreator = val }) , complementableListSetting "d" (\val es -> es { exportDrawers = val }) , ignoredSetting "date" , ignoredSetting "e"- , ignoredSetting "email"+ , booleanSetting "email" (\val es -> es { exportWithEmail = val }) , ignoredSetting "f" , integerSetting "H" (\val es -> es { exportHeadlineLevels = val }) , ignoredSetting "inline"
src/Text/Pandoc/Readers/Org/Inlines.hs view
@@ -37,13 +37,12 @@ import Text.Pandoc.Readers.Org.ParserState import Text.Pandoc.Readers.Org.Parsing import Text.Pandoc.Readers.Org.Shared- ( isImageFilename, rundocBlockClass, toRundocAttrib- , translateLang )+ ( cleanLinkString, isImageFilename, rundocBlockClass+ , toRundocAttrib, translateLang ) import qualified Text.Pandoc.Builder as B import Text.Pandoc.Builder ( Inlines ) import Text.Pandoc.Definition-import Text.Pandoc.Compat.Monoid ( (<>) ) import Text.Pandoc.Options import Text.Pandoc.Readers.LaTeX ( inlineCommand, rawLaTeXInline ) import Text.TeXMath ( readTeX, writePandoc, DisplayType(..) )@@ -52,9 +51,10 @@ import Prelude hiding (sequence) import Control.Monad ( guard, mplus, mzero, when, void ) import Data.Char ( isAlphaNum, isSpace )-import Data.List ( intersperse, isPrefixOf )+import Data.List ( intersperse ) import Data.Maybe ( fromMaybe ) import qualified Data.Map as M+import Data.Monoid ( (<>) ) import Data.Traversable (sequence) --@@ -435,9 +435,11 @@ char ']' return $ do src <- srcF- if isImageFilename title- then pure $ B.link src "" $ B.image title mempty mempty- else linkToInlinesF src =<< title'+ case cleanLinkString title of+ Just imgSrc | isImageFilename imgSrc ->+ pure $ B.link src "" $ B.image imgSrc mempty mempty+ _ ->+ linkToInlinesF src =<< title' selflinkOrImage :: OrgParser (F Inlines) selflinkOrImage = try $ do@@ -481,25 +483,6 @@ then const . pure $ B.image cleanedLink "" "" else pure . B.link cleanedLink "" Nothing -> internalLink linkStr -- other internal link---- | Cleanup and canonicalize a string describing a link. Return @Nothing@ if--- the string does not appear to be a link.-cleanLinkString :: String -> Maybe String-cleanLinkString s =- case s of- '/':_ -> Just $ "file://" ++ s -- absolute path- '.':'/':_ -> Just s -- relative path- '.':'.':'/':_ -> Just s -- relative path- -- Relative path or URL (file schema)- 'f':'i':'l':'e':':':s' -> Just $ if ("//" `isPrefixOf` s') then s else s'- _ | isUrl s -> Just s -- URL- _ -> Nothing- where- isUrl :: String -> Bool- isUrl cs =- let (scheme, path) = break (== ':') cs- in all (\c -> isAlphaNum c || c `elem` (".-"::String)) scheme- && not (null path) internalLink :: String -> Inlines -> F Inlines internalLink link title = do
+ src/Text/Pandoc/Readers/Org/Meta.hs view
@@ -0,0 +1,181 @@+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE TupleSections #-}+{-+Copyright (C) 2014-2016 Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>++This program is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++This program is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+GNU General Public License for more details.++You should have received a copy of the GNU General Public License+along with this program; if not, write to the Free Software+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA+-}++{- |+ Module : Text.Pandoc.Readers.Org.Meta+ Copyright : Copyright (C) 2014-2016 Albert Krewinkel+ License : GNU GPL, version 2 or above++ Maintainer : Albert Krewinkel <tarleb+pandoc@moltkeplatz.de>++Parsers for Org-mode meta declarations.+-}+module Text.Pandoc.Readers.Org.Meta+ ( metaLine+ , metaExport+ ) where++import Text.Pandoc.Readers.Org.BlockStarts+import Text.Pandoc.Readers.Org.ExportSettings ( exportSettings )+import Text.Pandoc.Readers.Org.Inlines+import Text.Pandoc.Readers.Org.ParserState+import Text.Pandoc.Readers.Org.Parsing++import qualified Text.Pandoc.Builder as B+import Text.Pandoc.Builder ( Blocks, Inlines )+import Text.Pandoc.Definition++import Control.Monad ( mzero )+import Data.Char ( toLower )+import Data.List ( intersperse )+import qualified Data.Map as M+import Data.Monoid ((<>))+import Network.HTTP ( urlEncode )++-- | Returns the current meta, respecting export options.+metaExport :: OrgParser (F Meta)+metaExport = do+ st <- getState+ let settings = orgStateExportSettings st+ return $ (if exportWithAuthor settings then id else removeMeta "author")+ . (if exportWithCreator settings then id else removeMeta "creator")+ . (if exportWithEmail settings then id else removeMeta "email")+ <$> orgStateMeta st++removeMeta :: String -> Meta -> Meta+removeMeta key meta' =+ let metaMap = unMeta meta'+ in Meta $ M.delete key metaMap++-- | Parse and handle a single line containing meta information+-- The order, in which blocks are tried, makes sure that we're not looking at+-- the beginning of a block, so we don't need to check for it+metaLine :: OrgParser Blocks+metaLine = mempty <$ metaLineStart <* (optionLine <|> declarationLine)++declarationLine :: OrgParser ()+declarationLine = try $ do+ key <- map toLower <$> metaKey+ (key', value) <- metaValue key+ updateState $ \st ->+ let meta' = B.setMeta key' <$> value <*> pure nullMeta+ in st { orgStateMeta = meta' <> orgStateMeta st }++metaKey :: OrgParser String+metaKey = map toLower <$> many1 (noneOf ": \n\r")+ <* char ':'+ <* skipSpaces++metaValue :: String -> OrgParser (String, (F MetaValue))+metaValue key =+ let inclKey = "header-includes"+ in case key of+ "author" -> (key,) <$> metaInlinesCommaSeparated+ "title" -> (key,) <$> metaInlines+ "date" -> (key,) <$> metaInlines+ "header-includes" -> (key,) <$> accumulatingList key metaInlines+ "latex_header" -> (inclKey,) <$>+ accumulatingList inclKey (metaExportSnippet "latex")+ "latex_class" -> ("documentclass",) <$> metaString+ -- Org-mode expects class options to contain the surrounding brackets,+ -- pandoc does not.+ "latex_class_options" -> ("classoption",) <$>+ metaModifiedString (filter (`notElem` "[]"))+ "html_head" -> (inclKey,) <$>+ accumulatingList inclKey (metaExportSnippet "html")+ _ -> (key,) <$> metaString++metaInlines :: OrgParser (F MetaValue)+metaInlines = fmap (MetaInlines . B.toList) <$> inlinesTillNewline++metaInlinesCommaSeparated :: OrgParser (F MetaValue)+metaInlinesCommaSeparated = do+ authStrs <- (many1 (noneOf ",\n")) `sepBy1` (char ',')+ newline+ authors <- mapM (parseFromString inlinesTillNewline . (++ "\n")) authStrs+ let toMetaInlines = MetaInlines . B.toList+ return $ MetaList . map toMetaInlines <$> sequence authors++metaString :: OrgParser (F MetaValue)+metaString = metaModifiedString id++metaModifiedString :: (String -> String) -> OrgParser (F MetaValue)+metaModifiedString f = return . MetaString . f <$> anyLine++-- | Read an format specific meta definition+metaExportSnippet :: String -> OrgParser (F MetaValue)+metaExportSnippet format =+ return . MetaInlines . B.toList . B.rawInline format <$> anyLine++-- | Accumulate the result of the @parser@ in a list under @key@.+accumulatingList :: String+ -> OrgParser (F MetaValue)+ -> OrgParser (F MetaValue)+accumulatingList key p = do+ value <- p+ meta' <- orgStateMeta <$> getState+ return $ (\m v -> MetaList (curList m ++ [v])) <$> meta' <*> value+ where curList m = case lookupMeta key m of+ Just (MetaList ms) -> ms+ Just x -> [x]+ _ -> []++--+-- export options+--+optionLine :: OrgParser ()+optionLine = try $ do+ key <- metaKey+ case key of+ "link" -> parseLinkFormat >>= uncurry addLinkFormat+ "options" -> exportSettings+ _ -> mzero++addLinkFormat :: String+ -> (String -> String)+ -> OrgParser ()+addLinkFormat key formatter = updateState $ \s ->+ let fs = orgStateLinkFormatters s+ in s{ orgStateLinkFormatters = M.insert key formatter fs }++parseLinkFormat :: OrgParser ((String, String -> String))+parseLinkFormat = try $ do+ linkType <- (:) <$> letter <*> many (alphaNum <|> oneOf "-_") <* skipSpaces+ linkSubst <- parseFormat+ return (linkType, linkSubst)++-- | An ad-hoc, single-argument-only implementation of a printf-style format+-- parser.+parseFormat :: OrgParser (String -> String)+parseFormat = try $ do+ replacePlain <|> replaceUrl <|> justAppend+ where+ -- inefficient, but who cares+ replacePlain = try $ (\x -> concat . flip intersperse x)+ <$> sequence [tillSpecifier 's', rest]+ replaceUrl = try $ (\x -> concat . flip intersperse x . urlEncode)+ <$> sequence [tillSpecifier 'h', rest]+ justAppend = try $ (++) <$> rest++ rest = manyTill anyChar (eof <|> () <$ oneOf "\n\r")+ tillSpecifier c = manyTill (noneOf "\n\r") (try $ string ('%':c:""))++inlinesTillNewline :: OrgParser (F Inlines)+inlinesTillNewline = trimInlinesF . mconcat <$> manyTill inline newline
src/Text/Pandoc/Readers/Org/ParserState.hs view
@@ -163,6 +163,9 @@ , exportSmartQuotes :: Bool -- ^ Parse quotes smartly , exportSpecialStrings :: Bool -- ^ Parse ellipses and dashes smartly , exportSubSuperscripts :: Bool -- ^ TeX-like syntax for sub- and superscripts+ , exportWithAuthor :: Bool -- ^ Include author in final meta-data+ , exportWithCreator :: Bool -- ^ Include creator in final meta-data+ , exportWithEmail :: Bool -- ^ Include email in final meta-data } instance Default ExportSettings where@@ -177,6 +180,9 @@ , exportSmartQuotes = True , exportSpecialStrings = True , exportSubSuperscripts = True+ , exportWithAuthor = True+ , exportWithCreator = True+ , exportWithEmail = True }
@@ -27,13 +27,15 @@ Utility functions used in other Pandoc Org modules. -} module Text.Pandoc.Readers.Org.Shared- ( isImageFilename+ ( cleanLinkString+ , isImageFilename , rundocBlockClass , toRundocAttrib , translateLang ) where import Control.Arrow ( first )+import Data.Char ( isAlphaNum ) import Data.List ( isPrefixOf, isSuffixOf ) @@ -41,11 +43,30 @@ isImageFilename :: String -> Bool isImageFilename filename = any (\x -> ('.':x) `isSuffixOf` filename) imageExtensions &&- (any (\x -> (x++":") `isPrefixOf` filename) protocols ||+ (any (\x -> (x ++ "://") `isPrefixOf` filename) protocols || ':' `notElem` filename) where imageExtensions = [ "jpeg" , "jpg" , "png" , "gif" , "svg" ] protocols = [ "file", "http", "https" ]++-- | Cleanup and canonicalize a string describing a link. Return @Nothing@ if+-- the string does not appear to be a link.+cleanLinkString :: String -> Maybe String+cleanLinkString s =+ case s of+ '/':_ -> Just $ "file://" ++ s -- absolute path+ '.':'/':_ -> Just s -- relative path+ '.':'.':'/':_ -> Just s -- relative path+ -- Relative path or URL (file schema)+ 'f':'i':'l':'e':':':s' -> Just $ if ("//" `isPrefixOf` s') then s else s'+ _ | isUrl s -> Just s -- URL+ _ -> Nothing+ where+ isUrl :: String -> Bool+ isUrl cs =+ let (scheme, path) = break (== ':') cs+ in all (\c -> isAlphaNum c || c `elem` (".-"::String)) scheme+ && not (null path) -- | Prefix used for Rundoc classes and arguments. rundocPrefix :: String
src/Text/Pandoc/Readers/RST.hs view
@@ -39,7 +39,7 @@ import Text.Pandoc.Parsing import Text.Pandoc.Options import Control.Monad ( when, liftM, guard, mzero )-import Data.List ( findIndex, intersperse, intercalate,+import Data.List ( findIndex, intercalate, transpose, sort, deleteFirstsBy, isSuffixOf , nub, union) import Data.Maybe (fromMaybe) import qualified Data.Map as M@@ -48,7 +48,7 @@ import qualified Text.Pandoc.Builder as B import Data.Sequence (viewr, ViewR(..)) import Data.Char (toLower, isHexDigit, isSpace)-import Text.Pandoc.Compat.Monoid ((<>))+import Data.Monoid ((<>)) import Text.Pandoc.Error -- | Parse reStructuredText string and return Pandoc document.@@ -228,7 +228,7 @@ lineBlock = try $ do lines' <- lineBlockLines lines'' <- mapM parseInlineFromString lines'- return $ B.para (mconcat $ intersperse B.linebreak lines'')+ return $ B.lineBlock lines'' -- -- paragraph block@@ -562,13 +562,11 @@ "rubric" -> B.para . B.strong <$> parseInlineFromString top _ | label `elem` ["attention","caution","danger","error","hint", "important","note","tip","warning"] ->- do let tit = B.para $ B.strong $ B.str label- bod <- parseFromString parseBlocks $ top ++ "\n\n" ++ body'- return $ B.blockQuote $ tit <> bod+ do bod <- parseFromString parseBlocks $ top ++ "\n\n" ++ body'+ return $ B.divWith ("",["admonition", label],[]) bod "admonition" ->- do tit <- B.para . B.strong <$> parseInlineFromString top- bod <- parseFromString parseBlocks body'- return $ B.blockQuote $ tit <> bod+ do bod <- parseFromString parseBlocks $ top ++ "\n\n" ++ body'+ return $ B.divWith ("",["admonition"],[]) bod "sidebar" -> do let subtit = maybe "" trim $ lookup "subtitle" fields tit <- B.para . B.strong <$> parseInlineFromString@@ -576,11 +574,11 @@ then "" else (": " ++ subtit)) bod <- parseFromString parseBlocks body'- return $ B.blockQuote $ tit <> bod+ return $ B.divWith ("",["sidebar"],[]) $ tit <> bod "topic" -> do tit <- B.para . B.strong <$> parseInlineFromString top bod <- parseFromString parseBlocks body'- return $ tit <> bod+ return $ B.divWith ("",["topic"],[]) $ tit <> bod "default-role" -> mempty <$ updateState (\s -> s { stateRstDefaultRole = case trim top of@@ -951,7 +949,8 @@ -- inline :: RSTParser Inlines-inline = choice [ whitespace+inline = choice [ note -- can start with whitespace, so try before ws+ , whitespace , link , str , endline@@ -960,7 +959,6 @@ , code , subst , interpretedRole- , note , smart , hyphens , escapedChar@@ -1176,6 +1174,7 @@ note :: RSTParser Inlines note = try $ do+ optional whitespace ref <- noteMarker char '_' state <- getState
src/Text/Pandoc/Readers/Textile.hs view
@@ -60,12 +60,12 @@ import Text.Pandoc.Readers.HTML ( htmlTag, isBlockTag, isInlineTag ) import Text.Pandoc.Shared (trim) import Text.Pandoc.Readers.LaTeX ( rawLaTeXInline, rawLaTeXBlock )-import Text.HTML.TagSoup (parseTags, innerText, fromAttrib, Tag(..))+import Text.HTML.TagSoup (fromAttrib, Tag(..)) import Text.HTML.TagSoup.Match-import Data.List ( intercalate )+import Data.List ( intercalate, transpose, intersperse ) import Data.Char ( digitToInt, isUpper ) import Control.Monad ( guard, liftM, when )-import Text.Pandoc.Compat.Monoid ((<>))+import Data.Monoid ((<>)) import Text.Printf import Debug.Trace (trace) import Text.Pandoc.Error@@ -134,7 +134,7 @@ , anyList , rawHtmlBlock , rawLaTeXBlock'- , maybeExplicitBlock "table" table+ , table , maybeExplicitBlock "p" para , mempty <$ blanklines ]@@ -161,16 +161,28 @@ codeBlockBc :: Parser [Char] ParserState Blocks codeBlockBc = try $ do- string "bc. "- contents <- manyTill anyLine blanklines- return $ B.codeBlock (unlines contents)+ string "bc."+ extended <- option False (True <$ char '.')+ char ' '+ let starts = ["p", "table", "bq", "bc", "h1", "h2", "h3",+ "h4", "h5", "h6", "pre", "###", "notextile"]+ let ender = choice $ map explicitBlockStart starts+ contents <- if extended+ then do+ f <- anyLine+ rest <- many (notFollowedBy ender *> anyLine)+ return (f:rest)+ else manyTill anyLine blanklines+ return $ B.codeBlock (trimTrailingNewlines (unlines contents)) +trimTrailingNewlines :: String -> String+trimTrailingNewlines = reverse . dropWhile (=='\n') . reverse+ -- | Code Blocks in Textile are between <pre> and </pre> codeBlockPre :: Parser [Char] ParserState Blocks codeBlockPre = try $ do (t@(TagOpen _ attrs),_) <- htmlTag (tagOpen (=="pre") (const True))- result' <- (innerText . parseTags) `fmap` -- remove internal tags- manyTill anyChar (htmlTag (tagClose (=="pre")))+ result' <- manyTill anyChar (htmlTag (tagClose (=="pre"))) optional blanklines -- drop leading newline if any let result'' = case result' of@@ -273,13 +285,20 @@ genericListStart :: Char -> Parser [Char] st () genericListStart c = () <$ try (many1 (char c) >> whitespace) -definitionListStart :: Parser [Char] ParserState Inlines-definitionListStart = try $ do+basicDLStart :: Parser [Char] ParserState ()+basicDLStart = do char '-' whitespace notFollowedBy newline++definitionListStart :: Parser [Char] ParserState Inlines+definitionListStart = try $ do+ basicDLStart trimInlines . mconcat <$>- many1Till inline (try (string ":=")) <* optional whitespace+ many1Till inline+ ( try (newline *> lookAhead basicDLStart)+ <|> try (lookAhead (() <$ string ":="))+ ) listInline :: Parser [Char] ParserState Inlines listInline = try (notFollowedBy newline >> inline)@@ -291,8 +310,8 @@ -- break. definitionListItem :: Parser [Char] ParserState (Inlines, [Blocks]) definitionListItem = try $ do- term <- definitionListStart- def' <- multilineDef <|> inlineDef+ term <- (mconcat . intersperse B.linebreak) <$> many1 definitionListStart+ def' <- string ":=" *> optional whitespace *> (multilineDef <|> inlineDef) return (term, def') where inlineDef :: Parser [Char] ParserState [Blocks] inlineDef = liftM (\d -> [B.plain d])@@ -328,47 +347,94 @@ -- Tables +toAlignment :: Char -> Alignment+toAlignment '<' = AlignLeft+toAlignment '>' = AlignRight+toAlignment '=' = AlignCenter+toAlignment _ = AlignDefault++cellAttributes :: Parser [Char] ParserState (Bool, Alignment)+cellAttributes = try $ do+ isHeader <- option False (True <$ char '_')+ -- we just ignore colspan and rowspan markers:+ optional $ try $ oneOf "/\\" >> many1 digit+ -- we pay attention to alignments:+ alignment <- option AlignDefault $ toAlignment <$> oneOf "<>="+ -- ignore other attributes for now:+ _ <- attributes+ char '.'+ return (isHeader, alignment)+ -- | A table cell spans until a pipe |-tableCell :: Bool -> Parser [Char] ParserState Blocks-tableCell headerCell = try $ do+tableCell :: Parser [Char] ParserState ((Bool, Alignment), Blocks)+tableCell = try $ do char '|'- when headerCell $ () <$ string "_."+ (isHeader, alignment) <- option (False, AlignDefault) $ cellAttributes notFollowedBy blankline raw <- trim <$> many (noneOf "|\n" <|> try (char '\n' <* notFollowedBy blankline)) content <- mconcat <$> parseFromString (many inline) raw- return $ B.plain content+ return ((isHeader, alignment), B.plain content) -- | A table row is made of many table cells-tableRow :: Parser [Char] ParserState [Blocks]-tableRow = many1 (tableCell False) <* char '|' <* newline--tableHeader :: Parser [Char] ParserState [Blocks]-tableHeader = many1 (tableCell True) <* char '|' <* newline+tableRow :: Parser [Char] ParserState [((Bool, Alignment), Blocks)]+tableRow = try $ do+ -- skip optional row attributes+ optional $ try $ do+ _ <- attributes+ char '.'+ many1 spaceChar+ many1 tableCell <* char '|' <* blankline --- | A table with an optional header. Current implementation can--- handle tables with and without header, but will parse cells--- alignment attributes as content.+-- | A table with an optional header. table :: Parser [Char] ParserState Blocks table = try $ do- headers <- option mempty $ tableHeader- rows <- many1 tableRow+ -- ignore table attributes+ caption <- option mempty $ try $ do+ string "table"+ _ <- attributes+ char '.'+ rawcapt <- trim <$> anyLine+ parseFromString (mconcat <$> many inline) rawcapt+ rawrows <- many1 $ (skipMany ignorableRow) >> tableRow+ skipMany ignorableRow blanklines+ let (headers, rows) = case rawrows of+ (toprow:rest) | any (fst . fst) toprow ->+ (toprow, rest)+ _ -> (mempty, rawrows) let nbOfCols = max (length headers) (length $ head rows)- return $ B.table mempty- (zip (replicate nbOfCols AlignDefault) (replicate nbOfCols 0.0))- headers- rows+ let aligns = map minimum $ transpose $ map (map (snd . fst)) (headers:rows)+ return $ B.table caption+ (zip aligns (replicate nbOfCols 0.0))+ (map snd headers)+ (map (map snd) rows) +-- | Ignore markers for cols, thead, tfoot.+ignorableRow :: Parser [Char] ParserState ()+ignorableRow = try $ do+ char '|'+ oneOf ":^-~"+ _ <- attributes+ char '.'+ _ <- anyLine+ return () +explicitBlockStart :: String -> Parser [Char] ParserState ()+explicitBlockStart name = try $ do+ string name+ attributes+ char '.'+ optional whitespace+ optional endline+ -- | Blocks like 'p' and 'table' do not need explicit block tag. -- However, they can be used to set HTML/CSS attributes when needed. maybeExplicitBlock :: String -- ^ block tag name -> Parser [Char] ParserState Blocks -- ^ implicit block -> Parser [Char] ParserState Blocks maybeExplicitBlock name blk = try $ do- optional $ try $ string name >> attributes >> char '.' >>- optional whitespace >> optional endline+ optional $ explicitBlockStart name blk @@ -527,7 +593,7 @@ then char ']' else lookAhead $ space <|> try (oneOf "!.,;:" *> (space <|> newline))- url <- manyTill nonspaceChar stop+ url <- many1Till nonspaceChar stop let name' = if B.toList name == [Str "$"] then B.str url else name return $ if attr == nullAttr then B.link url "" name'
src/Text/Pandoc/Readers/Txt2Tags.hs view
@@ -34,7 +34,7 @@ import qualified Text.Pandoc.Builder as B import Text.Pandoc.Builder ( Inlines, Blocks, trimInlines )-import Text.Pandoc.Compat.Monoid ((<>))+import Data.Monoid ((<>)) import Text.Pandoc.Definition import Text.Pandoc.Options import Text.Pandoc.Shared (escapeURI,compactify', compactify'DL)@@ -49,7 +49,7 @@ import Text.Pandoc.Error import Data.Time.LocalTime (getZonedTime)-import Text.Pandoc.Compat.Directory(getModificationTime)+import System.Directory(getModificationTime) import Data.Time.Format (formatTime) import Text.Pandoc.Compat.Time (defaultTimeLocale) import System.IO.Error (catchIOError)
@@ -64,9 +64,11 @@ compactify, compactify', compactify'DL,+ linesToPara, Element (..), hierarchicalize, uniqueIdent,+ inlineListToIdentifier, isHeaderBlock, headerShift, isTightList,@@ -84,6 +86,7 @@ fetchItem', openURL, collapseFilePath,+ filteredFilesFromArchive, -- * Error handling err, warn,@@ -110,6 +113,7 @@ import Data.Char ( toLower, isLower, isUpper, isAlpha, isLetter, isDigit, isSpace ) import Data.List ( find, stripPrefix, intercalate )+import Data.Maybe (mapMaybe) import Data.Version ( showVersion ) import qualified Data.Map as M import Network.URI ( escapeURIString, nonStrictRelativeTo,@@ -132,7 +136,7 @@ import System.IO.Temp import Text.HTML.TagSoup (renderTagsOptions, RenderOptions(..), Tag(..), renderOptions)-import Text.Pandoc.Compat.Monoid ((<>))+import Data.Monoid ((<>)) import qualified Data.ByteString as BS import qualified Data.ByteString.Char8 as B8 import Data.ByteString.Base64 (decodeLenient)@@ -152,16 +156,8 @@ #ifdef HTTP_CLIENT import Network.HTTP.Client (httpLbs, responseBody, responseHeaders, Request(port,host))-#if MIN_VERSION_http_client(0,4,30) import Network.HTTP.Client (parseRequest)-#else-import Network.HTTP.Client (parseUrl)-#endif-#if MIN_VERSION_http_client(0,4,18) import Network.HTTP.Client (newManager)-#else-import Network.HTTP.Client (withManager)-#endif import Network.HTTP.Client.Internal (addProxy) import Network.HTTP.Client.TLS (tlsManagerSettings) import System.Environment (getEnv)@@ -639,6 +635,15 @@ | otherwise -> items _ -> items +-- | Combine a list of lines by adding hard linebreaks.+combineLines :: [[Inline]] -> [Inline]+combineLines = intercalate [LineBreak]++-- | Convert a list of lines into a paragraph with hard line breaks. This is+-- useful e.g. for rudimentary support of LineBlock elements in writers.+linesToPara :: [[Inline]] -> Block+linesToPara = Para . combineLines+ isPara :: Block -> Bool isPara (Para _) = True isPara _ = False@@ -873,7 +878,7 @@ go as x = x : as #else getDataFileName fname' >>= checkExistence >>= BS.readFile- where fname' = if fname == "README" then fname else "data" </> fname+ where fname' = if fname == "MANUAL.txt" then fname else "data" </> fname checkExistence :: FilePath -> IO FilePath checkExistence fn = do@@ -956,11 +961,7 @@ in return $ Right (decodeLenient contents, Just mime) #ifdef HTTP_CLIENT | otherwise = withSocketsDo $ E.try $ do-#if MIN_VERSION_http_client(0,4,30) let parseReq = parseRequest-#else- let parseReq = parseUrl-#endif (proxy :: Either E.SomeException String) <- E.try $ getEnv "http_proxy" req <- parseReq u req' <- case proxy of@@ -968,11 +969,7 @@ Right pr -> (parseReq pr >>= \r -> return $ addProxy (host r) (port r) req) `mplus` return req-#if MIN_VERSION_http_client(0,4,18) resp <- newManager tlsManagerSettings >>= httpLbs req'-#else- resp <- withManager tlsManagerSettings $ httpLbs req'-#endif return (BS.concat $ toChunks $ responseBody resp, UTF8.toString `fmap` lookup hContentType (responseHeaders resp)) #else@@ -1037,6 +1034,16 @@ isSingleton _ = Nothing checkPathSeperator = fmap isPathSeparator . isSingleton +--+-- File selection from the archive+--+filteredFilesFromArchive :: Archive -> (FilePath -> Bool) -> [(FilePath, BL.ByteString)]+filteredFilesFromArchive zf f =+ mapMaybe (fileAndBinary zf) (filter f (filesInArchive zf))+ where+ fileAndBinary :: Archive -> FilePath -> Maybe (FilePath, BL.ByteString)+ fileAndBinary a fp = findEntryByPath fp a >>= \e -> Just (fp, fromEntry e)+ --- --- Squash blocks into inlines ---@@ -1044,6 +1051,7 @@ blockToInlines :: Block -> [Inline] blockToInlines (Plain ils) = ils blockToInlines (Para ils) = ils+blockToInlines (LineBlock lns) = combineLines lns blockToInlines (CodeBlock attr str) = [Code attr str] blockToInlines (RawBlock fmt str) = [RawInline fmt str] blockToInlines (BlockQuote blks) = blocksToInlines blks@@ -1071,7 +1079,7 @@ blocksToInlines :: [Block] -> [Inline] blocksToInlines = blocksToInlinesWithSep [Space, Str "¶", Space]- + -- -- Safe read
src/Text/Pandoc/Templates.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE TypeSynonymInstances, FlexibleInstances, CPP,+{-# LANGUAGE TypeSynonymInstances, FlexibleInstances, OverloadedStrings, GeneralizedNewtypeDeriving #-} {- Copyright (C) 2009-2016 John MacFarlane <jgm@berkeley.edu>@@ -28,96 +28,25 @@ Portability : portable A simple templating system with variable substitution and conditionals.-The following program illustrates its use: -> {-# LANGUAGE OverloadedStrings #-}-> import Data.Text-> import Data.Aeson-> import Text.Pandoc.Templates->-> data Employee = Employee { firstName :: String-> , lastName :: String-> , salary :: Maybe Int }-> instance ToJSON Employee where-> toJSON e = object [ "name" .= object [ "first" .= firstName e-> , "last" .= lastName e ]-> , "salary" .= salary e ]->-> employees :: [Employee]-> employees = [ Employee "John" "Doe" Nothing-> , Employee "Omar" "Smith" (Just 30000)-> , Employee "Sara" "Chen" (Just 60000) ]->-> template :: Template-> template = either error id $ compileTemplate-> "$for(employee)$Hi, $employee.name.first$. $if(employee.salary)$You make $employee.salary$.$else$No salary data.$endif$$sep$\n$endfor$"->-> main = putStrLn $ renderTemplate template $ object ["employee" .= employees ]--A slot for an interpolated variable is a variable name surrounded-by dollar signs. To include a literal @$@ in your template, use-@$$@. Variable names must begin with a letter and can contain letters,-numbers, @_@, @-@, and @.@.--The values of variables are determined by a JSON object that is-passed as a parameter to @renderTemplate@. So, for example,-@title@ will return the value of the @title@ field, and-@employee.salary@ will return the value of the @salary@ field-of the object that is the value of the @employee@ field.--The value of a variable will be indented to the same level as the-variable.--A conditional begins with @$if(variable_name)$@ and ends with @$endif$@.-It may optionally contain an @$else$@ section. The if section is-used if @variable_name@ has a non-null value, otherwise the else section-is used.--Conditional keywords should not be indented, or unexpected spacing-problems may occur.--The @$for$@ keyword can be used to iterate over an array. If-the value of the associated variable is not an array, a single-iteration will be performed on its value.--You may optionally specify separators using @$sep$@, as in the-example above.- -} module Text.Pandoc.Templates ( renderTemplate , renderTemplate'- , TemplateTarget(..)+ , TemplateTarget , varListToJSON , compileTemplate , Template , getDefaultTemplate ) where -import Data.Char (isAlphaNum)-import Control.Monad (guard, when)-import Data.Aeson (ToJSON(..), Value(..))-import qualified Text.Parsec as P-import Text.Parsec.Text (Parser)-import Text.Pandoc.Compat.Monoid ((<>))+import Text.DocTemplates (Template, TemplateTarget, compileTemplate,+ renderTemplate, applyTemplate,+ varListToJSON)+import Data.Aeson (ToJSON(..)) import qualified Data.Text as T-import Data.Text (Text)-import Data.Text.Encoding (encodeUtf8)-import Data.List (intersperse) import System.FilePath ((</>), (<.>))-import qualified Data.Map as M-import qualified Data.HashMap.Strict as H-import Data.Foldable (toList) import qualified Control.Exception.Extensible as E (try, IOException)-#if MIN_VERSION_blaze_html(0,5,0)-import Text.Blaze.Html (Html)-import Text.Blaze.Internal (preEscapedText)-#else-import Text.Blaze (preEscapedText, Html)-#endif-import Data.ByteString.Lazy (ByteString, fromChunks)-import Text.Pandoc.Shared (readDataFileUTF8, ordNub)-import Data.Vector ((!?))-import Control.Applicative (many, (<|>))+import Text.Pandoc.Shared (readDataFileUTF8) -- | Get default template for the specified writer. getDefaultTemplate :: (Maybe FilePath) -- ^ User data directory to search first@@ -139,191 +68,7 @@ _ -> let fname = "templates" </> "default" <.> format in E.try $ readDataFileUTF8 user fname -newtype Template = Template { unTemplate :: Value -> Text }- deriving Monoid--type Variable = [Text]--class TemplateTarget a where- toTarget :: Text -> a--instance TemplateTarget Text where- toTarget = id--instance TemplateTarget String where- toTarget = T.unpack--instance TemplateTarget ByteString where- toTarget = fromChunks . (:[]) . encodeUtf8--instance TemplateTarget Html where- toTarget = preEscapedText--varListToJSON :: [(String, String)] -> Value-varListToJSON assoc = toJSON $ M.fromList assoc'- where assoc' = [(T.pack k, toVal [T.pack z | (y,z) <- assoc,- not (null z),- y == k])- | k <- ordNub $ map fst assoc ]- toVal [x] = toJSON x- toVal [] = Null- toVal xs = toJSON xs--renderTemplate :: (ToJSON a, TemplateTarget b) => Template -> a -> b-renderTemplate (Template f) context = toTarget $ f $ toJSON context--compileTemplate :: Text -> Either String Template-compileTemplate template =- case P.parse (pTemplate <* P.eof) "template" template of- Left e -> Left (show e)- Right x -> Right x---- | Like 'renderTemplate', but compiles the template first,--- raising an error if compilation fails.+-- | Like 'applyTemplate', but raising an error if compilation fails. renderTemplate' :: (ToJSON a, TemplateTarget b) => String -> a -> b-renderTemplate' template =- renderTemplate (either error id $ compileTemplate $ T.pack template)--var :: Variable -> Template-var = Template . resolveVar--resolveVar :: Variable -> Value -> Text-resolveVar var' val =- case multiLookup var' val of- Just (Array vec) -> maybe mempty (resolveVar []) $ vec !? 0- Just (String t) -> T.stripEnd t- Just (Number n) -> T.pack $ show n- Just (Bool True) -> "true"- Just (Object _) -> "true"- Just _ -> mempty- Nothing -> mempty--multiLookup :: [Text] -> Value -> Maybe Value-multiLookup [] x = Just x-multiLookup (v:vs) (Object o) = H.lookup v o >>= multiLookup vs-multiLookup _ _ = Nothing--lit :: Text -> Template-lit = Template . const--cond :: Variable -> Template -> Template -> Template-cond var' (Template ifyes) (Template ifno) = Template $ \val ->- case resolveVar var' val of- "" -> ifno val- _ -> ifyes val--iter :: Variable -> Template -> Template -> Template-iter var' template sep = Template $ \val -> unTemplate- (case multiLookup var' val of- Just (Array vec) -> mconcat $ intersperse sep- $ map (setVar template var')- $ toList vec- Just x -> cond var' (setVar template var' x) mempty- Nothing -> mempty) val--setVar :: Template -> Variable -> Value -> Template-setVar (Template f) var' val = Template $ f . replaceVar var' val--replaceVar :: Variable -> Value -> Value -> Value-replaceVar [] new _ = new-replaceVar (v:vs) new (Object o) =- Object $ H.adjust (\x -> replaceVar vs new x) v o-replaceVar _ _ old = old----- parsing--pTemplate :: Parser Template-pTemplate = do- sp <- P.option mempty pInitialSpace- rest <- mconcat <$> many (pConditional <|>- pFor <|>- pNewline <|>- pVar <|>- pLit <|>- pEscapedDollar)- return $ sp <> rest--takeWhile1 :: (Char -> Bool) -> Parser Text-takeWhile1 f = T.pack <$> P.many1 (P.satisfy f)--pLit :: Parser Template-pLit = lit <$> takeWhile1 (\x -> x /='$' && x /= '\n')--pNewline :: Parser Template-pNewline = do- P.char '\n'- sp <- P.option mempty pInitialSpace- return $ lit "\n" <> sp--pInitialSpace :: Parser Template-pInitialSpace = do- sps <- takeWhile1 (==' ')- let indentVar = if T.null sps- then id- else indent (T.length sps)- v <- P.option mempty $ indentVar <$> pVar- return $ lit sps <> v--pEscapedDollar :: Parser Template-pEscapedDollar = lit "$" <$ P.try (P.string "$$")--pVar :: Parser Template-pVar = var <$> (P.try $ P.char '$' *> pIdent <* P.char '$')--pIdent :: Parser [Text]-pIdent = do- first <- pIdentPart- rest <- many (P.char '.' *> pIdentPart)- return (first:rest)--pIdentPart :: Parser Text-pIdentPart = P.try $ do- first <- P.letter- rest <- T.pack <$> P.many (P.satisfy (\c -> isAlphaNum c || c == '_' || c == '-'))- let id' = T.singleton first <> rest- guard $ id' `notElem` reservedWords- return id'--reservedWords :: [Text]-reservedWords = ["else","endif","for","endfor","sep"]--skipEndline :: Parser ()-skipEndline = P.try $ P.skipMany (P.satisfy (`elem` (" \t" :: String))) >> P.char '\n' >> return ()--pConditional :: Parser Template-pConditional = do- P.try $ P.string "$if("- id' <- pIdent- P.string ")$"- -- if newline after the "if", then a newline after "endif" will be swallowed- multiline <- P.option False (True <$ skipEndline)- ifContents <- pTemplate- elseContents <- P.option mempty $ P.try $- do P.string "$else$"- when multiline $ P.option () skipEndline- pTemplate- P.string "$endif$"- when multiline $ P.option () skipEndline- return $ cond id' ifContents elseContents--pFor :: Parser Template-pFor = do- P.try $ P.string "$for("- id' <- pIdent- P.string ")$"- -- if newline after the "for", then a newline after "endfor" will be swallowed- multiline <- P.option False $ skipEndline >> return True- contents <- pTemplate- sep <- P.option mempty $- do P.try $ P.string "$sep$"- when multiline $ P.option () skipEndline- pTemplate- P.string "$endfor$"- when multiline $ P.option () skipEndline- return $ iter id' contents sep+renderTemplate' template = either error id . applyTemplate (T.pack template) -indent :: Int -> Template -> Template-indent 0 x = x-indent ind (Template f) = Template $ \val -> indent' (f val)- where indent' t = T.concat- $ intersperse ("\n" <> T.replicate ind " ") $ T.lines t
src/Text/Pandoc/UTF8.hs view
@@ -1,4 +1,3 @@-{-# LANGUAGE CPP #-} {- Copyright (C) 2010-2016 John MacFarlane <jgm@berkeley.edu> @@ -116,11 +115,7 @@ fromStringLazy = TL.encodeUtf8 . TL.pack encodePath :: FilePath -> FilePath-decodeArg :: String -> String-#if MIN_VERSION_base(4,4,0) encodePath = id++decodeArg :: String -> String decodeArg = id-#else-encodePath = B.unpack . fromString-decodeArg = toString . B.pack-#endif
src/Text/Pandoc/Writers/AsciiDoc.hs view
@@ -51,6 +51,7 @@ import qualified Data.Map as M import Data.Aeson (Value(String), fromJSON, toJSON, Result(..)) import qualified Data.Text as T+import Data.Char (isSpace, isPunctuation) data WriterState = WriterState { defListMarker :: String , orderedListLevel :: Int@@ -136,6 +137,13 @@ then text "\\" else empty return $ esc <> contents <> blankline+blockToAsciiDoc opts (LineBlock lns) = do+ let docify line = if null line+ then return blankline+ else inlineListToAsciiDoc opts line+ let joinWithLinefeeds = nowrap . mconcat . intersperse cr+ contents <- joinWithLinefeeds <$> mapM docify lns+ return $ "[verse]" $$ text "--" $$ contents $$ text "--" $$ blankline blockToAsciiDoc _ (RawBlock f s) | f == "asciidoc" = return $ text s | otherwise = return empty@@ -321,6 +329,8 @@ -> State WriterState Doc blockListToAsciiDoc opts blocks = cat `fmap` mapM (blockToAsciiDoc opts) blocks +data SpacyLocation = End | Start+ -- | Convert list of Pandoc inline elements to asciidoc. inlineListToAsciiDoc :: WriterOptions -> [Inline] -> State WriterState Doc inlineListToAsciiDoc opts lst = do@@ -331,14 +341,14 @@ return result where go [] = return empty go (y:x:xs)- | not (isSpacy y) = do- y' <- if isSpacy x+ | not (isSpacy End y) = do+ y' <- if isSpacy Start x then inlineToAsciiDoc opts y else withIntraword $ inlineToAsciiDoc opts y x' <- withIntraword $ inlineToAsciiDoc opts x xs' <- go xs return (y' <> x' <> xs')- | not (isSpacy x) = do+ | not (isSpacy Start x) = do y' <- withIntraword $ inlineToAsciiDoc opts y xs' <- go (x:xs) return (y' <> xs')@@ -346,10 +356,17 @@ x' <- inlineToAsciiDoc opts x xs' <- go xs return (x' <> xs')- isSpacy Space = True- isSpacy LineBreak = True- isSpacy SoftBreak = True- isSpacy _ = False+ isSpacy :: SpacyLocation -> Inline -> Bool+ isSpacy _ Space = True+ isSpacy _ LineBreak = True+ isSpacy _ SoftBreak = True+ -- Note that \W characters count as spacy in AsciiDoc+ -- for purposes of determining interword:+ isSpacy End (Str xs) = case reverse xs of+ c:_ -> isPunctuation c || isSpace c+ _ -> False+ isSpacy Start (Str (c:_)) = isPunctuation c || isSpace c+ isSpacy _ _ = False setIntraword :: Bool -> State WriterState () setIntraword b = modify $ \st -> st{ intraword = b }@@ -449,4 +466,3 @@ let identifier = if (null ident) then empty else ("[[" <> text ident <> "]]") contents <- inlineListToAsciiDoc opts ils return $ identifier <> contents-
src/Text/Pandoc/Writers/CommonMark.hs view
@@ -33,7 +33,7 @@ import Text.Pandoc.Writers.HTML (writeHtmlString) import Text.Pandoc.Definition-import Text.Pandoc.Shared (isTightList)+import Text.Pandoc.Shared (isTightList, linesToPara) import Text.Pandoc.Templates (renderTemplate') import Text.Pandoc.Writers.Shared import Text.Pandoc.Options@@ -94,6 +94,7 @@ blockToNodes :: Block -> [Node] -> [Node] blockToNodes (Plain xs) = (node PARAGRAPH (inlinesToNodes xs) :) blockToNodes (Para xs) = (node PARAGRAPH (inlinesToNodes xs) :)+blockToNodes (LineBlock lns) = blockToNodes $ linesToPara lns blockToNodes (CodeBlock (_,classes,_) xs) = (node (CODE_BLOCK (T.pack (unwords classes)) (T.pack xs)) [] :) blockToNodes (RawBlock fmt xs)
src/Text/Pandoc/Writers/ConTeXt.hs view
@@ -83,9 +83,10 @@ ] let context = defField "toc" (writerTableOfContents options) $ defField "placelist" (intercalate ("," :: String) $- take (writerTOCDepth options + if writerChapters options- then 0- else 1)+ take (writerTOCDepth options ++ if writerTopLevelDivision options < Section+ then 0+ else 1) ["chapter","section","subsection","subsubsection", "subsubsubsection","subsubsubsubsection"]) $ defField "body" main@@ -163,6 +164,9 @@ blockToConTeXt (Para lst) = do contents <- inlineListToConTeXt lst return $ contents <> blankline+blockToConTeXt (LineBlock lns) = do+ doclines <- nowrap . vcat <$> mapM inlineListToConTeXt lns+ return $ "\\startlines" $$ doclines $$ "\\stoplines" <> blankline blockToConTeXt (BlockQuote lst) = do contents <- blockListToConTeXt lst return $ "\\startblockquote" $$ nest 0 contents $$ "\\stopblockquote" <> blankline@@ -409,7 +413,7 @@ Nothing -> txt fmap (wrapLang . wrapDir) $ inlineListToConTeXt ils --- | Craft the section header, inserting the secton reference, if supplied.+-- | Craft the section header, inserting the section reference, if supplied. sectionHeader :: Attr -> Int -> [Inline]@@ -418,21 +422,26 @@ contents <- inlineListToConTeXt lst st <- get let opts = stOptions st- let level' = if writerChapters opts then hdrLevel - 1 else hdrLevel+ let level' = case writerTopLevelDivision opts of+ Part -> hdrLevel - 2+ Chapter -> hdrLevel - 1+ Section -> hdrLevel let ident' = toLabel ident let (section, chapter) = if "unnumbered" `elem` classes then (text "subject", text "title") else (text "section", text "chapter")- return $ if level' >= 1 && level' <= 5- then char '\\'- <> text (concat (replicate (level' - 1) "sub"))- <> section- <> (if (not . null) ident' then brackets (text ident') else empty)- <> braces contents- <> blankline- else if level' == 0- then char '\\' <> chapter <> braces contents- else contents <> blankline+ return $ case level' of+ -1 -> text "\\part" <> braces contents+ 0 -> char '\\' <> chapter <> braces contents+ n | n >= 1 && n <= 5 -> char '\\'+ <> text (concat (replicate (n - 1) "sub"))+ <> section+ <> (if (not . null) ident'+ then brackets (text ident')+ else empty)+ <> braces contents+ <> blankline+ _ -> contents <> blankline fromBcp47' :: String -> String fromBcp47' = fromBcp47 . splitBy (=='-')@@ -467,4 +476,3 @@ fromIso "vi" = "vn" fromIso "zh" = "cn" fromIso l = l-
src/Text/Pandoc/Writers/Custom.hs view
@@ -227,6 +227,8 @@ blockToCustom lua (Para inlines) = callfunc lua "Para" inlines +blockToCustom lua (LineBlock linesList) = callfunc lua "LineBlock" linesList+ blockToCustom lua (RawBlock format str) = callfunc lua "RawBlock" format str
src/Text/Pandoc/Writers/Docbook.hs view
@@ -79,12 +79,16 @@ colwidth = if writerWrapText opts == WrapAuto then Just $ writerColumns opts else Nothing- render' = render colwidth- opts' = if "/book>" `isSuffixOf`- (trimr $ writerTemplate opts)- then opts{ writerChapters = True }- else opts- startLvl = if writerChapters opts' then 0 else 1+ render' = render colwidth+ opts' = if ("/book>" `isSuffixOf` (trimr $ writerTemplate opts) &&+ writerTopLevelDivision opts >= Section)+ then opts{ writerTopLevelDivision = Chapter }+ else opts+ -- The numbering here follows LaTeX's internal numbering+ startLvl = case writerTopLevelDivision opts' of+ Part -> -1+ Chapter -> 0+ Section -> 1 auths' = map (authorToDocbook opts) $ docAuthors meta meta' = B.setMeta "author" auths' meta Just metadata = metaToJSON opts@@ -111,11 +115,12 @@ then [Blk (Para [])] else elements tag = case lvl of- n | n == 0 -> "chapter"- | n >= 1 && n <= 5 -> if writerDocbook5 opts+ -1 -> "part"+ 0 -> "chapter"+ n | n >= 1 && n <= 5 -> if writerDocbook5 opts then "section" else "sect" ++ show n- | otherwise -> "simplesect"+ _ -> "simplesect" idAttr = [("id", writerIdentifierPrefix opts ++ id') | not (null id')] nsAttr = if writerDocbook5 opts && lvl == 0 then [("xmlns", "http://docbook.org/ns/docbook"),("xmlns:xlink", "http://www.w3.org/1999/xlink")] else []@@ -176,7 +181,11 @@ then flush $ nowrap $ inTags False "literallayout" attribs $ inlinesToDocbook opts lst else inTags True "para" attribs $ inlinesToDocbook opts lst-blockToDocbook opts (Div _ bs) = blocksToDocbook opts $ map plainToPara bs+blockToDocbook opts (Div (ident,_,_) bs) =+ (if null ident+ then mempty+ else selfClosingTag "anchor" [("id", ident)]) $$+ blocksToDocbook opts (map plainToPara bs) blockToDocbook _ (Header _ _ _) = empty -- should not occur after hierarchicalize blockToDocbook opts (Plain lst) = inlinesToDocbook opts lst -- title beginning with fig: indicates that the image is a figure@@ -194,6 +203,8 @@ blockToDocbook opts (Para lst) | hasLineBreaks lst = flush $ nowrap $ inTagsSimple "literallayout" $ inlinesToDocbook opts lst | otherwise = inTagsIndented "para" $ inlinesToDocbook opts lst+blockToDocbook opts (LineBlock lns) =+ blockToDocbook opts $ linesToPara lns blockToDocbook opts (BlockQuote blocks) = inTagsIndented "blockquote" $ blocksToDocbook opts blocks blockToDocbook _ (CodeBlock (_,classes,_) str) =@@ -313,7 +324,10 @@ inTagsSimple "quote" $ inlinesToDocbook opts lst inlineToDocbook opts (Cite _ lst) = inlinesToDocbook opts lst-inlineToDocbook opts (Span _ ils) =+inlineToDocbook opts (Span (ident,_,_) ils) =+ (if null ident+ then mempty+ else selfClosingTag "anchor" [("id", ident)]) <> inlinesToDocbook opts ils inlineToDocbook _ (Code _ str) = inTagsSimple "literal" $ text (escapeStringForXML str)@@ -378,4 +392,3 @@ role = if null cls then [] else [("role", unwords cls)]-
src/Text/Pandoc/Writers/Docx.hs view
@@ -54,18 +54,19 @@ import Text.TeXMath import Text.Pandoc.Readers.Docx.StyleMap import Text.Pandoc.Readers.Docx.Util (elemName)+import Control.Monad.Reader import Control.Monad.State import Text.Highlighting.Kate import Data.Unique (hashUnique, newUnique) import System.Random (randomRIO) import Text.Printf (printf) import qualified Control.Exception as E-import Text.Pandoc.Compat.Monoid ((<>))+import Data.Monoid ((<>)) import Text.Pandoc.MIME (MimeType, getMimeType, getMimeTypeDef, extensionFromMimeType) import Control.Applicative ((<|>))-import Data.Maybe (fromMaybe, mapMaybe, maybeToList)-import Data.Char (ord)+import Data.Maybe (fromMaybe, mapMaybe, maybeToList, isNothing)+import Data.Char (ord, isSpace, toLower) data ListMarker = NoMarker | BulletMarker@@ -91,50 +92,61 @@ OneParen -> '2' TwoParens -> '3' +data WriterEnv = WriterEnv{ envTextProperties :: [Element]+ , envParaProperties :: [Element]+ , envRTL :: Bool+ , envListLevel :: Int+ , envListNumId :: Int+ , envInDel :: Bool+ , envChangesAuthor :: String+ , envChangesDate :: String+ , envPrintWidth :: Integer+ }++defaultWriterEnv :: WriterEnv+defaultWriterEnv = WriterEnv{ envTextProperties = []+ , envParaProperties = []+ , envRTL = False+ , envListLevel = -1+ , envListNumId = 1+ , envInDel = False+ , envChangesAuthor = "unknown"+ , envChangesDate = "1969-12-31T19:00:00Z"+ , envPrintWidth = 1+ }+ data WriterState = WriterState{- stTextProperties :: [Element]- , stParaProperties :: [Element]- , stFootnotes :: [Element]+ stFootnotes :: [Element] , stSectionIds :: Set.Set String , stExternalLinks :: M.Map String String , stImages :: M.Map FilePath (String, String, Maybe MimeType, Element, B.ByteString)- , stListLevel :: Int- , stListNumId :: Int , stLists :: [ListMarker] , stInsId :: Int , stDelId :: Int- , stInDel :: Bool- , stChangesAuthor :: String- , stChangesDate :: String- , stPrintWidth :: Integer , stStyleMaps :: StyleMaps , stFirstPara :: Bool , stTocTitle :: [Inline]+ , stDynamicParaProps :: [String]+ , stDynamicTextProps :: [String] } defaultWriterState :: WriterState defaultWriterState = WriterState{- stTextProperties = []- , stParaProperties = []- , stFootnotes = defaultFootnotes+ stFootnotes = defaultFootnotes , stSectionIds = Set.empty , stExternalLinks = M.empty , stImages = M.empty- , stListLevel = -1- , stListNumId = 1 , stLists = [NoMarker] , stInsId = 1 , stDelId = 1- , stInDel = False- , stChangesAuthor = "unknown"- , stChangesDate = "1969-12-31T19:00:00Z"- , stPrintWidth = 1 , stStyleMaps = defaultStyleMaps , stFirstPara = False , stTocTitle = normalizeInlines [Str "Table of Contents"]+ , stDynamicParaProps = []+ , stDynamicTextProps = [] } -type WS a = StateT WriterState IO a+type WS = ReaderT WriterEnv (StateT WriterState IO) mknode :: Node t => String -> [(String,String)] -> t -> Element mknode s attrs =@@ -245,13 +257,29 @@ let tocTitle = fromMaybe (stTocTitle defaultWriterState) $ metaValueToInlines <$> lookupMeta "toc-title" meta - ((contents, footnotes), st) <- runStateT (writeOpenXML opts{writerWrapText = WrapNone} doc')- defaultWriterState{ stChangesAuthor = fromMaybe "unknown" username- , stChangesDate = formatTime defaultTimeLocale "%FT%XZ" utctime- , stPrintWidth = (maybe 420 (\x -> quot x 20) pgContentWidth)- , stStyleMaps = styleMaps- , stTocTitle = tocTitle- }+ let initialSt = defaultWriterState {+ stStyleMaps = styleMaps+ , stTocTitle = tocTitle+ }++ let isRTLmeta = case lookupMeta "dir" meta of+ Just (MetaString "rtl") -> True+ Just (MetaInlines [Str "rtl"]) -> True+ _ -> False++ let env = defaultWriterEnv {+ envRTL = isRTLmeta+ , envChangesAuthor = fromMaybe "unknown" username+ , envChangesDate = formatTime defaultTimeLocale "%FT%XZ" utctime+ , envPrintWidth = (maybe 420 (\x -> quot x 20) pgContentWidth)+ }+++ ((contents, footnotes), st) <- runStateT+ (runReaderT+ (writeOpenXML opts{writerWrapText = WrapNone} doc')+ env)+ initialSt let epochtime = floor $ utcTimeToPOSIXSeconds utctime let imgs = M.elems $ stImages st @@ -404,7 +432,21 @@ linkrels -- styles- let newstyles = styleToOpenXml styleMaps $ writerHighlightStyle opts++ -- We only want to inject paragraph and text properties that+ -- are not already in the style map. Note that keys in the stylemap+ -- are normalized as lowercase.+ let newDynamicParaProps = filter+ (\sty -> isNothing $ M.lookup (toLower <$> sty) $ getMap $ sParaStyleMap styleMaps)+ (stDynamicParaProps st)++ newDynamicTextProps = filter+ (\sty -> isNothing $ M.lookup (toLower <$> sty) $ getMap $ sCharStyleMap styleMaps)+ (stDynamicTextProps st)++ let newstyles = map newParaPropToOpenXml newDynamicParaProps +++ map newTextPropToOpenXml newDynamicTextProps +++ (styleToOpenXml styleMaps $ writerHighlightStyle opts) let styledoc' = styledoc{ elContent = modifyContent (elContent styledoc) } where modifyContent@@ -499,6 +541,28 @@ miscRelEntries ++ otherMediaEntries return $ fromArchive archive ++newParaPropToOpenXml :: String -> Element+newParaPropToOpenXml s =+ let styleId = filter (not . isSpace) s+ in mknode "w:style" [ ("w:type", "paragraph")+ , ("w:customStyle", "1")+ , ("w:styleId", styleId)]+ [ mknode "w:name" [("w:val", s)] ()+ , mknode "w:basedOn" [("w:val","BodyText")] ()+ , mknode "w:qFormat" [] ()+ ]++newTextPropToOpenXml :: String -> Element+newTextPropToOpenXml s =+ let styleId = filter (not . isSpace) s+ in mknode "w:style" [ ("w:type", "character")+ , ("w:customStyle", "1")+ , ("w:styleId", styleId)]+ [ mknode "w:name" [("w:val", s)] ()+ , mknode "w:basedOn" [("w:val","BodyTextChar")] ()+ ]+ styleToOpenXml :: StyleMaps -> Style -> [Element] styleToOpenXml sm style = maybeToList parStyle ++ mapMaybe toStyle alltoktypes@@ -722,17 +786,36 @@ -- already in word/document.xml.rel getUniqueId = liftIO $ (show . (+ 20) . hashUnique) `fmap` newUnique +-- | Key for specifying user-defined docx styles.+dynamicStyleKey :: String+dynamicStyleKey = "custom-style"+ -- | Convert a Pandoc block element to OpenXML. blockToOpenXML :: WriterOptions -> Block -> WS [Element]-blockToOpenXML _ Null = return []-blockToOpenXML opts (Div (_,["references"],_) bs) = do+blockToOpenXML opts blk = withDirection $ blockToOpenXML' opts blk++blockToOpenXML' :: WriterOptions -> Block -> WS [Element]+blockToOpenXML' _ Null = return []+blockToOpenXML' opts (Div (ident,classes,kvs) bs)+ | Just sty <- lookup dynamicStyleKey kvs = do+ modify $ \s -> s{stDynamicParaProps = sty : (stDynamicParaProps s)}+ withParaPropM (pStyleM sty) $ blocksToOpenXML opts bs+ | Just "rtl" <- lookup "dir" kvs = do+ let kvs' = filter (("dir", "rtl")/=) kvs+ local (\env -> env { envRTL = True }) $+ blockToOpenXML opts (Div (ident,classes,kvs') bs)+ | Just "ltr" <- lookup "dir" kvs = do+ let kvs' = filter (("dir", "ltr")/=) kvs+ local (\env -> env { envRTL = False }) $+ blockToOpenXML opts (Div (ident,classes,kvs') bs)+blockToOpenXML' opts (Div (_,["references"],_) bs) = do let (hs, bs') = span isHeaderBlock bs header <- blocksToOpenXML opts hs -- We put the Bibliography style on paragraphs after the header rest <- withParaPropM (pStyleM "Bibliography") $ blocksToOpenXML opts bs' return (header ++ rest)-blockToOpenXML opts (Div _ bs) = blocksToOpenXML opts bs-blockToOpenXML opts (Header lev (ident,_,_) lst) = do+blockToOpenXML' opts (Div _ bs) = blocksToOpenXML opts bs+blockToOpenXML' opts (Header lev (ident,_,_) lst) = do setFirstPara paraProps <- withParaPropM (pStyleM ("Heading "++show lev)) $ getParaProps False@@ -747,24 +830,23 @@ ,("w:name",bookmarkName)] () let bookmarkEnd = mknode "w:bookmarkEnd" [("w:id", id')] () return [mknode "w:p" [] (paraProps ++ [bookmarkStart, bookmarkEnd] ++ contents)]-blockToOpenXML opts (Plain lst) = withParaProp (pCustomStyle "Compact")+blockToOpenXML' opts (Plain lst) = withParaProp (pCustomStyle "Compact") $ blockToOpenXML opts (Para lst) -- title beginning with fig: indicates that the image is a figure-blockToOpenXML opts (Para [Image attr alt (src,'f':'i':'g':':':tit)]) = do+blockToOpenXML' opts (Para [Image attr alt (src,'f':'i':'g':':':tit)]) = do setFirstPara- pushParaProp $ pCustomStyle $- if null alt- then "Figure"- else "FigureWithCaption"- paraProps <- getParaProps False- popParaProp+ let prop = pCustomStyle $+ if null alt+ then "Figure"+ else "FigureWithCaption"+ paraProps <- local (\env -> env { envParaProperties = prop : envParaProperties env }) (getParaProps False) contents <- inlinesToOpenXML opts [Image attr alt (src,tit)] captionNode <- withParaProp (pCustomStyle "ImageCaption") $ blockToOpenXML opts (Para alt) return $ mknode "w:p" [] (paraProps ++ contents) : captionNode -- fixDisplayMath sometimes produces a Para [] as artifact-blockToOpenXML _ (Para []) = return []-blockToOpenXML opts (Para lst) = do+blockToOpenXML' _ (Para []) = return []+blockToOpenXML' opts (Para lst) = do isFirstPara <- gets stFirstPara paraProps <- getParaProps $ case lst of [Math DisplayMath _] -> True@@ -777,25 +859,26 @@ modify $ \s -> s { stFirstPara = False } contents <- inlinesToOpenXML opts lst return [mknode "w:p" [] (paraProps' ++ contents)]-blockToOpenXML _ (RawBlock format str)+blockToOpenXML' opts (LineBlock lns) = blockToOpenXML opts $ linesToPara lns+blockToOpenXML' _ (RawBlock format str) | format == Format "openxml" = return [ x | Elem x <- parseXML str ] | otherwise = return []-blockToOpenXML opts (BlockQuote blocks) = do+blockToOpenXML' opts (BlockQuote blocks) = do p <- withParaPropM (pStyleM "Block Text") $ blocksToOpenXML opts blocks setFirstPara return p-blockToOpenXML opts (CodeBlock attrs str) = do+blockToOpenXML' opts (CodeBlock attrs str) = do p <- withParaProp (pCustomStyle "SourceCode") (blockToOpenXML opts $ Para [Code attrs str]) setFirstPara return p-blockToOpenXML _ HorizontalRule = do+blockToOpenXML' _ HorizontalRule = do setFirstPara return [ mknode "w:p" [] $ mknode "w:r" [] $ mknode "w:pict" [] $ mknode "v:rect" [("style","width:0;height:1.5pt"), ("o:hralign","center"), ("o:hrstd","t"),("o:hr","t")] () ]-blockToOpenXML opts (Table caption aligns widths headers rows) = do+blockToOpenXML' opts (Table caption aligns widths headers rows) = do setFirstPara let captionStr = stringify caption caption' <- if null caption@@ -843,21 +926,21 @@ : [ mkrow True headers' | hasHeader ] ++ map (mkrow False) rows' )]-blockToOpenXML opts (BulletList lst) = do+blockToOpenXML' opts (BulletList lst) = do let marker = BulletMarker addList marker numid <- getNumId l <- asList $ concat `fmap` mapM (listItemToOpenXML opts numid) lst setFirstPara return l-blockToOpenXML opts (OrderedList (start, numstyle, numdelim) lst) = do+blockToOpenXML' opts (OrderedList (start, numstyle, numdelim) lst) = do let marker = NumberMarker numstyle numdelim start addList marker numid <- getNumId l <- asList $ concat `fmap` mapM (listItemToOpenXML opts numid) lst setFirstPara return l-blockToOpenXML opts (DefinitionList items) = do+blockToOpenXML' opts (DefinitionList items) = do l <- concat `fmap` mapM (definitionListItemToOpenXML opts) items setFirstPara return l@@ -895,49 +978,30 @@ inlinesToOpenXML opts lst = concat `fmap` mapM (inlineToOpenXML opts) lst withNumId :: Int -> WS a -> WS a-withNumId numid p = do- origNumId <- gets stListNumId- modify $ \st -> st{ stListNumId = numid }- result <- p- modify $ \st -> st{ stListNumId = origNumId }- return result+withNumId numid = local $ \env -> env{ envListNumId = numid } asList :: WS a -> WS a-asList p = do- origListLevel <- gets stListLevel- modify $ \st -> st{ stListLevel = stListLevel st + 1 }- result <- p- modify $ \st -> st{ stListLevel = origListLevel }- return result+asList = local $ \env -> env{ envListLevel = envListLevel env + 1 } getTextProps :: WS [Element] getTextProps = do- props <- gets stTextProperties+ props <- asks envTextProperties return $ if null props then [] else [mknode "w:rPr" [] props] -pushTextProp :: Element -> WS ()-pushTextProp d = modify $ \s -> s{ stTextProperties = d : stTextProperties s }--popTextProp :: WS ()-popTextProp = modify $ \s -> s{ stTextProperties = drop 1 $ stTextProperties s }- withTextProp :: Element -> WS a -> WS a-withTextProp d p = do- pushTextProp d- res <- p- popTextProp- return res+withTextProp d p =+ local (\env -> env {envTextProperties = d : envTextProperties env}) p withTextPropM :: WS Element -> WS a -> WS a withTextPropM = (. flip withTextProp) . (>>=) getParaProps :: Bool -> WS [Element] getParaProps displayMathPara = do- props <- gets stParaProperties- listLevel <- gets stListLevel- numid <- gets stListNumId+ props <- asks envParaProperties+ listLevel <- asks envListLevel+ numid <- asks envListNumId let listPr = if listLevel >= 0 && not displayMathPara then [ mknode "w:numPr" [] [ mknode "w:numId" [("w:val",show numid)] ()@@ -948,18 +1012,9 @@ [] -> [] ps -> [mknode "w:pPr" [] ps] -pushParaProp :: Element -> WS ()-pushParaProp d = modify $ \s -> s{ stParaProperties = d : stParaProperties s }--popParaProp :: WS ()-popParaProp = modify $ \s -> s{ stParaProperties = drop 1 $ stParaProperties s }- withParaProp :: Element -> WS a -> WS a-withParaProp d p = do- pushParaProp d- res <- p- popParaProp- return res+withParaProp d p =+ local (\env -> env {envParaProperties = d : envParaProperties env}) p withParaPropM :: WS Element -> WS a -> WS a withParaPropM = (. flip withParaProp) . (>>=)@@ -967,7 +1022,7 @@ formattedString :: String -> WS [Element] formattedString str = do props <- getTextProps- inDel <- gets stInDel+ inDel <- asks envInDel return [ mknode "w:r" [] $ props ++ [ mknode (if inDel then "w:delText" else "w:t")@@ -978,13 +1033,29 @@ -- | Convert an inline element to OpenXML. inlineToOpenXML :: WriterOptions -> Inline -> WS [Element]-inlineToOpenXML _ (Str str) = formattedString str-inlineToOpenXML opts Space = inlineToOpenXML opts (Str " ")-inlineToOpenXML opts SoftBreak = inlineToOpenXML opts (Str " ")-inlineToOpenXML opts (Span (_,classes,kvs) ils)+inlineToOpenXML opts il = withDirection $ inlineToOpenXML' opts il++inlineToOpenXML' :: WriterOptions -> Inline -> WS [Element]+inlineToOpenXML' _ (Str str) = formattedString str+inlineToOpenXML' opts Space = inlineToOpenXML opts (Str " ")+inlineToOpenXML' opts SoftBreak = inlineToOpenXML opts (Str " ")+inlineToOpenXML' opts (Span (ident,classes,kvs) ils)+ | Just sty <- lookup dynamicStyleKey kvs = do+ let kvs' = filter ((dynamicStyleKey, sty)/=) kvs+ modify $ \s -> s{stDynamicTextProps = sty : (stDynamicTextProps s)}+ withTextProp (rCustomStyle sty) $+ inlineToOpenXML opts (Span (ident,classes,kvs') ils)+ | Just "rtl" <- lookup "dir" kvs = do+ let kvs' = filter (("dir", "rtl")/=) kvs+ local (\env -> env { envRTL = True }) $+ inlineToOpenXML opts (Span (ident,classes,kvs') ils)+ | Just "ltr" <- lookup "dir" kvs = do+ let kvs' = filter (("dir", "ltr")/=) kvs+ local (\env -> env { envRTL = False }) $+ inlineToOpenXML opts (Span (ident,classes,kvs') ils) | "insertion" `elem` classes = do- defaultAuthor <- gets stChangesAuthor- defaultDate <- gets stChangesDate+ defaultAuthor <- asks envChangesAuthor+ defaultDate <- asks envChangesDate let author = fromMaybe defaultAuthor (lookup "author" kvs) date = fromMaybe defaultDate (lookup "date" kvs) insId <- gets stInsId@@ -995,15 +1066,13 @@ ("w:date", date)] x ] | "deletion" `elem` classes = do- defaultAuthor <- gets stChangesAuthor- defaultDate <- gets stChangesDate+ defaultAuthor <- asks envChangesAuthor+ defaultDate <- asks envChangesDate let author = fromMaybe defaultAuthor (lookup "author" kvs) date = fromMaybe defaultDate (lookup "date" kvs) delId <- gets stDelId modify $ \s -> s{stDelId = (delId + 1)}- modify $ \s -> s{stInDel = True}- x <- inlinesToOpenXML opts ils- modify $ \s -> s{stInDel = False}+ x <- local (\env -> env {envInDel = True}) (inlinesToOpenXML opts ils) return [ mknode "w:del" [("w:id", (show delId)), ("w:author", author), ("w:date", date)]@@ -1014,32 +1083,32 @@ (if "csl-no-strong" `elem` classes then off "w:b" else id) . (if "csl-no-smallcaps" `elem` classes then off "w:smallCaps" else id)) $ inlinesToOpenXML opts ils-inlineToOpenXML opts (Strong lst) =+inlineToOpenXML' opts (Strong lst) = withTextProp (mknode "w:b" [] ()) $ inlinesToOpenXML opts lst-inlineToOpenXML opts (Emph lst) =+inlineToOpenXML' opts (Emph lst) = withTextProp (mknode "w:i" [] ()) $ inlinesToOpenXML opts lst-inlineToOpenXML opts (Subscript lst) =+inlineToOpenXML' opts (Subscript lst) = withTextProp (mknode "w:vertAlign" [("w:val","subscript")] ()) $ inlinesToOpenXML opts lst-inlineToOpenXML opts (Superscript lst) =+inlineToOpenXML' opts (Superscript lst) = withTextProp (mknode "w:vertAlign" [("w:val","superscript")] ()) $ inlinesToOpenXML opts lst-inlineToOpenXML opts (SmallCaps lst) =+inlineToOpenXML' opts (SmallCaps lst) = withTextProp (mknode "w:smallCaps" [] ()) $ inlinesToOpenXML opts lst-inlineToOpenXML opts (Strikeout lst) =+inlineToOpenXML' opts (Strikeout lst) = withTextProp (mknode "w:strike" [] ()) $ inlinesToOpenXML opts lst-inlineToOpenXML _ LineBreak = return [br]-inlineToOpenXML _ (RawInline f str)+inlineToOpenXML' _ LineBreak = return [br]+inlineToOpenXML' _ (RawInline f str) | f == Format "openxml" = return [ x | Elem x <- parseXML str ] | otherwise = return []-inlineToOpenXML opts (Quoted quoteType lst) =+inlineToOpenXML' opts (Quoted quoteType lst) = inlinesToOpenXML opts $ [Str open] ++ lst ++ [Str close] where (open, close) = case quoteType of SingleQuote -> ("\x2018", "\x2019") DoubleQuote -> ("\x201C", "\x201D")-inlineToOpenXML opts (Math mathType str) = do+inlineToOpenXML' opts (Math mathType str) = do let displayType = if mathType == DisplayMath then DisplayBlock else DisplayInline@@ -1047,8 +1116,8 @@ case writeOMML displayType <$> readTeX str of Right r -> return [r] Left _ -> inlinesToOpenXML opts (texMathToInlines mathType str)-inlineToOpenXML opts (Cite _ lst) = inlinesToOpenXML opts lst-inlineToOpenXML opts (Code attrs str) = do+inlineToOpenXML' opts (Cite _ lst) = inlinesToOpenXML opts lst+inlineToOpenXML' opts (Code attrs str) = do let unhighlighted = intercalate [br] `fmap` (mapM formattedString $ lines str) formatOpenXML _fmtOpts = intercalate [br] . map (map toHlTok)@@ -1062,7 +1131,7 @@ Nothing -> unhighlighted Just h -> return h else unhighlighted-inlineToOpenXML opts (Note bs) = do+inlineToOpenXML' opts (Note bs) = do notes <- gets stFootnotes notenum <- getUniqueId footnoteStyle <- rStyleM "Footnote Reference"@@ -1073,25 +1142,23 @@ let insertNoteRef (Plain ils : xs) = Plain (notemarkerXml : Space : ils) : xs insertNoteRef (Para ils : xs) = Para (notemarkerXml : Space : ils) : xs insertNoteRef xs = Para [notemarkerXml] : xs- oldListLevel <- gets stListLevel- oldParaProperties <- gets stParaProperties- oldTextProperties <- gets stTextProperties- modify $ \st -> st{ stListLevel = -1, stParaProperties = [], stTextProperties = [] }- contents <- withParaPropM (pStyleM "Footnote Text") $ blocksToOpenXML opts- $ insertNoteRef bs- modify $ \st -> st{ stListLevel = oldListLevel, stParaProperties = oldParaProperties,- stTextProperties = oldTextProperties }++ contents <- local (\env -> env{ envListLevel = -1+ , envParaProperties = []+ , envTextProperties = [] })+ (withParaPropM (pStyleM "Footnote Text") $ blocksToOpenXML opts+ $ insertNoteRef bs) let newnote = mknode "w:footnote" [("w:id", notenum)] $ contents modify $ \s -> s{ stFootnotes = newnote : notes } return [ mknode "w:r" [] [ mknode "w:rPr" [] footnoteStyle , mknode "w:footnoteReference" [("w:id", notenum)] () ] ] -- internal link:-inlineToOpenXML opts (Link _ txt ('#':xs,_)) = do+inlineToOpenXML' opts (Link _ txt ('#':xs,_)) = do contents <- withTextPropM (rStyleM "Hyperlink") $ inlinesToOpenXML opts txt return [ mknode "w:hyperlink" [("w:anchor",xs)] contents ] -- external link:-inlineToOpenXML opts (Link _ txt (src,_)) = do+inlineToOpenXML' opts (Link _ txt (src,_)) = do contents <- withTextPropM (rStyleM "Hyperlink") $ inlinesToOpenXML opts txt extlinks <- gets stExternalLinks id' <- case M.lookup src extlinks of@@ -1102,9 +1169,9 @@ M.insert src i extlinks } return i return [ mknode "w:hyperlink" [("r:id",id')] contents ]-inlineToOpenXML opts (Image attr alt (src, _)) = do+inlineToOpenXML' opts (Image attr alt (src, _)) = do -- first, check to see if we've already done this image- pageWidth <- gets stPrintWidth+ pageWidth <- asks envPrintWidth imgs <- gets stImages case M.lookup src imgs of Just (_,_,_,elt,_) -> return [elt]@@ -1212,3 +1279,23 @@ | x > fromIntegral pageWidth = (pageWidth, floor $ ((fromIntegral pageWidth) / x) * y) | otherwise = (floor x, floor y)++withDirection :: WS a -> WS a+withDirection x = do+ isRTL <- asks envRTL+ paraProps <- asks envParaProperties+ textProps <- asks envTextProperties+ -- We want to clean all bidirection (bidi) and right-to-left (rtl)+ -- properties from the props first. This is because we don't want+ -- them to stack up.+ let paraProps' = filter (\e -> (qName . elName) e /= "bidi") paraProps+ textProps' = filter (\e -> (qName . elName) e /= "rtl") textProps+ if isRTL+ -- if we are going right-to-left, we (re?)add the properties.+ then flip local x $+ \env -> env { envParaProperties = (mknode "w:bidi" [] ()) : paraProps'+ , envTextProperties = (mknode "w:rtl" [] ()) : textProps'+ }+ else flip local x $ \env -> env { envParaProperties = paraProps'+ , envTextProperties = textProps'+ }
src/Text/Pandoc/Writers/DokuWiki.hs view
@@ -45,8 +45,8 @@ , writerStandalone , writerTemplate , writerWrapText), WrapOption(..) )-import Text.Pandoc.Shared ( escapeURI, removeFormatting, camelCaseToHyphenated- , trimr, normalize, substitute )+import Text.Pandoc.Shared ( escapeURI, linesToPara, removeFormatting+ , camelCaseToHyphenated, trimr, normalize, substitute ) import Text.Pandoc.Writers.Shared ( defField, metaToJSON ) import Text.Pandoc.ImageSize import Text.Pandoc.Templates ( renderTemplate' )@@ -146,6 +146,9 @@ return $ if useTags then "<HTML><p></HTML>" ++ contents ++ "<HTML></p></HTML>" else contents ++ if null indent then "\n" else ""++blockToDokuWiki opts (LineBlock lns) =+ blockToDokuWiki opts $ linesToPara lns blockToDokuWiki _ (RawBlock f str) | f == Format "dokuwiki" = return str
src/Text/Pandoc/Writers/EPUB.hs view
@@ -57,8 +57,6 @@ , ObfuscationMethod(NoObfuscation) ) import Text.Pandoc.Definition import Text.Pandoc.Walk (walk, walkM, query)-import Data.Default-import Text.Pandoc.Writers.Markdown (writePlain) import Control.Monad.State (modify, get, State, put, evalState) import Control.Monad (mplus, liftM, when) import Text.XML.Light ( unode, Element(..), unqual, Attr(..), add_attrs@@ -228,10 +226,10 @@ metaValueToString :: MetaValue -> String metaValueToString (MetaString s) = s-metaValueToString (MetaInlines ils) = writePlain def- (Pandoc nullMeta [Plain ils])-metaValueToString (MetaBlocks bs) = writePlain def (Pandoc nullMeta bs)-metaValueToString (MetaBool b) = show b+metaValueToString (MetaInlines ils) = stringify ils+metaValueToString (MetaBlocks bs) = stringify bs+metaValueToString (MetaBool True) = "true"+metaValueToString (MetaBool False) = "false" metaValueToString _ = "" getList :: String -> Meta -> (MetaValue -> a) -> [a]
src/Text/Pandoc/Writers/FB2.hs view
@@ -46,7 +46,8 @@ import Text.Pandoc.Definition import Text.Pandoc.Options (WriterOptions(..), HTMLMathMethod(..), def)-import Text.Pandoc.Shared (orderedListMarkers, isHeaderBlock, capitalize)+import Text.Pandoc.Shared (orderedListMarkers, isHeaderBlock, capitalize,+ linesToPara) -- | Data to be written at the end of the document: -- (foot)notes, URLs, references, images.@@ -323,6 +324,7 @@ map (el "p" . el "code") . lines $ s blockToXml (Div _ bs) = cMapM blockToXml bs blockToXml (BlockQuote bs) = liftM (list . el "cite") $ cMapM blockToXml bs+blockToXml (LineBlock lns) = blockToXml $ linesToPara lns blockToXml (OrderedList a bss) = do state <- get let pmrk = parentListMarker state
src/Text/Pandoc/Writers/HTML.hs view
@@ -31,7 +31,7 @@ -} module Text.Pandoc.Writers.HTML ( writeHtml , writeHtmlString ) where import Text.Pandoc.Definition-import Text.Pandoc.Compat.Monoid ((<>))+import Data.Monoid ((<>)) import Text.Pandoc.Shared import Text.Pandoc.Writers.Shared import Text.Pandoc.Options@@ -278,15 +278,13 @@ let slide = writerSlideVariant opts /= NoSlides && level <= slideLevel let num' = zipWith (+) num (writerNumberOffset opts ++ repeat 0) modify $ \st -> st{stSecNum = num'} -- update section number- -- always use level 1 for slide titles- let level' = if slide then 1 else level let titleSlide = slide && level < slideLevel header' <- if title' == [Str "\0"] -- marker for hrule then return mempty else do modify (\st -> st{ stElement = True}) res <- blockToHtml opts- (Header level' (id',classes,keyvals) title')+ (Header level (id',classes,keyvals) title') modify (\st -> st{ stElement = False}) return res @@ -463,6 +461,13 @@ blockToHtml opts (Para lst) = do contents <- inlineListToHtml opts lst return $ H.p contents+blockToHtml opts (LineBlock lns) =+ if writerWrapText opts == WrapNone+ then blockToHtml opts $ linesToPara lns+ else do+ let lf = preEscapedString "\n"+ htmlLines <- mconcat . intersperse lf <$> mapM (inlineListToHtml opts) lns+ return $ H.div ! A.style "white-space: pre-line;" $ htmlLines blockToHtml opts (Div attr@(ident, classes, kvs) bs) = do let speakerNotes = "notes" `elem` classes -- we don't want incremental output inside speaker notes, see #1394@@ -807,7 +812,7 @@ let brtag = if writerHtml5 opts then H5.br else H.br return $ case t of InlineMath -> m- DisplayMath -> brtag >> m >> brtag + DisplayMath -> brtag >> m >> brtag (RawInline f str) | f == Format "html" -> return $ preEscapedString str | otherwise -> return mempty
src/Text/Pandoc/Writers/Haddock.hs view
@@ -108,6 +108,8 @@ blockToHaddock opts (Para inlines) = -- TODO: if it contains linebreaks, we need to use a @...@ block (<> blankline) `fmap` blockToHaddock opts (Plain inlines)+blockToHaddock opts (LineBlock lns) =+ blockToHaddock opts $ linesToPara lns blockToHaddock _ (RawBlock f str) | f == "haddock" = do return $ text str <> text "\n"
src/Text/Pandoc/Writers/ICML.hs view
@@ -2,7 +2,7 @@ {- | Module : Text.Pandoc.Writers.ICML- Copyright : Copyright (C) 2013 github.com/mb21+ Copyright : Copyright (C) 2013-2016 github.com/mb21 License : GNU GPL, version 2 or above Stability : alpha@@ -18,7 +18,7 @@ import Text.Pandoc.XML import Text.Pandoc.Readers.TeXMath (texMathToInlines) import Text.Pandoc.Writers.Shared-import Text.Pandoc.Shared (splitBy, fetchItem, warn)+import Text.Pandoc.Shared (linesToPara, splitBy, fetchItem, warn) import Text.Pandoc.Options import Text.Pandoc.Templates (renderTemplate') import Text.Pandoc.Pretty@@ -297,6 +297,8 @@ caption <- parStyle opts (imgCaptionName:style) txt return $ intersperseBrs [figure, caption] blockToICML opts style (Para lst) = parStyle opts (paragraphName:style) lst+blockToICML opts style (LineBlock lns) =+ blockToICML opts style $ linesToPara lns blockToICML opts style (CodeBlock _ str) = parStyle opts (codeBlockName:style) $ [Str str] blockToICML _ _ (RawBlock f str) | f == Format "icml" = return $ text str@@ -321,13 +323,13 @@ else length $ head rows rowsToICML [] _ = return empty rowsToICML (col:rest) rowNr =- liftM2 ($$) (colsToICML col rowNr (0::Int)) $ rowsToICML rest (rowNr+1)- colsToICML [] _ _ = return empty- colsToICML (cell:rest) rowNr colNr = do+ liftM2 ($$) (colsToICML col aligns rowNr (0::Int)) $ rowsToICML rest (rowNr+1)+ colsToICML [] _ _ _ = return empty+ colsToICML _ [] _ _ = return empty+ colsToICML (cell:rest) (alig:restAligns) rowNr colNr = do let stl = if rowNr == 0 && not noHeader then tableHeaderName:style' else style'- alig = aligns !! colNr stl' | alig == AlignLeft = alignLeftName : stl | alig == AlignRight = alignRightName : stl | alig == AlignCenter = alignCenterName : stl@@ -335,7 +337,7 @@ c <- blocksToICML opts stl' cell let cl = return $ inTags True "Cell" [("Name", show colNr ++":"++ show rowNr), ("AppliedCellStyle","CellStyle/Cell")] c- liftM2 ($$) cl $ colsToICML rest rowNr (colNr+1)+ liftM2 ($$) cl $ colsToICML rest restAligns rowNr (colNr+1) in do let tabl = if noHeader then rows
src/Text/Pandoc/Writers/LaTeX.hs view
@@ -87,7 +87,8 @@ stOptions = options, stVerbInNote = False, stTable = False, stStrikeout = False, stUrl = False, stGraphics = False,- stLHS = False, stBook = writerChapters options,+ stLHS = False,+ stBook = writerTopLevelDivision options < Section, stCsquotes = False, stHighlighting = False, stIncremental = writerIncremental options, stInternalLinks = [], stUsesEuro = False }@@ -276,6 +277,7 @@ '€' -> "\\euro{}" ++ rest '{' -> "\\{" ++ rest '}' -> "\\}" ++ rest+ '`' | ctx == CodeString -> "\\textasciigrave{}" ++ rest '$' | not isUrl -> "\\$" ++ rest '%' -> "\\%" ++ rest '&' -> "\\&" ++ rest@@ -296,6 +298,7 @@ ']' -> "{]}" ++ rest -- optional arguments '\'' | ctx == CodeString -> "\\textquotesingle{}" ++ rest '\160' -> "~" ++ rest+ '\x202F' -> "\\," ++ rest '\x2026' -> "\\ldots{}" ++ rest '\x2018' | ligatures -> "`" ++ rest '\x2019' | ligatures -> "'" ++ rest@@ -421,7 +424,7 @@ lab <- labelFor ident let caption = "\\caption" <> captForLof <> braces capt <> lab figure <- hypertarget ident (cr <>- "\\begin{figure}[htbp]" $$ "\\centering" $$ img $$+ "\\begin{figure}" $$ "\\centering" $$ img $$ caption $$ "\\end{figure}" <> cr) return $ if inNote -- can't have figures in notes@@ -435,6 +438,8 @@ else inlineListToLaTeX [Str ".",Space,Str ".",Space,Str "."] blockToLaTeX (Para lst) = inlineListToLaTeX $ dropWhile isLineBreakOrSpace lst+blockToLaTeX (LineBlock lns) = do+ blockToLaTeX $ linesToPara lns blockToLaTeX (BlockQuote lst) = do beamer <- writerBeamer `fmap` gets stOptions case lst of@@ -732,7 +737,6 @@ noNote x = x let lstNoNotes = walk noNote lst txtNoNotes <- inlineListToLaTeX lstNoNotes- let star = if unnumbered then text "*" else empty -- footnotes in sections don't work (except for starred variants) -- unless you specify an optional argument: -- \section[mysec]{mysec\footnote{blah}}@@ -745,13 +749,20 @@ else braces (text "\\texorpdfstring" <> braces txt <> braces (text plain))- let stuffing = star <> optional <> contents book <- gets stBook opts <- gets stOptions- let level' = if book || writerChapters opts then level - 1 else level+ let topLevelDivision = min (if book then Chapter else Section)+ (writerTopLevelDivision opts)+ let level' = if writerBeamer opts && topLevelDivision < Section+ -- beamer has parts but no chapters+ then if level == 1 then -1 else level - 1+ else case topLevelDivision of+ Part -> level - 2+ Chapter -> level - 1+ Section -> level let sectionType = case level' of- 0 | writerBeamer opts -> "part"- | otherwise -> "chapter"+ -1 -> "part"+ 0 -> "chapter" 1 -> "section" 2 -> "subsection" 3 -> "subsubsection"@@ -765,6 +776,8 @@ -- see http://tex.stackexchange.com/questions/169830/ else empty lab <- labelFor ident+ let star = if unnumbered && level < 4 then text "*" else empty+ let stuffing = star <> optional <> contents stuffing' <- hypertarget ident $ text ('\\':sectionType) <> stuffing <> lab return $ if level' > 5 then txt
src/Text/Pandoc/Writers/Man.hs view
@@ -41,7 +41,6 @@ import Text.Pandoc.Pretty import Text.Pandoc.Builder (deleteMeta) import Control.Monad.State-import Data.Char ( isDigit ) type Notes = [[Block]] data WriterState = WriterState { stNotes :: Notes@@ -62,10 +61,11 @@ let title' = render' titleText let setFieldsFromTitle = case break (== ' ') title' of- (cmdName, rest) -> case reverse cmdName of- (')':d:'(':xs) | isDigit d ->- defField "title" (reverse xs) .- defField "section" [d] .+ (cmdName, rest) -> case break (=='(') cmdName of+ (xs, '(':ys) | not (null ys) &&+ last ys == ')' ->+ defField "title" xs .+ defField "section" (init ys) . case splitBy (=='|') rest of (ft:hds) -> defField "footer" (trim ft) .@@ -171,6 +171,8 @@ contents <- liftM vcat $ mapM (inlineListToMan opts) $ splitSentences inlines return $ text ".PP" $$ contents+blockToMan opts (LineBlock lns) =+ blockToMan opts $ linesToPara lns blockToMan _ (RawBlock f str) | f == Format "man" = return $ text str | otherwise = return empty@@ -367,4 +369,3 @@ notes <- liftM stNotes get let ref = show $ (length notes) return $ char '[' <> text ref <> char ']'-
src/Text/Pandoc/Writers/Markdown.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE OverloadedStrings, TupleSections, ScopedTypeVariables #-}+{-# LANGUAGE OverloadedStrings, TupleSections, ScopedTypeVariables, MultiWayIf #-} {- Copyright (C) 2006-2015 John MacFarlane <jgm@berkeley.edu> @@ -44,6 +44,7 @@ import Data.Char ( isSpace, isPunctuation, ord, chr ) import Data.Ord ( comparing ) import Text.Pandoc.Pretty+import Control.Monad.Reader import Control.Monad.State import Text.Pandoc.Writers.HTML (writeHtmlString) import Text.Pandoc.Readers.TeXMath (texMathToInlines)@@ -60,30 +61,52 @@ type Notes = [[Block]] type Ref = ([Inline], Target, Attr) type Refs = [Ref]-data WriterState = WriterState { stNotes :: Notes- , stRefs :: Refs- , stRefShortcutable :: Bool- , stInList :: Bool- , stIds :: Set.Set String- , stPlain :: Bool }++type MD = ReaderT WriterEnv (State WriterState)++evalMD :: MD a -> WriterEnv -> WriterState -> a+evalMD md env st = evalState (runReaderT md env) st++data WriterEnv = WriterEnv { envInList :: Bool+ , envPlain :: Bool+ , envRefShortcutable :: Bool+ , envBlockLevel :: Int+ }++instance Default WriterEnv+ where def = WriterEnv { envInList = False+ , envPlain = False+ , envRefShortcutable = True+ , envBlockLevel = 0+ }++data WriterState = WriterState { stNotes :: Notes+ , stRefs :: Refs+ , stIds :: Set.Set String+ , stNoteNum :: Int+ }+ instance Default WriterState- where def = WriterState{ stNotes = [], stRefs = [], stRefShortcutable = True,- stInList = False, stIds = Set.empty, stPlain = False }+ where def = WriterState{ stNotes = []+ , stRefs = []+ , stIds = Set.empty+ , stNoteNum = 1+ } -- | Convert Pandoc to Markdown. writeMarkdown :: WriterOptions -> Pandoc -> String writeMarkdown opts document =- evalState (pandocToMarkdown opts{- writerWrapText = if isEnabled Ext_hard_line_breaks opts- then WrapNone- else writerWrapText opts }- document) def+ evalMD (pandocToMarkdown opts{+ writerWrapText = if isEnabled Ext_hard_line_breaks opts+ then WrapNone+ else writerWrapText opts }+ document) def def -- | Convert Pandoc to plain text (like markdown, but without links, -- pictures, or inline formatting). writePlain :: WriterOptions -> Pandoc -> String writePlain opts document =- evalState (pandocToMarkdown opts document) def{ stPlain = True }+ evalMD (pandocToMarkdown opts document) def{ envPlain = True } def pandocTitleBlock :: Doc -> [Doc] -> Doc -> Doc pandocTitleBlock tit auths dat =@@ -146,12 +169,12 @@ jsonToYaml _ = empty -- | Return markdown representation of document.-pandocToMarkdown :: WriterOptions -> Pandoc -> State WriterState String+pandocToMarkdown :: WriterOptions -> Pandoc -> MD String pandocToMarkdown opts (Pandoc meta blocks) = do let colwidth = if writerWrapText opts == WrapAuto then Just $ writerColumns opts else Nothing- isPlain <- gets stPlain+ isPlain <- asks envPlain metadata <- metaToJSON opts (fmap (render colwidth) . blockListToMarkdown opts) (fmap (render colwidth) . inlineListToMarkdown opts)@@ -181,15 +204,10 @@ _ -> blocks else blocks body <- blockListToMarkdown opts blocks'- st <- get- notes' <- notesToMarkdown opts (reverse $ stNotes st)- st' <- get -- note that the notes may contain refs- refs' <- refsToMarkdown opts (reverse $ stRefs st')+ notesAndRefs' <- notesAndRefs opts let render' :: Doc -> String render' = render colwidth- let main = render' $ body <>- (if isEmpty notes' then empty else blankline <> notes') <>- (if isEmpty refs' then empty else blankline <> refs')+ let main = render' $ body <> notesAndRefs' let context = defField "toc" (render' toc) $ defField "body" main $ (if isNullMeta meta@@ -201,13 +219,13 @@ else return main -- | Return markdown representation of reference key table.-refsToMarkdown :: WriterOptions -> Refs -> State WriterState Doc+refsToMarkdown :: WriterOptions -> Refs -> MD Doc refsToMarkdown opts refs = mapM (keyToMarkdown opts) refs >>= return . vcat -- | Return markdown representation of a reference key. keyToMarkdown :: WriterOptions -> Ref- -> State WriterState Doc+ -> MD Doc keyToMarkdown opts (label, (src, tit), attr) = do label' <- inlineListToMarkdown opts label let tit' = if null tit@@ -218,13 +236,15 @@ <> linkAttributes opts attr -- | Return markdown representation of notes.-notesToMarkdown :: WriterOptions -> [[Block]] -> State WriterState Doc-notesToMarkdown opts notes =- mapM (\(num, note) -> noteToMarkdown opts num note) (zip [1..] notes) >>=- return . vsep+notesToMarkdown :: WriterOptions -> [[Block]] -> MD Doc+notesToMarkdown opts notes = do+ n <- gets stNoteNum+ notes' <- mapM (\(num, note) -> noteToMarkdown opts num note) (zip [n..] notes)+ modify $ \st -> st { stNoteNum = stNoteNum st + length notes }+ return $ vsep notes' -- | Return markdown representation of a note.-noteToMarkdown :: WriterOptions -> Int -> [Block] -> State WriterState Doc+noteToMarkdown :: WriterOptions -> Int -> [Block] -> MD Doc noteToMarkdown opts num blocks = do contents <- blockListToMarkdown opts blocks let num' = text $ writerIdentifierPrefix opts ++ show num@@ -261,7 +281,7 @@ tableOfContents opts headers = let opts' = opts { writerIgnoreNotes = True } contents = BulletList $ map (elementToListItem opts) $ hierarchicalize headers- in evalState (blockToMarkdown opts' contents) def+ in evalMD (blockToMarkdown opts' contents) def def -- | Converts an Element to a list item for a table of contents, elementToListItem :: WriterOptions -> Element -> [Block]@@ -312,22 +332,50 @@ Left _ -> False Right _ -> True +notesAndRefs :: WriterOptions -> MD Doc+notesAndRefs opts = do+ notes' <- reverse <$> gets stNotes >>= notesToMarkdown opts+ modify $ \s -> s { stNotes = [] }+ refs' <- reverse <$> gets stRefs >>= refsToMarkdown opts+ modify $ \s -> s { stRefs = [] }++ let endSpacing =+ if | writerReferenceLocation opts == EndOfDocument -> empty+ | isEmpty notes' && isEmpty refs' -> empty+ | otherwise -> blankline+ + return $+ (if isEmpty notes' then empty else blankline <> notes') <>+ (if isEmpty refs' then empty else blankline <> refs') <>+ endSpacing+ -- | Convert Pandoc block element to markdown. blockToMarkdown :: WriterOptions -- ^ Options -> Block -- ^ Block element- -> State WriterState Doc-blockToMarkdown _ Null = return empty-blockToMarkdown opts (Div attrs ils) = do+ -> MD Doc+blockToMarkdown opts blk =+ local (\env -> env {envBlockLevel = envBlockLevel env + 1}) $+ do doc <- blockToMarkdown' opts blk+ blkLevel <- asks envBlockLevel+ if writerReferenceLocation opts == EndOfBlock && blkLevel == 1+ then notesAndRefs opts >>= (\d -> return $ doc <> d)+ else return doc++blockToMarkdown' :: WriterOptions -- ^ Options+ -> Block -- ^ Block element+ -> MD Doc+blockToMarkdown' _ Null = return empty+blockToMarkdown' opts (Div attrs ils) = do contents <- blockListToMarkdown opts ils return $ if isEnabled Ext_raw_html opts && isEnabled Ext_markdown_in_html_blocks opts then tagWithAttrs "div" attrs <> blankline <> contents <> blankline <> "</div>" <> blankline else contents <> blankline-blockToMarkdown opts (Plain inlines) = do+blockToMarkdown' opts (Plain inlines) = do contents <- inlineListToMarkdown opts inlines -- escape if para starts with ordered list marker- st <- get+ isPlain <- asks envPlain let colwidth = if writerWrapText opts == WrapAuto then Just $ writerColumns opts else Nothing@@ -336,33 +384,47 @@ | otherwise = x : escapeDelimiter xs escapeDelimiter [] = [] let contents' = if isEnabled Ext_all_symbols_escapable opts &&- not (stPlain st) && beginsWithOrderedListMarker rendered+ not isPlain && beginsWithOrderedListMarker rendered then text $ escapeDelimiter rendered else contents return $ contents' <> cr -- title beginning with fig: indicates figure-blockToMarkdown opts (Para [Image attr alt (src,'f':'i':'g':':':tit)]) =+blockToMarkdown' opts (Para [Image attr alt (src,'f':'i':'g':':':tit)]) = blockToMarkdown opts (Para [Image attr alt (src,tit)])-blockToMarkdown opts (Para inlines) =+blockToMarkdown' opts (Para inlines) = (<> blankline) `fmap` blockToMarkdown opts (Plain inlines)-blockToMarkdown opts (RawBlock f str)- | f == "html" = do- plain <- gets stPlain+blockToMarkdown' opts (LineBlock lns) =+ if isEnabled Ext_line_blocks opts+ then do+ mdLines <- mapM (inlineListToMarkdown opts) lns+ return $ (vcat $ map (hang 2 (text "| ")) mdLines) <> blankline+ else blockToMarkdown opts $ linesToPara lns+blockToMarkdown' opts (RawBlock f str)+ | f == "markdown" = return $ text str <> text "\n"+ | f == "html" && isEnabled Ext_raw_html opts = do+ plain <- asks envPlain return $ if plain then empty else if isEnabled Ext_markdown_attribute opts then text (addMarkdownAttribute str) <> text "\n" else text str <> text "\n"- | f `elem` ["latex", "tex", "markdown"] = do- plain <- gets stPlain+ | f `elem` ["latex", "tex"] && isEnabled Ext_raw_tex opts = do+ plain <- asks envPlain return $ if plain then empty else text str <> text "\n"-blockToMarkdown _ (RawBlock _ _) = return empty-blockToMarkdown opts HorizontalRule = do+ | otherwise = return empty+blockToMarkdown' opts HorizontalRule = do return $ blankline <> text (replicate (writerColumns opts) '-') <> blankline-blockToMarkdown opts (Header level attr inlines) = do- plain <- gets stPlain+blockToMarkdown' opts (Header level attr inlines) = do+ -- first, if we're putting references at the end of a section, we+ -- put them here.+ blkLevel <- asks envBlockLevel+ refs <- if writerReferenceLocation opts == EndOfSection && blkLevel == 1+ then notesAndRefs opts+ else return empty++ plain <- asks envPlain -- we calculate the id that would be used by auto_identifiers -- so we know whether to print an explicit identifier ids <- gets stIds@@ -382,8 +444,7 @@ then capitalize inlines else inlines let setext = writerSetextHeaders opts- return $ nowrap- $ case level of+ hdr = nowrap $ case level of 1 | plain -> blanklines 3 <> contents <> blanklines 2 | setext -> contents <> attr' <> cr <> text (replicate (offset contents) '=') <>@@ -396,11 +457,13 @@ _ | plain || isEnabled Ext_literate_haskell opts -> contents <> blankline _ -> text (replicate level '#') <> space <> contents <> attr' <> blankline-blockToMarkdown opts (CodeBlock (_,classes,_) str)++ return $ refs <> hdr+blockToMarkdown' opts (CodeBlock (_,classes,_) str) | "haskell" `elem` classes && "literate" `elem` classes && isEnabled Ext_literate_haskell opts = return $ prefixed "> " (text str) <> blankline-blockToMarkdown opts (CodeBlock attribs str) = return $+blockToMarkdown' opts (CodeBlock attribs str) = return $ case attribs == nullAttr of False | isEnabled Ext_backtick_code_blocks opts -> backticks <> attrs <> cr <> text str <> cr <> backticks <> blankline@@ -422,8 +485,8 @@ else case attribs of (_,(cls:_),_) -> " " <> text cls _ -> empty-blockToMarkdown opts (BlockQuote blocks) = do- plain <- gets stPlain+blockToMarkdown' opts (BlockQuote blocks) = do+ plain <- asks envPlain -- if we're writing literate haskell, put a space before the bird tracks -- so they won't be interpreted as lhs... let leader = if isEnabled Ext_literate_haskell opts@@ -431,7 +494,7 @@ else if plain then " " else "> " contents <- blockListToMarkdown opts blocks return $ (prefixed leader contents) <> blankline-blockToMarkdown opts t@(Table caption aligns widths headers rows) = do+blockToMarkdown' opts t@(Table caption aligns widths headers rows) = do caption' <- inlineListToMarkdown opts caption let caption'' = if null caption || not (isEnabled Ext_table_captions opts) then empty@@ -460,14 +523,15 @@ | isEnabled Ext_grid_tables opts -> fmap (id,) $ gridTable opts (all null headers) aligns widths rawHeaders rawRows- | otherwise -> fmap (id,) $+ | isEnabled Ext_raw_html opts -> fmap (id,) $ return $ text $ writeHtmlString def $ Pandoc nullMeta [t]+ | otherwise -> return $ (id, text "[TABLE]") return $ nst $ tbl $$ blankline $$ caption'' $$ blankline-blockToMarkdown opts (BulletList items) = do+blockToMarkdown' opts (BulletList items) = do contents <- inList $ mapM (bulletListItemToMarkdown opts) items return $ cat contents <> blankline-blockToMarkdown opts (OrderedList (start,sty,delim) items) = do+blockToMarkdown' opts (OrderedList (start,sty,delim) items) = do let start' = if isEnabled Ext_startnum opts then start else 1 let sty' = if isEnabled Ext_fancy_lists opts then sty else DefaultStyle let delim' = if isEnabled Ext_fancy_lists opts then delim else DefaultDelim@@ -480,17 +544,12 @@ mapM (\(item, num) -> orderedListItemToMarkdown opts item num) $ zip markers' items return $ cat contents <> blankline-blockToMarkdown opts (DefinitionList items) = do+blockToMarkdown' opts (DefinitionList items) = do contents <- inList $ mapM (definitionListItemToMarkdown opts) items return $ cat contents <> blankline -inList :: State WriterState a -> State WriterState a-inList p = do- oldInList <- gets stInList- modify $ \st -> st{ stInList = True }- res <- p- modify $ \st -> st{ stInList = oldInList }- return res+inList :: MD a -> MD a+inList p = local (\env -> env {envInList = True}) p addMarkdownAttribute :: String -> String addMarkdownAttribute s =@@ -501,7 +560,7 @@ x /= "markdown"] _ -> s -pipeTable :: Bool -> [Alignment] -> [Doc] -> [[Doc]] -> State WriterState Doc+pipeTable :: Bool -> [Alignment] -> [Doc] -> [[Doc]] -> MD Doc pipeTable headless aligns rawHeaders rawRows = do let sp = text " " let blockFor AlignLeft x y = lblock (x + 2) (sp <> y) <> lblock 0 empty@@ -530,7 +589,7 @@ return $ header $$ border $$ body pandocTable :: WriterOptions -> Bool -> [Alignment] -> [Double]- -> [Doc] -> [[Doc]] -> State WriterState Doc+ -> [Doc] -> [[Doc]] -> MD Doc pandocTable opts headless aligns widths rawHeaders rawRows = do let isSimple = all (==0) widths let alignHeader alignment = case alignment of@@ -570,7 +629,7 @@ return $ head'' $$ underline $$ body $$ bottom gridTable :: WriterOptions -> Bool -> [Alignment] -> [Double]- -> [Doc] -> [[Doc]] -> State WriterState Doc+ -> [Doc] -> [[Doc]] -> MD Doc gridTable opts headless _aligns widths headers' rawRows = do let numcols = length headers' let widths' = if all (==0) widths@@ -597,7 +656,7 @@ return $ border '-' $$ head'' $$ body $$ border '-' -- | Convert bullet list item (list of blocks) to markdown.-bulletListItemToMarkdown :: WriterOptions -> [Block] -> State WriterState Doc+bulletListItemToMarkdown :: WriterOptions -> [Block] -> MD Doc bulletListItemToMarkdown opts items = do contents <- blockListToMarkdown opts items let sps = replicate (writerTabStop opts - 2) ' '@@ -615,7 +674,7 @@ orderedListItemToMarkdown :: WriterOptions -- ^ options -> String -- ^ list item marker -> [Block] -- ^ list item (list of blocks)- -> State WriterState Doc+ -> MD Doc orderedListItemToMarkdown opts marker items = do contents <- blockListToMarkdown opts items let sps = case length marker - writerTabStop opts of@@ -627,15 +686,15 @@ -- | Convert definition list item (label, list of blocks) to markdown. definitionListItemToMarkdown :: WriterOptions -> ([Inline],[[Block]])- -> State WriterState Doc+ -> MD Doc definitionListItemToMarkdown opts (label, defs) = do labelText <- inlineListToMarkdown opts label defs' <- mapM (mapM (blockToMarkdown opts)) defs if isEnabled Ext_definition_lists opts then do let tabStop = writerTabStop opts- st <- get- let leader = if stPlain st then " " else ": "+ isPlain <- asks envPlain+ let leader = if isPlain then " " else ": " let sps = case writerTabStop opts - 3 of n | n > 0 -> text $ replicate n ' ' _ -> text " "@@ -659,7 +718,7 @@ -- | Convert list of Pandoc block elements to markdown. blockListToMarkdown :: WriterOptions -- ^ Options -> [Block] -- ^ List of block elements- -> State WriterState Doc+ -> MD Doc blockListToMarkdown opts blocks = mapM (blockToMarkdown opts) (fixBlocks blocks) >>= return . cat -- insert comment between list and indented code block, or the@@ -680,11 +739,13 @@ isListBlock (OrderedList _ _) = True isListBlock (DefinitionList _) = True isListBlock _ = False- commentSep = RawBlock "html" "<!-- -->\n"+ commentSep = if isEnabled Ext_raw_html opts+ then RawBlock "html" "<!-- -->\n"+ else RawBlock "markdown" " " -- | Get reference for target; if none exists, create unique one and return. -- Prefer label if possible; otherwise, generate a unique key.-getReference :: Attr -> [Inline] -> Target -> State WriterState [Inline]+getReference :: Attr -> [Inline] -> Target -> MD [Inline] getReference attr label target = do st <- get case find (\(_,t,a) -> t == target && a == attr) (stRefs st) of@@ -702,9 +763,9 @@ return label' -- | Convert list of Pandoc inline elements to markdown.-inlineListToMarkdown :: WriterOptions -> [Inline] -> State WriterState Doc+inlineListToMarkdown :: WriterOptions -> [Inline] -> MD Doc inlineListToMarkdown opts lst = do- inlist <- gets stInList+ inlist <- asks envInList go (if inlist then avoidBadWrapsInList lst else lst) where go [] = return empty go (i:is) = case i of@@ -727,9 +788,9 @@ _ -> shortcutable where shortcutable = liftM2 (<>) (inlineToMarkdown opts i) (go is) unshortcutable = do- iMark <- withState (\s -> s { stRefShortcutable = False })- (inlineToMarkdown opts i)- modify (\s -> s {stRefShortcutable = True })+ iMark <- local+ (\env -> env { envRefShortcutable = False })+ (inlineToMarkdown opts i) fmap (iMark <>) (go is) isSp :: Inline -> Bool@@ -769,22 +830,22 @@ escapeSpaces x = x -- | Convert Pandoc inline element to markdown.-inlineToMarkdown :: WriterOptions -> Inline -> State WriterState Doc+inlineToMarkdown :: WriterOptions -> Inline -> MD Doc inlineToMarkdown opts (Span attrs ils) = do- plain <- gets stPlain+ plain <- asks envPlain contents <- inlineListToMarkdown opts ils return $ if not plain && (isEnabled Ext_raw_html opts || isEnabled Ext_native_spans opts) then tagWithAttrs "span" attrs <> contents <> text "</span>" else contents inlineToMarkdown opts (Emph lst) = do- plain <- gets stPlain+ plain <- asks envPlain contents <- inlineListToMarkdown opts lst return $ if plain then "_" <> contents <> "_" else "*" <> contents <> "*" inlineToMarkdown opts (Strong lst) = do- plain <- gets stPlain+ plain <- asks envPlain if plain then inlineListToMarkdown opts $ capitalize lst else do@@ -823,7 +884,7 @@ _ -> contents where toSubscript c = chr (0x2080 + (ord c - 48)) inlineToMarkdown opts (SmallCaps lst) = do- plain <- gets stPlain+ plain <- asks envPlain if not plain && (isEnabled Ext_raw_html opts || isEnabled Ext_native_spans opts) then do@@ -848,13 +909,13 @@ let attrs = if isEnabled Ext_inline_code_attributes opts && attr /= nullAttr then attrsToMarkdown attr else empty- plain <- gets stPlain+ plain <- asks envPlain if plain then return $ text str else return $ text (marker ++ spacer ++ str ++ spacer ++ marker) <> attrs inlineToMarkdown opts (Str str) = do- st <- get- if stPlain st+ isPlain <- asks envPlain+ if isPlain then return $ text str else return $ text $ escapeString opts str inlineToMarkdown opts (Math InlineMath str) =@@ -869,7 +930,7 @@ | isEnabled Ext_tex_math_double_backslash opts -> return $ "\\\\(" <> text str <> "\\\\)" | otherwise -> do- plain <- gets stPlain+ plain <- asks envPlain inlineListToMarkdown opts $ (if plain then makeMathPlainer else id) $ texMathToInlines InlineMath str@@ -883,7 +944,7 @@ | otherwise = (\x -> cr <> x <> cr) `fmap` inlineListToMarkdown opts (texMathToInlines DisplayMath str) inlineToMarkdown opts (RawInline f str) = do- plain <- gets stPlain+ plain <- asks envPlain if not plain && ( f == "markdown" || (isEnabled Ext_raw_tex opts && (f == "latex" || f == "tex")) ||@@ -891,7 +952,7 @@ then return $ text str else return empty inlineToMarkdown opts (LineBreak) = do- plain <- gets stPlain+ plain <- asks envPlain if plain || isEnabled Ext_hard_line_breaks opts then return cr else return $@@ -940,7 +1001,7 @@ attr /= nullAttr = -- use raw HTML return $ text $ trim $ writeHtmlString def $ Pandoc nullMeta [Plain [lnk]] | otherwise = do- plain <- gets stPlain+ plain <- asks envPlain linktext <- inlineListToMarkdown opts txt let linktitle = if null tit then empty@@ -951,7 +1012,7 @@ [Str s] | escapeURI s == srcSuffix -> True _ -> False let useRefLinks = writerReferenceLinks opts && not useAuto- shortcutable <- gets stRefShortcutable+ shortcutable <- asks envRefShortcutable let useShortcutRefLinks = shortcutable && isEnabled Ext_shortcut_reference_links opts ref <- if useRefLinks then getReference attr txt (src, tit) else return []@@ -979,7 +1040,7 @@ attr /= nullAttr = -- use raw HTML return $ text $ trim $ writeHtmlString def $ Pandoc nullMeta [Plain [img]] | otherwise = do- plain <- gets stPlain+ plain <- asks envPlain let txt = if null alternate || alternate == [Str source] -- to prevent autolinks then [Str ""]@@ -991,7 +1052,7 @@ inlineToMarkdown opts (Note contents) = do modify (\st -> st{ stNotes = contents : stNotes st }) st <- get- let ref = text $ writerIdentifierPrefix opts ++ show (length $ stNotes st)+ let ref = text $ writerIdentifierPrefix opts ++ show (stNoteNum st + (length $ stNotes st) - 1) if isEnabled Ext_footnotes opts then return $ "[^" <> ref <> "]" else return $ "[" <> ref <> "]"
src/Text/Pandoc/Writers/MediaWiki.hs view
@@ -120,6 +120,9 @@ then "<p>" ++ contents ++ "</p>" else contents ++ if null lev then "\n" else "" +blockToMediaWiki (LineBlock lns) =+ blockToMediaWiki $ linesToPara lns+ blockToMediaWiki (RawBlock f str) | f == Format "mediawiki" = return str | f == Format "html" = return str
src/Text/Pandoc/Writers/Native.hs view
@@ -45,6 +45,8 @@ -- | Prettyprint Pandoc block element. prettyBlock :: Block -> Doc+prettyBlock (LineBlock lines') =+ "LineBlock" $$ prettyList (map (text . show) lines') prettyBlock (BlockQuote blocks) = "BlockQuote" $$ prettyList (map prettyBlock blocks) prettyBlock (OrderedList attribs blockLists) =
src/Text/Pandoc/Writers/OpenDocument.hs view
@@ -33,6 +33,7 @@ import Text.Pandoc.Definition import Text.Pandoc.Options import Text.Pandoc.XML+import Text.Pandoc.Shared (linesToPara) import Text.Pandoc.Templates (renderTemplate') import Text.Pandoc.Readers.TeXMath import Text.Pandoc.Pretty@@ -291,6 +292,7 @@ | Para b <- bs = if null b then return empty else inParagraphTags =<< inlinesToOpenDocument o b+ | LineBlock b <- bs = blockToOpenDocument o $ linesToPara b | Div _ xs <- bs = blocksToOpenDocument o xs | Header i _ b <- bs = setFirstPara >> (inHeaderTags i =<< inlinesToOpenDocument o b)
src/Text/Pandoc/Writers/Org.hs view
@@ -39,8 +39,8 @@ import Text.Pandoc.Writers.Shared import Text.Pandoc.Pretty import Text.Pandoc.Templates (renderTemplate')-import Data.Char ( toLower )-import Data.List ( intersect, intersperse, partition, transpose )+import Data.Char ( isAlphaNum, toLower )+import Data.List ( isPrefixOf, intersect, intersperse, partition, transpose ) import Control.Monad.State data WriterState =@@ -158,13 +158,23 @@ blockToOrg (Para [Image attr txt (src,'f':'i':'g':':':tit)]) = do capt <- if null txt then return empty- else (\c -> "#+CAPTION: " <> c <> blankline) `fmap`- inlineListToOrg txt+ else ("#+CAPTION: " <>) `fmap` inlineListToOrg txt img <- inlineToOrg (Image attr txt (src,tit))- return $ capt <> img+ return $ capt $$ img $$ blankline blockToOrg (Para inlines) = do contents <- inlineListToOrg inlines return $ contents <> blankline+blockToOrg (LineBlock lns) = do+ let splitStanza [] = []+ splitStanza xs = case break (== mempty) xs of+ (l, []) -> l : []+ (l, _:r) -> l : splitStanza r+ let joinWithLinefeeds = nowrap . mconcat . intersperse cr+ let joinWithBlankLines = mconcat . intersperse blankline+ let prettyfyStanza ls = joinWithLinefeeds <$> mapM inlineListToOrg ls+ contents <- joinWithBlankLines <$> mapM prettyfyStanza (splitStanza lns)+ return $ blankline $$ "#+BEGIN_VERSE" $$+ nest 2 contents $$ "#+END_VERSE" <> blankline blockToOrg (RawBlock "html" str) = return $ blankline $$ "#+BEGIN_HTML" $$ nest 2 (text str) $$ "#+END_HTML" $$ blankline@@ -182,11 +192,7 @@ blockToOrg (CodeBlock (_,classes,_) str) = do opts <- stOptions <$> get let tabstop = writerTabStop opts- let at = classes `intersect` ["asymptote", "C", "clojure", "css", "ditaa",- "dot", "emacs-lisp", "gnuplot", "haskell", "js", "latex",- "ledger", "lisp", "matlab", "mscgen", "ocaml", "octave",- "oz", "perl", "plantuml", "python", "R", "ruby", "sass",- "scheme", "screen", "sh", "sql", "sqlite"]+ let at = map pandocLangToOrg classes `intersect` orgLangIdentifiers let (beg, end) = case at of [] -> ("#+BEGIN_EXAMPLE", "#+END_EXAMPLE") (x:_) -> ("#+BEGIN_SRC " ++ x, "#+END_SRC")@@ -355,16 +361,56 @@ case txt of [Str x] | escapeURI x == src -> -- autolink do modify $ \s -> s{ stLinks = True }- return $ "[[" <> text x <> "]]"+ return $ "[[" <> text (orgPath x) <> "]]" _ -> do contents <- inlineListToOrg txt modify $ \s -> s{ stLinks = True }- return $ "[[" <> text src <> "][" <> contents <> "]]"+ return $ "[[" <> text (orgPath src) <> "][" <> contents <> "]]" inlineToOrg (Image _ _ (source, _)) = do modify $ \s -> s{ stImages = True }- return $ "[[" <> text source <> "]]"+ return $ "[[" <> text (orgPath source) <> "]]" inlineToOrg (Note contents) = do -- add to notes in state notes <- get >>= (return . stNotes) modify $ \st -> st { stNotes = contents:notes } let ref = show $ (length notes) + 1- return $ " [" <> text ref <> "]"+ return $ "[" <> text ref <> "]"++orgPath :: String -> String+orgPath src =+ case src of+ [] -> mempty -- wiki link+ ('#':xs) -> xs -- internal link+ _ | isUrl src -> src+ _ | isFilePath src -> src+ _ -> "file:" <> src+ where+ isFilePath :: String -> Bool+ isFilePath cs = any (`isPrefixOf` cs) ["/", "./", "../", "file:"]++ isUrl :: String -> Bool+ isUrl cs =+ let (scheme, path) = break (== ':') cs+ in all (\c -> isAlphaNum c || c `elem` (".-"::String)) scheme+ && not (null path)++-- | Translate from pandoc's programming language identifiers to those used by+-- org-mode.+pandocLangToOrg :: String -> String+pandocLangToOrg cs =+ case cs of+ "c" -> "C"+ "cpp" -> "C++"+ "commonlisp" -> "lisp"+ "r" -> "R"+ "bash" -> "sh"+ _ -> cs++-- | List of language identifiers recognized by org-mode.+orgLangIdentifiers :: [String]+orgLangIdentifiers =+ [ "asymptote", "awk", "C", "C++", "clojure", "css", "d", "ditaa", "dot"+ , "calc", "emacs-lisp", "fortran", "gnuplot", "haskell", "java", "js"+ , "latex", "ledger", "lisp", "lilypond", "matlab", "mscgen", "ocaml"+ , "octave", "org", "oz", "perl", "plantuml", "processing", "python", "R"+ , "ruby", "sass", "scheme", "screen", "sed", "sh", "sql", "sqlite"+ ]
src/Text/Pandoc/Writers/RST.hs view
@@ -201,11 +201,12 @@ return $ hang 3 ".. " (fig $$ alt $$ classes $$ dims $+$ capt) $$ blankline blockToRST (Para inlines) | LineBreak `elem` inlines = do -- use line block if LineBreaks- lns <- mapM inlineListToRST $ splitBy (==LineBreak) inlines- return $ (vcat $ map (hang 2 (text "| ")) lns) <> blankline+ linesToLineBlock $ splitBy (==LineBreak) inlines | otherwise = do contents <- inlineListToRST inlines return $ contents <> blankline+blockToRST (LineBlock lns) =+ linesToLineBlock lns blockToRST (RawBlock f@(Format f') str) | f == "rst" = return $ text str | otherwise = return $ blankline <> ".. raw:: " <>@@ -327,6 +328,12 @@ contents <- liftM vcat $ mapM blockListToRST defs tabstop <- get >>= (return . writerTabStop . stOptions) return $ label' $$ nest tabstop (nestle contents <> cr)++-- | Format a list of lines as line block.+linesToLineBlock :: [[Inline]] -> State WriterState Doc+linesToLineBlock inlineLines = do+ lns <- mapM inlineListToRST inlineLines+ return $ (vcat $ map (hang 2 (text "| ")) lns) <> blankline -- | Convert list of Pandoc block elements to RST. blockListToRST' :: Bool
src/Text/Pandoc/Writers/RTF.hs view
@@ -233,6 +233,8 @@ rtfCompact indent 0 alignment $ inlineListToRTF lst blockToRTF indent alignment (Para lst) = rtfPar indent 0 alignment $ inlineListToRTF lst+blockToRTF indent alignment (LineBlock lns) =+ blockToRTF indent alignment $ linesToPara lns blockToRTF indent alignment (BlockQuote lst) = concatMap (blockToRTF (indent + indentIncrement) alignment) lst blockToRTF indent _ (CodeBlock _ str) =
src/Text/Pandoc/Writers/TEI.hs view
@@ -35,7 +35,7 @@ import Text.Pandoc.Writers.Shared import Text.Pandoc.Options import Text.Pandoc.Templates (renderTemplate')-import Data.List ( stripPrefix, isPrefixOf, isSuffixOf )+import Data.List ( stripPrefix, isPrefixOf ) import Data.Char ( toLower ) import Text.Pandoc.Highlighting ( languages, languagesByExtension ) import Text.Pandoc.Pretty@@ -60,19 +60,18 @@ then Just $ writerColumns opts else Nothing render' = render colwidth- opts' = if "/book>" `isSuffixOf`- (trimr $ writerTemplate opts)- then opts{ writerChapters = True }- else opts- startLvl = if writerChapters opts' then 0 else 1+ startLvl = case writerTopLevelDivision opts of+ Part -> -1+ Chapter -> 0+ Section -> 1 auths' = map (authorToTEI opts) $ docAuthors meta meta' = B.setMeta "author" auths' meta Just metadata = metaToJSON opts (Just . render colwidth . (vcat .- (map (elementToTEI opts' startLvl)) . hierarchicalize))- (Just . render colwidth . inlinesToTEI opts')+ (map (elementToTEI opts startLvl)) . hierarchicalize))+ (Just . render colwidth . inlinesToTEI opts) meta'- main = render' $ vcat (map (elementToTEI opts' startLvl) elements)+ main = render' $ vcat (map (elementToTEI opts startLvl) elements) context = defField "body" main $ defField "mathml" (case writerHTMLMathMethod opts of MathML _ -> True@@ -90,8 +89,10 @@ let elements' = if null elements then [Blk (Para [])] else elements+ -- level numbering correspond to LaTeX internals divType = case lvl of- n | n == 0 -> "chapter"+ n | n == -1 -> "part"+ | n == 0 -> "chapter" | n >= 1 && n <= 5 -> "level" ++ show n | otherwise -> "section" in inTags True "div" [("type", divType) | not (null id')] $@@ -108,7 +109,7 @@ plainToPara (Plain x) = Para x plainToPara x = x --- | Convert a list of pairs of terms and definitions into a TEI +-- | Convert a list of pairs of terms and definitions into a TEI -- list with labels and items. deflistItemsToTEI :: WriterOptions -> [([Inline],[[Block]])] -> Doc deflistItemsToTEI opts items =@@ -167,6 +168,8 @@ -- inTagsSimple "textobject" (inTagsSimple "phrase" alt)) blockToTEI opts (Para lst) = inTags False "p" [] $ inlinesToTEI opts lst+blockToTEI opts (LineBlock lns) =+ blockToTEI opts $ linesToPara lns blockToTEI opts (BlockQuote blocks) = inTagsIndented "quote" $ blocksToTEI opts blocks blockToTEI _ (CodeBlock (_,classes,_) str) =@@ -174,7 +177,7 @@ flush (text (escapeStringForXML str) <> cr <> text "</ab>") where lang = if null langs then ""- else escapeStringForXML (head langs) + else escapeStringForXML (head langs) isLang l = map toLower l `elem` map (map toLower) languages langsFrom s = if isLang s then [s]@@ -210,7 +213,7 @@ selfClosingTag "milestone" [("unit","undefined"), ("type","separator"),("rendition","line")] -- | TEI Tables--- TEI Simple's tables are composed of cells and rows; other +-- TEI Simple's tables are composed of cells and rows; other -- table info in the AST is here lossily discard. blockToTEI opts (Table _ _ _ headers rows) = let@@ -219,8 +222,8 @@ -- then return empty -- else tableRowToTEI opts headers in- inTags True "table" [] $ - vcat $ [headers'] <> map (tableRowToTEI opts) rows + inTags True "table" [] $+ vcat $ [headers'] <> map (tableRowToTEI opts) rows tableRowToTEI :: WriterOptions -> [[Block]]@@ -276,7 +279,7 @@ text (str) DisplayMath -> inTags True "figure" [("type","math")] $ inTags False "formula" [("notation","TeX")] $ text (str)- + inlineToTEI _ (RawInline f x) | f == "tei" = text x | otherwise = empty inlineToTEI _ LineBreak = selfClosingTag "lb" []@@ -317,4 +320,3 @@ role = if null cls then [] else [("role", unwords cls)]-
src/Text/Pandoc/Writers/Texinfo.hs view
@@ -145,6 +145,9 @@ blockToTexinfo (Para lst) = inlineListToTexinfo lst -- this is handled differently from Plain in blockListToTexinfo +blockToTexinfo (LineBlock lns) =+ blockToTexinfo $ linesToPara lns+ blockToTexinfo (BlockQuote lst) = do contents <- blockListToTexinfo lst return $ text "@quotation" $$
src/Text/Pandoc/Writers/Textile.hs view
@@ -130,6 +130,9 @@ then "<p>" ++ contents ++ "</p>" else contents ++ if null listLevel then "\n" else "" +blockToTextile opts (LineBlock lns) =+ blockToTextile opts $ linesToPara lns+ blockToTextile _ (RawBlock f str) | f == Format "html" || f == Format "textile" = return str | otherwise = return ""
src/Text/Pandoc/Writers/ZimWiki.hs view
@@ -33,7 +33,8 @@ module Text.Pandoc.Writers.ZimWiki ( writeZimWiki ) where import Text.Pandoc.Definition import Text.Pandoc.Options ( WriterOptions(writerTableOfContents, writerStandalone, writerTemplate, writerWrapText), WrapOption(..) )-import Text.Pandoc.Shared ( escapeURI, removeFormatting, trimr, substitute )+import Text.Pandoc.Shared ( escapeURI, linesToPara, removeFormatting, trimr+ , substitute ) import Text.Pandoc.Writers.Shared ( defField, metaToJSON ) import Text.Pandoc.ImageSize import Text.Pandoc.Templates ( renderTemplate' )@@ -110,6 +111,9 @@ -- useTags <- stUseTags <$> get contents <- inlineListToZimWiki opts inlines return $ contents ++ if null indent then "\n" else ""++blockToZimWiki opts (LineBlock lns) = do+ blockToZimWiki opts $ linesToPara lns blockToZimWiki opts (RawBlock f str) | f == Format "zimwiki" = return str
src/Text/Pandoc/XML.hs view
@@ -38,7 +38,7 @@ import Text.Pandoc.Pretty import Data.Char (ord, isAscii, isSpace)-import Text.Pandoc.Compat.TagSoupEntity (lookupEntity)+import Text.HTML.TagSoup.Entity (lookupEntity) -- | Escape one character as needed for XML. escapeCharForXML :: Char -> String@@ -101,7 +101,7 @@ fromEntities :: String -> String fromEntities ('&':xs) = case lookupEntity ent' of- Just c -> c : fromEntities rest+ Just c -> c ++ fromEntities rest Nothing -> '&' : fromEntities xs where (ent, rest) = case break (\c -> isSpace c || c == ';') xs of (zs,';':ys) -> (zs,ys)
stack.yaml view
@@ -8,8 +8,6 @@ packages: - '.' extra-deps:-- http-client-0.5.0-- http-client-tls-0.3.0-- data-default-instances-base-0.1.0.1-- cmark-0.5.3.1-resolver: nightly-2016-07-11+- doctemplates-0.1.0.2+- pandoc-types-1.17.0.4+resolver: lts-7.5
− tests/Tests/Arbitrary.hs
@@ -1,194 +0,0 @@-{-# OPTIONS_GHC -fno-warn-orphans #-}-{-# LANGUAGE TypeSynonymInstances, FlexibleInstances, ScopedTypeVariables #-}--- provides Arbitrary instance for Pandoc types-module Tests.Arbitrary ()-where-import Test.QuickCheck.Gen-import Test.QuickCheck.Arbitrary-import Control.Monad (liftM, liftM2)-import Text.Pandoc.Definition-import Text.Pandoc.Shared (normalize, escapeURI)-import Text.Pandoc.Builder--realString :: Gen String-realString = resize 8 $ listOf $ frequency [ (9, elements [' '..'\127'])- , (1, elements ['\128'..'\9999']) ]--arbAttr :: Gen Attr-arbAttr = do- id' <- elements ["","loc"]- classes <- elements [[],["haskell"],["c","numberLines"]]- keyvals <- elements [[],[("start","22")],[("a","11"),("b_2","a b c")]]- return (id',classes,keyvals)--instance Arbitrary Inlines where- arbitrary = liftM (fromList :: [Inline] -> Inlines) arbitrary--instance Arbitrary Blocks where- arbitrary = liftM (fromList :: [Block] -> Blocks) arbitrary--instance Arbitrary Inline where- arbitrary = resize 3 $ arbInline 2--arbInlines :: Int -> Gen [Inline]-arbInlines n = listOf1 (arbInline n) `suchThat` (not . startsWithSpace)- where startsWithSpace (Space:_) = True- startsWithSpace _ = False---- restrict to 3 levels of nesting max; otherwise we get--- bogged down in indefinitely large structures-arbInline :: Int -> Gen Inline-arbInline n = frequency $ [ (60, liftM Str realString)- , (60, return Space)- , (10, liftM2 Code arbAttr realString)- , (5, elements [ RawInline (Format "html") "<a id=\"eek\">"- , RawInline (Format "latex") "\\my{command}" ])- ] ++ [ x | x <- nesters, n > 1]- where nesters = [ (10, liftM Emph $ arbInlines (n-1))- , (10, liftM Strong $ arbInlines (n-1))- , (10, liftM Strikeout $ arbInlines (n-1))- , (10, liftM Superscript $ arbInlines (n-1))- , (10, liftM Subscript $ arbInlines (n-1))- , (10, liftM SmallCaps $ arbInlines (n-1))- , (10, do x1 <- arbitrary- x2 <- arbInlines (n-1)- return $ Quoted x1 x2)- , (10, do x1 <- arbitrary- x2 <- realString- return $ Math x1 x2)- , (10, do x0 <- arbAttr- x1 <- arbInlines (n-1)- x3 <- realString- x2 <- liftM escapeURI realString- return $ Link x0 x1 (x2,x3))- , (10, do x0 <- arbAttr- x1 <- arbInlines (n-1)- x3 <- realString- x2 <- liftM escapeURI realString- return $ Image x0 x1 (x2,x3))- , (2, liftM2 Cite arbitrary (arbInlines 1))- , (2, liftM Note $ resize 3 $ listOf1 $ arbBlock (n-1))- ]--instance Arbitrary Block where- arbitrary = resize 3 $ arbBlock 2--arbBlock :: Int -> Gen Block-arbBlock n = frequency $ [ (10, liftM Plain $ arbInlines (n-1))- , (15, liftM Para $ arbInlines (n-1))- , (5, liftM2 CodeBlock arbAttr realString)- , (2, elements [ RawBlock (Format "html")- "<div>\n*&*\n</div>"- , RawBlock (Format "latex")- "\\begin[opt]{env}\nhi\n{\\end{env}"- ])- , (5, do x1 <- choose (1 :: Int, 6)- x2 <- arbInlines (n-1)- return (Header x1 nullAttr x2))- , (2, return HorizontalRule)- ] ++ [x | x <- nesters, n > 0]- where nesters = [ (5, liftM BlockQuote $ listOf1 $ arbBlock (n-1))- , (5, do x2 <- arbitrary- x3 <- arbitrary- x1 <- arbitrary `suchThat` (> 0)- x4 <- listOf1 $ listOf1 $ arbBlock (n-1)- return $ OrderedList (x1,x2,x3) x4 )- , (5, liftM BulletList $ (listOf1 $ listOf1 $ arbBlock (n-1)))- , (5, do items <- listOf1 $ do- x1 <- listOf1 $ listOf1 $ arbBlock (n-1)- x2 <- arbInlines (n-1)- return (x2,x1)- return $ DefinitionList items)- , (2, do rs <- choose (1 :: Int, 4)- cs <- choose (1 :: Int, 4)- x1 <- arbInlines (n-1)- x2 <- vector cs- x3 <- vectorOf cs $ elements [0, 0.25]- x4 <- vectorOf cs $ listOf $ arbBlock (n-1)- x5 <- vectorOf rs $ vectorOf cs- $ listOf $ arbBlock (n-1)- return (Table x1 x2 x3 x4 x5))- ]--instance Arbitrary Pandoc where- arbitrary = resize 8 $ liftM normalize- $ liftM2 Pandoc arbitrary arbitrary--instance Arbitrary CitationMode where- arbitrary- = do x <- choose (0 :: Int, 2)- case x of- 0 -> return AuthorInText- 1 -> return SuppressAuthor- 2 -> return NormalCitation- _ -> error "FATAL ERROR: Arbitrary instance, logic bug"--instance Arbitrary Citation where- arbitrary- = do x1 <- listOf $ elements $ ['a'..'z'] ++ ['0'..'9'] ++ ['_']- x2 <- arbInlines 1- x3 <- arbInlines 1- x4 <- arbitrary- x5 <- arbitrary- x6 <- arbitrary- return (Citation x1 x2 x3 x4 x5 x6)--instance Arbitrary MathType where- arbitrary- = do x <- choose (0 :: Int, 1)- case x of- 0 -> return DisplayMath- 1 -> return InlineMath- _ -> error "FATAL ERROR: Arbitrary instance, logic bug"--instance Arbitrary QuoteType where- arbitrary- = do x <- choose (0 :: Int, 1)- case x of- 0 -> return SingleQuote- 1 -> return DoubleQuote- _ -> error "FATAL ERROR: Arbitrary instance, logic bug"--instance Arbitrary Meta where- arbitrary- = do (x1 :: Inlines) <- arbitrary- (x2 :: [Inlines]) <- liftM (filter (not . isNull)) arbitrary- (x3 :: Inlines) <- arbitrary- return $ setMeta "title" x1- $ setMeta "author" x2- $ setMeta "date" x3- $ nullMeta--instance Arbitrary Alignment where- arbitrary- = do x <- choose (0 :: Int, 3)- case x of- 0 -> return AlignLeft- 1 -> return AlignRight- 2 -> return AlignCenter- 3 -> return AlignDefault- _ -> error "FATAL ERROR: Arbitrary instance, logic bug"--instance Arbitrary ListNumberStyle where- arbitrary- = do x <- choose (0 :: Int, 6)- case x of- 0 -> return DefaultStyle- 1 -> return Example- 2 -> return Decimal- 3 -> return LowerRoman- 4 -> return UpperRoman- 5 -> return LowerAlpha- 6 -> return UpperAlpha- _ -> error "FATAL ERROR: Arbitrary instance, logic bug"--instance Arbitrary ListNumberDelim where- arbitrary- = do x <- choose (0 :: Int, 3)- case x of- 0 -> return DefaultDelim- 1 -> return Period- 2 -> return OneParen- 3 -> return TwoParens- _ -> error "FATAL ERROR: Arbitrary instance, logic bug"-
tests/Tests/Readers/Docx.hs view
@@ -182,6 +182,10 @@ "docx/already_auto_ident.docx" "docx/already_auto_ident.native" , testCompare+ "nested anchor spans in header"+ "docx/nested_anchors_in_header.docx"+ "docx/nested_anchors_in_header.native"+ , testCompare "single numbered item not made into list" "docx/numbered_header.docx" "docx/numbered_header.native"
tests/Tests/Readers/HTML.hs view
@@ -4,10 +4,9 @@ import Text.Pandoc.Definition import Test.Framework import Tests.Helpers-import Tests.Arbitrary()+import Text.Pandoc.Arbitrary() import Text.Pandoc.Builder import Text.Pandoc-import Text.Pandoc.Error html :: String -> Pandoc html = handleError . readHtml def
tests/Tests/Readers/LaTeX.hs view
@@ -4,10 +4,9 @@ import Text.Pandoc.Definition import Test.Framework import Tests.Helpers-import Tests.Arbitrary()+import Text.Pandoc.Arbitrary() import Text.Pandoc.Builder import Text.Pandoc-import Text.Pandoc.Error latex :: String -> Pandoc latex = handleError . readLaTeX def
tests/Tests/Readers/Markdown.hs view
@@ -4,12 +4,10 @@ import Text.Pandoc.Definition import Test.Framework import Tests.Helpers-import Tests.Arbitrary()+import Text.Pandoc.Arbitrary() import Text.Pandoc.Builder import qualified Data.Set as Set--- import Text.Pandoc.Shared ( normalize ) import Text.Pandoc-import Text.Pandoc.Error markdown :: String -> Pandoc markdown = handleError . readMarkdown def@@ -36,8 +34,11 @@ inp (inp, doc $ para ils) autolink :: String -> Inlines-autolink s = link s "" (str s)+autolink = autolinkWith nullAttr +autolinkWith :: Attr -> String -> Inlines+autolinkWith attr s = linkWith attr s "" (str s)+ bareLinkTests :: [(String, Inlines)] bareLinkTests = [ ("http://google.com is a search engine.",@@ -185,6 +186,11 @@ "<\n\na>" =?> para (text "<") <> para (text "a>") ]+ , testGroup "raw email addresses"+ [ test markdownGH "issue 2940" $+ "**@user**" =?>+ para (strong (text "@user"))+ ] , testGroup "emoji" [ test markdownGH "emoji symbols" $ ":smile: and :+1:" =?> para (text "😄 and 👍")@@ -214,6 +220,12 @@ , "a partial URL (#2277)" =: "<www.boe.es/buscar/act.php?id=BOE-A-1996-8930#a66>" =?> para (text "<www.boe.es/buscar/act.php?id=BOE-A-1996-8930#a66>")+ , "with some attributes" =:+ "<http://foo.bar>{#i .j .z k=v}" =?>+ para (autolinkWith ("i", ["j", "z"], [("k", "v")]) "http://foo.bar")+ , "with some attributes and spaces" =:+ "<http://foo.bar> {#i .j .z k=v}" =?>+ para (autolink "http://foo.bar" <> space <> text "{#i .j .z k=v}") ] , testGroup "links" [ "no autolink inside link" =:
tests/Tests/Readers/Odt.hs view
@@ -5,18 +5,13 @@ import Text.Pandoc.Readers.Native import Text.Pandoc.Readers.Markdown import Text.Pandoc.Definition-import Text.Pandoc.Error import Tests.Helpers import Test.Framework---import Test.HUnit (assertBool)---import Test.Framework.Providers.HUnit import qualified Data.ByteString.Lazy as B import Text.Pandoc.Readers.Odt import Text.Pandoc.Writers.Native (writeNative) import qualified Data.Map as M---import Text.Pandoc.MediaBag (MediaBag, lookupMedia, mediaDirectory)---import Codec.Archive.Zip-+import Text.Pandoc.Error tests :: [Test] tests = testsComparingToMarkdown ++ testsComparingToNative@@ -141,7 +136,6 @@ , "footnote" , "headers" -- , "horizontalRule"--- , "image" , "italic" -- , "listBlocks" , "paragraph"@@ -152,6 +146,9 @@ namesOfTestsComparingToNative :: [ String ] namesOfTestsComparingToNative = [ "blockquote"+ , "image"+ , "imageIndex"+ , "imageWithCaption" , "orderedListMixed" , "orderedListRoman" , "orderedListSimple"
tests/Tests/Readers/Org.hs view
@@ -7,7 +7,6 @@ import Text.Pandoc.Builder import Text.Pandoc import Data.List (intersperse)-import Text.Pandoc.Error org :: String -> Pandoc org = handleError . readOrg def@@ -219,12 +218,12 @@ (para $ link "" "" "New Link") , "Image link" =:- "[[sunset.png][dusk.svg]]" =?>+ "[[sunset.png][file:dusk.svg]]" =?> (para $ link "sunset.png" "" (image "dusk.svg" "" "")) , "Image link with non-image target" =:- "[[http://example.com][logo.png]]" =?>- (para $ link "http://example.com" "" (image "logo.png" "" ""))+ "[[http://example.com][./logo.png]]" =?>+ (para $ link "http://example.com" "" (image "./logo.png" "" "")) , "Plain link" =: "Posts on http://zeitlens.com/ can be funny at times." =?>@@ -467,9 +466,16 @@ , "Author" =: "#+author: Albert /Emacs-Fanboy/ Krewinkel" =?> let author = toList . spcSep $ [ "Albert", emph "Emacs-Fanboy", "Krewinkel" ]- meta = setMeta "author" (MetaInlines author) $ nullMeta+ meta = setMeta "author" (MetaList [MetaInlines author]) $ nullMeta in Pandoc meta mempty + , "Multiple authors" =:+ "#+author: James Dewey Watson, Francis Harry Compton Crick " =?>+ let watson = MetaInlines $ toList "James Dewey Watson"+ crick = MetaInlines $ toList "Francis Harry Compton Crick"+ meta = setMeta "author" (MetaList [watson, crick]) $ nullMeta+ in Pandoc meta mempty+ , "Date" =: "#+Date: Feb. *28*, 2014" =?> let date = toList . spcSep $ [ "Feb.", (strong "28") <> ",", "2014" ]@@ -478,8 +484,8 @@ , "Description" =: "#+DESCRIPTION: Explanatory text" =?>- let description = toList . spcSep $ [ "Explanatory", "text" ]- meta = setMeta "description" (MetaInlines description) $ nullMeta+ let description = "Explanatory text"+ meta = setMeta "description" (MetaString description) $ nullMeta in Pandoc meta mempty , "Properties drawer" =:@@ -489,6 +495,38 @@ ] =?> (mempty::Blocks) + , "LaTeX_headers options are translated to header-includes" =:+ "#+LaTeX_header: \\usepackage{tikz}" =?>+ let latexInlines = rawInline "latex" "\\usepackage{tikz}"+ inclList = MetaList [MetaInlines (toList latexInlines)]+ meta = setMeta "header-includes" inclList nullMeta+ in Pandoc meta mempty++ , "LaTeX_class option is translated to documentclass" =:+ "#+LATEX_CLASS: article" =?>+ let meta = setMeta "documentclass" (MetaString "article") nullMeta+ in Pandoc meta mempty++ , "LaTeX_class_options is translated to classoption" =:+ "#+LATEX_CLASS_OPTIONS: [a4paper]" =?>+ let meta = setMeta "classoption" (MetaString "a4paper") nullMeta+ in Pandoc meta mempty++ , "LaTeX_class_options is translated to classoption" =:+ "#+html_head: <meta/>" =?>+ let html = rawInline "html" "<meta/>"+ inclList = MetaList [MetaInlines (toList html)]+ meta = setMeta "header-includes" inclList nullMeta+ in Pandoc meta mempty++ , "later meta definitions take precedence" =:+ unlines [ "#+AUTHOR: this will not be used"+ , "#+author: Max"+ ] =?>+ let author = MetaInlines [Str "Max"]+ meta = setMeta "author" (MetaList [author]) $ nullMeta+ in Pandoc meta mempty+ , "Logbook drawer" =: unlines [ " :LogBook:" , " - State \"DONE\" from \"TODO\" [2014-03-03 Mon 11:00]"@@ -563,69 +601,91 @@ ] =?> (para (link "http://example.com/foo" "" "bar")) - , "Export option: Disable simple sub/superscript syntax" =:- unlines [ "#+OPTIONS: ^:nil"- , "a^b"- ] =?>- para "a^b" - , "Export option: directly select drawers to be exported" =:- unlines [ "#+OPTIONS: d:(\"IMPORTANT\")"- , ":IMPORTANT:"- , "23"- , ":END:"- , ":BORING:"- , "very boring"- , ":END:"- ] =?>- divWith (mempty, ["IMPORTANT", "drawer"], mempty) (para "23")+ , testGroup "export options" - , "Export option: exclude drawers from being exported" =:- unlines [ "#+OPTIONS: d:(not \"BORING\")"- , ":IMPORTANT:"- , "5"- , ":END:"- , ":BORING:"- , "very boring"- , ":END:"- ] =?>- divWith (mempty, ["IMPORTANT", "drawer"], mempty) (para "5")+ [ "disable simple sub/superscript syntax" =:+ unlines [ "#+OPTIONS: ^:nil"+ , "a^b"+ ] =?>+ para "a^b" - , "Export option: don't include archive trees" =:- unlines [ "#+OPTIONS: arch:nil"- , "* old :ARCHIVE:"- ] =?>- (mempty ::Blocks)+ , "directly select drawers to be exported" =:+ unlines [ "#+OPTIONS: d:(\"IMPORTANT\")"+ , ":IMPORTANT:"+ , "23"+ , ":END:"+ , ":BORING:"+ , "very boring"+ , ":END:"+ ] =?>+ divWith (mempty, ["IMPORTANT", "drawer"], mempty) (para "23") - , "Export option: include complete archive trees" =:- unlines [ "#+OPTIONS: arch:t"- , "* old :ARCHIVE:"- , " boring"- ] =?>- let tagSpan t = spanWith ("", ["tag"], [("data-tag-name", t)]) mempty- in mconcat [ headerWith ("old", [], mempty) 1 ("old" <> tagSpan "ARCHIVE")- , para "boring"- ]+ , "exclude drawers from being exported" =:+ unlines [ "#+OPTIONS: d:(not \"BORING\")"+ , ":IMPORTANT:"+ , "5"+ , ":END:"+ , ":BORING:"+ , "very boring"+ , ":END:"+ ] =?>+ divWith (mempty, ["IMPORTANT", "drawer"], mempty) (para "5") - , "Export option: include archive tree header only" =:- unlines [ "#+OPTIONS: arch:headline"- , "* old :ARCHIVE:"- , " boring"- ] =?>- let tagSpan t = spanWith ("", ["tag"], [("data-tag-name", t)]) mempty- in headerWith ("old", [], mempty) 1 ("old" <> tagSpan "ARCHIVE")+ , "don't include archive trees" =:+ unlines [ "#+OPTIONS: arch:nil"+ , "* old :ARCHIVE:"+ ] =?>+ (mempty ::Blocks) - , "Export option: limit headline depth" =:- unlines [ "#+OPTIONS: H:2"- , "* section"- , "** subsection"- , "*** list item 1"- , "*** list item 2"- ] =?>- mconcat [ headerWith ("section", [], []) 1 "section"- , headerWith ("subsection", [], []) 2 "subsection"- , orderedList [ para "list item 1", para "list item 2" ]- ]+ , "include complete archive trees" =:+ unlines [ "#+OPTIONS: arch:t"+ , "* old :ARCHIVE:"+ , " boring"+ ] =?>+ let tagSpan t = spanWith ("", ["tag"], [("data-tag-name", t)]) mempty+ in mconcat [ headerWith ("old", [], mempty) 1 ("old" <> tagSpan "ARCHIVE")+ , para "boring"+ ]++ , "include archive tree header only" =:+ unlines [ "#+OPTIONS: arch:headline"+ , "* old :ARCHIVE:"+ , " boring"+ ] =?>+ let tagSpan t = spanWith ("", ["tag"], [("data-tag-name", t)]) mempty+ in headerWith ("old", [], mempty) 1 ("old" <> tagSpan "ARCHIVE")++ , "limit headline depth" =:+ unlines [ "#+OPTIONS: H:2"+ , "* section"+ , "** subsection"+ , "*** list item 1"+ , "*** list item 2"+ ] =?>+ mconcat [ headerWith ("section", [], []) 1 "section"+ , headerWith ("subsection", [], []) 2 "subsection"+ , orderedList [ para "list item 1", para "list item 2" ]+ ]++ , "disable author export" =:+ unlines [ "#+OPTIONS: author:nil"+ , "#+AUTHOR: ShyGuy"+ ] =?>+ Pandoc nullMeta mempty++ , "disable creator export" =:+ unlines [ "#+OPTIONS: creator:nil"+ , "#+creator: The Architect"+ ] =?>+ Pandoc nullMeta mempty++ , "disable email export" =:+ unlines [ "#+OPTIONS: email:nil"+ , "#+email: no-mail-please@example.com"+ ] =?>+ Pandoc nullMeta mempty+ ] ] , testGroup "Basic Blocks" $@@ -757,6 +817,15 @@ ] =?> headerWith ("fubar", [], [("bar", "baz")]) 1 "foo" ++ , "Headers marked with a unnumbered property get a class of the same name" =:+ unlines [ "* Not numbered"+ , " :PROPERTIES:"+ , " :UNNUMBERED: t"+ , " :END:"+ ] =?>+ headerWith ("not-numbered", ["unnumbered"], []) 1 "Not numbered"+ , "Paragraph starting with an asterisk" =: "*five" =?> para "*five"@@ -810,29 +879,29 @@ [ "Figure" =: unlines [ "#+caption: A very courageous man." , "#+name: goodguy"- , "[[edward.jpg]]"+ , "[[file:edward.jpg]]" ] =?> para (image "edward.jpg" "fig:goodguy" "A very courageous man.") , "Figure with no name" =: unlines [ "#+caption: I've been through the desert on this"- , "[[horse.png]]"+ , "[[file:horse.png]]" ] =?> para (image "horse.png" "fig:" "I've been through the desert on this") , "Figure with `fig:` prefix in name" =: unlines [ "#+caption: Used as a metapher in evolutionary biology." , "#+name: fig:redqueen"- , "[[the-red-queen.jpg]]"+ , "[[./the-red-queen.jpg]]" ] =?>- para (image "the-red-queen.jpg" "fig:redqueen"+ para (image "./the-red-queen.jpg" "fig:redqueen" "Used as a metapher in evolutionary biology.") , "Figure with HTML attributes" =: unlines [ "#+CAPTION: mah brain just explodid" , "#+NAME: lambdacat" , "#+ATTR_HTML: :style color: blue :role button"- , "[[lambdacat.jpg]]"+ , "[[file:lambdacat.jpg]]" ] =?> let kv = [("style", "color: blue"), ("role", "button")] name = "fig:lambdacat"@@ -842,10 +911,16 @@ , "Labelled figure" =: unlines [ "#+CAPTION: My figure" , "#+LABEL: fig:myfig"- , "[[blub.png]]"+ , "[[file:blub.png]]" ] =?> let attr = ("fig:myfig", mempty, mempty) in para (imageWith attr "blub.png" "fig:" "My figure")++ , "Figure with empty caption" =:+ unlines [ "#+CAPTION:"+ , "[[file:guess.jpg]]"+ ] =?>+ para (image "guess.jpg" "fig:" "") ] , "Footnote" =:@@ -1420,14 +1495,11 @@ mconcat [ para $ spcSep [ "The", "first", "lines", "of" , "Goethe's", emph "Faust" <> ":"]- , para $ mconcat- [ spcSep [ "Habe", "nun,", "ach!", "Philosophie," ]- , linebreak- , spcSep [ "Juristerei", "und", "Medizin," ]- , linebreak- , spcSep [ "Und", "leider", "auch", "Theologie!" ]- , linebreak- , spcSep [ "Durchaus", "studiert,", "mit", "heißem", "Bemühn." ]+ , lineBlock+ [ "Habe nun, ach! Philosophie,"+ , "Juristerei und Medizin,"+ , "Und leider auch Theologie!"+ , "Durchaus studiert, mit heißem Bemühn." ] ] @@ -1438,7 +1510,15 @@ , "bar" , "#+END_VERSE" ] =?>- para ("foo" <> linebreak <> linebreak <> "bar")+ lineBlock [ "foo", mempty, "bar" ]++ , "Verse block with varying indentation" =:+ unlines [ "#+BEGIN_VERSE"+ , " hello darkness"+ , "my old friend"+ , "#+END_VERSE"+ ] =?>+ lineBlock [ "\160\160hello darkness", "my old friend" ] , "Raw block LaTeX" =: unlines [ "#+BEGIN_LaTeX"
tests/Tests/Readers/RST.hs view
@@ -4,10 +4,9 @@ import Text.Pandoc.Definition import Test.Framework import Tests.Helpers-import Tests.Arbitrary()+import Text.Pandoc.Arbitrary() import Text.Pandoc.Builder import Text.Pandoc-import Text.Pandoc.Error rst :: String -> Pandoc rst = handleError . readRST def{ readerStandalone = True }@@ -19,8 +18,7 @@ tests :: [Test] tests = [ "line block with blank line" =:- "| a\n|\n| b" =?> para (str "a") <>- para (str "\160b")+ "| a\n|\n| b" =?> lineBlock [ "a", mempty, "\160b" ] , testGroup "field list" [ "general" =: unlines [ "para"@@ -135,7 +133,7 @@ codeBlock "block quotes\n\ncan go on for many lines" <> para "but must stop here") , "line block with 3 lines" =: "| a\n| b\n| c"- =?> para ("a" <> linebreak <> "b" <> linebreak <> "c")+ =?> lineBlock ["a", "b", "c"] , "quoted literal block using >" =: "::\n\n> quoted\n> block\n\nOrdinary paragraph" =?> codeBlock "> quoted\n> block" <> para "Ordinary paragraph" , "quoted literal block using | (not a line block)" =: "::\n\n| quoted\n| block\n\nOrdinary paragraph"@@ -163,5 +161,14 @@ =: ".. role:: haskell(code)\n.. role:: lhs(haskell)\n\n:lhs:`text`" =?> para (codeWith ("", ["lhs", "haskell", "sourceCode"], []) "text") , "unknown role" =: ":unknown:`text`" =?> para (str "text")+ ]+ , testGroup "footnotes"+ [ "remove space before note" =: unlines+ [ "foo [1]_"+ , ""+ , ".. [1]"+ , " bar"+ ] =?>+ (para $ "foo" <> (note $ para "bar")) ] ]
tests/Tests/Readers/Txt2Tags.hs view
@@ -4,10 +4,9 @@ import Text.Pandoc.Definition import Test.Framework import Tests.Helpers-import Tests.Arbitrary()+import Text.Pandoc.Arbitrary() import Text.Pandoc.Builder import Text.Pandoc-import Text.Pandoc.Error import Data.List (intersperse) import Text.Pandoc.Readers.Txt2Tags
@@ -4,7 +4,7 @@ import Text.Pandoc.Shared import Test.Framework import Tests.Helpers-import Tests.Arbitrary()+import Text.Pandoc.Arbitrary() import Test.Framework.Providers.HUnit import Test.HUnit ( assertBool, (@?=) ) import Text.Pandoc.Builder
tests/Tests/Walk.hs view
@@ -6,7 +6,7 @@ import Test.Framework import Tests.Helpers import Data.Char (toUpper)-import Tests.Arbitrary()+import Text.Pandoc.Arbitrary() import Data.Generics tests :: [Test]
tests/Tests/Writers/AsciiDoc.hs view
@@ -4,7 +4,7 @@ import Text.Pandoc.Builder import Text.Pandoc import Tests.Helpers-import Tests.Arbitrary()+import Text.Pandoc.Arbitrary() asciidoc :: (ToPandoc a) => a -> String asciidoc = writeAsciiDoc def{ writerWrapText = WrapNone } . toPandoc
tests/Tests/Writers/ConTeXt.hs view
@@ -5,7 +5,7 @@ import Text.Pandoc.Builder import Text.Pandoc import Tests.Helpers-import Tests.Arbitrary()+import Text.Pandoc.Arbitrary() context :: (ToPandoc a) => a -> String context = writeConTeXt def . toPandoc
tests/Tests/Writers/Docbook.hs view
@@ -5,11 +5,14 @@ import Text.Pandoc.Builder import Text.Pandoc import Tests.Helpers-import Tests.Arbitrary()+import Text.Pandoc.Arbitrary() docbook :: (ToPandoc a) => a -> String-docbook = writeDocbook def{ writerWrapText = WrapNone } . toPandoc+docbook = docbookWithOpts def{ writerWrapText = WrapNone } +docbookWithOpts :: ToPandoc a => WriterOptions -> a -> String+docbookWithOpts opts = writeDocbook opts . toPandoc+ {- "my test" =: X =?> Y @@ -224,6 +227,58 @@ , " </varlistentry>" , "</variablelist>" ]+ ]+ ]+ , testGroup "writer options" $+ [ testGroup "top-level division" $+ let+ headers = header 1 (text "header1")+ <> header 2 (text "header2")+ <> header 3 (text "header3")++ docbookTopLevelDiv :: (ToPandoc a) => Division -> a -> String+ docbookTopLevelDiv division =+ docbookWithOpts def{ writerTopLevelDivision = division }+ in+ [ test (docbookTopLevelDiv Section) "sections as top-level" $ headers =?>+ unlines [ "<sect1>"+ , " <title>header1</title>"+ , " <sect2>"+ , " <title>header2</title>"+ , " <sect3>"+ , " <title>header3</title>"+ , " <para>"+ , " </para>"+ , " </sect3>"+ , " </sect2>"+ , "</sect1>"+ ]+ , test (docbookTopLevelDiv Chapter) "chapters as top-level" $ headers =?>+ unlines [ "<chapter>"+ , " <title>header1</title>"+ , " <sect1>"+ , " <title>header2</title>"+ , " <sect2>"+ , " <title>header3</title>"+ , " <para>"+ , " </para>"+ , " </sect2>"+ , " </sect1>"+ , "</chapter>"+ ]+ , test (docbookTopLevelDiv Part) "parts as top-level" $ headers =?>+ unlines [ "<part>"+ , " <title>header1</title>"+ , " <chapter>"+ , " <title>header2</title>"+ , " <sect1>"+ , " <title>header3</title>"+ , " <para>"+ , " </para>"+ , " </sect1>"+ , " </chapter>"+ , "</part>"+ ] ] ] ]
tests/Tests/Writers/Docx.hs view
@@ -13,120 +13,137 @@ type Options = (WriterOptions, ReaderOptions) compareOutput :: Options- -> FilePath- -> IO (Pandoc, Pandoc)-compareOutput opts nativeFile = do- nf <- Prelude.readFile nativeFile+ -> FilePath+ -> FilePath+ -> IO (Pandoc, Pandoc)+compareOutput opts nativeFileIn nativeFileOut = do+ nf <- Prelude.readFile nativeFileIn+ nf' <- Prelude.readFile nativeFileOut let wopts = fst opts df <- writeDocx wopts{writerUserDataDir = Just (".." </> "data")} (handleError $ readNative nf) let (p, _) = handleError $ readDocx (snd opts) df- return (p, handleError $ readNative nf)+ return (p, handleError $ readNative nf') -testCompareWithOptsIO :: Options -> String -> FilePath -> IO Test-testCompareWithOptsIO opts name nativeFile = do- (dp, np) <- compareOutput opts nativeFile+testCompareWithOptsIO :: Options -> String -> FilePath -> FilePath -> IO Test+testCompareWithOptsIO opts name nativeFileIn nativeFileOut = do+ (dp, np) <- compareOutput opts nativeFileIn nativeFileOut return $ test id name (dp, np) -testCompareWithOpts :: Options -> String -> FilePath -> Test-testCompareWithOpts opts name nativeFile =- buildTest $ testCompareWithOptsIO opts name nativeFile+testCompareWithOpts :: Options -> String -> FilePath -> FilePath -> Test+testCompareWithOpts opts name nativeFileIn nativeFileOut =+ buildTest $ testCompareWithOptsIO opts name nativeFileIn nativeFileOut -testCompare :: String -> FilePath -> Test-testCompare = testCompareWithOpts def+roundTripCompareWithOpts :: Options -> String -> FilePath -> Test+roundTripCompareWithOpts opts name nativeFile =+ testCompareWithOpts opts name nativeFile nativeFile +-- testCompare :: String -> FilePath -> FilePath -> Test+-- testCompare = testCompareWithOpts def++roundTripCompare :: String -> FilePath -> Test+roundTripCompare = roundTripCompareWithOpts def+ tests :: [Test] tests = [ testGroup "inlines"- [ testCompare+ [ roundTripCompare "font formatting" "docx/inline_formatting_writer.native"- , testCompare+ , roundTripCompare "font formatting with character styles" "docx/char_styles.native"- , testCompare+ , roundTripCompare "hyperlinks" "docx/links_writer.native"- , testCompare+ , roundTripCompare "inline image" "docx/image_no_embed_writer.native"- , testCompare+ , roundTripCompare "inline image in links" "docx/inline_images_writer.native"- , testCompare+ , roundTripCompare "handling unicode input" "docx/unicode.native"- , testCompare+ , roundTripCompare "literal tabs" "docx/tabs.native"- , testCompare+ , roundTripCompare "normalizing inlines" "docx/normalize.native"- , testCompare+ , roundTripCompare "normalizing inlines deep inside blocks" "docx/deep_normalize.native"- , testCompare+ , roundTripCompare "move trailing spaces outside of formatting" "docx/trailing_spaces_in_formatting.native"- , testCompare+ , roundTripCompare "inline code (with VerbatimChar style)" "docx/inline_code.native"- , testCompare+ , roundTripCompare "inline code in subscript and superscript" "docx/verbatim_subsuper.native" ] , testGroup "blocks"- [ testCompare+ [ roundTripCompare "headers" "docx/headers.native"- , testCompare+ , roundTripCompare "headers already having auto identifiers" "docx/already_auto_ident.native"- , testCompare+ , roundTripCompare "numbered headers automatically made into list" "docx/numbered_header.native"- , testCompare+ , roundTripCompare "i18n blocks (headers and blockquotes)" "docx/i18n_blocks.native" -- Continuation does not survive round-trip- , testCompare+ , roundTripCompare "lists" "docx/lists_writer.native"- , testCompare+ , roundTripCompare "definition lists" "docx/definition_list.native"- , testCompare+ , roundTripCompare "custom defined lists in styles" "docx/german_styled_lists.native"- , testCompare+ , roundTripCompare "footnotes and endnotes" "docx/notes.native"- , testCompare+ , roundTripCompare "blockquotes (parsing indent as blockquote)" "docx/block_quotes_parse_indent.native"- , testCompare+ , roundTripCompare "hanging indents" "docx/hanging_indent.native" -- tables headers do not survive round-trip, should look into that- , testCompare+ , roundTripCompare "tables" "docx/tables.native"- , testCompare+ , roundTripCompare "tables with lists in cells" "docx/table_with_list_cell.native"- , testCompare+ , roundTripCompare "code block" "docx/codeblock.native"- , testCompare+ , roundTripCompare "dropcap paragraphs" "docx/drop_cap.native" ] , testGroup "metadata"- [ testCompareWithOpts (def,def{readerStandalone=True})+ [ roundTripCompareWithOpts (def,def{readerStandalone=True}) "metadata fields" "docx/metadata.native"- , testCompareWithOpts (def,def{readerStandalone=True})+ , roundTripCompareWithOpts (def,def{readerStandalone=True}) "stop recording metadata with normal text" "docx/metadata_after_normal.native"+ ]+ , testGroup "customized styles"+ [ testCompareWithOpts+ ( def{writerReferenceDocx=Just "docx/custom-style-reference.docx"}+ , def)+ "simple customized blocks and inlines"+ "docx/custom-style-roundtrip-start.native"+ "docx/custom-style-roundtrip-end.native" ] ]
tests/Tests/Writers/HTML.hs view
@@ -5,7 +5,7 @@ import Text.Pandoc.Builder import Text.Pandoc import Tests.Helpers-import Tests.Arbitrary()+import Text.Pandoc.Arbitrary() html :: (ToPandoc a) => a -> String html = writeHtmlString def{ writerWrapText = WrapNone } . toPandoc
tests/Tests/Writers/LaTeX.hs view
@@ -2,17 +2,20 @@ module Tests.Writers.LaTeX (tests) where import Test.Framework-import Text.Pandoc.Builder-import Text.Pandoc import Tests.Helpers-import Tests.Arbitrary()+import Text.Pandoc+import Text.Pandoc.Arbitrary ()+import Text.Pandoc.Builder latex :: (ToPandoc a) => a -> String-latex = writeLaTeX def{ writerHighlight = True } . toPandoc+latex = latexWithOpts def{ writerHighlight = True } latexListing :: (ToPandoc a) => a -> String-latexListing = writeLaTeX def{ writerListings = True } . toPandoc+latexListing = latexWithOpts def{ writerListings = True } +latexWithOpts :: (ToPandoc a) => WriterOptions -> a -> String+latexWithOpts opts = writeLaTeX opts . toPandoc+ {- "my test" =: X =?> Y @@ -75,5 +78,55 @@ "\\sout{\\texttt{foo} bar}" , "single quotes" =: code "dog's" =?> "\\texttt{dog\\textquotesingle{}s}"+ , "backtick" =:+ code "`nu?`" =?> "\\texttt{\\textasciigrave{}nu?\\textasciigrave{}}"+ ]+ , testGroup "writer options"+ [ testGroup "top-level division" $+ let+ headers = header 1 (text "header1")+ <> header 2 (text "header2")+ <> header 3 (text "header3")++ latexTopLevelDiv :: (ToPandoc a) => Division -> a -> String+ latexTopLevelDiv division =+ latexWithOpts def{ writerTopLevelDivision = division }++ beamerTopLevelDiv :: (ToPandoc a) => Division -> a -> String+ beamerTopLevelDiv division =+ latexWithOpts def { writerTopLevelDivision = division+ , writerBeamer = True }+ in+ [ test (latexTopLevelDiv Section) "sections as top-level" $ headers =?>+ unlines [ "\\section{header1}\n"+ , "\\subsection{header2}\n"+ , "\\subsubsection{header3}"+ ]+ , test (latexTopLevelDiv Chapter) "chapters as top-level" $ headers =?>+ unlines [ "\\chapter{header1}\n"+ , "\\section{header2}\n"+ , "\\subsection{header3}"+ ]+ , test (latexTopLevelDiv Part) "parts as top-level" $ headers =?>+ unlines [ "\\part{header1}\n"+ , "\\chapter{header2}\n"+ , "\\section{header3}"+ ]+ , test (beamerTopLevelDiv Section) "sections as top-level in beamer" $ headers =?>+ unlines [ "\\section{header1}\n"+ , "\\subsection{header2}\n"+ , "\\subsubsection{header3}"+ ]+ , test (beamerTopLevelDiv Chapter) "chapters are as part in beamer" $ headers =?>+ unlines [ "\\part{header1}\n"+ , "\\section{header2}\n"+ , "\\subsection{header3}"+ ]+ , test (beamerTopLevelDiv Part) "parts as top-level in beamer" $ headers =?>+ unlines [ "\\part{header1}\n"+ , "\\section{header2}\n"+ , "\\subsection{header3}"+ ]+ ] ] ]
tests/Tests/Writers/Markdown.hs view
@@ -6,11 +6,14 @@ import Text.Pandoc.Builder import Text.Pandoc import Tests.Helpers-import Tests.Arbitrary()+import Text.Pandoc.Arbitrary() markdown :: (ToPandoc a) => a -> String markdown = writeMarkdown def . toPandoc +markdownWithOpts :: (ToPandoc a) => WriterOptions -> a -> String+markdownWithOpts opts x = writeMarkdown opts $ toPandoc x+ {- "my test" =: X =?> Y @@ -36,13 +39,146 @@ =: bulletList [ plain "foo" <> bulletList [ plain "bar" ], plain "baz" ] =?> "- foo\n - bar\n- baz\n"- ] ++ [shortcutLinkRefsTests]+ ] ++ [noteTests] ++ [shortcutLinkRefsTests] +{-++Testing with the following text:++First Header+============++This is a footnote.[^1] And this is a [link](https://www.google.com).++> A note inside a block quote.[^2]+>+> A second paragraph.++Second Header+=============++Some more text.+++[^1]: Down here.++[^2]: The second note.++-}++noteTestDoc :: Blocks+noteTestDoc =+ header 1 "First Header" <>+ para ("This is a footnote." <>+ note (para "Down here.") <>+ " And this is a " <>+ link "https://www.google.com" "" "link" <>+ ".") <>+ blockQuote (para ("A note inside a block quote." <>+ note (para "The second note.")) <>+ para ("A second paragraph.")) <>+ header 1 "Second Header" <>+ para "Some more text."++++noteTests :: Test+noteTests = testGroup "note and reference location"+ [ test (markdownWithOpts def)+ "footnotes at the end of a document" $+ noteTestDoc =?>+ (unlines $ [ "First Header"+ , "============"+ , ""+ , "This is a footnote.[^1] And this is a [link](https://www.google.com)."+ , ""+ , "> A note inside a block quote.[^2]"+ , ">"+ , "> A second paragraph."+ , ""+ , "Second Header"+ , "============="+ , ""+ , "Some more text."+ , ""+ , "[^1]: Down here."+ , ""+ , "[^2]: The second note."+ ])+ , test (markdownWithOpts def{writerReferenceLocation=EndOfBlock})+ "footnotes at the end of blocks" $+ noteTestDoc =?>+ (unlines $ [ "First Header"+ , "============"+ , ""+ , "This is a footnote.[^1] And this is a [link](https://www.google.com)."+ , ""+ , "[^1]: Down here."+ , ""+ , "> A note inside a block quote.[^2]"+ , ">"+ , "> A second paragraph."+ , ""+ , "[^2]: The second note."+ , ""+ , "Second Header"+ , "============="+ , ""+ , "Some more text."+ ])+ , test (markdownWithOpts def{writerReferenceLocation=EndOfBlock, writerReferenceLinks=True})+ "footnotes and reference links at the end of blocks" $+ noteTestDoc =?>+ (unlines $ [ "First Header"+ , "============"+ , ""+ , "This is a footnote.[^1] And this is a [link]."+ , ""+ , "[^1]: Down here."+ , ""+ , " [link]: https://www.google.com"+ , ""+ , "> A note inside a block quote.[^2]"+ , ">"+ , "> A second paragraph."+ , ""+ , "[^2]: The second note."+ , ""+ , "Second Header"+ , "============="+ , ""+ , "Some more text."+ ])+ , test (markdownWithOpts def{writerReferenceLocation=EndOfSection})+ "footnotes at the end of section" $+ noteTestDoc =?>+ (unlines $ [ "First Header"+ , "============"+ , ""+ , "This is a footnote.[^1] And this is a [link](https://www.google.com)."+ , ""+ , "> A note inside a block quote.[^2]"+ , ">"+ , "> A second paragraph."+ , ""+ , "[^1]: Down here."+ , ""+ , "[^2]: The second note."+ , ""+ , "Second Header"+ , "============="+ , ""+ , "Some more text."+ ])++ ]+ shortcutLinkRefsTests :: Test shortcutLinkRefsTests = let infix 4 =: (=:) :: (ToString a, ToPandoc a)- => String -> (a, String) -> Test++ => String -> (a, String) -> Test (=:) = test (writeMarkdown (def {writerReferenceLinks = True}) . toPandoc) in testGroup "Shortcut reference links" [ "Simple link (shortcutable)"
tests/Tests/Writers/Native.hs view
@@ -4,7 +4,7 @@ import Text.Pandoc.Builder import Text.Pandoc import Tests.Helpers-import Tests.Arbitrary()+import Text.Pandoc.Arbitrary() p_write_rt :: Pandoc -> Bool p_write_rt d =
tests/Tests/Writers/Plain.hs view
@@ -5,7 +5,7 @@ import Text.Pandoc.Builder import Text.Pandoc import Tests.Helpers-import Tests.Arbitrary()+import Text.Pandoc.Arbitrary() infix 4 =:
tests/Tests/Writers/RST.hs view
@@ -5,7 +5,7 @@ import Text.Pandoc.Builder import Text.Pandoc import Tests.Helpers-import Tests.Arbitrary()+import Text.Pandoc.Arbitrary() infix 4 =: (=:) :: (ToString a, ToPandoc a)
tests/Tests/Writers/TEI.hs view
@@ -5,7 +5,7 @@ import Text.Pandoc.Builder import Text.Pandoc import Tests.Helpers-import Tests.Arbitrary()+import Text.Pandoc.Arbitrary() {- "my test" =: X =?> Y
+ tests/docx/custom-style-reference.docx view
binary file changed (absent → 14846 bytes)
+ tests/docx/custom-style-roundtrip-end.native view
@@ -0,0 +1,5 @@+[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "test",Space,Str "of",Space,Str "custom-styles."]+,Para [Str "Here",Space,Str "is",Space,Str "something",Space,Emph [Str "emphasized"],Str ".",Space,Str "And",Space,Str "here",Space,Str "is",Space,Str "something",Space,Strong [Str "strong"],Str "."]+,BlockQuote+ [Para [Str "One",Space,Str "paragraph",Space,Str "of",Space,Str "text."]+ ,Para [Str "And",Space,Str "another",Space,Str "paragraph",Space,Str "of",Space,Emph [Str "really",Space,Str "cool"],Space,Str "text."]]]
+ tests/docx/custom-style-roundtrip-start.native view
@@ -0,0 +1,5 @@+[Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "test",Space,Str "of",Space,Str "custom-styles."]+,Para [Str "Here",Space,Str "is",Space,Str "something",Space,Span ("",[],[("custom-style","Emphatic")]) [Str "emphasized"],Str ".",Space,Str "And",SoftBreak,Str "here",Space,Str "is",Space,Str "something",Space,Span ("",[],[("custom-style","Strengthened")]) [Str "strong"],Str "."]+,Div ("",[],[("custom-style","My Block Style")])+ [Para [Str "One",Space,Str "paragraph",Space,Str "of",Space,Str "text."]+ ,Para [Str "And",Space,Str "another",Space,Str "paragraph",Space,Str "of",Space,Span ("",[],[("custom-style","Emphatic")]) [Str "really",SoftBreak,Str "cool"],Space,Str "text."]]]
+ tests/docx/nested_anchors_in_header.docx view
binary file changed (absent → 17535 bytes)
+ tests/docx/nested_anchors_in_header.native view
@@ -0,0 +1,10 @@+[Header 1 ("short-instructions",[],[]) [Str "Short",Space,Str "instructions"]+,Para [Link ("",[],[]) [Str "Open",Space,Str "remote",Space,Str "folder"] ("#remote-folder-or-longlonglonglonglong-file-with-manymanymanymany-letters-inside-opening","")]+,Para [Str "Do",Space,Str "staff"]+,Para [Link ("",[],[]) [Str "Close",Space,Str "remote",Space,Str "folder"] ("#remote-folder-or-longlonglonglonglong-file-with-manymanymanymany-letters-inside-closing","")]+,Header 1 ("some-instructions",[],[]) [Str "Some",Space,Str "instructions"]+,Para [Str "Lines"]+,Header 2 ("remote-folder-or-longlonglonglonglong-file-with-manymanymanymany-letters-inside-opening",[],[]) [Str "Remote",Space,Str "folder",Space,Str "or",Space,Str "longlonglonglonglong",Space,Str "file",Space,Str "with",Space,Str "manymanymanymany",Space,Str "letters",Space,Str "inside",Space,Str "opening"]+,Para [Str "Open",Space,Str "folder"]+,Header 2 ("remote-folder-or-longlonglonglonglong-file-with-manymanymanymany-letters-inside-closing",[],[]) [Str "Remote",Space,Str "folder",Space,Str "or",Space,Str "longlonglonglonglong",Space,Str "file",Space,Str "with",Space,Str "manymanymanymany",Space,Str "letters",Space,Str "inside",Space,Str "closing"]+,Para [Str "Close",Space,Str "folder"]]
tests/lhs-test.latex view
@@ -84,6 +84,12 @@ \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}} \fi +% set default figure placement to htbp+\makeatletter+\def\fps@figure{htbp}+\makeatother++ \date{} \begin{document}
tests/lhs-test.latex+lhs view
@@ -48,6 +48,12 @@ \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}} \fi +% set default figure placement to htbp+\makeatletter+\def\fps@figure{htbp}+\makeatother++ \date{} \begin{document}
− tests/mallard-reader.native
@@ -1,3 +0,0 @@-Pandoc (Meta {unMeta = fromList [("guide-group",MetaInlines [Str ""]),("guide-xref",MetaInlines [Str "index#intro"]),("title",MetaInlines [Str "Title"])]})-[Header 1 ("introduction",[],[]) [Str "Title"]-,Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "test."]]
tests/markdown-reader-more.native view
@@ -84,8 +84,14 @@ ,BlockQuote [Header 2 ("foobar",["baz"],[("key","val")]) [Str "Header",Space,Str "attributes",Space,Str "inside",Space,Str "block",Space,Str "quote"]] ,Header 2 ("line-blocks",[],[]) [Str "Line",Space,Str "blocks"]-,Para [Str "But",Space,Str "can",Space,Str "a",Space,Str "bee",Space,Str "be",Space,Str "said",Space,Str "to",Space,Str "be",LineBreak,Str "\160\160\160\160or",Space,Str "not",Space,Str "to",Space,Str "be",Space,Str "an",Space,Str "entire",Space,Str "bee,",LineBreak,Str "\160\160\160\160\160\160\160\160when",Space,Str "half",Space,Str "the",Space,Str "bee",Space,Str "is",Space,Str "not",Space,Str "a",Space,Str "bee,",LineBreak,Str "\160\160\160\160\160\160\160\160\160\160\160\160due",Space,Str "to",Space,Str "some",Space,Str "ancient",Space,Str "injury?"]-,Para [Str "Continuation",Space,Str "line",LineBreak,Str "\160\160and",Space,Str "another"]+,LineBlock+ [[Str "But",Space,Str "can",Space,Str "a",Space,Str "bee",Space,Str "be",Space,Str "said",Space,Str "to",Space,Str "be"]+ ,[Str "\160\160\160\160or",Space,Str "not",Space,Str "to",Space,Str "be",Space,Str "an",Space,Str "entire",Space,Str "bee,"]+ ,[Str "\160\160\160\160\160\160\160\160when",Space,Str "half",Space,Str "the",Space,Str "bee",Space,Str "is",Space,Str "not",Space,Str "a",Space,Str "bee,"]+ ,[Str "\160\160\160\160\160\160\160\160\160\160\160\160due",Space,Str "to",Space,Str "some",Space,Str "ancient",Space,Str "injury?"]+ ,[]+ ,[Str "Continuation",Space,Str "line"]+ ,[Str "\160\160and",Space,Str "another"]] ,Header 2 ("grid-tables",[],[]) [Str "Grid",Space,Str "Tables"] ,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.2638888888888889,0.16666666666666666,0.18055555555555555] [[Plain [Str "col",Space,Str "1"]]@@ -163,4 +169,6 @@ ,Para [Link ("",[],[]) [Str "foo2"] ("","")] ,Header 2 ("wrapping-shouldnt-introduce-new-list-items",[],[]) [Str "Wrapping",Space,Str "shouldn\8217t",Space,Str "introduce",Space,Str "new",Space,Str "list",Space,Str "items"] ,BulletList- [[Plain [Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "2015."]]]]+ [[Plain [Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "blah",Space,Str "2015."]]]+,Header 2 ("bracketed-spans",[],[]) [Str "Bracketed",Space,Str "spans"]+,Para [Span ("id",["class"],[("key","val")]) [Emph [Str "foo"],Space,Str "bar",Space,Str "baz",Space,Link ("",[],[]) [Str "link"] ("url","")]]]
tests/markdown-reader-more.txt view
@@ -287,3 +287,6 @@ - blah blah blah blah blah blah blah blah blah blah blah blah blah blah 2015. +## Bracketed spans++[*foo* bar baz [link](url)]{.class #id key=val}
+ tests/odt/native/image.native view
@@ -0,0 +1,1 @@+[Para [Image ("",[],[("width","5.292cm"),("height","5.292cm")]) [] ("Pictures/10000000000000FA000000FAD6A15225.jpg","")]]
+ tests/odt/native/imageIndex.native view
@@ -0,0 +1,1 @@+[Para [Image ("",[],[("width","5.292cm"),("height","5.292cm")]) [Str "Abbildung",Space,Str "1:",Space,Str "Image",Space,Str "caption"] ("Pictures/10000000000000FA000000FAD6A15225.jpg","fig:")]]
+ tests/odt/native/imageWithCaption.native view
@@ -0,0 +1,1 @@+[Para [Image ("",[],[("width","5.292cm"),("height","5.292cm")]) [Str "Abbildung",Space,Str "1:",Space,Str "Image",Space,Str "caption"] ("Pictures/10000000000000FA000000FAD6A15225.jpg","fig:")]]
tests/odt/native/orderedListMixed.native view
@@ -1,1 +1,1 @@-Pandoc (Meta {unMeta = fromList []}) [OrderedList (1,Decimal,Period) [[Plain [Str "A",Space,Str "list",Space,Str "item"]],[Plain [Str "A",Space,Str "second"]],[Para [Str "A",Space,Str "third"],OrderedList (1,Decimal,Period) [[Para [Str "New",Space,Str "level!"],OrderedList (1,LowerAlpha,OneParen) [[Plain [Str "And",Space,Str "another!"]],[Plain [Str "It's",Space,Str "great",Space,Str "up",Space,Str "here!"]]]],[Plain [Str "Oh",Space,Str "noes"]],[Plain [Str "We",Space,Str "fell!"]]]],[Plain [Str "Maybe",Space,Str "someone"]],[Plain [Str "Pushed",Space,Str "us?"]]]]+Pandoc (Meta {unMeta = fromList []}) [OrderedList (1,Decimal,Period) [[Plain [Str "A",Space,Str "list",Space,Str "item"]],[Plain [Str "A",Space,Str "second"]],[Para [Str "A",Space,Str "third"],OrderedList (1,Decimal,Period) [[Para [Str "New",Space,Str "level!"],OrderedList (1,LowerAlpha,OneParen) [[Plain [Str "And",Space,Str "another!"]],[Plain [Str "It's",Space,Str "great",Space,Str "up",Space,Str "here!"]]]],[Plain [Str "Oh",Space,Str "noes"]],[Plain [Str "We",Space,Str "fell!"]]]],[Plain [Str "Maybe",Space,Str "someone"]],[Plain [Str "Pushed",Space,Str "us?"]]],Para [],OrderedList (4,Decimal,Period) [[Plain [Str "Start",Space,Str "new",Space,Str "list,",Space,Str "but",Space,Str "a",Space,Str "different",Space,Str "starting",Space,Str "point."]] ,[Plain [Str "Because",Space,Str "we",Space,Str "can."]]]]
tests/odt/native/orderedListRoman.native view
@@ -1,1 +1,1 @@-Pandoc (Meta {unMeta = fromList []}) [OrderedList (1,UpperRoman,Period) [[Plain[Str "A",Space,Str "list",Space,Str "item"]],[Plain [Str "A",Space,Str "second"]],[Para [Str "A",Space,Str "third"],OrderedList (1,UpperRoman,Period) [[Para [Str "New",Space,Str "level!"],OrderedList (1,UpperRoman,Period) [[Plain [Str "And",Space,Str "another!"]],[Plain [Str "It's",Space,Str "great",Space,Str "up",Space,Str "here!"]]]],[Plain [Str "Oh",Space,Str "noes"]],[Plain [Str "We",Space,Str "fell!"]]]],[Plain [Str "Maybe",Space,Str "someone"]],[Plain [Str "Pushed",Space,Str "us?"]]]]+Pandoc (Meta {unMeta = fromList []}) [OrderedList (1,UpperRoman,Period) [[Plain[Str "A",Space,Str "list",Space,Str "item"]],[Plain [Str "A",Space,Str "second"]],[Para [Str "A",Space,Str "third"],OrderedList (1,UpperRoman,Period) [[Para [Str "New",Space,Str "level!"],OrderedList (1,UpperRoman,Period) [[Plain [Str "And",Space,Str "another!"]],[Plain [Str "It's",Space,Str "great",Space,Str "up",Space,Str "here!"]]]],[Plain [Str "Oh",Space,Str "noes"]],[Plain [Str "We",Space,Str "fell!"]]]],[Plain [Str "Maybe",Space,Str "someone"]],[Plain [Str "Pushed",Space,Str "us?"]]],Para [],OrderedList (4,UpperRoman,Period) [[Plain [Str "Start",Space,Str "new",Space,Str "list,",Space,Str "but",Space,Str "a",Space,Str "different",Space,Str "starting",Space,Str "point."]] ,[Plain [Str "Because",Space,Str "we",Space,Str "can."]]]]
tests/odt/native/orderedListSimple.native view
@@ -1,1 +1,1 @@-Pandoc (Meta {unMeta = fromList []}) [OrderedList (1,Decimal,Period) [[Plain [Str "A",Space,Str "list",Space,Str "item"]],[Plain [Str "A",Space,Str "second"]],[Para [Str "A",Space,Str "third"],OrderedList (1,Decimal,Period) [[Para [Str "New",Space,Str "level!"],OrderedList (1,Decimal,Period) [[Plain [Str "And",Space,Str "another!"]],[Plain [Str "It's",Space,Str "great",Space,Str "up",Space,Str "here!"]]]],[Plain [Str "Oh",Space,Str "noes"]],[Plain [Str "We",Space,Str "fell!"]]]],[Plain [Str "Maybe",Space,Str "someone"]],[Plain [Str "Pushed",Space,Str "us?"]]]]+Pandoc (Meta {unMeta = fromList []}) [OrderedList (1,Decimal,Period) [[Plain [Str "A",Space,Str "list",Space,Str "item"]],[Plain [Str "A",Space,Str "second"]],[Para [Str "A",Space,Str "third"],OrderedList (1,Decimal,Period) [[Para [Str "New",Space,Str "level!"],OrderedList (1,Decimal,Period) [[Plain [Str "And",Space,Str "another!"]],[Plain [Str "It's",Space,Str "great",Space,Str "up",Space,Str "here!"]]]],[Plain [Str "Oh",Space,Str "noes"]],[Plain [Str "We",Space,Str "fell!"]]]],[Plain [Str "Maybe",Space,Str "someone"]],[Plain [Str "Pushed",Space,Str "us?"]]],Para [],OrderedList (4,Decimal,Period) [[Plain [Str "Start",Space,Str "new",Space,Str "list,",Space,Str "but",Space,Str "a",Space,Str "different",Space,Str "starting",Space,Str "point."]] ,[Plain [Str "Because",Space,Str "we",Space,Str "can."]]]]
tests/odt/native/referenceToText.native view
@@ -1,1 +1,1 @@-[Para [Span ("an anchor",[],[]) [],Str "Some",Space,Str "text."],Para [Str "A",Space,Str "reference",Space,Str "to",Space,Link ("",[],[]) [Str "Some",Space,Str "text"] ("#an anchor",""),Str "."]]+[Para [Span ("an anchor",[],[]) [],Str "Some",Space,Str "text."],Para [Str "A",Space,Str "reference",Space,Str "to",Space,Link ("",[],[]) [Str "Some",Space,Str "text"] ("#an anchor",""),Str "."],Para [Str "Some",Space,Str "text",LineBreak,Str "Another",Space,Str "one",Space,Str "with",Space,Str "a",Space,Str "link",Span ("anchor",[],[]) []]]
tests/odt/odt/orderedListMixed.odt view
binary file changed (10580 → 11970 bytes)
tests/odt/odt/orderedListRoman.odt view
binary file changed (10622 → 11730 bytes)
tests/odt/odt/orderedListSimple.odt view
binary file changed (10570 → 11817 bytes)
tests/odt/odt/referenceToText.odt view
binary file changed (10179 → 10208 bytes)
tests/rst-reader.native view
@@ -230,8 +230,14 @@ ,Para [Str "Another",Space,Str "paragraph"] ,Para [Str "A",Space,Str "third",Space,Str "paragraph"] ,Header 1 ("line-blocks",[],[]) [Str "Line",Space,Str "blocks"]-,Para [Str "But",Space,Str "can",Space,Str "a",Space,Str "bee",Space,Str "be",Space,Str "said",Space,Str "to",Space,Str "be",LineBreak,Str "\160\160\160\160or",Space,Str "not",Space,Str "to",Space,Str "be",Space,Str "an",Space,Str "entire",Space,Str "bee,",LineBreak,Str "\160\160\160\160\160\160\160\160when",Space,Str "half",Space,Str "the",Space,Str "bee",Space,Str "is",Space,Str "not",Space,Str "a",Space,Str "bee,",LineBreak,Str "\160\160\160\160\160\160\160\160\160\160\160\160due",Space,Str "to",Space,Str "some",Space,Str "ancient",Space,Str "injury?"]-,Para [Str "Continuation",Space,Str "line",LineBreak,Str "\160\160and",Space,Str "another"]+,LineBlock+ [[Str "But",Space,Str "can",Space,Str "a",Space,Str "bee",Space,Str "be",Space,Str "said",Space,Str "to",Space,Str "be"]+ ,[Str "\160\160\160\160or",Space,Str "not",Space,Str "to",Space,Str "be",Space,Str "an",Space,Str "entire",Space,Str "bee,"]+ ,[Str "\160\160\160\160\160\160\160\160when",Space,Str "half",Space,Str "the",Space,Str "bee",Space,Str "is",Space,Str "not",Space,Str "a",Space,Str "bee,"]+ ,[Str "\160\160\160\160\160\160\160\160\160\160\160\160due",Space,Str "to",Space,Str "some",Space,Str "ancient",Space,Str "injury?"]+ ,[]+ ,[Str "Continuation",Space,Str "line"]+ ,[Str "\160\160and",Space,Str "another"]] ,Header 1 ("simple-tables",[],[]) [Str "Simple",Space,Str "Tables"] ,Table [] [AlignDefault,AlignDefault,AlignDefault] [0.0,0.0,0.0] [[Plain [Str "col",Space,Str "1"]]
tests/textile-reader.native view
@@ -25,7 +25,9 @@ ,CodeBlock ("",[],[]) " ---- (should be four hyphens)\n\n sub status {\n print \"working\";\n }\n\n this code block is indented by one tab" ,Para [Str "And:"] ,CodeBlock ("",[],[]) " this code block is indented by two tabs\n\n These should not be escaped: \\$ \\\\ \\> \\[ \\{"-,CodeBlock ("",[],[]) "Code block with .bc\n continued\n @</\\\n"+,CodeBlock ("",[],[]) "Code block with .bc\n continued\n @</\\"+,CodeBlock ("",[],[]) "extended code block\n\n continued"+,Para [Str "ended",Space,Str "by",Space,Str "paragraph"] ,Para [Str "Inline",Space,Str "code:",Space,Code ("",[],[]) "<tt>",Str ",",Space,Code ("",[],[]) "@",Str "."] ,Header 1 ("notextile",[],[]) [Str "Notextile"] ,Para [Str "A",Space,Str "block",Space,Str "of",Space,Str "text",Space,Str "can",Space,Str "be",Space,Str "protected",Space,Str "with",Space,Str "notextile",Space,Str ":"]@@ -94,6 +96,7 @@ ,Header 2 ("explicit",[],[]) [Str "Explicit"] ,Para [Str "Just",Space,Str "a",Space,Link ("",[],[]) [Str "url"] ("http://www.url.com","")] ,Para [Link ("",[],[]) [Str "Email",Space,Str "link"] ("mailto:nobody@nowhere.net","")]+,Para [Str "\"not",Space,Str "a",Space,Str "link\":",Space,Str "foo"] ,Para [Str "Automatic",Space,Str "linking",Space,Str "to",Space,Link ("",[],[]) [Str "http://www.example.com"] ("http://www.example.com",""),Str "."] ,Para [Link ("",[],[]) [Str "Example"] ("http://www.example.com/",""),Str ":",Space,Str "Example",Space,Str "of",Space,Str "a",Space,Str "link",Space,Str "followed",Space,Str "by",Space,Str "a",Space,Str "colon."] ,Para [Str "A",Space,Str "link",Link ("",[],[]) [Str "with",Space,Str "brackets"] ("http://www.example.com",""),Str "and",Space,Str "no",Space,Str "spaces."]
tests/textile-reader.textile view
@@ -68,6 +68,11 @@ continued @</\ +bc.. extended code block++ continued+p. ended by paragraph+ Inline code: @<tt>@, <tt>@</tt>. h1. Notextile@@ -168,6 +173,8 @@ Just a "url":http://www.url.com "Email link":mailto:nobody@nowhere.net++"not a link": foo Automatic linking to "$":http://www.example.com.
tests/writer.asciidoc view
@@ -435,11 +435,11 @@ Inline Markup ------------- -This is __emphasized__, and so __is this__.+This is _emphasized_, and so _is this_. -This is **strong**, and so **is this**.+This is *strong*, and so *is this*. -An __link:/url[emphasized link]__.+An _link:/url[emphasized link]_. *_This is strong and em._* @@ -451,7 +451,7 @@ This is code: `>`, `$`, `\`, `\$`, `<html>`. -[line-through]*This is __strikeout__.*+[line-through]*This is _strikeout_.* Superscripts: a^bc^d a^_hello_^ a^hello there^.
tests/writer.latex view
@@ -62,6 +62,12 @@ \renewcommand{\subparagraph}[1]{\oldsubparagraph{#1}\mbox{}} \fi +% set default figure placement to htbp+\makeatletter+\def\fps@figure{htbp}+\makeatother++ \title{Pandoc Test Suite} \author{John MacFarlane \and Anonymous} \date{July 17, 2006}@@ -917,7 +923,7 @@ From ``Voyage dans la Lune'' by Georges Melies (1902): -\begin{figure}[htbp]+\begin{figure} \centering \includegraphics{lalune.jpg} \caption{lalune}
tests/writer.org view
@@ -808,9 +808,9 @@ From "Voyage dans la Lune" by Georges Melies (1902): #+CAPTION: lalune+[[file:lalune.jpg]] -[[lalune.jpg]]-Here is a movie [[movie.jpg]] icon.+Here is a movie [[file:movie.jpg]] icon. -------------- @@ -819,15 +819,15 @@ :CUSTOM_ID: footnotes :END: -Here is a footnote reference, [1] and another. [2] This should /not/ be a+Here is a footnote reference,[1] and another.[2] This should /not/ be a footnote reference, because it contains a space.[\^my note] Here is an inline-note. [3]+note.[3] #+BEGIN_QUOTE- Notes can go in quotes. [4]+ Notes can go in quotes.[4] #+END_QUOTE -1. And in list items. [5]+1. And in list items.[5] This paragraph should not be part of the note, as it is not indented.
tests/writers-lang-and-dir.latex view
@@ -77,6 +77,12 @@ \newenvironment{LTR}{\beginL}{\endL} \fi +% set default figure placement to htbp+\makeatletter+\def\fps@figure{htbp}+\makeatother++ \date{} \begin{document}