Development documentation may describe unreleased features. Type ? for keyboard shortcuts · Switch to the latest release: 3.0 Docs
Bundling CSS in a custom HTML plug-in
You can create a DITA-OT plug-in that provides a custom stylesheet with the typography and colors that define your corporate identity. Coworkers can install this plug-in to ensure consistent HTML output across projects without having to copy the stylesheet to each project.
About this task
This scenario walks through the process of creating a very simple plug-in
(com.example.html5.custom.css
) that creates a new transformation type:
html5-custom-css.
The html5-custom-css transformation includes a custom CSS file and sets three parameters to integrate the custom stylesheet in the generated HTML5 output. These parameter settings make the following changes:
-
Specify the name of the custom .css file with args.css.
The value of this parameter tells DITA-OT to use the custom .css file provided by the plug-in.
-
Ensure that the custom .css file is copied to the output directory by setting args.copycss to yes.
-
Set the relative path for .css files in the output folder with args.csspath.
CSS files are copied to the root level of the output folder by default. Setting this parameter places CSS files in a dedicated subfolder.
All three parameters are set in the Ant script (build.xml).
Procedure
Results
The new plug-in directory has the following layout and files:
com.example.html5.custom.css
├── build.xml
├── css
│ └── custom.css
└── plugin.xml
What to do next
- Run dita-ot-dir/bin/dita --install to install the plug-in and make the html5-custom-css transformation available.
- Build output with the new transformation type to verify that the plug-in works as intended.
dita-ot-dir/bin/dita --input=my.ditamap --format=html5-custom-css
- Refine the styles in your custom.css file as necessary.