Skip to content

Commit 3196947

Browse files
lmunchtarleb
authored andcommitted
Updated test and docs for include-files filter
1 parent ef3dd71 commit 3196947

File tree

6 files changed

+45
-5
lines changed

6 files changed

+45
-5
lines changed

include-files/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ expected.native: sample.md file-a.md file-b.md file-c.md include-files.lua
1010
pandoc --lua-filter=include-files.lua --output $@ $<
1111

1212
expected-auto.native: sample.md file-a.md file-b.md file-c.md include-files.lua
13-
pandoc --lua-filter=include-files.lua --output $@ $<
13+
pandoc --lua-filter=include-files.lua -M include-auto --output $@ $<
1414

1515
.PHONY: test

include-files/README.md

+7-4
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,13 @@ Only plain-text formats are accepted.
6262
### Recursive transclusion
6363

6464
Included files can in turn include other files. Note that all
65-
filenames must be relative to the directory from which pandoc is
66-
run. I.e., if a file `a/b.md` is included in the main document,
67-
and another file `a/b/c.md` should be included, the full relative
68-
path must be used. Writing `b/c.md` in `a/b.md` would _not_ work.
65+
filenames must be relative to the directory from which they are
66+
included. I.e., if a file `a/b.md` is included in the main
67+
document, and another file `a/b/c.md` should be included from
68+
`a/b.md`, then the relative path from `a/b.md` must be used, in
69+
this case `b/c.md`. The full relative path will be automatically
70+
generated in the final document. The same goes for image paths and
71+
codeblock file paths using the `include-code-files` filter.
6972

7073
## Example
7174

include-files/expected-auto.native

+7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
,Para [Str "This",Space,Str "is",Space,Code ("",[],[]) "file-a.md",Str "."]
1717
,Header 3 ("title-of-file-a",[],[]) [Str "Title",Space,Str "of",Space,Str "file-a"]
1818
,Para [Str "This",Space,Str "is",Space,Code ("",[],[]) "file-a.md",Str "."]
19+
,Header 1 ("subdirectories",[],[]) [Str "Subdirectories"]
20+
,Header 2 ("image-include",[],[]) [Str "Image",Space,Str "include"]
21+
,Para [Str "Image",Space,Str "relative",Space,Str "path",Space,Str "will",Space,Str "be",Space,Str "updated."]
22+
,Para [Image ("",[],[]) [Str "Image",Space,Str "title"] ("subdir/someimage.png","fig:")]
23+
,Header 2 ("source-include",[],[]) [Str "Source",Space,Str "include"]
24+
,Para [Str "File",Space,Str "inclusion",Space,Str "codeblocks",Space,Str "for",Space,Str "use",Space,Str "with",Space,Str "include-code-files",Space,Str "will",Space,Str "be",SoftBreak,Str "updated",Space,Str "too."]
25+
,CodeBlock ("",["c"],[("include","subdir/somecode.c")]) ""
1926
,Header 1 ("appendix",[],[]) [Str "Appendix"]
2027
,Para [Str "More",Space,Str "info",Space,Str "goes",Space,Str "here."]
2128
,Header 2 ("questionaire",[],[]) [Str "Questionaire"]

include-files/expected.native

+7
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@
1616
,Para [Str "This",Space,Str "is",Space,Code ("",[],[]) "file-a.md",Str "."]
1717
,Header 2 ("title-of-file-a",[],[]) [Str "Title",Space,Str "of",Space,Str "file-a"]
1818
,Para [Str "This",Space,Str "is",Space,Code ("",[],[]) "file-a.md",Str "."]
19+
,Header 1 ("subdirectories",[],[]) [Str "Subdirectories"]
20+
,Header 1 ("image-include",[],[]) [Str "Image",Space,Str "include"]
21+
,Para [Str "Image",Space,Str "relative",Space,Str "path",Space,Str "will",Space,Str "be",Space,Str "updated."]
22+
,Para [Image ("",[],[]) [Str "Image",Space,Str "title"] ("subdir/someimage.png","fig:")]
23+
,Header 1 ("source-include",[],[]) [Str "Source",Space,Str "include"]
24+
,Para [Str "File",Space,Str "inclusion",Space,Str "codeblocks",Space,Str "for",Space,Str "use",Space,Str "with",Space,Str "include-code-files",Space,Str "will",Space,Str "be",SoftBreak,Str "updated",Space,Str "too."]
25+
,CodeBlock ("",["c"],[("include","subdir/somecode.c")]) ""
1926
,Header 1 ("appendix",[],[]) [Str "Appendix"]
2027
,Para [Str "More",Space,Str "info",Space,Str "goes",Space,Str "here."]
2128
,Header 2 ("questionaire",[],[]) [Str "Questionaire"]

include-files/sample.md

+9
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ file-d.org
2828
file-f.md
2929
```
3030

31+
# Subdirectories
32+
33+
``` {.include}
34+
// file-g.md includes an image and source code. The relative
35+
// path used in file-g.md will be prefixed with subdir in the
36+
// final document.
37+
subdir/file-g.md
38+
```
39+
3140
# Appendix
3241

3342
More info goes here.

include-files/subdir/file-g.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Image include
2+
3+
Image relative path will be updated.
4+
5+
![Image title](someimage.png)
6+
7+
# Source include
8+
9+
File inclusion codeblocks for use with include-code-files will be
10+
updated too.
11+
12+
```{.c include=somecode.c}
13+
```
14+

0 commit comments

Comments
 (0)