diff --git a/resource/amend-uri.js b/resource/amend-uri.js new file mode 100644 index 0000000..3cd6c83 --- /dev/null +++ b/resource/amend-uri.js @@ -0,0 +1,36 @@ +/* + * This file is part of the DITA Passthrough Plug-in project. + * See the accompanying LICENSE file for applicable licenses. + */ + +// +// Converts a value to relative path +// +// @param path - The relative path of the file +// @param href - The relative path of the image +// + +var path = attributes.get("path"); +var href = attributes.get("href"); + +var hrefElements = href.split('/'); +var pathElements = path.split('/'); +var fullPath = []; + +for each (var elem in pathElements) { + if (elem !== ''){ + fullPath.push(elem) + } +} + + +for each (var elem in hrefElements) { + if (elem === ''){ + } else if (elem === '..'){ + fullPath.pop() + } else { + fullPath.push(elem) + } +} + +project.setProperty(attributes.get("to"), fullPath.join('/')); \ No newline at end of file diff --git a/resource/antlib.xml b/resource/antlib.xml index 28af128..b1886f8 100644 --- a/resource/antlib.xml +++ b/resource/antlib.xml @@ -6,16 +6,28 @@ - + + + + + + + +