Create custom styles when editoria boots up
Problem Statement; Editoria allows a manuscript to be imported and creates a semantic HTML that can be used for editing and downstream processing. This is fine for most use cases. But in Amnet’s production users, generally, upload manuscripts that are already tagged and styled. Since Editoria strips off these custom styles, our production team has to manually create custom styles and tag them in the Wax editor. This is a redundant and cumbersome process we want to eliminate.
The goal of this feature request;
- Allow Editoria to create configured custom styles while it boots up. This will help us to create a set of custom styles that are followed by our production for a book.
- To retain custom styles from the manuscript as class attributes in the converted HTML. That way, PagedJS templates can use these classes to style the book.
- Do this without affecting Editoria’s current setup drastically. This must be enabled only through a configuration flag.
- Keep the configurations in one place, preferably in Editoria.
Approach;
Part 1 (Editoria); has a separate table in its database to maintain custom styles. A new migration script can be created to import a set of custom styles. We can trigger this migration on the server start. We can introduce these new environment variables for that.
IMPORT_CUSTOM_STYLES:<Boolean>
(False by default)
CUSTOM_TAGS_IMPORT_PATH:<STRING>
RETAIN_CUSTOM_STYLES:<Boolean>
(False by default)
By setting IMPORT_CUSTOM_STYLES
to true
, we can import custom styles defined in CUSTOM_TAGS_IMPORT_PATH
. These will be set in config/custom-environment-variables.js
Part 2(XSweet); with RETAIN_CUSTOM_STYLES
set to true
, Editoria will post the manuscript and custom styles in the POST
call to the doc2html
API of XSweet. We will make changes to PIPELINED.xsl
to retain these custom styles.