diff --git a/src/Text/Pandoc/Writers/OpenDocument.hs b/src/Text/Pandoc/Writers/OpenDocument.hs
index 514327e9a..21d709f98 100644
--- a/src/Text/Pandoc/Writers/OpenDocument.hs
+++ b/src/Text/Pandoc/Writers/OpenDocument.hs
@@ -193,10 +193,15 @@ formulaStyle mt = inTags False "style:style"
,("style:horizontal-rel", "paragraph-content")
,("style:wrap", "none")]
-inHeaderTags :: PandocMonad m => Int -> Doc -> OD m Doc
-inHeaderTags i d =
+inHeaderTags :: PandocMonad m => Int -> String -> Doc -> OD m Doc
+inHeaderTags i ident d =
return $ inTags False "text:h" [ ("text:style-name", "Heading_20_" ++ show i)
- , ("text:outline-level", show i)] d
+ , ("text:outline-level", show i)]
+ $ if null ident
+ then d
+ else selfClosingTag "text:bookmark-start" [ ("text:name", ident) ]
+ <> d <>
+ selfClosingTag "text:bookmark-end" [ ("text:name", ident) ]
inQuotes :: QuoteType -> Doc -> Doc
inQuotes SingleQuote s = char '\8216' <> s <> char '\8217'
@@ -349,8 +354,9 @@ blockToOpenDocument o bs
| LineBlock b <- bs = blockToOpenDocument o $ linesToPara b
| Div attr xs <- bs = withLangFromAttr attr
(blocksToOpenDocument o xs)
- | Header i _ b <- bs = setFirstPara >>
- (inHeaderTags i =<< inlinesToOpenDocument o b)
+ | Header i (ident,_,_) b
+ <- bs = setFirstPara >> (inHeaderTags i ident
+ =<< inlinesToOpenDocument o b)
| BlockQuote b <- bs = setFirstPara >> mkBlockQuote b
| DefinitionList b <- bs = setFirstPara >> defList b
| BulletList b <- bs = setFirstPara >> bulletListToOpenDocument o b
diff --git a/test/writer.opendocument b/test/writer.opendocument
index 081b33971..535130c0a 100644
--- a/test/writer.opendocument
+++ b/test/writer.opendocument
@@ -803,23 +803,31 @@
This is a set of tests for pandoc. Most
of them are adapted from John Gruber’s markdown test suite.
-Headers
-Level 2 with an
+Headers
+Level
+2 with an
embedded
-link
-Level 3 with
-emphasis
-Level 4
-Level 5
-Level 1
-Level 2 with
-emphasis
-Level 3
+link
+Level
+3 with
+emphasis
+Level
+4
+Level
+5
+Level
+1
+Level
+2 with
+emphasis
+Level
+3
with no blank line
-Level 2
+Level
+2
with no blank line
-Paragraphs
+Paragraphs
Here’s a regular
paragraph.
In Markdown 1.0.0 and earlier. Version
@@ -830,8 +838,8 @@ criminey.
There should be a hard line
breakhere.
-Block
-Quotes
+Block
+Quotes
E-mail style:
This is a block quote. It is pretty
short.
@@ -855,8 +863,8 @@ short.
2 > 1.
And a following paragraph.
-Code
-Blocks
+Code
+Blocks
Code:
---- (should be four hyphens)
@@ -870,8 +878,8 @@ Blocks
These should not be escaped: \$ \\ \> \[ \{
-Lists
-Unordered
+Lists
+Unordered
Asterisks tight:
@@ -944,7 +952,7 @@ Blocks
Minus 3
-Ordered
+Ordered
Tight:
@@ -1007,7 +1015,7 @@ Blocks
Item 3.
-Nested
+Nested
Tab
@@ -1068,8 +1076,8 @@ paragraphs:
Third
-Tabs and
-spaces
+Tabs
+and spaces
this is a list item indented with
@@ -1089,8 +1097,8 @@ spaces
-Fancy list
-markers
+Fancy
+list markers
begins with 2
@@ -1157,8 +1165,8 @@ item:
M.A. 2007
B. Williams
-Definition
-Lists
+Definition
+Lists
Tight using spaces:
apple
red fruit
@@ -1225,8 +1233,8 @@ fruit
sublist
-HTML
-Blocks
+HTML
+Blocks
Simple block on one
line:
foo
@@ -1262,8 +1270,8 @@ spaces on the line:
<hr />
Hr’s:
-Inline
-Markup
+Inline
+Markup
This is
emphasized, and so
is this.
@@ -1300,8 +1308,9 @@ Hmany of themO.
These should not be superscripts or
subscripts, because of the unescaped spaces: a^b c^d, a~b c~d.
-Smart quotes,
-ellipses, dashes
+Smart
+quotes, ellipses,
+dashes
“Hello,” said the spider.
“‘Shelob’ is my name.”
‘A’, ‘B’, and ‘C’ are letters.
@@ -1319,7 +1328,7 @@ five.
1987–1999.
Ellipses…and…and….
-LaTeX
+LaTeX
@@ -1371,8 +1380,8 @@ five.
Here’s a LaTeX table:
-Special
-Characters
+Special
+Characters
Here is some unicode:
@@ -1415,8 +1424,8 @@ it.
Plus: +
Minus: -
-Links
-Explicit
+Links
+Explicit
Just a
URL.
URL
@@ -1433,7 +1442,7 @@ and title
Email
link
Empty.
-Reference
+Reference
Foo
bar.
With
@@ -1453,8 +1462,8 @@ by itself should be a link.
bar.
Foo
biz.
-With
-ampersands
+With
+ampersands
Here’s a
link
with an ampersand in the URL.
@@ -1467,7 +1476,7 @@ link.
Here’s an
inline
link in pointy braces.
-Autolinks
+Autolinks
With an ampersand:
http://example.com/?foo=1&bar=2
@@ -1489,7 +1498,7 @@ link in pointy braces.
<http://example.com/>
or here: <http://example.com/>
-Images
+Images
From “Voyage dans la Lune” by
Georges Melies (1902):
@@ -1498,7 +1507,7 @@ Georges Melies (1902):
icon.
-Footnotes
+Footnotes
Here is a footnote
reference,1Here
is the footnote. It can go anywhere after the footnote reference. It need not