Search code examples
htmlcssditadita-ot

How can I override default css in html5 converting with DITA-OT 3.0.4?


I'm using DITA-OT 3.0.4.

I'm trying to convert my markdown file to html5 with the following command.

dita --input="note.ditamap" --output="out" --format=html5 --args.css=style.css --args.cssroot=metadata --args.copycss=yes --args.csspath=css

And I have these directory structure.

├── note.ditamap
├── metadata
│   ├── note.properties
│   └── style.css(this is my custom CSS)

As a result of the above command, converting is succeeded, but the output html(i.e. index.html) did not contain the custom CSS.

I also tried with these command and properties, but the result is the same as before.

dita --input="note.ditamap" --output="out" --format=html5 --propertyfile="metadata/note.properties"

Here is the note.properties content.

args.csspath = css
args.copycss = YES
args.css = style.css
args.cssroot = metadata

I found output html refers ${DITA_INSTALL_DIR}/dita-ot-3.0.4/plugins/org.dita.html5/css/commonltr.css, so I appended my CSS to it and my expected output is coming, but I think it is not good because these changes will affect all other projects.

I checked some documents and issues on GitHub, but I could not find the solution yet. Do you have any suggestion?

References:


Solution

  • Your "args.cssroot" is given as a relative location "metadata". The documentation for the parameter states something like:

       The value you enter here will be interpreted relative to the location of the input map file.
    

    but from what I looked in the build files this is not true, the relative location seems to be relative to the current folder where the publishing process started (which is probably the "DITA-OT\bin"). So maybe you could try to pass args.cssroot as an absolute path, see if it works better for you.

    Usually in such cases instead of passing the args.cssroot I pass directly the "args.css" as an absolute path, this also seems to work for me.