DeepIDML is a parser focus on grabbing information from IDML file.
import { DeepIDML } from 'deep-idml';
const paraXml: string = `<ParagraphStyle
FillColor="Color/Black"
FontStyle="Regular"
PointSize="12">
</ParagraphStyle>`
const deeper: DeepIDML = new DeepIDML();
deeper.setXML(XMLdata);
console.log(deeper.getJSON());
console.log(deeper.getCss());
$ npm i deep-idml
In most situations, any information about styles are in the Resources/Styles.xml which unzip from IDML file. And the snippet shows as below:
<idPkg:Styles>
...
<RootParagraphStyleGroup Self="u74">
<ParagraphStyle Self="ParagraphStyle/Table%3a12-13w table (7/9 80%25)" Name="Table:12-13w table (7/9 80%)">
<Properties>
<BasedOn type="object">ParagraphStyle/Table%3a12-13 table (7/9 80%25)</BasedOn>
</Properties>
</ParagraphStyle>
</RootParagraphStyleGroup>
...
</idPkg:Styles>
With DeepIDML, people can simply set Resources/Style.xml file as prarmete into funciton, and it will return parsed css property
const deeper: DeepIDML = new DeepIDML();
const parsedCssProps = deeper.getTraversaledParagraphStyleGroups(paraXml);
console.log(parsedCssProps);
// Result
'Table:12-13w table (7/9 80%)': {
transform: 'skewX(0)',
'font-style': 'Regular',
'text-indent': '0px',
color: 'Black',
letterSpacing: '0',
textDecoration: 'underline',
fontSize: '7',
textAlign: 'left',
marginLeft: '0',
marginRight: '0',
'@_BasedOn': 'Table:12-13 table (7/9 80%)'
},
Generated using TypeDoc