Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update relative file paths in fetched remarks #6

Open
opoudjis opened this issue Jan 8, 2021 · 3 comments
Open

Update relative file paths in fetched remarks #6

opoudjis opened this issue Jan 8, 2021 · 3 comments
Assignees

Comments

@opoudjis
Copy link
Contributor

opoudjis commented Jan 8, 2021

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:

  • For all relative file paths in asciidoctor source
    • Prefix the file path with the path of the Lutaml file

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:

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.

@ronaldtse
Copy link
Contributor

ronaldtse commented Jan 12, 2021

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.

@opoudjis
Copy link
Contributor Author

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.

@opoudjis
Copy link
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants