diff options
| author | Shulhan <ms@kilabit.info> | 2024-10-13 23:50:54 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2024-10-13 23:50:54 +0700 |
| commit | 37563af4c7e82fab352f4ab9137f808058e483e2 (patch) | |
| tree | e1758abaf802d1e94aad393e71c9b0b5fd0ede37 /element_include_test.go | |
| parent | 013bf4d56baf977244c670a77048ca6d946c1f56 (diff) | |
| download | asciidoctor-go-37563af4c7e82fab352f4ab9137f808058e483e2.tar.xz | |
all: fix reading include file when parent path is absolute
Previously, if the parent document is opened using absolute path and it
contains include directive, the included file will fail to read because
the parent path is joined with current working directory.
Diffstat (limited to 'element_include_test.go')
| -rw-r--r-- | element_include_test.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/element_include_test.go b/element_include_test.go new file mode 100644 index 0000000..f337537 --- /dev/null +++ b/element_include_test.go @@ -0,0 +1,43 @@ +package asciidoctor + +import ( + "bytes" + "os" + "path/filepath" + "testing" + + "git.sr.ht/~shulhan/pakakeh.go/lib/test" +) + +func TestParseIncludeWithAbsolutePath(t *testing.T) { + var ( + tdata *test.Data + err error + ) + tdata, err = test.LoadData(`testdata/include_test.txt`) + if err != nil { + t.Fatal(err) + } + + var wd string + + wd, err = os.Getwd() + if err != nil { + t.Fatal(err) + } + + var fadoc = filepath.Join(wd, `testdata`, `include.adoc`) + var doc *Document + + doc, err = Open(fadoc) + if err != nil { + t.Fatal(err) + } + + var got bytes.Buffer + + doc.ToHTMLEmbedded(&got) + + var exp = string(tdata.Output[`include`]) + test.Assert(t, `ParseIncludeWithAbsolutePath`, exp, got.String()) +} |
