Skip to content
/ jdita Public
forked from evolvedbinary/lwdita

Tool for converting LwDITA XDITA format to JSON

License

Notifications You must be signed in to change notification settings

ccheraa/jdita

 
 

Repository files navigation

JDita Version 0.1.0 Coverage Status

This tool generates JDita (JSON representation of LwDita) from XDita files


Requirements

For development, you will only need Node.js and a node package manager, like Yarn, to be installed in your environement.

Usage

You can add JDita to your project using npm or yarn

npm install --save jdita

or

yarn add jdita
const { xditaToJson } = require("jdita");

const xml = `
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD LIGHTWEIGHT DITA Topic//EN" "lw-topic.dtd">
<topic>...</topic>
`
xditaToJson(xml)
  .then(JDitaDocument => console.log(JSON.stringify(result, null, 2)))
  .catch(error => console.log('Failed to convert:', error));

By default, xditaToJson will fail when it encounters any error (XML syntax errors, validation errors,...). If you want to ignore any errors and work with whatever data the function could collect, set the second argument abortOnError to false:

xditaToJson(xml, false)

About

Tool for converting LwDITA XDITA format to JSON

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%