Files
pandoc/test/command/6384.md
T
John MacFarlane 311a340687 Add prefixes to identifiers with --file-scope. (#8282)
This change only affects the case where `--file-scope` is used
and more than one file is specified on the command line.

In this case, identifiers will be prefixed with a string
derived from the file path, to disambiguate them. For example,
an identifier `foo` in `contents/file1.txt` will become
`contents__file1.txt__foo`.  Links will be adjusted accordingly:
if `file2.txt` links to `file1.txt#foo`, then the link will
be changed to point to `#file1.txt__foo`.  Similarly, a link
to `file1.txt` will point to `#file1.txt`.  A Div with an
identifier derived from the file path will be added around
each file's content, so that links to files will still work.

Closes #6384.

[API change]: Text.Pandoc.Shared exports `textToIdentifier`.
2022-09-18 18:11:40 -07:00

489 B

% pandoc --wrap=preserve --file-scope command/file1.txt command/file2.txt
^D
<div id="command__file1.txt">
<h1 id="command__file1.txt__zed">Zed</h1>
<p><a href="bar">foo</a>
and <a href="#command__file1.txt__zed">Zed</a>
and <a href="#command__file2.txt__zed">other Zed</a>
and <a href="#command__file2.txt">other file</a>
and <a href="c.md#zed">foreign Zed</a></p>
</div>
<div id="command__file2.txt">
<h2 id="command__file2.txt__zed">Zed</h2>
<p><a href="baz">foo</a></p>
</div>