git.iko.soy/typeable/pandoc
on master help sign in
TEI writer: Use 'xml:id', not 'id' attribute.

Closes #4371.

commitded2e211ca181603ab1a0da3f938508efdb7cdf0 authorJohn MacFarlane <jgm@berkeley.edu> dateFri 16 Feb 2018, 10:41 (9 years ago) parent0e4b8ae
2 files changed+34−34
src/Text/Pandoc/Writers/TEI.hs+3−3 test/writer.tei+31−31
src/Text/Pandoc/Writers/TEI.hs+3−3
@@ -104,7 +104,7 @@ elementToTEI opts lvl (Sec _ _num (id',_,_) title elements) = do
104104 contents <- vcat <$> mapM (elementToTEI opts (lvl + 1)) elements'
105105 titleContents <- inlinesToTEI opts title
106106 return $ inTags True "div" (("type", divType) :
107− [("id", writerIdentifierPrefix opts ++ id') | not (null id')]) $
107+ [("xml:id", writerIdentifierPrefix opts ++ id') | not (null id')]) $
108108 inTagsSimple "head" titleContents $$ contents
109109
110110-- | Convert a list of Pandoc blocks to TEI.
@@ -156,7 +156,7 @@ blockToTEI _ Null = return empty
156156-- Add ids to paragraphs in divs with ids - this is needed for
157157-- pandoc-citeproc to get link anchors in bibliographies:
158158blockToTEI opts (Div (ident,_,_) [Para lst]) = do
159− let attribs = [("id", ident) | not (null ident)]
159+ let attribs = [("xml:id", ident) | not (null ident)]
160160 inTags False "p" attribs <$> inlinesToTEI opts lst
161161blockToTEI opts (Div _ bs) = blocksToTEI opts $ map plainToPara bs
162162blockToTEI _ h@Header{} = do
@@ -342,7 +342,7 @@ idAndRole (id',cls,_) = ident ++ role
342342 where
343343 ident = if null id'
344344 then []
345− else [("id", id')]
345+ else [("xml:id", id')]
346346 role = if null cls
347347 then []
348348 else [("role", unwords cls)]
test/writer.tei+31−31
@@ -20,15 +20,15 @@
2020<p>This is a set of tests for pandoc. Most of them are adapted from John
2121Gruber’s markdown test suite.</p>
2222<milestone unit="undefined" type="separator" rendition="line" />
23−<div type="level1" id="headers">
23+<div type="level1" xml:id="headers">
2424 <head>Headers</head>
25− <div type="level2" id="level-2-with-an-embedded-link">
25+ <div type="level2" xml:id="level-2-with-an-embedded-link">
2626 <head>Level 2 with an <ref target="/url">embedded link</ref></head>
27− <div type="level3" id="level-3-with-emphasis">
27+ <div type="level3" xml:id="level-3-with-emphasis">
2828 <head>Level 3 with <hi rendition="simple:italic">emphasis</hi></head>
29− <div type="level4" id="level-4">
29+ <div type="level4" xml:id="level-4">
3030 <head>Level 4</head>
31− <div type="level5" id="level-5">
31+ <div type="level5" xml:id="level-5">
3232 <head>Level 5</head>
3333 <p></p>
3434 </div>
@@ -36,22 +36,22 @@ Gruber’s markdown test suite.</p>
3636 </div>
3737 </div>
3838</div>
39−<div type="level1" id="level-1">
39+<div type="level1" xml:id="level-1">
4040 <head>Level 1</head>
41− <div type="level2" id="level-2-with-emphasis">
41+ <div type="level2" xml:id="level-2-with-emphasis">
4242 <head>Level 2 with <hi rendition="simple:italic">emphasis</hi></head>
43− <div type="level3" id="level-3">
43+ <div type="level3" xml:id="level-3">
4444 <head>Level 3</head>
4545 <p>with no blank line</p>
4646 </div>
4747 </div>
48− <div type="level2" id="level-2">
48+ <div type="level2" xml:id="level-2">
4949 <head>Level 2</head>
5050 <p>with no blank line</p>
5151 <milestone unit="undefined" type="separator" rendition="line" />
5252 </div>
5353</div>
54−<div type="level1" id="paragraphs">
54+<div type="level1" xml:id="paragraphs">
5555 <head>Paragraphs</head>
5656 <p>Here’s a regular paragraph.</p>
5757 <p>In Markdown 1.0.0 and earlier. Version 8. This line turns into a list
@@ -61,7 +61,7 @@ Gruber’s markdown test suite.</p>
6161 <p>There should be a hard line break<lb />here.</p>
6262 <milestone unit="undefined" type="separator" rendition="line" />
6363</div>
64−<div type="level1" id="block-quotes">
64+<div type="level1" xml:id="block-quotes">
6565 <head>Block Quotes</head>
6666 <p>E-mail style:</p>
6767 <quote>
@@ -95,7 +95,7 @@ sub status {
9595 <p>And a following paragraph.</p>
9696 <milestone unit="undefined" type="separator" rendition="line" />
9797</div>
98−<div type="level1" id="code-blocks">
98+<div type="level1" xml:id="code-blocks">
9999 <head>Code Blocks</head>
100100 <p>Code:</p>
101101 <ab type='codeblock '>
@@ -115,9 +115,9 @@ These should not be escaped: \$ \\ \&gt; \[ \{
115115</ab>
116116 <milestone unit="undefined" type="separator" rendition="line" />
117117</div>
118−<div type="level1" id="lists">
118+<div type="level1" xml:id="lists">
119119 <head>Lists</head>
120− <div type="level2" id="unordered">
120+ <div type="level2" xml:id="unordered">
121121 <head>Unordered</head>
122122 <p>Asterisks tight:</p>
123123 <list type="unordered">
@@ -192,7 +192,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
192192 </item>
193193 </list>
194194 </div>
195− <div type="level2" id="ordered">
195+ <div type="level2" xml:id="ordered">
196196 <head>Ordered</head>
197197 <p>Tight:</p>
198198 <list type="ordered:arabic">
@@ -257,7 +257,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
257257 </item>
258258 </list>
259259 </div>
260− <div type="level2" id="nested">
260+ <div type="level2" xml:id="nested">
261261 <head>Nested</head>
262262 <list type="unordered">
263263 <item>
@@ -321,7 +321,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
321321 </item>
322322 </list>
323323 </div>
324− <div type="level2" id="tabs-and-spaces">
324+ <div type="level2" xml:id="tabs-and-spaces">
325325 <head>Tabs and spaces</head>
326326 <list type="unordered">
327327 <item>
@@ -340,7 +340,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
340340 </item>
341341 </list>
342342 </div>
343− <div type="level2" id="fancy-list-markers">
343+ <div type="level2" xml:id="fancy-list-markers">
344344 <head>Fancy list markers</head>
345345 <list type="ordered:arabic">
346346 <item n="2">
@@ -408,7 +408,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
408408 <milestone unit="undefined" type="separator" rendition="line" />
409409 </div>
410410</div>
411−<div type="level1" id="definition-lists">
411+<div type="level1" xml:id="definition-lists">
412412 <head>Definition Lists</head>
413413 <p>Tight using spaces:</p>
414414 <list type="definition">
@@ -554,7 +554,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
554554 </item>
555555 </list>
556556</div>
557−<div type="level1" id="html-blocks">
557+<div type="level1" xml:id="html-blocks">
558558 <head>HTML Blocks</head>
559559 <p>Simple block on one line:</p>
560560 <p>foo</p>
@@ -592,7 +592,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
592592 <p>Hr’s:</p>
593593 <milestone unit="undefined" type="separator" rendition="line" />
594594</div>
595−<div type="level1" id="inline-markup">
595+<div type="level1" xml:id="inline-markup">
596596 <head>Inline Markup</head>
597597 <p>This is <hi rendition="simple:italic">emphasized</hi>, and so
598598 <hi rendition="simple:italic">is this</hi>.</p>
@@ -625,7 +625,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
625625 spaces: a^b c^d, a~b c~d.</p>
626626 <milestone unit="undefined" type="separator" rendition="line" />
627627</div>
628−<div type="level1" id="smart-quotes-ellipses-dashes">
628+<div type="level1" xml:id="smart-quotes-ellipses-dashes">
629629 <head>Smart quotes, ellipses, dashes</head>
630630 <p><quote>Hello,</quote> said the spider. <quote><quote>Shelob</quote> is my
631631 name.</quote></p>
@@ -642,7 +642,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
642642 <p>Ellipses…and…and….</p>
643643 <milestone unit="undefined" type="separator" rendition="line" />
644644</div>
645−<div type="level1" id="latex">
645+<div type="level1" xml:id="latex">
646646 <head>LaTeX</head>
647647 <list type="unordered">
648648 <item>
@@ -694,7 +694,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
694694 <p>Here’s a LaTeX table:</p>
695695 <milestone unit="undefined" type="separator" rendition="line" />
696696</div>
697−<div type="level1" id="special-characters">
697+<div type="level1" xml:id="special-characters">
698698 <head>Special Characters</head>
699699 <p>Here is some unicode:</p>
700700 <list type="unordered">
@@ -737,9 +737,9 @@ These should not be escaped: \$ \\ \&gt; \[ \{
737737 <p>Minus: -</p>
738738 <milestone unit="undefined" type="separator" rendition="line" />
739739</div>
740−<div type="level1" id="links">
740+<div type="level1" xml:id="links">
741741 <head>Links</head>
742− <div type="level2" id="explicit">
742+ <div type="level2" xml:id="explicit">
743743 <head>Explicit</head>
744744 <p>Just a <ref target="/url/">URL</ref>.</p>
745745 <p><ref target="/url/">URL and title</ref>.</p>
@@ -751,7 +751,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
751751 <p>Email link (nobody@nowhere.net)</p>
752752 <p><ref target="">Empty</ref>.</p>
753753 </div>
754− <div type="level2" id="reference">
754+ <div type="level2" xml:id="reference">
755755 <head>Reference</head>
756756 <p>Foo <ref target="/url/">bar</ref>.</p>
757757 <p>With <ref target="/url/">embedded [brackets]</ref>.</p>
@@ -766,7 +766,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
766766 <p>Foo <ref target="/url/">bar</ref>.</p>
767767 <p>Foo <ref target="/url/">biz</ref>.</p>
768768 </div>
769− <div type="level2" id="with-ampersands">
769+ <div type="level2" xml:id="with-ampersands">
770770 <head>With ampersands</head>
771771 <p>Here’s a <ref target="http://example.com/?foo=1&amp;bar=2">link with an
772772 ampersand in the URL</ref>.</p>
@@ -776,7 +776,7 @@ These should not be escaped: \$ \\ \&gt; \[ \{
776776 <p>Here’s an <ref target="/script?foo=1&amp;bar=2">inline link in pointy
777777 braces</ref>.</p>
778778 </div>
779− <div type="level2" id="autolinks">
779+ <div type="level2" xml:id="autolinks">
780780 <head>Autolinks</head>
781781 <p>With an ampersand:
782782 <ref target="http://example.com/?foo=1&amp;bar=2">http://example.com/?foo=1&amp;bar=2</ref></p>
@@ -804,7 +804,7 @@ or here: &lt;http://example.com/&gt;
804804 <milestone unit="undefined" type="separator" rendition="line" />
805805 </div>
806806</div>
807−<div type="level1" id="images">
807+<div type="level1" xml:id="images">
808808 <head>Images</head>
809809 <p>From <quote>Voyage dans la Lune</quote> by Georges Melies (1902):</p>
810810 <p><figure>
@@ -818,7 +818,7 @@ or here: &lt;http://example.com/&gt;
818818 </figure> icon.</p>
819819 <milestone unit="undefined" type="separator" rendition="line" />
820820</div>
821−<div type="level1" id="footnotes">
821+<div type="level1" xml:id="footnotes">
822822 <head>Footnotes</head>
823823 <p>Here is a footnote reference,<note>
824824 <p>Here is the footnote. It can go anywhere after the footnote reference.