Error occured of "include file not found" by using asciidoc include directive.
UsedPartsJapan opened this issue · comments
Summary
When using the include directive in an AsciiDoc file, an "include file not found" error occurs.
asciidoctor: ERROR: : line 3: include file not found: D:/Document/share/TechnicalSiteGenerator/HonKit/resources/included1.txt
asciidoctor: ERROR: : line 8: include file not found: Q:/Document/share/TechnicalSiteGenerator/HonKit/resources/included2.txt
asciidoctor: ERROR: : line 13: include file not found: Q:/Document/share/TechnicalSiteGenerator/HonKit/resources/included3.txt
- HonKit version: 4.0.8
Step to reproduce
- make content1.adoc file like bellow.
----
include:: ./resources/included1.txt[]
----
- build
npx honkit build
- Link to code example:
sample.zip
Expected results
This is the included text1 !
Actual results
Unresolved directive in - include::./resources/included1.txt[]
$ npx honkit build --log=debug
debug: readme found at README.adoc
debug: summary file found at SUMMARY.adoc
debug: cleanup folder "Q:\Document\share\TechnicalSiteGenerator\HonKit_book"
info: 4 plugins are installed
info: 4 explicitly listed
info: plugin "search-pro-fixed" is loaded
info: plugin "highlight" is loaded
info: plugin "fontsettings" is loaded
info: plugin "theme-default" is loaded
info: found 3 pages
info: found 3 asset files
debug: calling hook "config"
debug: calling hook "init"
debug: copy assets from theme Q:\Document\share\TechnicalSiteGenerator\HonKit\node_modules@honkit\honkit-plugin-theme-default_assets\website
debug: copy resources from plugin Q:\Document\share\TechnicalSiteGenerator\HonKit\node_modules\gitbook-plugin-fontsettings\assets
debug: copy resources from plugin Q:\Document\share\TechnicalSiteGenerator\HonKit\node_modules@honkit\honkit-plugin-highlight\css
debug: copy resources from plugin Q:\Document\share\TechnicalSiteGenerator\HonKit\node_modules\gitbook-plugin-search-pro-fixed\assets
debug: copy asset "chapter-1\resources\included1.txt"
debug: copy asset "chapter-1\resources\included2.txt"
debug: copy asset "chapter-1\resources\included3.txt"
debug: calling hook "page:before"
debug: calling hook "page:before"
debug: calling hook "page:before"
asciidoctor: ERROR: : line 3: include file not found1: Q:/Document/share/TechnicalSiteGenerator/HonKit/resources/included1.txt
asciidoctor: ERROR: : line 8: include file not found1: Q:/Document/share/TechnicalSiteGenerator/HonKit/resources/included2.txt
asciidoctor: ERROR: : line 13: include file not found1: Q:/Doc
ument/share/TechnicalSiteGenerator/HonKit/resources/included3.txt
debug: calling hook "page"
debug: calling hook "page"
debug: calling hook "page"
debug: index page README.adoc
debug: index page chapter-1/README.adoc
debug: index page chapter-1/content1.adoc
debug: calling hook "finish:before"
debug: calling hook "finish"
debug: write search index
info: >> generation finished with success in 29.6s !
Thanks for report.
I confirmed it.
It is failed on Windows/Linux.
https://github.com/azu/honkit-issue-356/actions/runs/5564350767/jobs/10163899453
The cause seems to be that the base directory is not taken into convert function.
- Actual: Q:/Document/share/TechnicalSiteGenerator/HonKit/resources/included1.txt
- Expected: Q:/Document/share/TechnicalSiteGenerator/HonKit/docs/chapter-1/resources/included1.txt
----
include:: ./docs/chapter-1resources/included1.txt[]
----
This will works but is not user-friendly.
Currently, the execution directory, not the file, seems to have become the starting point for path resolution.
Note: how to fix
📝 I dig it, but it is a bit complex…
I want to pass base directory to these convert
method.
honkit/packages/@honkit/asciidoc/src/toHTML.ts
Lines 6 to 13 in 777bfa4
Call Stack
- wrap
asciidocToHTML
honkit/packages/@honkit/html/src/index.ts
Lines 37 to 44 in 1a9cbf9
toHTML(args[0])
callasciidocToHTML
honkit/packages/@honkit/html/src/index.ts
Line 22 in 1a9cbf9
We need to add second argument for passing base dir.
type AbstractConvertOptions = {
baseDir: string;
};
function compose(toHTML, fn) {
return function WRAP_TO_HTML(content: string, options: AbstractConvertOptions) {
const args = _.toArray(arguments);
args[0] = toHTML(content, options);
return fn.apply(null, args);
};
}
- pass second args when call the WRAP_TO_HTML function
honkit/packages/honkit/src/models/parser.ts
Lines 27 to 91 in 8ba2096
This change will be breaking changes.
Related
This issue is fixed in https://github.com/honkit/honkit/releases/tag/v5.0.0
please try it!