@@ -188,15 +188,23 @@ formulaStyle mt = inTags False "style:style"
188 ,("style:horizontal-rel", "paragraph-content")
188 ,("style:horizontal-rel", "paragraph-content")
189 ,("style:wrap", "none")]
189 ,("style:wrap", "none")]
191+inBookmarkTags :: Text -> Doc Text -> Doc Text
192+inBookmarkTags ident d =
193+ selfClosingTag "text:bookmark-start" [ ("text:name", ident) ]
195+ selfClosingTag "text:bookmark-end" [ ("text:name", ident) ]
197+selfClosingBookmark :: Text -> Doc Text
198+selfClosingBookmark ident =
199+ selfClosingTag "text:bookmark" [("text:name", ident)]
191inHeaderTags :: PandocMonad m => Int -> Text -> Doc Text -> OD m (Doc Text)
201inHeaderTags :: PandocMonad m => Int -> Text -> Doc Text -> OD m (Doc Text)
192inHeaderTags i ident d =
202inHeaderTags i ident d =
193 return $ inTags False "text:h" [ ("text:style-name", "Heading_20_" <> tshow i)
203 return $ inTags False "text:h" [ ("text:style-name", "Heading_20_" <> tshow i)
194 , ("text:outline-level", tshow i)]
204 , ("text:outline-level", tshow i)]
195 $ if T.null ident
205 $ if T.null ident
197− else selfClosingTag "text:bookmark-start" [ ("text:name", ident) ]
207+ else inBookmarkTags ident d
199− selfClosingTag "text:bookmark-end" [ ("text:name", ident) ]
201inQuotes :: QuoteType -> Doc Text -> Doc Text
209inQuotes :: QuoteType -> Doc Text -> Doc Text
202inQuotes SingleQuote s = char '\8216' <> s <> char '\8217'
210inQuotes SingleQuote s = char '\8216' <> s <> char '\8217'
@@ -360,12 +368,7 @@ blockToOpenDocument o bs
360 then return empty
368 then return empty
361 else inParagraphTags =<< inlinesToOpenDocument o b
369 else inParagraphTags =<< inlinesToOpenDocument o b
362 | LineBlock b <- bs = blockToOpenDocument o $ linesToPara b
370 | LineBlock b <- bs = blockToOpenDocument o $ linesToPara b
363− | Div attr xs <- bs = do
371+ | Div attr xs <- bs = mkDiv attr xs
364− let (_,_,kvs) = attr
365− withLangFromAttr attr $
366− case lookup "custom-style" kvs of
367− Just sty -> withParagraphStyle o sty xs
368− _ -> blocksToOpenDocument o xs
369 | Header i (ident,_,_) b
372 | Header i (ident,_,_) b
370 <- bs = setFirstPara >> (inHeaderTags i ident
373 <- bs = setFirstPara >> (inHeaderTags i ident
371 =<< inlinesToOpenDocument o b)
374 =<< inlinesToOpenDocument o b)
@@ -390,6 +393,16 @@ blockToOpenDocument o bs
390 setInDefinitionList False
393 setInDefinitionList False
392 preformatted s = flush . vcat <$> mapM (inPreformattedTags . escapeStringForXML) (T.lines s)
395 preformatted s = flush . vcat <$> mapM (inPreformattedTags . escapeStringForXML) (T.lines s)
397+ let (ident,_,kvs) = attr
398+ i = withLangFromAttr attr $
399+ case lookup "custom-style" kvs of
400+ Just sty -> withParagraphStyle o sty s
401+ _ -> blocksToOpenDocument o s
402+ mkBookmarkedDiv = inTags False "text:section" [("text:name", ident)]
405+ else fmap mkBookmarkedDiv i
393 mkBlockQuote b = do increaseIndent
406 mkBlockQuote b = do increaseIndent
394 i <- paraStyle
407 i <- paraStyle
395 [("style:parent-style-name","Quotations")]
408 [("style:parent-style-name","Quotations")]
@@ -567,7 +580,7 @@ inlineToOpenDocument o ils
567 | writerWrapText o == WrapPreserve
580 | writerWrapText o == WrapPreserve
568 -> return $ preformatted "\n"
581 -> return $ preformatted "\n"
569 | otherwise -> return space
582 | otherwise -> return space
570− Span attr xs -> withLangFromAttr attr (inlinesToOpenDocument o xs)
583+ Span attr xs -> mkSpan attr xs
571 LineBreak -> return $ selfClosingTag "text:line-break" []
584 LineBreak -> return $ selfClosingTag "text:line-break" []
572 Str s -> return $ handleSpaces $ escapeStringForXML s
585 Str s -> return $ handleSpaces $ escapeStringForXML s
573 Emph l -> withTextStyle Italic $ inlinesToOpenDocument o l
586 Emph l -> withTextStyle Italic $ inlinesToOpenDocument o l
@@ -625,6 +638,16 @@ inlineToOpenDocument o ils
625 , ("xlink:type" , "simple")
638 , ("xlink:type" , "simple")
626 , ("xlink:show" , "embed" )
639 , ("xlink:show" , "embed" )
627 , ("xlink:actuate", "onLoad")]
640 , ("xlink:actuate", "onLoad")]
642+ let (ident,_,_) = attr
643+ i = withLangFromAttr attr (inlinesToOpenDocument o xs)
644+ mkBookmarkedSpan b =
646+ then selfClosingBookmark ident
647+ else inBookmarkTags ident b
650+ else fmap mkBookmarkedSpan i
628 mkNote l = do
651 mkNote l = do
629 n <- length <$> gets stNotes
652 n <- length <$> gets stNotes
630 let footNote t = inTags False "text:note"
653 let footNote t = inTags False "text:note"