git.iko.soy/typeable/pandoc
on master help sign in
Docx writer: Bibliography entries get Bibliography style.

Closes #1559.

commit0ef1f787c7a243d6cbc64f60dcb38b218608f2b8 authorJohn MacFarlane <jgm@berkeley.edu> dateSat 23 Aug 2014, 20:51 (12 years ago) parent2956ef2
3 files changed+9−5
README+3−3 data/reference.docx src/Text/Pandoc/Writers/Docx.hs+6−2
README+3−3
@@ -551,9 +551,9 @@ Options affecting specific writers
551551 used. The following styles are used by pandoc: [paragraph]
552552 Normal, Compact, Title, Subtitle, Authors, Date, Abstract, Heading 1,
553553 Heading 2, Heading 3, Heading 4, Heading 5, Block Quote, Definition Term,
554− Definition, Body Text, Table Caption, Image Caption; [character] Default
555− Paragraph Font, Body Text Char, Verbatim Char, Footnote Ref,
556− Link.
554+ Definition, Bibliography, Body Text, Table Caption, Image Caption;
555+ [character] Default Paragraph Font, Body Text Char, Verbatim Char,
556+ Footnote Ref, Link.
557557
558558`--epub-stylesheet=`*FILE*
559559: Use the specified CSS file to style the EPUB. If no stylesheet
data/reference.docx

Binary file not shown.

src/Text/Pandoc/Writers/Docx.hs+6−2
@@ -532,13 +532,17 @@ getUniqueId = liftIO $ (show . (+ 20) . hashUnique) `fmap` newUnique
532532-- | Convert a Pandoc block element to OpenXML.
533533blockToOpenXML :: WriterOptions -> Block -> WS [Element]
534534blockToOpenXML _ Null = return []
535+blockToOpenXML opts (Div (_,["references"],_) bs) = do
536+ let (hs, bs') = span isHeaderBlock bs
537+ header <- blocksToOpenXML opts hs
538+ -- We put the Bibliography style on paragraphs after the header
539+ rest <- withParaProp (pStyle "Bibliography") $ blocksToOpenXML opts bs'
540+ return (header ++ rest)
535541blockToOpenXML opts (Div _ bs) = blocksToOpenXML opts bs
536542blockToOpenXML opts (Header lev (ident,_,_) lst) = do
537−
538543 paraProps <- withParaProp (pStyle $ "Heading" ++ show lev) $
539544 getParaProps False
540545 contents <- inlinesToOpenXML opts lst
541−
542546 usedIdents <- gets stSectionIds
543547 let bookmarkName = if null ident
544548 then uniqueIdent lst usedIdents