git.iko.soy/typeable/pandoc
on master help sign in
HTML reader now recognizes DocBook block and inline tags.
1b81981John MacFarlane
README+3−4
@@ -1514,7 +1514,7 @@ MediaWiki
1514Textile
1514Textile
1515 ~ It will be rendered inside `<span class="math">` tags.
1515 ~ It will be rendered inside `<span class="math">` tags.
1516
1516
1517−RTF, Docbook, OpenDocument, ODT
1517+RTF, DocBook, OpenDocument, ODT
1518 ~ It will be rendered, if possible, using unicode characters,
1518 ~ It will be rendered, if possible, using unicode characters,
1519 and will otherwise appear verbatim.
1519 and will otherwise appear verbatim.
1520
1520
@@ -1523,7 +1523,7 @@ HTML, Slidy, DZSlides, S5, EPUB
1523 command-line options selected:
1523 command-line options selected:
1524
1524
1525 1. The default is to render TeX math as far as possible using unicode
1525 1. The default is to render TeX math as far as possible using unicode
1526− characters, as with RTF, Docbook, and OpenDocument output. Formulas
1526+ characters, as with RTF, DocBook, and OpenDocument output. Formulas
1527 are put inside a `span` with `class="math"`, so that they may be
1527 are put inside a `span` with `class="math"`, so that they may be
1528 styled differently from the surrounding text if needed.
1528 styled differently from the surrounding text if needed.
1529
1529
@@ -1565,7 +1565,7 @@ HTML, Slidy, DZSlides, S5, EPUB
1565Raw HTML
1565Raw HTML
1566--------
1566--------
1567
1567
1568−Markdown allows you to insert raw HTML anywhere in a document
1568+Markdown allows you to insert raw HTML (or DocBook) anywhere in a document
1569(except verbatim contexts, where `<`, `>`, and `&` are interpreted
1569(except verbatim contexts, where `<`, `>`, and `&` are interpreted
1570literally).
1570literally).
1571
1571
@@ -1610,7 +1610,6 @@ markdown with HTML block elements. For example, one can surround
1610a block of markdown text with `<div>` tags without preventing it
1610a block of markdown text with `<div>` tags without preventing it
1611from being interpreted as markdown.
1611from being interpreted as markdown.
1612
1612
1613−
1614Raw TeX
1613Raw TeX
1615-------
1614-------
1616
1615
src/Text/Pandoc/Readers/HTML.hs+24−5
@@ -503,16 +503,35 @@ blockHtmlTags = ["address", "blockquote", "body", "center", "dir", "div",
503 "dt", "frameset", "li", "tbody", "td", "tfoot",
503 "dt", "frameset", "li", "tbody", "td", "tfoot",
504 "th", "thead", "tr", "script", "style"]
504 "th", "thead", "tr", "script", "style"]
505
505
506+-- We want to allow raw docbook in markdown documents, so we
507+-- include docbook block tags here too.
508+blockDocBookTags :: [String]
509+blockDocBookTags = ["calloutlist", "bibliolist", "glosslist", "itemizedlist",
510+ "orderedlist", "segmentedlist", "simplelist",
511+ "variablelist", "caution", "important", "note", "tip",
512+ "warning", "address", "literallayout", "programlisting",
513+ "programlistingco", "screen", "screenco", "screenshot",
514+ "synopsis", "example", "informalexample", "figure",
515+ "informalfigure", "table", "informaltable", "para",
516+ "simpara", "formalpara", "equation", "informalequation",
517+ "figure", "screenshot", "mediaobject", "qandaset",
518+ "procedure", "task", "cmdsynopsis", "funcsynopsis",
519+ "classsynopsis", "blockquote", "epigraph", "msgset",
520+ "sidebar"]
521+
522+blockTags :: [String]
523+blockTags = blockHtmlTags ++ blockDocBookTags
524+
506isInlineTag :: Tag String -> Bool
525isInlineTag :: Tag String -> Bool
507−isInlineTag t = tagOpen (`notElem` blockHtmlTags) (const True) t ||
526+isInlineTag t = tagOpen (`notElem` blockTags) (const True) t ||
508− tagClose (`notElem` blockHtmlTags) t ||
527+ tagClose (`notElem` blockTags) t ||
509 tagComment (const True) t
528 tagComment (const True) t
510
529
511isBlockTag :: Tag String -> Bool
530isBlockTag :: Tag String -> Bool
512isBlockTag t = tagOpen (`elem` blocktags) (const True) t ||
531isBlockTag t = tagOpen (`elem` blocktags) (const True) t ||
513 tagClose (`elem` blocktags) t ||
532 tagClose (`elem` blocktags) t ||
514 tagComment (const True) t
533 tagComment (const True) t
515− where blocktags = blockHtmlTags ++ eitherBlockOrInline
534+ where blocktags = blockTags ++ eitherBlockOrInline
516
535
517isTextTag :: Tag String -> Bool
536isTextTag :: Tag String -> Bool
518isTextTag = tagText (const True)
537isTextTag = tagText (const True)
@@ -547,8 +566,8 @@ t `closes` t2 |
547 t `elem` ["h1","h2","h3","h4","h5","h6","dl","ol","ul","table","div","p"] &&
566 t `elem` ["h1","h2","h3","h4","h5","h6","dl","ol","ul","table","div","p"] &&
548 t2 `elem` ["h1","h2","h3","h4","h5","h6","p" ] = True -- not "div"
567 t2 `elem` ["h1","h2","h3","h4","h5","h6","p" ] = True -- not "div"
549t1 `closes` t2 |
568t1 `closes` t2 |
550− t1 `elem` blockHtmlTags &&
569+ t1 `elem` blockTags &&
551− t2 `notElem` (blockHtmlTags ++ eitherBlockOrInline) = True
570+ t2 `notElem` (blockTags ++ eitherBlockOrInline) = True
552_ `closes` _ = False
571_ `closes` _ = False
553
572
554--- parsers for use in markdown, textile readers
573--- parsers for use in markdown, textile readers
src/Text/Pandoc/Writers/Docbook.hs+2−1
@@ -255,7 +255,8 @@ inlineToDocbook _ EnDash = text "–"
255inlineToDocbook _ (Code _ str) =
255inlineToDocbook _ (Code _ str) =
256 inTagsSimple "literal" $ text (escapeStringForXML str)
256 inTagsSimple "literal" $ text (escapeStringForXML str)
257inlineToDocbook opts (Math _ str) = inlinesToDocbook opts $ readTeXMath str
257inlineToDocbook opts (Math _ str) = inlinesToDocbook opts $ readTeXMath str
258−inlineToDocbook _ (RawInline _ _) = empty
258+inlineToDocbook _ (RawInline f x) | f == "html" || f == "docbook" = text x
259+ | otherwise = empty
259inlineToDocbook _ LineBreak = inTagsSimple "literallayout" empty
260inlineToDocbook _ LineBreak = inTagsSimple "literallayout" empty
260inlineToDocbook _ Space = space
261inlineToDocbook _ Space = space
261inlineToDocbook opts (Link txt (src, _)) =
262inlineToDocbook opts (Link txt (src, _)) =