From 0ef1f787c7a243d6cbc64f60dcb38b218608f2b8 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 23 Aug 2014 20:51:18 -0700 Subject: [PATCH] Docx writer: Bibliography entries get Bibliography style. Closes #1559. --- README | 6 +++--- data/reference.docx | Bin 8592 -> 8619 bytes src/Text/Pandoc/Writers/Docx.hs | 8 ++++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README b/README index af46d520b..6966f44c0 100644 --- a/README +++ b/README @@ -551,9 +551,9 @@ Options affecting specific writers used. The following styles are used by pandoc: [paragraph] Normal, Compact, Title, Subtitle, Authors, Date, Abstract, Heading 1, Heading 2, Heading 3, Heading 4, Heading 5, Block Quote, Definition Term, - Definition, Body Text, Table Caption, Image Caption; [character] Default - Paragraph Font, Body Text Char, Verbatim Char, Footnote Ref, - Link. + Definition, Bibliography, Body Text, Table Caption, Image Caption; + [character] Default Paragraph Font, Body Text Char, Verbatim Char, + Footnote Ref, Link. `--epub-stylesheet=`*FILE* : Use the specified CSS file to style the EPUB. If no stylesheet diff --git a/data/reference.docx b/data/reference.docx index 08059eb3c8cf27f54c27f5eabfe24b6d601c20bf..0c717b3b6ad7c7fe77c5d80e93ddacb6c4c38cb3 100644 GIT binary patch delta 1660 zcmV-?27~#KL#souqz4TMofkzMrJ2Pc1^@uwld%UI2ar(tQ;<;klhX%9f1|mBbZ2xm z62fQi?|jd=!Hg3c49)Hv%QSG{P?rSDp?N)}xw!`uM(fS`~zMxLz<3Mz5%R25b>>&X|@f8WVnf7+OPj9!B zxgnzt<{Y^BUeceBNMOEue`OfJ(521=UZBVmTv}oqyJD#=F)5>JCG80f1UGI^5qAig z0R=oXeG*XiaTIW30)i12BTkSOT**JQh{HwBd`?`jb_!$jf57bqc|+6gZ)0O#je00p zDijB=ucvvQInx|Q9h!)}o{n-|oON<}NE?Mr!3d!)d0{DeJVXwOf0>|#z#t5mm(n<4 zew<>b(o&kYI5Yu@nI?(@2fX-1oi%o+0)U}unThfG@`@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sE9?Y#)}MWAJY+JlWLd&tIgPH`E2?b@zTsecIYr64PTp zGEXQK0j&587Evz?wH@#-6fa0X z$bHRUAwg}vvK7Zqp&*Dv4^2t9xGDS@C)r;AGSt?q$L$z`e<37 zo!H}#&rYGeIuVE38~=c!+^-68)bAOi9BV0I+HSogeS7WnePj87*&GStSI43}c7;;4 zf4X%?RQa=rfKw0g?ChC0RU9W9yeix`9qMrR9WQpAA*IKm$+*Exj6AZ;ZsSpi8Fv^7 z#eWwg^ue`0xEMJ!s0I&_`Vi}@S51IZ8Zigva^dl?6k!4xF$S~ORj|_TD{PbmmbC}| zlRvBb3AB_aUBt>z)oBw^;}!c0-^)p6e{{VSP!7_@qoK_b+J$wptP?A#tm)}SElCUP zFOWbpxI;%jj~&AQEwE1>liMVYogc{4($0`WNcSxSX>XbIIZ*kcBki*PU1e4ky8nYq}X%P)b zPyIywrnDjk1^@s8lb9bV1E|v1lf)l70_hEsAU*>04wFD2Jp%m?lYbyQ0gscsAVLA# alm8$;0j85bAwB`XlYSv5296y70001i(I4&r diff --git a/src/Text/Pandoc/Writers/Docx.hs b/src/Text/Pandoc/Writers/Docx.hs index fbf38e6f1..b283238da 100644 --- a/src/Text/Pandoc/Writers/Docx.hs +++ b/src/Text/Pandoc/Writers/Docx.hs @@ -532,13 +532,17 @@ getUniqueId = liftIO $ (show . (+ 20) . hashUnique) `fmap` newUnique -- | Convert a Pandoc block element to OpenXML. blockToOpenXML :: WriterOptions -> Block -> WS [Element] blockToOpenXML _ Null = return [] +blockToOpenXML opts (Div (_,["references"],_) bs) = do + let (hs, bs') = span isHeaderBlock bs + header <- blocksToOpenXML opts hs + -- We put the Bibliography style on paragraphs after the header + rest <- withParaProp (pStyle "Bibliography") $ blocksToOpenXML opts bs' + return (header ++ rest) blockToOpenXML opts (Div _ bs) = blocksToOpenXML opts bs blockToOpenXML opts (Header lev (ident,_,_) lst) = do - paraProps <- withParaProp (pStyle $ "Heading" ++ show lev) $ getParaProps False contents <- inlinesToOpenXML opts lst - usedIdents <- gets stSectionIds let bookmarkName = if null ident then uniqueIdent lst usedIdents