Open opoudjis opened 3 years ago
The relative file paths, in the asciidoctor of the remarks extracted by lutaml from expressir, need to be updated to reflect the calling environment. So:
[lutaml, ../../../resources/action_schema/action_schema.exp, repo]
is fetching a line containing:
image::action_schemaexpg1.xml[]
Something needs to update that URL, so that the expression reads:
image::../../../resources/action_schema/action_schemaexpg1.xml[]
Wouldn't it be better to allow the user to have the image::...
path manually specified to the path they want?
Imagine that you have a different source path for images that is separate from the schema path.
Maybe you want to have the "context path" available as a separate variable inside that context? e.g. {{ context_path }}
here stands for ../../../resources/action_schema
.
So a separate assets directory variable?
The only way that would be acceptable is as a separate and optional parameter to the lutaml macro. The behaviour implemented is fully appropriate as a default.
For now, we are addressing this by using absolute paths, when we iterate through multiple schemas. Highly desirable to make them relative paths relative to the embedding document, so that the document can stay portable. This only impacts the asciidoc; we are using data uri encoding for the XML output.
The relative file paths, in the asciidoctor of the remarks extracted by lutaml from expressir, need to be updated to reflect the calling environment. So:
[lutaml, ../../../resources/action_schema/action_schema.exp, repo]
is fetching a line containing:
image::action_schemaexpg1.xml[]
Something needs to update that URL, so that the expression reads:
image::../../../resources/action_schema/action_schemaexpg1.xml[]
This means:
If the relative path is, say,
../../x
, it would turn into../../../resources/action_schema/../../x
You must not update absolute paths, which are recognised as follows:
^[^/:]+://|^[A-Z]:/
(e.g.file:///
,http://
,c:/
)The paths to be so updated are:
\blink:{path}\[
e.g.link:downloads/report.pdf[Get Report]
; see https://docs.asciidoctor.org/asciidoc/latest/macros/link-macro/\bimage:{path}\[
e.g.image:pause.png[title="Pause"]
; see https://docs.asciidoctor.org/asciidoc/latest/macros/images/\bvideo:{path}\[
e.g.video::video_file.mp4[]
; see https://docs.asciidoctor.org/asciidoc/latest/macros/audio-and-video/\baudio:{path}\[
e.g.audio::video_file.mp4[]
; see https://docs.asciidoctor.org/asciidoc/latest/macros/audio-and-video/\binclude:{path}\[
e.g.include::sales/2016/results.csv[]
; see https://docs.asciidoctor.org/asciidoc/latest/directives/include/So, in sum:
\b(link|image|video|audio|include)(?![^/:]+://|[A-Z]:/)(?<link>[^\[]+)\[
I am ignoring
icon:[]
macros, since they are assumed to be fixed to one directory for an asciidoc document (https://docs.asciidoctor.org/asciidoc/latest/macros/icons/), and we don't process them currently anyway.I am ignoring the link attribute of images, because that would be extremely difficult to deal with via regexes, and because that is assumed to be an absolute link by default anyway.