From 311a3406878d4f02ffe4c087ece82f9d4156ff92 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 19 Sep 2022 03:11:40 +0200 Subject: 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`. --- test/command/6384.md | 16 ++++++++++++++++ test/command/file1.txt | 9 +++++++++ test/command/file2.txt | 5 +++++ 3 files changed, 30 insertions(+) create mode 100644 test/command/6384.md create mode 100644 test/command/file1.txt create mode 100644 test/command/file2.txt (limited to 'test/command') diff --git a/test/command/6384.md b/test/command/6384.md new file mode 100644 index 000000000..1be1c3e45 --- /dev/null +++ b/test/command/6384.md @@ -0,0 +1,16 @@ +``` +% pandoc --wrap=preserve --file-scope command/file1.txt command/file2.txt +^D +
+

Zed

+

foo +and Zed +and other Zed +and other file +and foreign Zed

+
+
+

Zed

+

foo

+
+``` diff --git a/test/command/file1.txt b/test/command/file1.txt new file mode 100644 index 000000000..5416f3a6c --- /dev/null +++ b/test/command/file1.txt @@ -0,0 +1,9 @@ +# Zed + +[foo]: bar + +[foo] +and [Zed](#zed) +and [other Zed](command/file2.txt#zed) +and [other file](command/file2.txt) +and [foreign Zed](c.md#zed) diff --git a/test/command/file2.txt b/test/command/file2.txt new file mode 100644 index 000000000..20ee06c8c --- /dev/null +++ b/test/command/file2.txt @@ -0,0 +1,5 @@ +## Zed + +[foo]: baz + +[foo] -- cgit v1.2.3