asciidoctor / asciidoctorj

:coffee: Java bindings for Asciidoctor. Asciidoctor on the JVM!
http://asciidoctor.org
Apache License 2.0
623 stars 173 forks source link

Fixes #1135. Target file name should be relative to destination dir i… #1137

Closed robertpanzer closed 1 year ago

robertpanzer commented 1 year ago

…f source dir is given.

Thank you for opening a pull request and contributing to AsciidoctorJ!

Please take a bit of time giving some details about your pull request:

Kind of change

Description

What is the goal of this pull request? When giving asciidoctor a source dir and a destination dir, source files are created relative to the destination dir instead of flat, i.e. srcdir/a/b/index.adoc should be converted to destinationdir/a/b/index.html instead of destinationdir/index.html.

AsciidoctorJ currently does not do that, this PR tries to fix this.

How does it achieve that?

Similar to how Asciidoctor does, the "invoker" checks if the source file is relative to the srcdir option and then relativizes the path.

Are there any alternative ways to implement this?

Are there any implications of this pull request? Anything a user must know?

Issue

If this PR fixes an open issue, please add a line of the form:

Fixes #1135

For now this is WIP, I need to test what this change means for linked resources etc.

robertpanzer commented 1 year ago

Added a test and fixed the special case where the srcDir is ..

I consider this as a breaking change, hence this should not go into the 2.x line.

robertpanzer commented 1 year ago

Another option to solve this might be to directly create a Ruby Asciidoctor::Cli::Invoker with the parsed options, and then call invoke!. Iirc @mojavelinux asked for that in the past a couple of times already, maybe now is the time to do it.

That should be a separate effort though. I'll merge this for now, and check in another PR whether I can change the AsciidoctorJ CLI to reuse the Asciidoctor CLI.