    {-# LANGUAGE OverloadedStrings #-}
    {- |
       Module      : Text.Pandoc.Readers.DocBook
       Copyright   : Copyright (C) 2006-2020 John MacFarlane
       License     : GNU GPL, version 2 or above

       Maintainer  : John MacFarlane <jgm@berkeley.edu>
       Stability   : alpha
       Portability : portable

    Conversion of DocBook XML to 'Pandoc' document.
    -}
    module Text.Pandoc.Readers.DocBook ( readDocBook ) where
    import Control.Monad.State.Strict
    import Data.Char (isSpace, toUpper)
    import Data.Default
    import Data.Either (rights)
    import Data.Foldable (asum)
    import Data.Generics
    import Data.List (intersperse)
    import Data.Maybe (fromMaybe)
    import Data.Text (Text)
    import qualified Data.Text as T
    import Text.HTML.TagSoup.Entity (lookupEntity)
    import Text.Pandoc.Builder
    import Text.Pandoc.Class.PandocMonad (PandocMonad, report)
    import Text.Pandoc.Options
    import Text.Pandoc.Logging (LogMessage(..))
    import Text.Pandoc.Shared (crFilter, safeRead)
    import Text.TeXMath (readMathML, writeTeX)
    import Text.XML.Light

    {-

    List of all DocBook tags, with [x] indicating implemented,
    [o] meaning intentionally left unimplemented (pass through):

    [o] abbrev - An abbreviation, especially one followed by a period
    [x] abstract - A summary
    [o] accel - A graphical user interface (GUI) keyboard shortcut
    [x] ackno - Acknowledgements in an Article
    [o] acronym - An often pronounceable word made from the initial
    [o] action - A response to a user event
    [o] address - A real-world address, generally a postal address
    [ ] affiliation - The institutional affiliation of an individual
    [ ] alt - Text representation for a graphical element
    [o] anchor - A spot in the document
    [x] answer - An answer to a question posed in a QandASet
    [x] appendix - An appendix in a Book or Article
    [x] appendixinfo - Meta-information for an Appendix
    [o] application - The name of a software program
    [x] area - A region defined for a Callout in a graphic or code example
    [x] areaset - A set of related areas in a graphic or code example
    [x] areaspec - A collection of regions in a graphic or code example
    [ ] arg - An argument in a CmdSynopsis
    [x] article - An article
    [x] articleinfo - Meta-information for an Article
    [ ] artpagenums - The page numbers of an article as published
    [x] attribution - The source of a block quote or epigraph
    [ ] audiodata - Pointer to external audio data
    [ ] audioobject - A wrapper for audio data and its associated meta-information
    [x] author - The name of an individual author
    [ ] authorblurb - A short description or note about an author
    [x] authorgroup - Wrapper for author information when a document has
        multiple authors or collaborators
    [x] authorinitials - The initials or other short identifier for an author
    [o] beginpage - The location of a page break in a print version of the document
    [ ] bibliocoverage - The spatial or temporal coverage of a document
    [x] bibliodiv - A section of a Bibliography
    [x] biblioentry - An entry in a Bibliography
    [x] bibliography - A bibliography
    [ ] bibliographyinfo - Meta-information for a Bibliography
    [ ] biblioid - An identifier for a document
    [o] bibliolist - A wrapper for a set of bibliography entries
    [ ] bibliomisc - Untyped bibliographic information
    [x] bibliomixed - An entry in a Bibliography
    [ ] bibliomset - A cooked container for related bibliographic information
    [ ] biblioref - A cross reference to a bibliographic entry
    [ ] bibliorelation - The relationship of a document to another
    [ ] biblioset - A raw container for related bibliographic information
    [ ] bibliosource - The source of a document
    [ ] blockinfo - Meta-information for a block element
    [x] blockquote - A quotation set off from the main text
    [x] book - A book
    [x] bookinfo - Meta-information for a Book
    [x] bridgehead - A free-floating heading
    [x] callout - A “called out” description of a marked Area
    [x] calloutlist - A list of Callouts
    [x] caption - A caption
    [x] caution - A note of caution
    [x] chapter - A chapter, as of a book
    [x] chapterinfo - Meta-information for a Chapter
    [ ] citation - An inline bibliographic reference to another published work
    [ ] citebiblioid - A citation of a bibliographic identifier
    [ ] citerefentry - A citation to a reference page
    [ ] citetitle - The title of a cited work
    [ ] city - The name of a city in an address
    [x] classname - The name of a class, in the object-oriented programming sense
    [ ] classsynopsis - The syntax summary for a class definition
    [ ] classsynopsisinfo - Information supplementing the contents of
        a ClassSynopsis
    [ ] cmdsynopsis - A syntax summary for a software command
    [ ] co - The location of a callout embedded in text
    [x] code - An inline code fragment
    [x] col - Specifications for a column in an HTML table
    [x] colgroup - A group of columns in an HTML table
    [ ] collab - Identifies a collaborator
    [ ] collabname - The name of a collaborator
    [ ] colophon - Text at the back of a book describing facts about its production
    [x] colspec - Specifications for a column in a table
    [x] command - The name of an executable program or other software command
    [x] computeroutput - Data, generally text, displayed or presented by a computer
    [ ] confdates - The dates of a conference for which a document was written
    [ ] confgroup - A wrapper for document meta-information about a conference
    [ ] confnum - An identifier, frequently numerical, associated with a conference for which a document was written
    [ ] confsponsor - The sponsor of a conference for which a document was written
    [ ] conftitle - The title of a conference for which a document was written
    [x] constant - A programming or system constant
    [ ] constraint - A constraint in an EBNF production
    [ ] constraintdef - The definition of a constraint in an EBNF production
    [ ] constructorsynopsis - A syntax summary for a constructor
    [ ] contractnum - The contract number of a document
    [ ] contractsponsor - The sponsor of a contract
    [ ] contrib - A summary of the contributions made to a document by a
        credited source
    [ ] copyright - Copyright information about a document
    [ ] coref - A cross reference to a co
    [ ] corpauthor - A corporate author, as opposed to an individual
    [ ] corpcredit - A corporation or organization credited in a document
    [ ] corpname - The name of a corporation
    [ ] country - The name of a country
    [ ] database - The name of a database, or part of a database
    [x] date - The date of publication or revision of a document
    [ ] dedication - A wrapper for the dedication section of a book
    [ ] destructorsynopsis - A syntax summary for a destructor
    [ ] edition - The name or number of an edition of a document
    [ ] editor - The name of the editor of a document
    [x] email - An email address
    [x] emphasis - Emphasized text
    [x] entry - A cell in a table
    [ ] entrytbl - A subtable appearing in place of an Entry in a table
    [ ] envar - A software environment variable
    [x] epigraph - A short inscription at the beginning of a document or component
        note:  also handle embedded attribution tag
    [x] equation - A displayed mathematical equation
    [ ] errorcode - An error code
    [ ] errorname - An error name
    [ ] errortext - An error message.
    [ ] errortype - The classification of an error message
    [ ] example - A formal example, with a title
    [ ] exceptionname - The name of an exception
    [ ] fax - A fax number
    [ ] fieldsynopsis - The name of a field in a class definition
    [x] figure - A formal figure, generally an illustration, with a title
    [x] filename - The name of a file
    [ ] firstname - The first name of a person
    [ ] firstterm - The first occurrence of a term
    [x] footnote - A footnote
    [ ] footnoteref - A cross reference to a footnote (a footnote mark)
    [x] foreignphrase - A word or phrase in a language other than the primary
        language of the document
    [x] formalpara - A paragraph with a title
    [ ] funcdef - A function (subroutine) name and its return type
    [ ] funcparams - Parameters for a function referenced through a function
        pointer in a synopsis
    [ ] funcprototype - The prototype of a function
    [ ] funcsynopsis - The syntax summary for a function definition
    [ ] funcsynopsisinfo - Information supplementing the FuncDefs of a FuncSynopsis
    [x] function - The name of a function or subroutine, as in a
        programming language
    [x] glossary - A glossary
    [x] glossaryinfo - Meta-information for a Glossary
    [x] glossdef - A definition in a GlossEntry
    [x] glossdiv - A division in a Glossary
    [x] glossentry - An entry in a Glossary or GlossList
    [x] glosslist - A wrapper for a set of GlossEntrys
    [x] glosssee - A cross-reference from one GlossEntry to another
    [x] glossseealso - A cross-reference from one GlossEntry to another
    [x] glossterm - A glossary term
    [ ] graphic - A displayed graphical object (not an inline)
        Note: in DocBook v5 `graphic` is discarded
    [ ] graphicco - A graphic that contains callout areas
        Note: in DocBook v5 `graphicco` is discarded
    [ ] group - A group of elements in a CmdSynopsis
    [ ] guibutton - The text on a button in a GUI
    [ ] guiicon - Graphic and/or text appearing as a icon in a GUI
    [ ] guilabel - The text of a label in a GUI
    [x] guimenu - The name of a menu in a GUI
    [x] guimenuitem - The name of a terminal menu item in a GUI
    [x] guisubmenu - The name of a submenu in a GUI
    [ ] hardware - A physical part of a computer system
    [ ] highlights - A summary of the main points of the discussed component
    [ ] holder - The name of the individual or organization that holds a copyright
    [o] honorific - The title of a person
    [ ] html:form - An HTML form
    [x] imagedata - Pointer to external image data (only `fileref` attribute
        implemented but not `entityref` which would require parsing of the DTD)
    [x] imageobject - A wrapper for image data and its associated meta-information
    [ ] imageobjectco - A wrapper for an image object with callouts
    [x] important - An admonition set off from the text
    [x] index - An index
    [x] indexdiv - A division in an index
    [x] indexentry - An entry in an index
    [x] indexinfo - Meta-information for an Index
    [x] indexterm - A wrapper for terms to be indexed
    [x] info - A wrapper for information about a component or other block. (DocBook v5)
    [x] informalequation - A displayed mathematical equation without a title
    [x] informalexample - A displayed example without a title
    [ ] informalfigure - A untitled figure
    [ ] informaltable - A table without a title
    [ ] initializer - The initializer for a FieldSynopsis
    [x] inlineequation - A mathematical equation or expression occurring inline
    [ ] inlinegraphic - An object containing or pointing to graphical data
        that will be rendered inline
    [x] inlinemediaobject - An inline media object (video, audio, image, and so on)
    [ ] interface - An element of a GUI
    [ ] interfacename - The name of an interface
    [ ] invpartnumber - An inventory part number
    [ ] isbn - The International Standard Book Number of a document
    [ ] issn - The International Standard Serial Number of a periodical
    [ ] issuenum - The number of an issue of a journal
    [x] itemizedlist - A list in which each entry is marked with a bullet or
        other dingbat
    [ ] itermset - A set of index terms in the meta-information of a document
    [ ] jobtitle - The title of an individual in an organization
    [x] keycap - The text printed on a key on a keyboard
    [ ] keycode - The internal, frequently numeric, identifier for a key
        on a keyboard
    [x] keycombo - A combination of input actions
    [ ] keysym - The symbolic name of a key on a keyboard
    [ ] keyword - One of a set of keywords describing the content of a document
    [ ] keywordset - A set of keywords describing the content of a document
    [ ] label - A label on a Question or Answer
    [ ] legalnotice - A statement of legal obligations or requirements
    [ ] lhs - The left-hand side of an EBNF production
    [ ] lineage - The portion of a person's name indicating a relationship to
        ancestors
    [ ] lineannotation - A comment on a line in a verbatim listing
    [x] link - A hypertext link
    [x] listitem - A wrapper for the elements of a list item
    [x] literal - Inline text that is some literal value
    [x] literallayout - A block of text in which line breaks and white space are
        to be reproduced faithfully
    [ ] lot - A list of the titles of formal objects (as tables or figures) in
        a document
    [ ] lotentry - An entry in a list of titles
    [ ] manvolnum - A reference volume number
    [x] markup - A string of formatting markup in text that is to be
        represented literally
    [x] mathphrase - A mathematical phrase, an expression that can be represented
        with ordinary text and a small amount of markup
    [ ] medialabel - A name that identifies the physical medium on which some
        information resides
    [x] mediaobject - A displayed media object (video, audio, image, etc.)
    [ ] mediaobjectco - A media object that contains callouts
    [x] member - An element of a simple list
    [x] menuchoice - A selection or series of selections from a menu
    [ ] methodname - The name of a method
    [ ] methodparam - Parameters to a method
    [ ] methodsynopsis - A syntax summary for a method
    [x] mml:math - A MathML equation
    [ ] modespec - Application-specific information necessary for the
        completion of an OLink
    [ ] modifier - Modifiers in a synopsis
    [ ] mousebutton - The conventional name of a mouse button
    [ ] msg - A message in a message set
    [ ] msgaud - The audience to which a message in a message set is relevant
    [ ] msgentry - A wrapper for an entry in a message set
    [ ] msgexplan - Explanatory material relating to a message in a message set
    [ ] msginfo - Information about a message in a message set
    [ ] msglevel - The level of importance or severity of a message in a message set
    [ ] msgmain - The primary component of a message in a message set
    [ ] msgorig - The origin of a message in a message set
    [ ] msgrel - A related component of a message in a message set
    [ ] msgset - A detailed set of messages, usually error messages
    [ ] msgsub - A subcomponent of a message in a message set
    [ ] msgtext - The actual text of a message component in a message set
    [ ] nonterminal - A non-terminal in an EBNF production
    [x] note - A message set off from the text
    [ ] objectinfo - Meta-information for an object
    [ ] olink - A link that addresses its target indirectly, through an entity
    [ ] ooclass - A class in an object-oriented programming language
    [ ] ooexception - An exception in an object-oriented programming language
    [ ] oointerface - An interface in an object-oriented programming language
    [x] option - An option for a software command
    [x] optional - Optional information
    [x] orderedlist - A list in which each entry is marked with a sequentially
        incremented label
    [ ] orgdiv - A division of an organization
    [ ] orgname - The name of an organization other than a corporation
    [ ] otheraddr - Uncategorized information in address
    [ ] othercredit - A person or entity, other than an author or editor,
        credited in a document
    [ ] othername - A component of a persons name that is not a first name,
        surname, or lineage
    [ ] package - A package
    [ ] pagenums - The numbers of the pages in a book, for use in a bibliographic
        entry
    [x] para - A paragraph
    [ ] paramdef - Information about a function parameter in a programming language
    [x] parameter - A value or a symbolic reference to a value
    [ ] part - A division in a book
    [ ] partinfo - Meta-information for a Part
    [ ] partintro - An introduction to the contents of a part
    [ ] personblurb - A short description or note about a person
    [ ] personname - The personal name of an individual
    [ ] phone - A telephone number
    [ ] phrase - A span of text
    [ ] pob - A post office box in an address
    [ ] postcode - A postal code in an address
    [x] preface - Introductory matter preceding the first chapter of a book
    [ ] prefaceinfo - Meta-information for a Preface
    [ ] primary - The primary word or phrase under which an index term should be
        sorted
    [ ] primaryie - A primary term in an index entry, not in the text
    [ ] printhistory - The printing history of a document
    [ ] procedure - A list of operations to be performed in a well-defined sequence
    [ ] production - A production in a set of EBNF productions
    [ ] productionrecap - A cross-reference to an EBNF production
    [ ] productionset - A set of EBNF productions
    [ ] productname - The formal name of a product
    [ ] productnumber - A number assigned to a product
    [x] programlisting - A literal listing of all or part of a program
    [ ] programlistingco - A program listing with associated areas used in callouts
    [x] prompt - A character or string indicating the start of an input field in
        a computer display
    [ ] property - A unit of data associated with some part of a computer system
    [ ] pubdate - The date of publication of a document
    [ ] publisher - The publisher of a document
    [ ] publishername - The name of the publisher of a document
    [ ] pubsnumber - A number assigned to a publication other than an ISBN or ISSN
        or inventory part number
    [x] qandadiv - A titled division in a QandASet
    [o] qandaentry - A question/answer set within a QandASet
    [o] qandaset - A question-and-answer set
    [x] question - A question in a QandASet
    [x] quote - An inline quotation
    [ ] refclass - The scope or other indication of applicability of a
        reference entry
    [ ] refdescriptor - A description of the topic of a reference page
    [ ] refentry - A reference page (originally a UNIX man-style reference page)
    [ ] refentryinfo - Meta-information for a Refentry
    [ ] refentrytitle - The title of a reference page
    [ ] reference - A collection of reference entries
    [ ] referenceinfo - Meta-information for a Reference
    [ ] refmeta - Meta-information for a reference entry
    [ ] refmiscinfo - Meta-information for a reference entry other than the title
        and volume number
    [ ] refname - The name of (one of) the subject(s) of a reference page
    [ ] refnamediv - The name, purpose, and classification of a reference page
    [ ] refpurpose - A short (one sentence) synopsis of the topic of a reference
        page
    [x] refsect1 - A major subsection of a reference entry
    [x] refsect1info - Meta-information for a RefSect1
    [x] refsect2 - A subsection of a RefSect1
    [x] refsect2info - Meta-information for a RefSect2
    [x] refsect3 - A subsection of a RefSect2
    [x] refsect3info - Meta-information for a RefSect3
    [x] refsection - A recursive section in a refentry
    [x] refsectioninfo - Meta-information for a refsection
    [ ] refsynopsisdiv - A syntactic synopsis of the subject of the reference page
    [ ] refsynopsisdivinfo - Meta-information for a RefSynopsisDiv
    [x] releaseinfo - Information about a particular release of a document
    [ ] remark - A remark (or comment) intended for presentation in a draft
        manuscript
    [ ] replaceable - Content that may or must be replaced by the user
    [ ] returnvalue - The value returned by a function
    [ ] revdescription - A extended description of a revision to a document
    [ ] revhistory - A history of the revisions to a document
    [ ] revision - An entry describing a single revision in the history of the
        revisions to a document
    [ ] revnumber - A document revision number
    [ ] revremark - A description of a revision to a document
    [ ] rhs - The right-hand side of an EBNF production
    [x] row - A row in a table
    [ ] sbr - An explicit line break in a command synopsis
    [x] screen - Text that a user sees or might see on a computer screen
    [o] screenco - A screen with associated areas used in callouts
    [o] screeninfo - Information about how a screen shot was produced
    [ ] screenshot - A representation of what the user sees or might see on a
        computer screen
    [ ] secondary - A secondary word or phrase in an index term
    [ ] secondaryie - A secondary term in an index entry, rather than in the text
    [x] sect1 - A top-level section of document
    [x] sect1info - Meta-information for a Sect1
    [x] sect2 - A subsection within a Sect1
    [x] sect2info - Meta-information for a Sect2
    [x] sect3 - A subsection within a Sect2
    [x] sect3info - Meta-information for a Sect3
    [x] sect4 - A subsection within a Sect3
    [x] sect4info - Meta-information for a Sect4
    [x] sect5 - A subsection within a Sect4
    [x] sect5info - Meta-information for a Sect5
    [x] section - A recursive section
    [x] sectioninfo - Meta-information for a recursive section
    [x] see - Part of an index term directing the reader instead to another entry
        in the index
    [x] seealso - Part of an index term directing the reader also to another entry
        in the index
    [ ] seealsoie - A See also entry in an index, rather than in the text
    [ ] seeie - A See entry in an index, rather than in the text
    [x] seg - An element of a list item in a segmented list
    [x] seglistitem - A list item in a segmented list
    [x] segmentedlist - A segmented list, a list of sets of elements
    [x] segtitle - The title of an element of a list item in a segmented list
    [ ] seriesvolnums - Numbers of the volumes in a series of books
    [ ] set - A collection of books
    [ ] setindex - An index to a set of books
    [ ] setindexinfo - Meta-information for a SetIndex
    [ ] setinfo - Meta-information for a Set
    [ ] sgmltag - A component of SGML markup
    [ ] shortaffil - A brief description of an affiliation
    [ ] shortcut - A key combination for an action that is also accessible through
        a menu
    [ ] sidebar - A portion of a document that is isolated from the main
        narrative flow
    [ ] sidebarinfo - Meta-information for a Sidebar
    [x] simpara - A paragraph that contains only text and inline markup, no block
        elements
    [x] simplelist - An undecorated list of single words or short phrases
    [ ] simplemsgentry - A wrapper for a simpler entry in a message set
    [ ] simplesect - A section of a document with no subdivisions
    [ ] spanspec - Formatting information for a spanned column in a table
    [ ] state - A state or province in an address
    [ ] step - A unit of action in a procedure
    [ ] stepalternatives - Alternative steps in a procedure
    [ ] street - A street address in an address
    [ ] structfield - A field in a structure (in the programming language sense)
    [ ] structname - The name of a structure (in the programming language sense)
    [ ] subject - One of a group of terms describing the subject matter of a
        document
    [ ] subjectset - A set of terms describing the subject matter of a document
    [ ] subjectterm - A term in a group of terms describing the subject matter of
        a document
    [x] subscript - A subscript (as in H2O, the molecular formula for water)
    [ ] substeps - A wrapper for steps that occur within steps in a procedure
    [x] subtitle - The subtitle of a document
    [x] superscript - A superscript (as in x2, the mathematical notation for x
        multiplied by itself)
    [ ] surname - A family name; in western cultures the last name
    [ ] svg:svg - An SVG graphic
    [x] symbol - A name that is replaced by a value before processing
    [ ] synopfragment - A portion of a CmdSynopsis broken out from the main body
        of the synopsis
    [ ] synopfragmentref - A reference to a fragment of a command synopsis
    [ ] synopsis - A general-purpose element for representing the syntax of
        commands or functions
    [ ] systemitem - A system-related item or term
    [ ] table - A formal table in a document
    [ ] task - A task to be completed
    [ ] taskprerequisites - The prerequisites for a task
    [ ] taskrelated - Information related to a task
    [ ] tasksummary - A summary of a task
    [x] tbody - A wrapper for the rows of a table or informal table
    [x] td - A table entry in an HTML table
    [x] term - The word or phrase being defined or described in a variable list
    [ ] termdef - An inline term definition
    [ ] tertiary - A tertiary word or phrase in an index term
    [ ] tertiaryie - A tertiary term in an index entry, rather than in the text
    [ ] textdata - Pointer to external text data
    [ ] textobject - A wrapper for a text description of an object and its
        associated meta-information
    [ ] tfoot - A table footer consisting of one or more rows
    [x] tgroup - A wrapper for the main content of a table, or part of a table
    [x] th - A table header entry in an HTML table
    [x] thead - A table header consisting of one or more rows
    [x] tip - A suggestion to the user, set off from the text
    [x] title - The text of the title of a section of a document or of a formal
        block-level element
    [x] titleabbrev - The abbreviation of a Title
    [x] toc - A table of contents
    [x] tocback - An entry in a table of contents for a back matter component
    [x] tocchap - An entry in a table of contents for a component in the body of
        a document
    [x] tocentry - A component title in a table of contents
    [x] tocfront - An entry in a table of contents for a front matter component
    [x] toclevel1 - A top-level entry within a table of contents entry for a
        chapter-like component
    [x] toclevel2 - A second-level entry within a table of contents entry for a
        chapter-like component
    [x] toclevel3 - A third-level entry within a table of contents entry for a
        chapter-like component
    [x] toclevel4 - A fourth-level entry within a table of contents entry for a
        chapter-like component
    [x] toclevel5 - A fifth-level entry within a table of contents entry for a
        chapter-like component
    [x] tocpart - An entry in a table of contents for a part of a book
    [ ] token - A unit of information
    [x] tr - A row in an HTML table
    [ ] trademark - A trademark
    [x] type - The classification of a value
    [x] ulink - A link that addresses its target by means of a URL
        (Uniform Resource Locator)
    [x] uri - A Uniform Resource Identifier
    [x] userinput - Data entered by the user
    [x] varargs - An empty element in a function synopsis indicating a variable
        number of arguments
    [x] variablelist - A list in which each entry is composed of a set of one or
        more terms and an associated description
    [x] varlistentry - A wrapper for a set of terms and the associated description
        in a variable list
    [x] varname - The name of a variable
    [ ] videodata - Pointer to external video data
    [ ] videoobject - A wrapper for video data and its associated meta-information
    [ ] void - An empty element in a function synopsis indicating that the
        function in question takes no arguments
    [ ] volumenum - The volume number of a document in a set (as of books in a set
        or articles in a journal)
    [x] warning - An admonition set off from the text
    [x] wordasword - A word meant specifically as a word and not representing
        anything else
    [x] xref - A cross reference to another part of the document
    [ ] year - The year of publication of a document
    [x] ?asciidoc-br? - line break from asciidoc docbook output
    -}

    type DB m = StateT DBState m

    data DBState = DBState{ DBState -> Int
    dbSectionLevel :: Int
                          , DBState -> QuoteType
    dbQuoteType    :: QuoteType
                          , DBState -> Meta
    dbMeta         :: Meta
                          , DBState -> Bool
    dbBook         :: Bool
                          , DBState -> Inlines
    dbFigureTitle  :: Inlines
                          , DBState -> [Content]
    dbContent      :: [Content]
                          } deriving Int -> DBState -> ShowS
    [DBState] -> ShowS
    DBState -> String
    (Int -> DBState -> ShowS)
    -> (DBState -> String) -> ([DBState] -> ShowS) -> Show DBState
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [DBState] -> ShowS
    $cshowList :: [DBState] -> ShowS
    show :: DBState -> String
    $cshow :: DBState -> String
    showsPrec :: Int -> DBState -> ShowS
    $cshowsPrec :: Int -> DBState -> ShowS
    Show

    instance Default DBState where
      def :: DBState
    def = DBState :: Int -> QuoteType -> Meta -> Bool -> Inlines -> [Content] -> DBState
    DBState{ dbSectionLevel :: Int
    dbSectionLevel = 0
                   , dbQuoteType :: QuoteType
    dbQuoteType = QuoteType
    DoubleQuote
                   , dbMeta :: Meta
    dbMeta = Meta
    forall a. Monoid a => a
    mempty
                   , dbBook :: Bool
    dbBook = Bool
    False
                   , dbFigureTitle :: Inlines
    dbFigureTitle = Inlines
    forall a. Monoid a => a
    mempty
                   , dbContent :: [Content]
    dbContent = [] }

    readDocBook :: PandocMonad m => ReaderOptions -> Text -> m Pandoc
    readDocBook :: ReaderOptions -> Text -> m Pandoc
    readDocBook _ inp :: Text
    inp = do
      let tree :: [Content]
    tree = [Content] -> [Content]
    normalizeTree ([Content] -> [Content])
    -> (Text -> [Content]) -> Text -> [Content]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> [Content]
    forall s. XmlSource s => s -> [Content]
    parseXML (Text -> [Content]) -> (Text -> Text) -> Text -> [Content]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> Text
    handleInstructions (Text -> [Content]) -> Text -> [Content]
    forall a b. (a -> b) -> a -> b
    $ Text -> Text
    crFilter Text
    inp
      (bs :: [Blocks]
    bs, st' :: DBState
    st') <- (StateT DBState m [Blocks] -> DBState -> m ([Blocks], DBState))
    -> DBState -> StateT DBState m [Blocks] -> m ([Blocks], DBState)
    forall a b c. (a -> b -> c) -> b -> a -> c
    flip StateT DBState m [Blocks] -> DBState -> m ([Blocks], DBState)
    forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
    runStateT (DBState
    forall a. Default a => a
    def{ dbContent :: [Content]
    dbContent = [Content]
    tree }) (StateT DBState m [Blocks] -> m ([Blocks], DBState))
    -> StateT DBState m [Blocks] -> m ([Blocks], DBState)
    forall a b. (a -> b) -> a -> b
    $ (Content -> StateT DBState m Blocks)
    -> [Content] -> StateT DBState m [Blocks]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Content -> StateT DBState m Blocks
    forall (m :: * -> *). PandocMonad m => Content -> DB m Blocks
    parseBlock [Content]
    tree
      Pandoc -> m Pandoc
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Pandoc -> m Pandoc) -> Pandoc -> m Pandoc
    forall a b. (a -> b) -> a -> b
    $ Meta -> [Block] -> Pandoc
    Pandoc (DBState -> Meta
    dbMeta DBState
    st') (Blocks -> [Block]
    forall a. Many a -> [a]
    toList (Blocks -> [Block]) -> ([Blocks] -> Blocks) -> [Blocks] -> [Block]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Blocks] -> Blocks
    forall a. Monoid a => [a] -> a
    mconcat ([Blocks] -> [Block]) -> [Blocks] -> [Block]
    forall a b. (a -> b) -> a -> b
    $ [Blocks]
    bs)

    -- We treat <?asciidoc-br?> specially (issue #1236), converting it
    -- to <br/>, since xml-light doesn't parse the instruction correctly.
    -- Other xml instructions are simply removed from the input stream.
    handleInstructions :: Text -> Text
    handleInstructions :: Text -> Text
    handleInstructions = String -> Text
    T.pack (String -> Text) -> (Text -> String) -> Text -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ShowS
    handleInstructions' ShowS -> (Text -> String) -> Text -> String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Text -> String
    T.unpack

    handleInstructions' :: String -> String
    handleInstructions' :: ShowS
    handleInstructions' ('<':'?':'a':'s':'c':'i':'i':'d':'o':'c':'-':'b':'r':'?':'>':xs :: String
    xs) = '<'Char -> ShowS
    forall a. a -> [a] -> [a]
    :'b'Char -> ShowS
    forall a. a -> [a] -> [a]
    :'r'Char -> ShowS
    forall a. a -> [a] -> [a]
    :'/'Char -> ShowS
    forall a. a -> [a] -> [a]
    :'>'Char -> ShowS
    forall a. a -> [a] -> [a]
    : ShowS
    handleInstructions' String
    xs
    handleInstructions' xs :: String
    xs = case (Char -> Bool) -> String -> (String, String)
    forall a. (a -> Bool) -> [a] -> ([a], [a])
    break (Char -> Char -> Bool
    forall a. Eq a => a -> a -> Bool
    =='<') String
    xs of
                                 (ys :: String
    ys, [])     -> String
    ys
                                 ([], '<':zs :: String
    zs) -> '<' Char -> ShowS
    forall a. a -> [a] -> [a]
    : ShowS
    handleInstructions' String
    zs
                                 (ys :: String
    ys, zs :: String
    zs)     -> String
    ys String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ ShowS
    handleInstructions' String
    zs

    getFigure :: PandocMonad m => Element -> DB m Blocks
    getFigure :: Element -> DB m Blocks
    getFigure e :: Element
    e = do
      Inlines
    tit <- case (Element -> Bool) -> Element -> Maybe Element
    filterChild (Text -> Element -> Bool
    named "title") Element
    e of
                  Just t :: Element
    t  -> Element -> DB m Inlines
    forall (m :: * -> *). PandocMonad m => Element -> DB m Inlines
    getInlines Element
    t
                  Nothing -> Inlines -> DB m Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return Inlines
    forall a. Monoid a => a
    mempty
      (DBState -> DBState) -> StateT DBState m ()
    forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
    modify ((DBState -> DBState) -> StateT DBState m ())
    -> (DBState -> DBState) -> StateT DBState m ()
    forall a b. (a -> b) -> a -> b
    $ \st :: DBState
    st -> DBState
    st{ dbFigureTitle :: Inlines
    dbFigureTitle = Inlines
    tit }
      Blocks
    res <- Element -> DB m Blocks
    forall (m :: * -> *). PandocMonad m => Element -> DB m Blocks
    getBlocks Element
    e
      (DBState -> DBState) -> StateT DBState m ()
    forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
    modify ((DBState -> DBState) -> StateT DBState m ())
    -> (DBState -> DBState) -> StateT DBState m ()
    forall a b. (a -> b) -> a -> b
    $ \st :: DBState
    st -> DBState
    st{ dbFigureTitle :: Inlines
    dbFigureTitle = Inlines
    forall a. Monoid a => a
    mempty }
      Blocks -> DB m Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return Blocks
    res

    -- normalize input, consolidating adjacent Text and CRef elements
    normalizeTree :: [Content] -> [Content]
    normalizeTree :: [Content] -> [Content]
    normalizeTree = (forall a. Data a => a -> a) -> forall a. Data a => a -> a
    everywhere (([Content] -> [Content]) -> a -> a
    forall a b. (Typeable a, Typeable b) => (b -> b) -> a -> a
    mkT [Content] -> [Content]
    go)
      where go :: [Content] -> [Content]
            go :: [Content] -> [Content]
    go (Text (CData CDataRaw _ _):xs :: [Content]
    xs) = [Content]
    xs
            go (Text (CData CDataText s1 :: String
    s1 z :: Maybe Line
    z):Text (CData CDataText s2 :: String
    s2 _):xs :: [Content]
    xs) =
               CData -> Content
    Text (CDataKind -> String -> Maybe Line -> CData
    CData CDataKind
    CDataText (String
    s1 String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ String
    s2) Maybe Line
    z)Content -> [Content] -> [Content]
    forall a. a -> [a] -> [a]
    :[Content]
    xs
            go (Text (CData CDataText s1 :: String
    s1 z :: Maybe Line
    z):CRef r :: String
    r:xs :: [Content]
    xs) =
               CData -> Content
    Text (CDataKind -> String -> Maybe Line -> CData
    CData CDataKind
    CDataText (String
    s1 String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ ShowS
    convertEntity String
    r) Maybe Line
    z)Content -> [Content] -> [Content]
    forall a. a -> [a] -> [a]
    :[Content]
    xs
            go (CRef r :: String
    r:Text (CData CDataText s1 :: String
    s1 z :: Maybe Line
    z):xs :: [Content]
    xs) =
                 CData -> Content
    Text (CDataKind -> String -> Maybe Line -> CData
    CData CDataKind
    CDataText (ShowS
    convertEntity String
    r String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ String
    s1) Maybe Line
    z)Content -> [Content] -> [Content]
    forall a. a -> [a] -> [a]
    :[Content]
    xs
            go (CRef r1 :: String
    r1:CRef r2 :: String
    r2:xs :: [Content]
    xs) =
                 CData -> Content
    Text (CDataKind -> String -> Maybe Line -> CData
    CData CDataKind
    CDataText (ShowS
    convertEntity String
    r1 String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ ShowS
    convertEntity String
    r2) Maybe Line
    forall a. Maybe a
    Nothing)Content -> [Content] -> [Content]
    forall a. a -> [a] -> [a]
    :[Content]
    xs
            go xs :: [Content]
    xs = [Content]
    xs

    convertEntity :: String -> String
    convertEntity :: ShowS
    convertEntity e :: String
    e = String -> Maybe String -> String
    forall a. a -> Maybe a -> a
    Data.Maybe.fromMaybe ((Char -> Char) -> ShowS
    forall a b. (a -> b) -> [a] -> [b]
    map Char -> Char
    toUpper String
    e) (String -> Maybe String
    lookupEntity String
    e)

    -- convenience function to get an attribute value, defaulting to ""
    attrValue :: String -> Element -> Text
    attrValue :: String -> Element -> Text
    attrValue attr :: String
    attr elt :: Element
    elt =
      Text -> (String -> Text) -> Maybe String -> Text
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe "" String -> Text
    T.pack ((QName -> Bool) -> [Attr] -> Maybe String
    lookupAttrBy (\x :: QName
    x -> QName -> String
    qName QName
    x String -> String -> Bool
    forall a. Eq a => a -> a -> Bool
    == String
    attr) (Element -> [Attr]
    elAttribs Element
    elt))

    -- convenience function
    named :: Text -> Element -> Bool
    named :: Text -> Element -> Bool
    named s :: Text
    s e :: Element
    e = QName -> String
    qName (Element -> QName
    elName Element
    e) String -> String -> Bool
    forall a. Eq a => a -> a -> Bool
    == Text -> String
    T.unpack Text
    s

    --

    addMetadataFromElement :: PandocMonad m => Element -> DB m Blocks
    addMetadataFromElement :: Element -> DB m Blocks
    addMetadataFromElement e :: Element
    e = do
        case (Element -> Bool) -> Element -> Maybe Element
    filterChild (Text -> Element -> Bool
    named "title") Element
    e of
             Nothing -> () -> StateT DBState m ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
             Just z :: Element
    z  -> do
               Element -> DB m Inlines
    forall (m :: * -> *). PandocMonad m => Element -> DB m Inlines
    getInlines Element
    z DB m Inlines
    -> (Inlines -> StateT DBState m ()) -> StateT DBState m ()
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= Text -> Inlines -> StateT DBState m ()
    forall (m :: * -> *) a.
    (PandocMonad m, ToMetaValue a) =>
    Text -> a -> DB m ()
    addMeta "title"
               Text -> Element -> StateT DBState m ()
    forall (m :: * -> *).
    PandocMonad m =>
    Text -> Element -> StateT DBState m ()
    addMetaField "subtitle" Element
    z
        case (Element -> Bool) -> Element -> Maybe Element
    filterChild (Text -> Element -> Bool
    named "authorgroup") Element
    e of
             Nothing -> () -> StateT DBState m ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
             Just z :: Element
    z  -> Text -> Element -> StateT DBState m ()
    forall (m :: * -> *).
    PandocMonad m =>
    Text -> Element -> StateT DBState m ()
    addMetaField "author" Element
    z
        Text -> Element -> StateT DBState m ()
    forall (m :: * -> *).
    PandocMonad m =>
    Text -> Element -> StateT DBState m ()
    addMetaField "subtitle" Element
    e
        Text -> Element -> StateT DBState m ()
    forall (m :: * -> *).
    PandocMonad m =>
    Text -> Element -> StateT DBState m ()
    addMetaField "author" Element
    e
        Text -> Element -> StateT DBState m ()
    forall (m :: * -> *).
    PandocMonad m =>
    Text -> Element -> StateT DBState m ()
    addMetaField "date" Element
    e
        Text -> Element -> StateT DBState m ()
    forall (m :: * -> *).
    PandocMonad m =>
    Text -> Element -> StateT DBState m ()
    addMetaField "release" Element
    e
        Blocks -> DB m Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return Blocks
    forall a. Monoid a => a
    mempty
      where addMetaField :: Text -> Element -> StateT DBState m ()
    addMetaField fieldname :: Text
    fieldname elt :: Element
    elt =
                case (Element -> Bool) -> Element -> [Element]
    filterChildren (Text -> Element -> Bool
    named Text
    fieldname) Element
    elt of
                       []  -> () -> StateT DBState m ()
    forall (m :: * -> *) a. Monad m => a -> m a
    return ()
                       [z :: Element
    z] -> Element -> DB m Inlines
    forall (m :: * -> *). PandocMonad m => Element -> DB m Inlines
    getInlines Element
    z DB m Inlines
    -> (Inlines -> StateT DBState m ()) -> StateT DBState m ()
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= Text -> Inlines -> StateT DBState m ()
    forall (m :: * -> *) a.
    (PandocMonad m, ToMetaValue a) =>
    Text -> a -> DB m ()
    addMeta Text
    fieldname
                       zs :: [Element]
    zs  -> (Element -> DB m Inlines)
    -> [Element] -> StateT DBState m [Inlines]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Element -> DB m Inlines
    forall (m :: * -> *). PandocMonad m => Element -> DB m Inlines
    getInlines [Element]
    zs StateT DBState m [Inlines]
    -> ([Inlines] -> StateT DBState m ()) -> StateT DBState m ()
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= Text -> [Inlines] -> StateT DBState m ()
    forall (m :: * -> *) a.
    (PandocMonad m, ToMetaValue a) =>
    Text -> a -> DB m ()
    addMeta Text
    fieldname

    addMeta :: PandocMonad m => ToMetaValue a => Text -> a -> DB m ()
    addMeta :: Text -> a -> DB m ()
    addMeta field :: Text
    field val :: a
    val = (DBState -> DBState) -> DB m ()
    forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
    modify (Text -> a -> DBState -> DBState
    forall a b. (HasMeta a, ToMetaValue b) => Text -> b -> a -> a
    setMeta Text
    field a
    val)

    instance HasMeta DBState where
      setMeta :: Text -> b -> DBState -> DBState
    setMeta field :: Text
    field v :: b
    v s :: DBState
    s =  DBState
    s {dbMeta :: Meta
    dbMeta = Text -> b -> Meta -> Meta
    forall a b. (HasMeta a, ToMetaValue b) => Text -> b -> a -> a
    setMeta Text
    field b
    v (DBState -> Meta
    dbMeta DBState
    s)}
      deleteMeta :: Text -> DBState -> DBState
    deleteMeta field :: Text
    field s :: DBState
    s = DBState
    s {dbMeta :: Meta
    dbMeta = Text -> Meta -> Meta
    forall a. HasMeta a => Text -> a -> a
    deleteMeta Text
    field (DBState -> Meta
    dbMeta DBState
    s)}

    isBlockElement :: Content -> Bool
    isBlockElement :: Content -> Bool
    isBlockElement (Elem e :: Element
    e) = QName -> String
    qName (Element -> QName
    elName Element
    e) String -> [String] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `elem` [String]
    blockTags
    isBlockElement _ = Bool
    False

    blockTags :: [String]
    blockTags :: [String]
    blockTags = ["toc","index","para","formalpara","simpara",
               "ackno","epigraph","blockquote","bibliography","bibliodiv",
               "biblioentry","glossee","glosseealso","glossary",
               "glossdiv","glosslist","chapter","appendix","preface",
               "bridgehead","sect1","sect2","sect3","sect4","sect5","section",
               "refsect1","refsect2","refsect3","refsection", "qandadiv",
               "question","answer","abstract","itemizedlist","orderedlist",
               "variablelist","article","book","table","informaltable",
               "informalexample", "linegroup",
               "screen","programlisting","example","calloutlist"] [String] -> [String] -> [String]
    forall a. [a] -> [a] -> [a]
    ++ [String]
    admonitionTags

    admonitionTags :: [String]
    admonitionTags :: [String]
    admonitionTags = ["important","caution","note","tip","warning"]

    -- Trim leading and trailing newline characters
    trimNl :: Text -> Text
    trimNl :: Text -> Text
    trimNl = (Char -> Bool) -> Text -> Text
    T.dropAround (Char -> Char -> Bool
    forall a. Eq a => a -> a -> Bool
    == '\n')

    -- meld text into beginning of first paragraph of Blocks.
    -- assumes Blocks start with a Para; if not, does nothing.
    addToStart :: Inlines -> Blocks -> Blocks
    addToStart :: Inlines -> Blocks -> Blocks
    addToStart toadd :: Inlines
    toadd bs :: Blocks
    bs =
      case Blocks -> [Block]
    forall a. Many a -> [a]
    toList Blocks
    bs of
        (Para xs :: [Inline]
    xs : rest :: [Block]
    rest) -> Inlines -> Blocks
    para (Inlines
    toadd Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <> [Inline] -> Inlines
    forall a. [a] -> Many a
    fromList [Inline]
    xs) Blocks -> Blocks -> Blocks
    forall a. Semigroup a => a -> a -> a
    <> [Block] -> Blocks
    forall a. [a] -> Many a
    fromList [Block]
    rest
        _                -> Blocks
    bs

    -- function that is used by both mediaobject (in parseBlock)
    -- and inlinemediaobject (in parseInline)
    -- A DocBook mediaobject is a wrapper around a set of alternative presentations
    getMediaobject :: PandocMonad m => Element -> DB m Inlines
    getMediaobject :: Element -> DB m Inlines
    getMediaobject e :: Element
    e = do
      (imageUrl :: Text
    imageUrl, attr :: Attr
    attr) <-
        case (Element -> Bool) -> Element -> Maybe Element
    filterChild (Text -> Element -> Bool
    named "imageobject") Element
    e of
          Nothing  -> (Text, Attr) -> StateT DBState m (Text, Attr)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text
    forall a. Monoid a => a
    mempty, Attr
    nullAttr)
          Just z :: Element
    z   -> case (Element -> Bool) -> Element -> Maybe Element
    filterChild (Text -> Element -> Bool
    named "imagedata") Element
    z of
                        Nothing -> (Text, Attr) -> StateT DBState m (Text, Attr)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text
    forall a. Monoid a => a
    mempty, Attr
    nullAttr)
                        Just i :: Element
    i  -> let atVal :: String -> Text
    atVal a :: String
    a = String -> Element -> Text
    attrValue String
    a Element
    i
                                       w :: [(Text, Text)]
    w = case String -> Text
    atVal "width" of
                                             "" -> []
                                             d :: Text
    d  -> [("width", Text
    d)]
                                       h :: [(Text, Text)]
    h = case String -> Text
    atVal "depth" of
                                             "" -> []
                                             d :: Text
    d  -> [("height", Text
    d)]
                                       atr :: Attr
    atr = (String -> Text
    atVal "id", Text -> [Text]
    T.words (Text -> [Text]) -> Text -> [Text]
    forall a b. (a -> b) -> a -> b
    $ String -> Text
    atVal "role", [(Text, Text)]
    w [(Text, Text)] -> [(Text, Text)] -> [(Text, Text)]
    forall a. [a] -> [a] -> [a]
    ++ [(Text, Text)]
    h)
                                   in  (Text, Attr) -> StateT DBState m (Text, Attr)
    forall (m :: * -> *) a. Monad m => a -> m a
    return (String -> Text
    atVal "fileref", Attr
    atr)
      let getCaption :: Element -> StateT DBState m Inlines
    getCaption el :: Element
    el = case (Element -> Bool) -> Element -> Maybe Element
    filterChild (\x :: Element
    x -> Text -> Element -> Bool
    named "caption" Element
    x
                                                Bool -> Bool -> Bool
    || Text -> Element -> Bool
    named "textobject" Element
    x
                                                Bool -> Bool -> Bool
    || Text -> Element -> Bool
    named "alt" Element
    x) Element
    el of
                            Nothing -> Inlines -> StateT DBState m Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return Inlines
    forall a. Monoid a => a
    mempty
                            Just z :: Element
    z  -> [Inlines] -> Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([Inlines] -> Inlines)
    -> StateT DBState m [Inlines] -> StateT DBState m Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
                                             (Content -> StateT DBState m Inlines)
    -> [Content] -> StateT DBState m [Inlines]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Content -> StateT DBState m Inlines
    forall (m :: * -> *). PandocMonad m => Content -> DB m Inlines
    parseInline (Element -> [Content]
    elContent Element
    z)
      Inlines
    figTitle <- (DBState -> Inlines) -> DB m Inlines
    forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
    gets DBState -> Inlines
    dbFigureTitle
      let (caption :: DB m Inlines
    caption, title :: Text
    title) = if Inlines -> Bool
    forall a. Many a -> Bool
    isNull Inlines
    figTitle
                                then (Element -> DB m Inlines
    forall (m :: * -> *). PandocMonad m => Element -> DB m Inlines
    getCaption Element
    e, "")
                                else (Inlines -> DB m Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return Inlines
    figTitle, "fig:")
      (Inlines -> Inlines) -> DB m Inlines -> DB m Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap (Attr -> Text -> Text -> Inlines -> Inlines
    imageWith Attr
    attr Text
    imageUrl Text
    title) DB m Inlines
    caption

    getBlocks :: PandocMonad m => Element -> DB m Blocks
    getBlocks :: Element -> DB m Blocks
    getBlocks e :: Element
    e =  [Blocks] -> Blocks
    forall a. Monoid a => [a] -> a
    mconcat ([Blocks] -> Blocks) -> StateT DBState m [Blocks] -> DB m Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
                     (Content -> DB m Blocks) -> [Content] -> StateT DBState m [Blocks]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Content -> DB m Blocks
    forall (m :: * -> *). PandocMonad m => Content -> DB m Blocks
    parseBlock (Element -> [Content]
    elContent Element
    e)

    parseBlock :: PandocMonad m => Content -> DB m Blocks
    parseBlock :: Content -> DB m Blocks
    parseBlock (Text (CData CDataRaw _ _)) = Blocks -> DB m Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return Blocks
    forall a. Monoid a => a
    mempty -- DOCTYPE
    parseBlock (Text (CData _ s :: String
    s _)) = if (Char -> Bool) -> String -> Bool
    forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
    all Char -> Bool
    isSpace String
    s
                                         then Blocks -> DB m Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return Blocks
    forall a. Monoid a => a
    mempty
                                         else Blocks -> DB m Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Blocks -> DB m Blocks) -> Blocks -> DB m Blocks
    forall a b. (a -> b) -> a -> b
    $ Inlines -> Blocks
    plain (Inlines -> Blocks) -> Inlines -> Blocks
    forall a b. (a -> b) -> a -> b
    $ Inlines -> Inlines
    trimInlines (Inlines -> Inlines) -> Inlines -> Inlines
    forall a b. (a -> b) -> a -> b
    $ Text -> Inlines
    text (Text -> Inlines) -> Text -> Inlines
    forall a b. (a -> b) -> a -> b
    $ String -> Text
    T.pack String
    s
    parseBlock (CRef x :: String
    x) = Blocks -> DB m Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Blocks -> DB m Blocks) -> Blocks -> DB m Blocks
    forall a b. (a -> b) -> a -> b
    $ Inlines -> Blocks
    plain (Inlines -> Blocks) -> Inlines -> Blocks
    forall a b. (a -> b) -> a -> b
    $ Text -> Inlines
    str (Text -> Inlines) -> Text -> Inlines
    forall a b. (a -> b) -> a -> b
    $ Text -> Text
    T.toUpper (Text -> Text) -> Text -> Text
    forall a b. (a -> b) -> a -> b
    $ String -> Text
    T.pack String
    x
    parseBlock (Elem e :: Element
    e) =
      case QName -> String
    qName (Element -> QName
    elName Element
    e) of
            "toc"   -> DB m Blocks
    skip -- skip TOC, since in pandoc it's autogenerated
            "index" -> DB m Blocks
    skip -- skip index, since page numbers meaningless
            "para"  -> (Inlines -> Blocks) -> [Content] -> DB m Blocks
    forall (m :: * -> *).
    PandocMonad m =>
    (Inlines -> Blocks) -> [Content] -> StateT DBState m Blocks
    parseMixed Inlines -> Blocks
    para (Element -> [Content]
    elContent Element
    e)
            "formalpara" -> do
               Blocks
    tit <- case (Element -> Bool) -> Element -> Maybe Element
    filterChild (Text -> Element -> Bool
    named "title") Element
    e of
                            Just t :: Element
    t  -> (Inlines -> Blocks
    para (Inlines -> Blocks) -> (Inlines -> Inlines) -> Inlines -> Blocks
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Inlines -> Inlines
    strong (Inlines -> Inlines) -> (Inlines -> Inlines) -> Inlines -> Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <> Text -> Inlines
    str ".")) (Inlines -> Blocks) -> StateT DBState m Inlines -> DB m Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
                                         Element -> StateT DBState m Inlines
    forall (m :: * -> *). PandocMonad m => Element -> DB m Inlines
    getInlines Element
    t
                            Nothing -> Blocks -> DB m Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return Blocks
    forall a. Monoid a => a
    mempty
               (Blocks
    tit Blocks -> Blocks -> Blocks
    forall a. Semigroup a => a -> a -> a
    <>) (Blocks -> Blocks) -> DB m Blocks -> DB m Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Inlines -> Blocks) -> [Content] -> DB m Blocks
    forall (m :: * -> *).
    PandocMonad m =>
    (Inlines -> Blocks) -> [Content] -> StateT DBState m Blocks
    parseMixed Inlines -> Blocks
    para (Element -> [Content]
    elContent Element
    e)
            "simpara"  -> (Inlines -> Blocks) -> [Content] -> DB m Blocks
    forall (m :: * -> *).
    PandocMonad m =>
    (Inlines -> Blocks) -> [Content] -> StateT DBState m Blocks
    parseMixed Inlines -> Blocks
    para (Element -> [Content]
    elContent Element
    e)
            "ackno"  -> (Inlines -> Blocks) -> [Content] -> DB m Blocks
    forall (m :: * -> *).
    PandocMonad m =>
    (Inlines -> Blocks) -> [Content] -> StateT DBState m Blocks
    parseMixed Inlines -> Blocks
    para (Element -> [Content]
    elContent Element
    e)
            "epigraph" -> DB m Blocks
    parseBlockquote
            "blockquote" -> DB m Blocks
    parseBlockquote
            "attribution" -> DB m Blocks
    skip
            "titleabbrev" -> DB m Blocks
    skip
            "authorinitials" -> DB m Blocks
    skip
            "bibliography" -> Int -> DB m Blocks
    forall (m :: * -> *).
    PandocMonad m =>
    Int -> StateT DBState m Blocks
    sect 0
            "bibliodiv" -> Int -> DB m Blocks
    forall (m :: * -> *).
    PandocMonad m =>
    Int -> StateT DBState m Blocks
    sect 1
            "biblioentry" -> (Inlines -> Blocks) -> [Content] -> DB m Blocks
    forall (m :: * -> *).
    PandocMonad m =>
    (Inlines -> Blocks) -> [Content] -> StateT DBState m Blocks
    parseMixed Inlines -> Blocks
    para (Element -> [Content]
    elContent Element
    e)
            "bibliomixed" -> (Inlines -> Blocks) -> [Content] -> DB m Blocks
    forall (m :: * -> *).
    PandocMonad m =>
    (Inlines -> Blocks) -> [Content] -> StateT DBState m Blocks
    parseMixed Inlines -> Blocks
    para (Element -> [Content]
    elContent Element
    e)
            "equation"         -> Inlines -> Blocks
    para (Inlines -> Blocks) -> StateT DBState m Inlines -> DB m Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Element -> (Text -> Inlines) -> StateT DBState m Inlines
    forall (m :: * -> *).
    Monad m =>
    Element -> (Text -> Inlines) -> m Inlines
    equation Element
    e Text -> Inlines
    displayMath
            "informalequation" -> Inlines -> Blocks
    para (Inlines -> Blocks) -> StateT DBState m Inlines -> DB m Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Element -> (Text -> Inlines) -> StateT DBState m Inlines
    forall (m :: * -> *).
    Monad m =>
    Element -> (Text -> Inlines) -> m Inlines
    equation Element
    e Text -> Inlines
    displayMath
            "glosssee" -> Inlines -> Blocks
    para (Inlines -> Blocks) -> (Inlines -> Inlines) -> Inlines -> Blocks
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (\ils :: Inlines
    ils -> Text -> Inlines
    text "See " Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <> Inlines
    ils Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <> Text -> Inlines
    str ".")
                             (Inlines -> Blocks) -> StateT DBState m Inlines -> DB m Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Element -> StateT DBState m Inlines
    forall (m :: * -> *). PandocMonad m => Element -> DB m Inlines
    getInlines Element
    e
            "glossseealso" -> Inlines -> Blocks
    para (Inlines -> Blocks) -> (Inlines -> Inlines) -> Inlines -> Blocks
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (\ils :: Inlines
    ils -> Text -> Inlines
    text "See also " Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <> Inlines
    ils Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <> Text -> Inlines
    str ".")
                             (Inlines -> Blocks) -> StateT DBState m Inlines -> DB m Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Element -> StateT DBState m Inlines
    forall (m :: * -> *). PandocMonad m => Element -> DB m Inlines
    getInlines Element
    e
            "glossary" -> Int -> DB m Blocks
    forall (m :: * -> *).
    PandocMonad m =>
    Int -> StateT DBState m Blocks
    sect 0
            "glossdiv" -> [(Inlines, [Blocks])] -> Blocks
    definitionList ([(Inlines, [Blocks])] -> Blocks)
    -> StateT DBState m [(Inlines, [Blocks])] -> DB m Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
                      (Element -> StateT DBState m (Inlines, [Blocks]))
    -> [Element] -> StateT DBState m [(Inlines, [Blocks])]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Element -> StateT DBState m (Inlines, [Blocks])
    forall (m :: * -> *).
    PandocMonad m =>
    Element -> StateT DBState m (Inlines, [Blocks])
    parseGlossEntry ((Element -> Bool) -> Element -> [Element]
    filterChildren (Text -> Element -> Bool
    named "glossentry") Element
    e)
            "glosslist" -> [(Inlines, [Blocks])] -> Blocks
    definitionList ([(Inlines, [Blocks])] -> Blocks)
    -> StateT DBState m [(Inlines, [Blocks])] -> DB m Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
                      (Element -> StateT DBState m (Inlines, [Blocks]))
    -> [Element] -> StateT DBState m [(Inlines, [Blocks])]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Element -> StateT DBState m (Inlines, [Blocks])
    forall (m :: * -> *).
    PandocMonad m =>
    Element -> StateT DBState m (Inlines, [Blocks])
    parseGlossEntry ((Element -> Bool) -> Element -> [Element]
    filterChildren (Text -> Element -> Bool
    named "glossentry") Element
    e)
            "chapter" -> (DBState -> DBState) -> StateT DBState m ()
    forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
    modify (\st :: DBState
    st -> DBState
    st{ dbBook :: Bool
    dbBook = Bool
    True}) StateT DBState m () -> DB m Blocks -> DB m Blocks
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Int -> DB m Blocks
    forall (m :: * -> *).
    PandocMonad m =>
    Int -> StateT DBState m Blocks
    sect 0
            "appendix" -> Int -> DB m Blocks
    forall (m :: * -> *).
    PandocMonad m =>
    Int -> StateT DBState m Blocks
    sect 0
            "preface" -> Int -> DB m Blocks
    forall (m :: * -> *).
    PandocMonad m =>
    Int -> StateT DBState m Blocks
    sect 0
            "bridgehead" -> Inlines -> Blocks
    para (Inlines -> Blocks) -> (Inlines -> Inlines) -> Inlines -> Blocks
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Inlines -> Inlines
    strong (Inlines -> Blocks) -> StateT DBState m Inlines -> DB m Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Element -> StateT DBState m Inlines
    forall (m :: * -> *). PandocMonad m => Element -> DB m Inlines
    getInlines Element
    e
            "sect1" -> Int -> DB m Blocks
    forall (m :: * -> *).
    PandocMonad m =>
    Int -> StateT DBState m Blocks
    sect 1
            "sect2" -> Int -> DB m Blocks
    forall (m :: * -> *).
    PandocMonad m =>
    Int -> StateT DBState m Blocks
    sect 2
            "sect3" -> Int -> DB m Blocks
    forall (m :: * -> *).
    PandocMonad m =>
    Int -> StateT DBState m Blocks
    sect 3
            "sect4" -> Int -> DB m Blocks
    forall (m :: * -> *).
    PandocMonad m =>
    Int -> StateT DBState m Blocks
    sect 4
            "sect5" -> Int -> DB m Blocks
    forall (m :: * -> *).
    PandocMonad m =>
    Int -> StateT DBState m Blocks
    sect 5
            "section" -> (DBState -> Int) -> StateT DBState m Int
    forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
    gets DBState -> Int
    dbSectionLevel StateT DBState m Int -> (Int -> DB m Blocks) -> DB m Blocks
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= Int -> DB m Blocks
    forall (m :: * -> *).
    PandocMonad m =>
    Int -> StateT DBState m Blocks
    sect (Int -> DB m Blocks) -> (Int -> Int) -> Int -> DB m Blocks
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Int -> Int -> Int
    forall a. Num a => a -> a -> a
    +1)
            "refsect1" -> Int -> DB m Blocks
    forall (m :: * -> *).
    PandocMonad m =>
    Int -> StateT DBState m Blocks
    sect 1
            "refsect2" -> Int -> DB m Blocks
    forall (m :: * -> *).
    PandocMonad m =>
    Int -> StateT DBState m Blocks
    sect 2
            "refsect3" -> Int -> DB m Blocks
    forall (m :: * -> *).
    PandocMonad m =>
    Int -> StateT DBState m Blocks
    sect 3
            "refsection" -> (DBState -> Int) -> StateT DBState m Int
    forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
    gets DBState -> Int
    dbSectionLevel StateT DBState m Int -> (Int -> DB m Blocks) -> DB m Blocks
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= Int -> DB m Blocks
    forall (m :: * -> *).
    PandocMonad m =>
    Int -> StateT DBState m Blocks
    sect (Int -> DB m Blocks) -> (Int -> Int) -> Int -> DB m Blocks
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Int -> Int -> Int
    forall a. Num a => a -> a -> a
    +1)
            l :: String
    l | String
    l String -> [String] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `elem` [String]
    admonitionTags -> Text -> DB m Blocks
    forall (m :: * -> *).
    PandocMonad m =>
    Text -> StateT DBState m Blocks
    parseAdmonition (Text -> DB m Blocks) -> Text -> DB m Blocks
    forall a b. (a -> b) -> a -> b
    $ String -> Text
    T.pack String
    l
            "area" -> DB m Blocks
    skip
            "areaset" -> DB m Blocks
    skip
            "areaspec" -> DB m Blocks
    skip
            "qandadiv" -> (DBState -> Int) -> StateT DBState m Int
    forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
    gets DBState -> Int
    dbSectionLevel StateT DBState m Int -> (Int -> DB m Blocks) -> DB m Blocks
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= Int -> DB m Blocks
    forall (m :: * -> *).
    PandocMonad m =>
    Int -> StateT DBState m Blocks
    sect (Int -> DB m Blocks) -> (Int -> Int) -> Int -> DB m Blocks
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Int -> Int -> Int
    forall a. Num a => a -> a -> a
    +1)
            "question" -> Inlines -> Blocks -> Blocks
    addToStart (Inlines -> Inlines
    strong (Text -> Inlines
    str "Q:") Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <> Text -> Inlines
    str " ") (Blocks -> Blocks) -> DB m Blocks -> DB m Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Element -> DB m Blocks
    forall (m :: * -> *). PandocMonad m => Element -> DB m Blocks
    getBlocks Element
    e
            "answer" -> Inlines -> Blocks -> Blocks
    addToStart (Inlines -> Inlines
    strong (Text -> Inlines
    str "A:") Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <> Text -> Inlines
    str " ") (Blocks -> Blocks) -> DB m Blocks -> DB m Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Element -> DB m Blocks
    forall (m :: * -> *). PandocMonad m => Element -> DB m Blocks
    getBlocks Element
    e
            "abstract" -> Blocks -> Blocks
    blockQuote (Blocks -> Blocks) -> DB m Blocks -> DB m Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Element -> DB m Blocks
    forall (m :: * -> *). PandocMonad m => Element -> DB m Blocks
    getBlocks Element
    e
            "calloutlist" -> [Blocks] -> Blocks
    bulletList ([Blocks] -> Blocks) -> StateT DBState m [Blocks] -> DB m Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> StateT DBState m [Blocks]
    callouts
            "itemizedlist" -> [Blocks] -> Blocks
    bulletList ([Blocks] -> Blocks) -> StateT DBState m [Blocks] -> DB m Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> StateT DBState m [Blocks]
    listitems
            "orderedlist" -> do
              let listStyle :: ListNumberStyle
    listStyle = case String -> Element -> Text
    attrValue "numeration" Element
    e of
                                   "arabic"     -> ListNumberStyle
    Decimal
                                   "loweralpha" -> ListNumberStyle
    LowerAlpha
                                   "upperalpha" -> ListNumberStyle
    UpperAlpha
                                   "lowerroman" -> ListNumberStyle
    LowerRoman
                                   "upperroman" -> ListNumberStyle
    UpperRoman
                                   _            -> ListNumberStyle
    Decimal
              let start :: Int
    start = Int -> Maybe Int -> Int
    forall a. a -> Maybe a -> a
    fromMaybe 1 (Maybe Int -> Int) -> Maybe Int -> Int
    forall a b. (a -> b) -> a -> b
    $
                          (String -> Element -> Text
    attrValue "override" (Element -> Text) -> Maybe Element -> Maybe Text
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Element -> Bool) -> Element -> Maybe Element
    filterElement (Text -> Element -> Bool
    named "listitem") Element
    e)
                           Maybe Text -> (Text -> Maybe Int) -> Maybe Int
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= Text -> Maybe Int
    forall (m :: * -> *) a. (MonadPlus m, Read a) => Text -> m a
    safeRead
              ListAttributes -> [Blocks] -> Blocks
    orderedListWith (Int
    start,ListNumberStyle
    listStyle,ListNumberDelim
    DefaultDelim)
                ([Blocks] -> Blocks) -> StateT DBState m [Blocks] -> DB m Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> StateT DBState m [Blocks]
    listitems
            "variablelist" -> [(Inlines, [Blocks])] -> Blocks
    definitionList ([(Inlines, [Blocks])] -> Blocks)
    -> StateT DBState m [(Inlines, [Blocks])] -> DB m Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> StateT DBState m [(Inlines, [Blocks])]
    deflistitems
            "figure" -> Element -> DB m Blocks
    forall (m :: * -> *). PandocMonad m => Element -> DB m Blocks
    getFigure Element
    e
            "mediaobject" -> Inlines -> Blocks
    para (Inlines -> Blocks) -> StateT DBState m Inlines -> DB m Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Element -> StateT DBState m Inlines
    forall (m :: * -> *). PandocMonad m => Element -> DB m Inlines
    getMediaobject Element
    e
            "caption" -> DB m Blocks
    skip
            "info" -> Element -> DB m Blocks
    forall (m :: * -> *). PandocMonad m => Element -> DB m Blocks
    addMetadataFromElement Element
    e
            "articleinfo" -> Element -> DB m Blocks
    forall (m :: * -> *). PandocMonad m => Element -> DB m Blocks
    addMetadataFromElement Element
    e
            "sectioninfo" -> DB m Blocks
    skip -- keywords & other metadata
            "refsectioninfo" -> DB m Blocks
    skip -- keywords & other metadata
            "refsect1info" -> DB m Blocks
    skip -- keywords & other metadata
            "refsect2info" -> DB m Blocks
    skip -- keywords & other metadata
            "refsect3info" -> DB m Blocks
    skip -- keywords & other metadata
            "sect1info" -> DB m Blocks
    skip  -- keywords & other metadata
            "sect2info" -> DB m Blocks
    skip  -- keywords & other metadata
            "sect3info" -> DB m Blocks
    skip  -- keywords & other metadata
            "sect4info" -> DB m Blocks
    skip  -- keywords & other metadata
            "sect5info" -> DB m Blocks
    skip  -- keywords & other metadata
            "chapterinfo" -> DB m Blocks
    skip -- keywords & other metadata
            "glossaryinfo" -> DB m Blocks
    skip  -- keywords & other metadata
            "appendixinfo" -> DB m Blocks
    skip  -- keywords & other metadata
            "bookinfo" -> Element -> DB m Blocks
    forall (m :: * -> *). PandocMonad m => Element -> DB m Blocks
    addMetadataFromElement Element
    e
            "article" -> (DBState -> DBState) -> StateT DBState m ()
    forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
    modify (\st :: DBState
    st -> DBState
    st{ dbBook :: Bool
    dbBook = Bool
    False }) StateT DBState m () -> DB m Blocks -> DB m Blocks
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >>
                               Element -> DB m Blocks
    forall (m :: * -> *). PandocMonad m => Element -> DB m Blocks
    addMetadataFromElement Element
    e DB m Blocks -> DB m Blocks -> DB m Blocks
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Element -> DB m Blocks
    forall (m :: * -> *). PandocMonad m => Element -> DB m Blocks
    getBlocks Element
    e
            "book" -> (DBState -> DBState) -> StateT DBState m ()
    forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
    modify (\st :: DBState
    st -> DBState
    st{ dbBook :: Bool
    dbBook = Bool
    True }) StateT DBState m () -> DB m Blocks -> DB m Blocks
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >>
                        Element -> DB m Blocks
    forall (m :: * -> *). PandocMonad m => Element -> DB m Blocks
    addMetadataFromElement Element
    e DB m Blocks -> DB m Blocks -> DB m Blocks
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Element -> DB m Blocks
    forall (m :: * -> *). PandocMonad m => Element -> DB m Blocks
    getBlocks Element
    e
            "table" -> DB m Blocks
    parseTable
            "informaltable" -> DB m Blocks
    parseTable
            "informalexample" -> Attr -> Blocks -> Blocks
    divWith ("", ["informalexample"], []) (Blocks -> Blocks) -> DB m Blocks -> DB m Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
                                 Element -> DB m Blocks
    forall (m :: * -> *). PandocMonad m => Element -> DB m Blocks
    getBlocks Element
    e
            "linegroup" -> [Inlines] -> Blocks
    lineBlock ([Inlines] -> Blocks) -> StateT DBState m [Inlines] -> DB m Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> StateT DBState m [Inlines]
    lineItems
            "literallayout" -> DB m Blocks
    codeBlockWithLang
            "screen" -> DB m Blocks
    codeBlockWithLang
            "programlisting" -> DB m Blocks
    codeBlockWithLang
            "?xml"  -> Blocks -> DB m Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return Blocks
    forall a. Monoid a => a
    mempty
            "title" -> Blocks -> DB m Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return Blocks
    forall a. Monoid a => a
    mempty     -- handled in parent element
            "subtitle" -> Blocks -> DB m Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return Blocks
    forall a. Monoid a => a
    mempty  -- handled in parent element
            _       -> DB m Blocks
    skip DB m Blocks -> DB m Blocks -> DB m Blocks
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> Element -> DB m Blocks
    forall (m :: * -> *). PandocMonad m => Element -> DB m Blocks
    getBlocks Element
    e
       where skip :: DB m Blocks
    skip = do
               m () -> StateT DBState m ()
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
    (MonadTrans t, Monad m) =>
    m a -> t m a
    lift (m () -> StateT DBState m ()) -> m () -> StateT DBState m ()
    forall a b. (a -> b) -> a -> b
    $ LogMessage -> m ()
    forall (m :: * -> *). PandocMonad m => LogMessage -> m ()
    report (LogMessage -> m ()) -> LogMessage -> m ()
    forall a b. (a -> b) -> a -> b
    $ Text -> LogMessage
    IgnoredElement (Text -> LogMessage) -> Text -> LogMessage
    forall a b. (a -> b) -> a -> b
    $ String -> Text
    T.pack (String -> Text) -> String -> Text
    forall a b. (a -> b) -> a -> b
    $ QName -> String
    qName (Element -> QName
    elName Element
    e)
               Blocks -> DB m Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return Blocks
    forall a. Monoid a => a
    mempty

             parseMixed :: (Inlines -> Blocks) -> [Content] -> StateT DBState m Blocks
    parseMixed container :: Inlines -> Blocks
    container conts :: [Content]
    conts = do
               let (ils :: [Content]
    ils,rest :: [Content]
    rest) = (Content -> Bool) -> [Content] -> ([Content], [Content])
    forall a. (a -> Bool) -> [a] -> ([a], [a])
    break Content -> Bool
    isBlockElement [Content]
    conts
               Inlines
    ils' <- (Inlines -> Inlines
    trimInlines (Inlines -> Inlines)
    -> ([Inlines] -> Inlines) -> [Inlines] -> Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Inlines] -> Inlines
    forall a. Monoid a => [a] -> a
    mconcat) ([Inlines] -> Inlines)
    -> StateT DBState m [Inlines] -> StateT DBState m Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Content -> StateT DBState m Inlines)
    -> [Content] -> StateT DBState m [Inlines]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Content -> StateT DBState m Inlines
    forall (m :: * -> *). PandocMonad m => Content -> DB m Inlines
    parseInline [Content]
    ils
               let p :: Blocks
    p = if Inlines
    ils' Inlines -> Inlines -> Bool
    forall a. Eq a => a -> a -> Bool
    == Inlines
    forall a. Monoid a => a
    mempty then Blocks
    forall a. Monoid a => a
    mempty else Inlines -> Blocks
    container Inlines
    ils'
               case [Content]
    rest of
                     []     -> Blocks -> StateT DBState m Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return Blocks
    p
                     (r :: Content
    r:rs :: [Content]
    rs) -> do
                        Blocks
    b <- Content -> StateT DBState m Blocks
    forall (m :: * -> *). PandocMonad m => Content -> DB m Blocks
    parseBlock Content
    r
                        Blocks
    x <- (Inlines -> Blocks) -> [Content] -> StateT DBState m Blocks
    parseMixed Inlines -> Blocks
    container [Content]
    rs
                        Blocks -> StateT DBState m Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Blocks -> StateT DBState m Blocks)
    -> Blocks -> StateT DBState m Blocks
    forall a b. (a -> b) -> a -> b
    $ Blocks
    p Blocks -> Blocks -> Blocks
    forall a. Semigroup a => a -> a -> a
    <> Blocks
    b Blocks -> Blocks -> Blocks
    forall a. Semigroup a => a -> a -> a
    <> Blocks
    x
             codeBlockWithLang :: DB m Blocks
    codeBlockWithLang = do
               let classes' :: [Text]
    classes' = case String -> Element -> Text
    attrValue "language" Element
    e of
                                    "" -> []
                                    x :: Text
    x  -> [Text
    x]
               Blocks -> DB m Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Blocks -> DB m Blocks) -> Blocks -> DB m Blocks
    forall a b. (a -> b) -> a -> b
    $ Attr -> Text -> Blocks
    codeBlockWith (String -> Element -> Text
    attrValue "id" Element
    e, [Text]
    classes', [])
                      (Text -> Blocks) -> Text -> Blocks
    forall a b. (a -> b) -> a -> b
    $ Text -> Text
    trimNl (Text -> Text) -> Text -> Text
    forall a b. (a -> b) -> a -> b
    $ String -> Text
    T.pack (String -> Text) -> String -> Text
    forall a b. (a -> b) -> a -> b
    $ Element -> String
    strContentRecursive Element
    e
             parseBlockquote :: DB m Blocks
    parseBlockquote = do
                Blocks
    attrib <- case (Element -> Bool) -> Element -> Maybe Element
    filterChild (Text -> Element -> Bool
    named "attribution") Element
    e of
                                 Nothing  -> Blocks -> DB m Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return Blocks
    forall a. Monoid a => a
    mempty
                                 Just z :: Element
    z   -> (Inlines -> Blocks
    para (Inlines -> Blocks)
    -> ([Inlines] -> Inlines) -> [Inlines] -> Blocks
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Text -> Inlines
    str "— " Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <>) (Inlines -> Inlines)
    -> ([Inlines] -> Inlines) -> [Inlines] -> Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Inlines] -> Inlines
    forall a. Monoid a => [a] -> a
    mconcat)
                                             ([Inlines] -> Blocks) -> StateT DBState m [Inlines] -> DB m Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
                                                  (Content -> StateT DBState m Inlines)
    -> [Content] -> StateT DBState m [Inlines]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Content -> StateT DBState m Inlines
    forall (m :: * -> *). PandocMonad m => Content -> DB m Inlines
    parseInline (Element -> [Content]
    elContent Element
    z)
                Blocks
    contents <- Element -> DB m Blocks
    forall (m :: * -> *). PandocMonad m => Element -> DB m Blocks
    getBlocks Element
    e
                Blocks -> DB m Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Blocks -> DB m Blocks) -> Blocks -> DB m Blocks
    forall a b. (a -> b) -> a -> b
    $ Blocks -> Blocks
    blockQuote (Blocks
    contents Blocks -> Blocks -> Blocks
    forall a. Semigroup a => a -> a -> a
    <> Blocks
    attrib)
             listitems :: StateT DBState m [Blocks]
    listitems = (Element -> DB m Blocks) -> [Element] -> StateT DBState m [Blocks]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Element -> DB m Blocks
    forall (m :: * -> *). PandocMonad m => Element -> DB m Blocks
    getBlocks ([Element] -> StateT DBState m [Blocks])
    -> [Element] -> StateT DBState m [Blocks]
    forall a b. (a -> b) -> a -> b
    $ (Element -> Bool) -> Element -> [Element]
    filterChildren (Text -> Element -> Bool
    named "listitem") Element
    e
             callouts :: StateT DBState m [Blocks]
    callouts = (Element -> DB m Blocks) -> [Element] -> StateT DBState m [Blocks]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Element -> DB m Blocks
    forall (m :: * -> *). PandocMonad m => Element -> DB m Blocks
    getBlocks ([Element] -> StateT DBState m [Blocks])
    -> [Element] -> StateT DBState m [Blocks]
    forall a b. (a -> b) -> a -> b
    $ (Element -> Bool) -> Element -> [Element]
    filterChildren (Text -> Element -> Bool
    named "callout") Element
    e
             deflistitems :: StateT DBState m [(Inlines, [Blocks])]
    deflistitems = (Element -> StateT DBState m (Inlines, [Blocks]))
    -> [Element] -> StateT DBState m [(Inlines, [Blocks])]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Element -> StateT DBState m (Inlines, [Blocks])
    forall (m :: * -> *).
    PandocMonad m =>
    Element -> StateT DBState m (Inlines, [Blocks])
    parseVarListEntry ([Element] -> StateT DBState m [(Inlines, [Blocks])])
    -> [Element] -> StateT DBState m [(Inlines, [Blocks])]
    forall a b. (a -> b) -> a -> b
    $ (Element -> Bool) -> Element -> [Element]
    filterChildren
                         (Text -> Element -> Bool
    named "varlistentry") Element
    e
             parseVarListEntry :: Element -> StateT DBState m (Inlines, [Blocks])
    parseVarListEntry e' :: Element
    e' = do
                         let terms :: [Element]
    terms = (Element -> Bool) -> Element -> [Element]
    filterChildren (Text -> Element -> Bool
    named "term") Element
    e'
                         let items :: [Element]
    items = (Element -> Bool) -> Element -> [Element]
    filterChildren (Text -> Element -> Bool
    named "listitem") Element
    e'
                         [Inlines]
    terms' <- (Element -> StateT DBState m Inlines)
    -> [Element] -> StateT DBState m [Inlines]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Element -> StateT DBState m Inlines
    forall (m :: * -> *). PandocMonad m => Element -> DB m Inlines
    getInlines [Element]
    terms
                         [Blocks]
    items' <- (Element -> StateT DBState m Blocks)
    -> [Element] -> StateT DBState m [Blocks]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Element -> StateT DBState m Blocks
    forall (m :: * -> *). PandocMonad m => Element -> DB m Blocks
    getBlocks [Element]
    items
                         (Inlines, [Blocks]) -> StateT DBState m (Inlines, [Blocks])
    forall (m :: * -> *) a. Monad m => a -> m a
    return ([Inlines] -> Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([Inlines] -> Inlines) -> [Inlines] -> Inlines
    forall a b. (a -> b) -> a -> b
    $ Inlines -> [Inlines] -> [Inlines]
    forall a. a -> [a] -> [a]
    intersperse (Text -> Inlines
    str "; ") [Inlines]
    terms', [Blocks]
    items')
             parseGlossEntry :: Element -> StateT DBState m (Inlines, [Blocks])
    parseGlossEntry e' :: Element
    e' = do
                         let terms :: [Element]
    terms = (Element -> Bool) -> Element -> [Element]
    filterChildren (Text -> Element -> Bool
    named "glossterm") Element
    e'
                         let items :: [Element]
    items = (Element -> Bool) -> Element -> [Element]
    filterChildren (Text -> Element -> Bool
    named "glossdef") Element
    e'
                         [Inlines]
    terms' <- (Element -> StateT DBState m Inlines)
    -> [Element] -> StateT DBState m [Inlines]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Element -> StateT DBState m Inlines
    forall (m :: * -> *). PandocMonad m => Element -> DB m Inlines
    getInlines [Element]
    terms
                         [Blocks]
    items' <- (Element -> StateT DBState m Blocks)
    -> [Element] -> StateT DBState m [Blocks]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Element -> StateT DBState m Blocks
    forall (m :: * -> *). PandocMonad m => Element -> DB m Blocks
    getBlocks [Element]
    items
                         (Inlines, [Blocks]) -> StateT DBState m (Inlines, [Blocks])
    forall (m :: * -> *) a. Monad m => a -> m a
    return ([Inlines] -> Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([Inlines] -> Inlines) -> [Inlines] -> Inlines
    forall a b. (a -> b) -> a -> b
    $ Inlines -> [Inlines] -> [Inlines]
    forall a. a -> [a] -> [a]
    intersperse (Text -> Inlines
    str "; ") [Inlines]
    terms', [Blocks]
    items')
             parseTable :: DB m Blocks
    parseTable = do
                          let isCaption :: Element -> Bool
    isCaption x :: Element
    x = Text -> Element -> Bool
    named "title" Element
    x Bool -> Bool -> Bool
    || Text -> Element -> Bool
    named "caption" Element
    x
                          Inlines
    caption <- case (Element -> Bool) -> Element -> Maybe Element
    filterChild Element -> Bool
    isCaption Element
    e of
                                           Just t :: Element
    t  -> Element -> StateT DBState m Inlines
    forall (m :: * -> *). PandocMonad m => Element -> DB m Inlines
    getInlines Element
    t
                                           Nothing -> Inlines -> StateT DBState m Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return Inlines
    forall a. Monoid a => a
    mempty
                          let e' :: Element
    e' = Element -> Maybe Element -> Element
    forall a. a -> Maybe a -> a
    fromMaybe Element
    e (Maybe Element -> Element) -> Maybe Element -> Element
    forall a b. (a -> b) -> a -> b
    $ (Element -> Bool) -> Element -> Maybe Element
    filterChild (Text -> Element -> Bool
    named "tgroup") Element
    e
                          let isColspec :: Element -> Bool
    isColspec x :: Element
    x = Text -> Element -> Bool
    named "colspec" Element
    x Bool -> Bool -> Bool
    || Text -> Element -> Bool
    named "col" Element
    x
                          let colspecs :: [Element]
    colspecs = case (Element -> Bool) -> Element -> Maybe Element
    filterChild (Text -> Element -> Bool
    named "colgroup") Element
    e' of
                                               Just c :: Element
    c -> (Element -> Bool) -> Element -> [Element]
    filterChildren Element -> Bool
    isColspec Element
    c
                                               _      -> (Element -> Bool) -> Element -> [Element]
    filterChildren Element -> Bool
    isColspec Element
    e'
                          let isRow :: Element -> Bool
    isRow x :: Element
    x = Text -> Element -> Bool
    named "row" Element
    x Bool -> Bool -> Bool
    || Text -> Element -> Bool
    named "tr" Element
    x
                          [Blocks]
    headrows <- case (Element -> Bool) -> Element -> Maybe Element
    filterChild (Text -> Element -> Bool
    named "thead") Element
    e' of
                                           Just h :: Element
    h  -> case (Element -> Bool) -> Element -> Maybe Element
    filterChild Element -> Bool
    isRow Element
    h of
                                                           Just x :: Element
    x  -> Element -> StateT DBState m [Blocks]
    parseRow Element
    x
                                                           Nothing -> [Blocks] -> StateT DBState m [Blocks]
    forall (m :: * -> *) a. Monad m => a -> m a
    return []
                                           Nothing -> [Blocks] -> StateT DBState m [Blocks]
    forall (m :: * -> *) a. Monad m => a -> m a
    return []
                          [[Blocks]]
    bodyrows <- case (Element -> Bool) -> Element -> Maybe Element
    filterChild (Text -> Element -> Bool
    named "tbody") Element
    e' of
                                           Just b :: Element
    b  -> (Element -> StateT DBState m [Blocks])
    -> [Element] -> StateT DBState m [[Blocks]]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Element -> StateT DBState m [Blocks]
    parseRow
                                                      ([Element] -> StateT DBState m [[Blocks]])
    -> [Element] -> StateT DBState m [[Blocks]]
    forall a b. (a -> b) -> a -> b
    $ (Element -> Bool) -> Element -> [Element]
    filterChildren Element -> Bool
    isRow Element
    b
                                           Nothing -> (Element -> StateT DBState m [Blocks])
    -> [Element] -> StateT DBState m [[Blocks]]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Element -> StateT DBState m [Blocks]
    parseRow
                                                      ([Element] -> StateT DBState m [[Blocks]])
    -> [Element] -> StateT DBState m [[Blocks]]
    forall a b. (a -> b) -> a -> b
    $ (Element -> Bool) -> Element -> [Element]
    filterChildren Element -> Bool
    isRow Element
    e'
                          let toAlignment :: Element -> Alignment
    toAlignment c :: Element
    c = case QName -> Element -> Maybe String
    findAttr (String -> QName
    unqual "align") Element
    c of
                                                    Just "left"   -> Alignment
    AlignLeft
                                                    Just "right"  -> Alignment
    AlignRight
                                                    Just "center" -> Alignment
    AlignCenter
                                                    _             -> Alignment
    AlignDefault
                          let toWidth :: Element -> Double
    toWidth c :: Element
    c = case QName -> Element -> Maybe String
    findAttr (String -> QName
    unqual "colwidth") Element
    c of
                                                    Just w :: String
    w -> Double -> Maybe Double -> Double
    forall a. a -> Maybe a -> a
    fromMaybe 0
                                                       (Maybe Double -> Double) -> Maybe Double -> Double
    forall a b. (a -> b) -> a -> b
    $ Text -> Maybe Double
    forall (m :: * -> *) a. (MonadPlus m, Read a) => Text -> m a
    safeRead (Text -> Maybe Double) -> Text -> Maybe Double
    forall a b. (a -> b) -> a -> b
    $ "0" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> (Char -> Bool) -> Text -> Text
    T.filter (\x :: Char
    x ->
                                                         (Char
    x Char -> Char -> Bool
    forall a. Ord a => a -> a -> Bool
    >= '0' Bool -> Bool -> Bool
    && Char
    x Char -> Char -> Bool
    forall a. Ord a => a -> a -> Bool
    <= '9')
                                                          Bool -> Bool -> Bool
    || Char
    x Char -> Char -> Bool
    forall a. Eq a => a -> a -> Bool
    == '.') (String -> Text
    T.pack String
    w)
                                                    Nothing -> 0 :: Double
                          let numrows :: Int
    numrows = case [[Blocks]]
    bodyrows of
                                             [] -> 0
                                             xs :: [[Blocks]]
    xs -> [Int] -> Int
    forall (t :: * -> *) a. (Foldable t, Ord a) => t a -> a
    maximum ([Int] -> Int) -> [Int] -> Int
    forall a b. (a -> b) -> a -> b
    $ ([Blocks] -> Int) -> [[Blocks]] -> [Int]
    forall a b. (a -> b) -> [a] -> [b]
    map [Blocks] -> Int
    forall (t :: * -> *) a. Foldable t => t a -> Int
    length [[Blocks]]
    xs
                          let aligns :: [Alignment]
    aligns = case [Element]
    colspecs of
                                         [] -> Int -> Alignment -> [Alignment]
    forall a. Int -> a -> [a]
    replicate Int
    numrows Alignment
    AlignDefault
                                         cs :: [Element]
    cs -> (Element -> Alignment) -> [Element] -> [Alignment]
    forall a b. (a -> b) -> [a] -> [b]
    map Element -> Alignment
    toAlignment [Element]
    cs
                          let widths :: [Double]
    widths = case [Element]
    colspecs of
                                         []  -> Int -> Double -> [Double]
    forall a. Int -> a -> [a]
    replicate Int
    numrows 0
                                         cs :: [Element]
    cs  -> let ws :: [Double]
    ws = (Element -> Double) -> [Element] -> [Double]
    forall a b. (a -> b) -> [a] -> [b]
    map Element -> Double
    toWidth [Element]
    cs
                                                    tot :: Double
    tot = [Double] -> Double
    forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
    sum [Double]
    ws
                                                in  if (Double -> Bool) -> [Double] -> Bool
    forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
    all (Double -> Double -> Bool
    forall a. Ord a => a -> a -> Bool
    > 0) [Double]
    ws
                                                       then (Double -> Double) -> [Double] -> [Double]
    forall a b. (a -> b) -> [a] -> [b]
    map (Double -> Double -> Double
    forall a. Fractional a => a -> a -> a
    / Double
    tot) [Double]
    ws
                                                       else Int -> Double -> [Double]
    forall a. Int -> a -> [a]
    replicate Int
    numrows 0
                          let headrows' :: [Blocks]
    headrows' = if [Blocks] -> Bool
    forall (t :: * -> *) a. Foldable t => t a -> Bool
    null [Blocks]
    headrows
                                             then Int -> Blocks -> [Blocks]
    forall a. Int -> a -> [a]
    replicate Int
    numrows Blocks
    forall a. Monoid a => a
    mempty
                                             else [Blocks]
    headrows
                          Blocks -> DB m Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Blocks -> DB m Blocks) -> Blocks -> DB m Blocks
    forall a b. (a -> b) -> a -> b
    $ Inlines
    -> [(Alignment, Double)] -> [Blocks] -> [[Blocks]] -> Blocks
    table Inlines
    caption ([Alignment] -> [Double] -> [(Alignment, Double)]
    forall a b. [a] -> [b] -> [(a, b)]
    zip [Alignment]
    aligns [Double]
    widths)
                                     [Blocks]
    headrows' [[Blocks]]
    bodyrows
             isEntry :: Element -> Bool
    isEntry x :: Element
    x  = Text -> Element -> Bool
    named "entry" Element
    x Bool -> Bool -> Bool
    || Text -> Element -> Bool
    named "td" Element
    x Bool -> Bool -> Bool
    || Text -> Element -> Bool
    named "th" Element
    x
             parseRow :: Element -> StateT DBState m [Blocks]
    parseRow = (Element -> DB m Blocks) -> [Element] -> StateT DBState m [Blocks]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM ((Inlines -> Blocks) -> [Content] -> DB m Blocks
    forall (m :: * -> *).
    PandocMonad m =>
    (Inlines -> Blocks) -> [Content] -> StateT DBState m Blocks
    parseMixed Inlines -> Blocks
    plain ([Content] -> DB m Blocks)
    -> (Element -> [Content]) -> Element -> DB m Blocks
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Element -> [Content]
    elContent) ([Element] -> StateT DBState m [Blocks])
    -> (Element -> [Element]) -> Element -> StateT DBState m [Blocks]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Element -> Bool) -> Element -> [Element]
    filterChildren Element -> Bool
    isEntry
             sect :: Int -> StateT DBState m Blocks
    sect n :: Int
    n = do Bool
    isbook <- (DBState -> Bool) -> StateT DBState m Bool
    forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
    gets DBState -> Bool
    dbBook
                         let n' :: Int
    n' = if Bool
    isbook Bool -> Bool -> Bool
    || Int
    n Int -> Int -> Bool
    forall a. Eq a => a -> a -> Bool
    == 0 then Int
    n Int -> Int -> Int
    forall a. Num a => a -> a -> a
    + 1 else Int
    n
                         Inlines
    headerText <- case (Element -> Bool) -> Element -> Maybe Element
    filterChild (Text -> Element -> Bool
    named "title") Element
    e Maybe Element -> Maybe Element -> Maybe Element
    forall (m :: * -> *) a. MonadPlus m => m a -> m a -> m a
    `mplus`
                                            ((Element -> Bool) -> Element -> Maybe Element
    filterChild (Text -> Element -> Bool
    named "info") Element
    e Maybe Element -> (Element -> Maybe Element) -> Maybe Element
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>=
                                                (Element -> Bool) -> Element -> Maybe Element
    filterChild (Text -> Element -> Bool
    named "title")) of
                                          Just t :: Element
    t  -> Element -> DB m Inlines
    forall (m :: * -> *). PandocMonad m => Element -> DB m Inlines
    getInlines Element
    t
                                          Nothing -> Inlines -> DB m Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return Inlines
    forall a. Monoid a => a
    mempty
                         (DBState -> DBState) -> StateT DBState m ()
    forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
    modify ((DBState -> DBState) -> StateT DBState m ())
    -> (DBState -> DBState) -> StateT DBState m ()
    forall a b. (a -> b) -> a -> b
    $ \st :: DBState
    st -> DBState
    st{ dbSectionLevel :: Int
    dbSectionLevel = Int
    n }
                         Blocks
    b <- Element -> StateT DBState m Blocks
    forall (m :: * -> *). PandocMonad m => Element -> DB m Blocks
    getBlocks Element
    e
                         let ident :: Text
    ident = String -> Element -> Text
    attrValue "id" Element
    e
                         (DBState -> DBState) -> StateT DBState m ()
    forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
    modify ((DBState -> DBState) -> StateT DBState m ())
    -> (DBState -> DBState) -> StateT DBState m ()
    forall a b. (a -> b) -> a -> b
    $ \st :: DBState
    st -> DBState
    st{ dbSectionLevel :: Int
    dbSectionLevel = Int
    n Int -> Int -> Int
    forall a. Num a => a -> a -> a
    - 1 }
                         Blocks -> StateT DBState m Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Blocks -> StateT DBState m Blocks)
    -> Blocks -> StateT DBState m Blocks
    forall a b. (a -> b) -> a -> b
    $ Attr -> Int -> Inlines -> Blocks
    headerWith (Text
    ident,[],[]) Int
    n' Inlines
    headerText Blocks -> Blocks -> Blocks
    forall a. Semigroup a => a -> a -> a
    <> Blocks
    b
             lineItems :: StateT DBState m [Inlines]
    lineItems = (Element -> StateT DBState m Inlines)
    -> [Element] -> StateT DBState m [Inlines]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Element -> StateT DBState m Inlines
    forall (m :: * -> *). PandocMonad m => Element -> DB m Inlines
    getInlines ([Element] -> StateT DBState m [Inlines])
    -> [Element] -> StateT DBState m [Inlines]
    forall a b. (a -> b) -> a -> b
    $ (Element -> Bool) -> Element -> [Element]
    filterChildren (Text -> Element -> Bool
    named "line") Element
    e
             -- | Admonitions are parsed into a div. Following other Docbook tools that output HTML,
             -- we parse the optional title as a div with the @title@ class, and give the
             -- block itself a class corresponding to the admonition name.
             parseAdmonition :: Text -> StateT DBState m Blocks
    parseAdmonition label :: Text
    label = do
               -- <title> elements can be directly nested inside an admonition block, use
               -- it if it's there. It is unclear whether we should include the label in
               -- the title: docbook references are ambiguous on that, and some implementations of admonitions
               -- (e.g. asciidoctor) just use an icon in all cases. To be conservative, we don't
               -- include the label and leave it to styling.
               Blocks
    title <- case (Element -> Bool) -> Element -> Maybe Element
    filterChild (Text -> Element -> Bool
    named "title") Element
    e of
                            Just t :: Element
    t  -> Attr -> Blocks -> Blocks
    divWith ("", ["title"], []) (Blocks -> Blocks) -> (Inlines -> Blocks) -> Inlines -> Blocks
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Inlines -> Blocks
    plain (Inlines -> Blocks)
    -> StateT DBState m Inlines -> StateT DBState m Blocks
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Element -> StateT DBState m Inlines
    forall (m :: * -> *). PandocMonad m => Element -> DB m Inlines
    getInlines Element
    t
                            Nothing -> Blocks -> StateT DBState m Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return Blocks
    forall a. Monoid a => a
    mempty
               -- this will ignore the title element if it is present
               Blocks
    b <- Element -> StateT DBState m Blocks
    forall (m :: * -> *). PandocMonad m => Element -> DB m Blocks
    getBlocks Element
    e
               -- we also attach the label as a class, so it can be styled properly
               Blocks -> StateT DBState m Blocks
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Blocks -> StateT DBState m Blocks)
    -> Blocks -> StateT DBState m Blocks
    forall a b. (a -> b) -> a -> b
    $ Attr -> Blocks -> Blocks
    divWith (String -> Element -> Text
    attrValue "id" Element
    e,[Text
    label],[]) (Blocks
    title Blocks -> Blocks -> Blocks
    forall a. Semigroup a => a -> a -> a
    <> Blocks
    b)

    getInlines :: PandocMonad m => Element -> DB m Inlines
    getInlines :: Element -> DB m Inlines
    getInlines e' :: Element
    e' = (Inlines -> Inlines
    trimInlines (Inlines -> Inlines)
    -> ([Inlines] -> Inlines) -> [Inlines] -> Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Inlines] -> Inlines
    forall a. Monoid a => [a] -> a
    mconcat) ([Inlines] -> Inlines)
    -> StateT DBState m [Inlines] -> DB m Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
                     (Content -> DB m Inlines)
    -> [Content] -> StateT DBState m [Inlines]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Content -> DB m Inlines
    forall (m :: * -> *). PandocMonad m => Content -> DB m Inlines
    parseInline (Element -> [Content]
    elContent Element
    e')

    strContentRecursive :: Element -> String
    strContentRecursive :: Element -> String
    strContentRecursive = Element -> String
    strContent (Element -> String) -> (Element -> Element) -> Element -> String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    .
      (\e' :: Element
    e' -> Element
    e'{ elContent :: [Content]
    elContent = (Content -> Content) -> [Content] -> [Content]
    forall a b. (a -> b) -> [a] -> [b]
    map Content -> Content
    elementToStr ([Content] -> [Content]) -> [Content] -> [Content]
    forall a b. (a -> b) -> a -> b
    $ Element -> [Content]
    elContent Element
    e' })

    elementToStr :: Content -> Content
    elementToStr :: Content -> Content
    elementToStr (Elem e' :: Element
    e') = CData -> Content
    Text (CData -> Content) -> CData -> Content
    forall a b. (a -> b) -> a -> b
    $ CDataKind -> String -> Maybe Line -> CData
    CData CDataKind
    CDataText (Element -> String
    strContentRecursive Element
    e') Maybe Line
    forall a. Maybe a
    Nothing
    elementToStr x :: Content
    x = Content
    x

    parseInline :: PandocMonad m => Content -> DB m Inlines
    parseInline :: Content -> DB m Inlines
    parseInline (Text (CData _ s :: String
    s _)) = Inlines -> DB m Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> DB m Inlines) -> Inlines -> DB m Inlines
    forall a b. (a -> b) -> a -> b
    $ Text -> Inlines
    text (Text -> Inlines) -> Text -> Inlines
    forall a b. (a -> b) -> a -> b
    $ String -> Text
    T.pack String
    s
    parseInline (CRef ref :: String
    ref) =
      Inlines -> DB m Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> DB m Inlines) -> Inlines -> DB m Inlines
    forall a b. (a -> b) -> a -> b
    $ Text -> Inlines
    text (Text -> Inlines) -> Text -> Inlines
    forall a b. (a -> b) -> a -> b
    $ Text -> (String -> Text) -> Maybe String -> Text
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe (Text -> Text
    T.toUpper (Text -> Text) -> Text -> Text
    forall a b. (a -> b) -> a -> b
    $ String -> Text
    T.pack String
    ref) String -> Text
    T.pack (Maybe String -> Text) -> Maybe String -> Text
    forall a b. (a -> b) -> a -> b
    $ String -> Maybe String
    lookupEntity String
    ref
    parseInline (Elem e :: Element
    e) =
      case QName -> String
    qName (Element -> QName
    elName Element
    e) of
            "equation" -> Element -> (Text -> Inlines) -> DB m Inlines
    forall (m :: * -> *).
    Monad m =>
    Element -> (Text -> Inlines) -> m Inlines
    equation Element
    e Text -> Inlines
    displayMath
            "informalequation" -> Element -> (Text -> Inlines) -> DB m Inlines
    forall (m :: * -> *).
    Monad m =>
    Element -> (Text -> Inlines) -> m Inlines
    equation Element
    e Text -> Inlines
    displayMath
            "inlineequation" -> Element -> (Text -> Inlines) -> DB m Inlines
    forall (m :: * -> *).
    Monad m =>
    Element -> (Text -> Inlines) -> m Inlines
    equation Element
    e Text -> Inlines
    math
            "subscript" -> Inlines -> Inlines
    subscript (Inlines -> Inlines) -> DB m Inlines -> DB m Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> DB m Inlines
    innerInlines
            "superscript" -> Inlines -> Inlines
    superscript (Inlines -> Inlines) -> DB m Inlines -> DB m Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> DB m Inlines
    innerInlines
            "inlinemediaobject" -> Element -> DB m Inlines
    forall (m :: * -> *). PandocMonad m => Element -> DB m Inlines
    getMediaobject Element
    e
            "quote" -> do
                QuoteType
    qt <- (DBState -> QuoteType) -> StateT DBState m QuoteType
    forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
    gets DBState -> QuoteType
    dbQuoteType
                let qt' :: QuoteType
    qt' = if QuoteType
    qt QuoteType -> QuoteType -> Bool
    forall a. Eq a => a -> a -> Bool
    == QuoteType
    SingleQuote then QuoteType
    DoubleQuote else QuoteType
    SingleQuote
                (DBState -> DBState) -> StateT DBState m ()
    forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
    modify ((DBState -> DBState) -> StateT DBState m ())
    -> (DBState -> DBState) -> StateT DBState m ()
    forall a b. (a -> b) -> a -> b
    $ \st :: DBState
    st -> DBState
    st{ dbQuoteType :: QuoteType
    dbQuoteType = QuoteType
    qt' }
                Inlines
    contents <- DB m Inlines
    innerInlines
                (DBState -> DBState) -> StateT DBState m ()
    forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
    modify ((DBState -> DBState) -> StateT DBState m ())
    -> (DBState -> DBState) -> StateT DBState m ()
    forall a b. (a -> b) -> a -> b
    $ \st :: DBState
    st -> DBState
    st{ dbQuoteType :: QuoteType
    dbQuoteType = QuoteType
    qt }
                Inlines -> DB m Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> DB m Inlines) -> Inlines -> DB m Inlines
    forall a b. (a -> b) -> a -> b
    $ if QuoteType
    qt QuoteType -> QuoteType -> Bool
    forall a. Eq a => a -> a -> Bool
    == QuoteType
    SingleQuote
                            then Inlines -> Inlines
    singleQuoted Inlines
    contents
                            else Inlines -> Inlines
    doubleQuoted Inlines
    contents
            "simplelist" -> DB m Inlines
    simpleList
            "segmentedlist" -> DB m Inlines
    segmentedList
            "classname" -> DB m Inlines
    codeWithLang
            "code" -> DB m Inlines
    codeWithLang
            "filename" -> DB m Inlines
    codeWithLang
            "literal" -> DB m Inlines
    codeWithLang
            "computeroutput" -> DB m Inlines
    codeWithLang
            "prompt" -> DB m Inlines
    codeWithLang
            "parameter" -> DB m Inlines
    codeWithLang
            "option" -> DB m Inlines
    codeWithLang
            "optional" -> do Inlines
    x <- Element -> DB m Inlines
    forall (m :: * -> *). PandocMonad m => Element -> DB m Inlines
    getInlines Element
    e
                             Inlines -> DB m Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> DB m Inlines) -> Inlines -> DB m Inlines
    forall a b. (a -> b) -> a -> b
    $ Text -> Inlines
    str "[" Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <> Inlines
    x Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <> Text -> Inlines
    str "]"
            "markup" -> DB m Inlines
    codeWithLang
            "wordasword" -> Inlines -> Inlines
    emph (Inlines -> Inlines) -> DB m Inlines -> DB m Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> DB m Inlines
    innerInlines
            "command" -> DB m Inlines
    codeWithLang
            "varname" -> DB m Inlines
    codeWithLang
            "function" -> DB m Inlines
    codeWithLang
            "type"    -> DB m Inlines
    codeWithLang
            "symbol"  -> DB m Inlines
    codeWithLang
            "constant" -> DB m Inlines
    codeWithLang
            "userinput" -> DB m Inlines
    codeWithLang
            "varargs" -> Inlines -> DB m Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> DB m Inlines) -> Inlines -> DB m Inlines
    forall a b. (a -> b) -> a -> b
    $ Text -> Inlines
    code "(...)"
            "keycap" -> Inlines -> DB m Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Text -> Inlines
    str (Text -> Inlines) -> Text -> Inlines
    forall a b. (a -> b) -> a -> b
    $ String -> Text
    T.pack (String -> Text) -> String -> Text
    forall a b. (a -> b) -> a -> b
    $ Element -> String
    strContent Element
    e)
            "keycombo" -> [Inlines] -> Inlines
    keycombo ([Inlines] -> Inlines)
    -> StateT DBState m [Inlines] -> DB m Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
                             (Content -> DB m Inlines)
    -> [Content] -> StateT DBState m [Inlines]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Content -> DB m Inlines
    forall (m :: * -> *). PandocMonad m => Content -> DB m Inlines
    parseInline (Element -> [Content]
    elContent Element
    e)
            "menuchoice" -> [Inlines] -> Inlines
    menuchoice ([Inlines] -> Inlines)
    -> StateT DBState m [Inlines] -> DB m Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
                             (Content -> DB m Inlines)
    -> [Content] -> StateT DBState m [Inlines]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Content -> DB m Inlines
    forall (m :: * -> *). PandocMonad m => Content -> DB m Inlines
    parseInline (
                                            (Content -> Bool) -> [Content] -> [Content]
    forall a. (a -> Bool) -> [a] -> [a]
    filter Content -> Bool
    isGuiMenu ([Content] -> [Content]) -> [Content] -> [Content]
    forall a b. (a -> b) -> a -> b
    $ Element -> [Content]
    elContent Element
    e)
            "xref" -> do
                [Content]
    content <- DBState -> [Content]
    dbContent (DBState -> [Content])
    -> StateT DBState m DBState -> StateT DBState m [Content]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> StateT DBState m DBState
    forall s (m :: * -> *). MonadState s m => m s
    get
                let linkend :: Text
    linkend = String -> Element -> Text
    attrValue "linkend" Element
    e
                let title :: Text
    title = case String -> Element -> Text
    attrValue "endterm" Element
    e of
                                ""      -> Text -> (Element -> Text) -> Maybe Element -> Text
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe "???" Element -> Text
    xrefTitleByElem
                                             (Text -> [Content] -> Maybe Element
    findElementById Text
    linkend [Content]
    content)
                                endterm :: Text
    endterm -> Text -> (Element -> Text) -> Maybe Element -> Text
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe "???" (String -> Text
    T.pack (String -> Text) -> (Element -> String) -> Element -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Element -> String
    strContent)
                                             (Text -> [Content] -> Maybe Element
    findElementById Text
    endterm [Content]
    content)
                Inlines -> DB m Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> DB m Inlines) -> Inlines -> DB m Inlines
    forall a b. (a -> b) -> a -> b
    $ Text -> Text -> Inlines -> Inlines
    link ("#" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> Text
    linkend) "" (Text -> Inlines
    text Text
    title)
            "email" -> Inlines -> DB m Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> DB m Inlines) -> Inlines -> DB m Inlines
    forall a b. (a -> b) -> a -> b
    $ Text -> Text -> Inlines -> Inlines
    link ("mailto:" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> String -> Text
    T.pack (Element -> String
    strContent Element
    e)) ""
                              (Inlines -> Inlines) -> Inlines -> Inlines
    forall a b. (a -> b) -> a -> b
    $ Text -> Inlines
    str (Text -> Inlines) -> Text -> Inlines
    forall a b. (a -> b) -> a -> b
    $ String -> Text
    T.pack (String -> Text) -> String -> Text
    forall a b. (a -> b) -> a -> b
    $ Element -> String
    strContent Element
    e
            "uri" -> Inlines -> DB m Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> DB m Inlines) -> Inlines -> DB m Inlines
    forall a b. (a -> b) -> a -> b
    $ Text -> Text -> Inlines -> Inlines
    link (String -> Text
    T.pack (String -> Text) -> String -> Text
    forall a b. (a -> b) -> a -> b
    $ Element -> String
    strContent Element
    e) "" (Inlines -> Inlines) -> Inlines -> Inlines
    forall a b. (a -> b) -> a -> b
    $ Text -> Inlines
    str (Text -> Inlines) -> Text -> Inlines
    forall a b. (a -> b) -> a -> b
    $ String -> Text
    T.pack (String -> Text) -> String -> Text
    forall a b. (a -> b) -> a -> b
    $ Element -> String
    strContent Element
    e
            "ulink" -> Text -> Text -> Inlines -> Inlines
    link (String -> Element -> Text
    attrValue "url" Element
    e) "" (Inlines -> Inlines) -> DB m Inlines -> DB m Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> DB m Inlines
    innerInlines
            "link" -> do
                 Inlines
    ils <- DB m Inlines
    innerInlines
                 let href :: Text
    href = case QName -> Element -> Maybe String
    findAttr (String -> Maybe String -> Maybe String -> QName
    QName "href" (String -> Maybe String
    forall a. a -> Maybe a
    Just "http://www.w3.org/1999/xlink") Maybe String
    forall a. Maybe a
    Nothing) Element
    e of
                                   Just h :: String
    h -> String -> Text
    T.pack String
    h
                                   _      -> "#" Text -> Text -> Text
    forall a. Semigroup a => a -> a -> a
    <> String -> Element -> Text
    attrValue "linkend" Element
    e
                 let ils' :: Inlines
    ils' = if Inlines
    ils Inlines -> Inlines -> Bool
    forall a. Eq a => a -> a -> Bool
    == Inlines
    forall a. Monoid a => a
    mempty then Text -> Inlines
    str Text
    href else Inlines
    ils
                 let attr :: (Text, [Text], [a])
    attr = (String -> Element -> Text
    attrValue "id" Element
    e, Text -> [Text]
    T.words (Text -> [Text]) -> Text -> [Text]
    forall a b. (a -> b) -> a -> b
    $ String -> Element -> Text
    attrValue "role" Element
    e, [])
                 Inlines -> DB m Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> DB m Inlines) -> Inlines -> DB m Inlines
    forall a b. (a -> b) -> a -> b
    $ Attr -> Text -> Text -> Inlines -> Inlines
    linkWith Attr
    forall a. (Text, [Text], [a])
    attr Text
    href "" Inlines
    ils'
            "foreignphrase" -> Inlines -> Inlines
    emph (Inlines -> Inlines) -> DB m Inlines -> DB m Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> DB m Inlines
    innerInlines
            "emphasis" -> case String -> Element -> Text
    attrValue "role" Element
    e of
                                 "bold"          -> Inlines -> Inlines
    strong (Inlines -> Inlines) -> DB m Inlines -> DB m Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> DB m Inlines
    innerInlines
                                 "strong"        -> Inlines -> Inlines
    strong (Inlines -> Inlines) -> DB m Inlines -> DB m Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> DB m Inlines
    innerInlines
                                 "strikethrough" -> Inlines -> Inlines
    strikeout (Inlines -> Inlines) -> DB m Inlines -> DB m Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> DB m Inlines
    innerInlines
                                 _               -> Inlines -> Inlines
    emph (Inlines -> Inlines) -> DB m Inlines -> DB m Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> DB m Inlines
    innerInlines
            "footnote" -> (Blocks -> Inlines
    note (Blocks -> Inlines) -> ([Blocks] -> Blocks) -> [Blocks] -> Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Blocks] -> Blocks
    forall a. Monoid a => [a] -> a
    mconcat) ([Blocks] -> Inlines) -> StateT DBState m [Blocks] -> DB m Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
                             (Content -> StateT DBState m Blocks)
    -> [Content] -> StateT DBState m [Blocks]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Content -> StateT DBState m Blocks
    forall (m :: * -> *). PandocMonad m => Content -> DB m Blocks
    parseBlock (Element -> [Content]
    elContent Element
    e)
            "title" -> Inlines -> DB m Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return Inlines
    forall a. Monoid a => a
    mempty
            "affiliation" -> DB m Inlines
    skip
            -- Note: this isn't a real docbook tag; it's what we convert
            -- <?asciidor-br?> to in handleInstructions, above.  A kludge to
            -- work around xml-light's inability to parse an instruction.
            "br" -> Inlines -> DB m Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return Inlines
    linebreak
            _          -> DB m Inlines
    skip DB m Inlines -> DB m Inlines -> DB m Inlines
    forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
    >> DB m Inlines
    innerInlines
       where skip :: DB m Inlines
    skip = do
               m () -> StateT DBState m ()
    forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
    (MonadTrans t, Monad m) =>
    m a -> t m a
    lift (m () -> StateT DBState m ()) -> m () -> StateT DBState m ()
    forall a b. (a -> b) -> a -> b
    $ LogMessage -> m ()
    forall (m :: * -> *). PandocMonad m => LogMessage -> m ()
    report (LogMessage -> m ()) -> LogMessage -> m ()
    forall a b. (a -> b) -> a -> b
    $ Text -> LogMessage
    IgnoredElement (Text -> LogMessage) -> Text -> LogMessage
    forall a b. (a -> b) -> a -> b
    $ String -> Text
    T.pack (String -> Text) -> String -> Text
    forall a b. (a -> b) -> a -> b
    $ QName -> String
    qName (Element -> QName
    elName Element
    e)
               Inlines -> DB m Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return Inlines
    forall a. Monoid a => a
    mempty

             innerInlines :: DB m Inlines
    innerInlines = (Inlines -> Inlines
    trimInlines (Inlines -> Inlines)
    -> ([Inlines] -> Inlines) -> [Inlines] -> Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . [Inlines] -> Inlines
    forall a. Monoid a => [a] -> a
    mconcat) ([Inlines] -> Inlines)
    -> StateT DBState m [Inlines] -> DB m Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$>
                              (Content -> DB m Inlines)
    -> [Content] -> StateT DBState m [Inlines]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Content -> DB m Inlines
    forall (m :: * -> *). PandocMonad m => Content -> DB m Inlines
    parseInline (Element -> [Content]
    elContent Element
    e)
             codeWithLang :: DB m Inlines
    codeWithLang = do
               let classes' :: [Text]
    classes' = case String -> Element -> Text
    attrValue "language" Element
    e of
                                   "" -> []
                                   l :: Text
    l  -> [Text
    l]
               Inlines -> DB m Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> DB m Inlines) -> Inlines -> DB m Inlines
    forall a b. (a -> b) -> a -> b
    $ Attr -> Text -> Inlines
    codeWith (String -> Element -> Text
    attrValue "id" Element
    e,[Text]
    classes',[]) (Text -> Inlines) -> Text -> Inlines
    forall a b. (a -> b) -> a -> b
    $ String -> Text
    T.pack (String -> Text) -> String -> Text
    forall a b. (a -> b) -> a -> b
    $ Element -> String
    strContentRecursive Element
    e
             simpleList :: DB m Inlines
    simpleList = ([Inlines] -> Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([Inlines] -> Inlines)
    -> ([Inlines] -> [Inlines]) -> [Inlines] -> Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Inlines -> [Inlines] -> [Inlines]
    forall a. a -> [a] -> [a]
    intersperse (Text -> Inlines
    str "," Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <> Inlines
    space)) ([Inlines] -> Inlines)
    -> StateT DBState m [Inlines] -> DB m Inlines
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Element -> DB m Inlines)
    -> [Element] -> StateT DBState m [Inlines]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Element -> DB m Inlines
    forall (m :: * -> *). PandocMonad m => Element -> DB m Inlines
    getInlines
                             ((Element -> Bool) -> Element -> [Element]
    filterChildren (Text -> Element -> Bool
    named "member") Element
    e)
             segmentedList :: DB m Inlines
    segmentedList = do
               Inlines
    tit <- DB m Inlines
    -> (Element -> DB m Inlines) -> Maybe Element -> DB m Inlines
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe (Inlines -> DB m Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return Inlines
    forall a. Monoid a => a
    mempty) Element -> DB m Inlines
    forall (m :: * -> *). PandocMonad m => Element -> DB m Inlines
    getInlines (Maybe Element -> DB m Inlines) -> Maybe Element -> DB m Inlines
    forall a b. (a -> b) -> a -> b
    $ (Element -> Bool) -> Element -> Maybe Element
    filterChild (Text -> Element -> Bool
    named "title") Element
    e
               [Inlines]
    segtits <- (Element -> DB m Inlines)
    -> [Element] -> StateT DBState m [Inlines]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Element -> DB m Inlines
    forall (m :: * -> *). PandocMonad m => Element -> DB m Inlines
    getInlines ([Element] -> StateT DBState m [Inlines])
    -> [Element] -> StateT DBState m [Inlines]
    forall a b. (a -> b) -> a -> b
    $ (Element -> Bool) -> Element -> [Element]
    filterChildren (Text -> Element -> Bool
    named "segtitle") Element
    e
               [[Inlines]]
    segitems <- (Element -> StateT DBState m [Inlines])
    -> [Element] -> StateT DBState m [[Inlines]]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM ((Element -> DB m Inlines)
    -> [Element] -> StateT DBState m [Inlines]
    forall (t :: * -> *) (m :: * -> *) a b.
    (Traversable t, Monad m) =>
    (a -> m b) -> t a -> m (t b)
    mapM Element -> DB m Inlines
    forall (m :: * -> *). PandocMonad m => Element -> DB m Inlines
    getInlines ([Element] -> StateT DBState m [Inlines])
    -> (Element -> [Element]) -> Element -> StateT DBState m [Inlines]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Element -> Bool) -> Element -> [Element]
    filterChildren (Text -> Element -> Bool
    named "seg"))
                              ([Element] -> StateT DBState m [[Inlines]])
    -> [Element] -> StateT DBState m [[Inlines]]
    forall a b. (a -> b) -> a -> b
    $ (Element -> Bool) -> Element -> [Element]
    filterChildren (Text -> Element -> Bool
    named "seglistitem") Element
    e
               let toSeg :: [Inlines] -> Inlines
    toSeg = [Inlines] -> Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([Inlines] -> Inlines)
    -> ([Inlines] -> [Inlines]) -> [Inlines] -> Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Inlines -> Inlines -> Inlines)
    -> [Inlines] -> [Inlines] -> [Inlines]
    forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
    zipWith (\x :: Inlines
    x y :: Inlines
    y -> Inlines -> Inlines
    strong (Inlines
    x Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <> Text -> Inlines
    str ":") Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <> Inlines
    space Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <>
                                      Inlines
    y Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <> Inlines
    linebreak) [Inlines]
    segtits
               let segs :: Inlines
    segs = [Inlines] -> Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([Inlines] -> Inlines) -> [Inlines] -> Inlines
    forall a b. (a -> b) -> a -> b
    $ ([Inlines] -> Inlines) -> [[Inlines]] -> [Inlines]
    forall a b. (a -> b) -> [a] -> [b]
    map [Inlines] -> Inlines
    toSeg [[Inlines]]
    segitems
               let tit' :: Inlines
    tit' = if Inlines
    tit Inlines -> Inlines -> Bool
    forall a. Eq a => a -> a -> Bool
    == Inlines
    forall a. Monoid a => a
    mempty
                             then Inlines
    forall a. Monoid a => a
    mempty
                             else Inlines -> Inlines
    strong Inlines
    tit Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <> Inlines
    linebreak
               Inlines -> DB m Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> DB m Inlines) -> Inlines -> DB m Inlines
    forall a b. (a -> b) -> a -> b
    $ Inlines
    linebreak Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <> Inlines
    tit' Inlines -> Inlines -> Inlines
    forall a. Semigroup a => a -> a -> a
    <> Inlines
    segs
             keycombo :: [Inlines] -> Inlines
    keycombo = Attr -> Inlines -> Inlines
    spanWith ("",["keycombo"],[]) (Inlines -> Inlines)
    -> ([Inlines] -> Inlines) -> [Inlines] -> Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    .
                        [Inlines] -> Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([Inlines] -> Inlines)
    -> ([Inlines] -> [Inlines]) -> [Inlines] -> Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Inlines -> [Inlines] -> [Inlines]
    forall a. a -> [a] -> [a]
    intersperse (Text -> Inlines
    str "+")
             menuchoice :: [Inlines] -> Inlines
    menuchoice = Attr -> Inlines -> Inlines
    spanWith ("",["menuchoice"],[]) (Inlines -> Inlines)
    -> ([Inlines] -> Inlines) -> [Inlines] -> Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    .
                        [Inlines] -> Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([Inlines] -> Inlines)
    -> ([Inlines] -> [Inlines]) -> [Inlines] -> Inlines
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Inlines -> [Inlines] -> [Inlines]
    forall a. a -> [a] -> [a]
    intersperse (Text -> Inlines
    text " > ")
             isGuiMenu :: Content -> Bool
    isGuiMenu (Elem x :: Element
    x) = Text -> Element -> Bool
    named "guimenu" Element
    x Bool -> Bool -> Bool
    || Text -> Element -> Bool
    named "guisubmenu" Element
    x Bool -> Bool -> Bool
    ||
                                  Text -> Element -> Bool
    named "guimenuitem" Element
    x
             isGuiMenu _        = Bool
    False

             findElementById :: Text -> [Content] -> Maybe Element
    findElementById idString :: Text
    idString content :: [Content]
    content
                = [Maybe Element] -> Maybe Element
    forall (t :: * -> *) (f :: * -> *) a.
    (Foldable t, Alternative f) =>
    t (f a) -> f a
    asum [(Element -> Bool) -> Element -> Maybe Element
    filterElement (\x :: Element
    x -> String -> Element -> Text
    attrValue "id" Element
    x Text -> Text -> Bool
    forall a. Eq a => a -> a -> Bool
    == Text
    idString) Element
    el | Elem el :: Element
    el <- [Content]
    content]

             -- Use the 'xreflabel' attribute for getting the title of a xref link;
             -- if there's no such attribute, employ some heuristics based on what
             -- docbook-xsl does.
             xrefTitleByElem :: Element -> Text
    xrefTitleByElem el :: Element
    el
                 | Bool -> Bool
    not (Text -> Bool
    T.null Text
    xrefLabel) = Text
    xrefLabel
                 | Bool
    otherwise              = case QName -> String
    qName (Element -> QName
    elName Element
    el) of
                      "chapter"      -> String -> Element -> Text
    descendantContent "title" Element
    el
                      "section"      -> String -> Element -> Text
    descendantContent "title" Element
    el
                      "sect1"        -> String -> Element -> Text
    descendantContent "title" Element
    el
                      "sect2"        -> String -> Element -> Text
    descendantContent "title" Element
    el
                      "sect3"        -> String -> Element -> Text
    descendantContent "title" Element
    el
                      "sect4"        -> String -> Element -> Text
    descendantContent "title" Element
    el
                      "sect5"        -> String -> Element -> Text
    descendantContent "title" Element
    el
                      "cmdsynopsis"  -> String -> Element -> Text
    descendantContent "command" Element
    el
                      "funcsynopsis" -> String -> Element -> Text
    descendantContent "function" Element
    el
                      _              -> String -> Text
    T.pack (String -> Text) -> String -> Text
    forall a b. (a -> b) -> a -> b
    $ QName -> String
    qName (Element -> QName
    elName Element
    el) String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ "_title"
              where
                xrefLabel :: Text
    xrefLabel = String -> Element -> Text
    attrValue "xreflabel" Element
    el
                descendantContent :: String -> Element -> Text
    descendantContent name :: String
    name = Text -> (Element -> Text) -> Maybe Element -> Text
    forall b a. b -> (a -> b) -> Maybe a -> b
    maybe "???" (String -> Text
    T.pack (String -> Text) -> (Element -> String) -> Element -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Element -> String
    strContent)
                                       (Maybe Element -> Text)
    -> (Element -> Maybe Element) -> Element -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (QName -> Bool) -> Element -> Maybe Element
    filterElementName (\n :: QName
    n -> QName -> String
    qName QName
    n String -> String -> Bool
    forall a. Eq a => a -> a -> Bool
    == String
    name)

    -- | Extract a math equation from an element
    --
    -- asciidoc can generate Latex math in CDATA sections.
    --
    -- Note that if some MathML can't be parsed it is silently ignored!
    equation
      :: Monad m
      => Element
      -- ^ The element from which to extract a mathematical equation
      -> (Text -> Inlines)
      -- ^ A constructor for some Inlines, taking the TeX code as input
      -> m Inlines
    equation :: Element -> (Text -> Inlines) -> m Inlines
    equation e :: Element
    e constructor :: Text -> Inlines
    constructor =
      Inlines -> m Inlines
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Inlines -> m Inlines) -> Inlines -> m Inlines
    forall a b. (a -> b) -> a -> b
    $ [Inlines] -> Inlines
    forall a. Monoid a => [a] -> a
    mconcat ([Inlines] -> Inlines) -> [Inlines] -> Inlines
    forall a b. (a -> b) -> a -> b
    $ (Text -> Inlines) -> [Text] -> [Inlines]
    forall a b. (a -> b) -> [a] -> [b]
    map Text -> Inlines
    constructor ([Text] -> [Inlines]) -> [Text] -> [Inlines]
    forall a b. (a -> b) -> a -> b
    $ [Text]
    mathMLEquations [Text] -> [Text] -> [Text]
    forall a. Semigroup a => a -> a -> a
    <> [Text]
    latexEquations
      where
        mathMLEquations :: [Text]
        mathMLEquations :: [Text]
    mathMLEquations = ([Exp] -> Text) -> [[Exp]] -> [Text]
    forall a b. (a -> b) -> [a] -> [b]
    map [Exp] -> Text
    writeTeX ([[Exp]] -> [Text]) -> [[Exp]] -> [Text]
    forall a b. (a -> b) -> a -> b
    $ [Either Text [Exp]] -> [[Exp]]
    forall a b. [Either a b] -> [b]
    rights ([Either Text [Exp]] -> [[Exp]]) -> [Either Text [Exp]] -> [[Exp]]
    forall a b. (a -> b) -> a -> b
    $ (Element -> Bool)
    -> (Element -> Either Text [Exp]) -> [Either Text [Exp]]
    forall b. (Element -> Bool) -> (Element -> b) -> [b]
    readMath
          (\x :: Element
    x -> QName -> String
    qName (Element -> QName
    elName Element
    x) String -> String -> Bool
    forall a. Eq a => a -> a -> Bool
    == "math" Bool -> Bool -> Bool
    && QName -> Maybe String
    qPrefix (Element -> QName
    elName Element
    x) Maybe String -> Maybe String -> Bool
    forall a. Eq a => a -> a -> Bool
    == String -> Maybe String
    forall a. a -> Maybe a
    Just "mml")
          (Text -> Either Text [Exp]
    readMathML (Text -> Either Text [Exp])
    -> (Element -> Text) -> Element -> Either Text [Exp]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> Text
    T.pack (String -> Text) -> (Element -> String) -> Element -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Element -> String
    showElement)

        latexEquations :: [Text]
        latexEquations :: [Text]
    latexEquations = (Element -> Bool) -> (Element -> Text) -> [Text]
    forall b. (Element -> Bool) -> (Element -> b) -> [b]
    readMath (\x :: Element
    x -> QName -> String
    qName (Element -> QName
    elName Element
    x) String -> String -> Bool
    forall a. Eq a => a -> a -> Bool
    == "mathphrase")
                                  ([Text] -> Text
    T.concat ([Text] -> Text) -> (Element -> [Text]) -> Element -> Text
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (Content -> Text) -> [Content] -> [Text]
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap Content -> Text
    showVerbatimCData ([Content] -> [Text])
    -> (Element -> [Content]) -> Element -> [Text]
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Element -> [Content]
    elContent)

        readMath :: (Element -> Bool) -> (Element -> b) -> [b]
        readMath :: (Element -> Bool) -> (Element -> b) -> [b]
    readMath childPredicate :: Element -> Bool
    childPredicate fromElement :: Element -> b
    fromElement =
          (Element -> b) -> [Element] -> [b]
    forall a b. (a -> b) -> [a] -> [b]
    map (Element -> b
    fromElement (Element -> b) -> (Element -> Element) -> Element -> b
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (forall a. Data a => a -> a) -> forall a. Data a => a -> a
    everywhere ((QName -> QName) -> a -> a
    forall a b. (Typeable a, Typeable b) => (b -> b) -> a -> a
    mkT QName -> QName
    removePrefix))
          ([Element] -> [b]) -> [Element] -> [b]
    forall a b. (a -> b) -> a -> b
    $ (Element -> Bool) -> Element -> [Element]
    filterChildren Element -> Bool
    childPredicate Element
    e

    -- | Get the actual text stored in a CData block. 'showContent'
    -- returns the text still surrounded by the [[CDATA]] tags.
    showVerbatimCData :: Content -> Text
    showVerbatimCData :: Content -> Text
    showVerbatimCData (Text (CData _ d :: String
    d _)) = String -> Text
    T.pack String
    d
    showVerbatimCData c :: Content
    c = String -> Text
    T.pack (String -> Text) -> String -> Text
    forall a b. (a -> b) -> a -> b
    $ Content -> String
    showContent Content
    c

    -- | Set the prefix of a name to 'Nothing'
    removePrefix :: QName -> QName
    removePrefix :: QName -> QName
    removePrefix elname :: QName
    elname = QName
    elname { qPrefix :: Maybe String
    qPrefix = Maybe String
    forall a. Maybe a
    Nothing }