{"id":30612615,"url":"https://github.com/evolvedbinary/lwdita","last_synced_at":"2026-03-05T13:32:48.416Z","repository":{"id":38356352,"uuid":"259761780","full_name":"evolvedbinary/lwdita","owner":"evolvedbinary","description":"Tools and libraries for working with LwDITA","archived":false,"fork":false,"pushed_at":"2025-11-10T14:21:43.000Z","size":2424,"stargazers_count":1,"open_issues_count":3,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-11-10T14:29:02.558Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/evolvedbinary.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-04-28T22:03:47.000Z","updated_at":"2025-11-10T14:19:47.000Z","dependencies_parsed_at":"2023-12-19T12:25:30.184Z","dependency_job_id":"f0da9e71-b520-4e1c-a0f5-5e6ea4aab1bf","html_url":"https://github.com/evolvedbinary/lwdita","commit_stats":null,"previous_names":["evolvedbinary/lwdita","evolvedbinary/xdita-to-jdita"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/evolvedbinary/lwdita","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolvedbinary%2Flwdita","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolvedbinary%2Flwdita/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolvedbinary%2Flwdita/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolvedbinary%2Flwdita/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evolvedbinary","download_url":"https://codeload.github.com/evolvedbinary/lwdita/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolvedbinary%2Flwdita/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30127870,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T12:40:50.676Z","status":"ssl_error","status_checked_at":"2026-03-05T12:39:32.209Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-30T05:34:41.325Z","updated_at":"2026-03-05T13:32:48.400Z","avatar_url":"https://github.com/evolvedbinary.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LwDITA\n\n[![Node.js Version](https://img.shields.io/node/v-lts/@evolvedbinary/lwdita-ast)](https://nodejs.org)\n[![Npm Package Version](https://img.shields.io/npm/v/@evolvedbinary/lwdita-ast)](https://www.npmjs.com/package/@evolvedbinary/prosemirror-ast)\n[![Build Status](https://circleci.com/gh/evolvedbinary/lwdita.svg?style=svg)](https://circleci.com/gh/evolvedbinary/lwdita)\n[![Coverage Status](https://coveralls.io/repos/github/evolvedbinary/lwdita/badge.svg?branch=main)](https://coveralls.io/github/evolvedbinary/lwdita?branch=main)\n\nThis repository contains a number of tools and libraries for working with LwDITA (Lightweight DITA):\n1. lwdita-xdita\n  A parser and serializer for XDITA (which is the XML representation of LwDITA). This can serialize/deserialize XDITA to an lwdita-ast object tree.\n2. lwdita-ast\n  An object representation of the LwDITA conceptual model. This is used by lwdita-xdita.\n  The `lwdita-ast` AST complies with the LwDITA specs v0.3.0.2, see: [https://github.com/oasis-tcs/dita-lwdita/releases/tag/v0.3.0.2](https://github.com/oasis-tcs/dita-lwdita/releases/tag/v0.3.0.2)\n\n---\n\n## Working with XDITA\n\nYou can add lwdita-xml library to your project using `npm` or `yarn`\n\n```bash\nnpm install --save @evolvedbinary/lwdita-xdita\n```\n\nor\n\n```bash\nyarn add @evolvedbinary/lwdita-xdita\n```\n\n### XDITA Parsing Example\n\nThe following example code shows how to parse XDITA to an lwdita-ast object tree.\n\n```javascript\nimport { xditaToAst, astToJdita } from \"@evolvedbinary/lwdita-xdita/converter\";\n\nconst xdita = `\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003c!DOCTYPE topic PUBLIC \"-//OASIS//DTD LIGHTWEIGHT DITA Topic//EN\" \"lw-topic.dtd\"\u003e\n\u003ctopic\u003e...\u003c/topic\u003e\n`\n\nconst abortOnError = true;\n\nxditaToAst(xdita, abortOnError)\n  .then(ast =\u003e console.log(JSON.stringify(ast.json, null, 2))\n  .catch(e =\u003e console.log('Failed to convert:', e));\n```\n\nAs `abortOnError` is set to `true` above, `xditaToAst` will fail when it encounters any error (XML syntax errors, validation errors, etc.). If instead you want to ignore any errors and work with whatever data the function could collect, `abortOnError` to `false` instead.\n\n#### Experimental JDita Model\nIf you would prefer a simpler object model than the lwdita-ast to work with, we have an experimental object model called JDita. To use this, you can pass the output of `xditaToAst` through the experimental converter function `astToJdita`. Note that this API is subject to change! For example:\n\n```javascript\nxditaToAst(xdita, abortOnError)\n  .then(ast =\u003e astToJdita(ast))\n  .then(jdita =\u003e console.log(JSON.stringify(jdita.json, null, 2))\n  .catch(e =\u003e console.log('Failed to convert:', e));\n```\n\n### XDITA Serialization Example\n\nA full example with an additional option for serializing the AST object back into XML can be found in the file [example.ts](packages/lwdita-xdita/example.ts).\n\n```javascript\nimport { InMemoryTextSimpleOutputStreamCollector, XditaSerializer } from \"@evolvedbinary/lwdita-xdita/xdita-serializer\";\n\nconst indentXmlOutput = true;\nconst indentation = '\\t';\nconst indentationSize = 1;\n\nconst outputStream = new InMemoryTextSimpleOutputStreamCollector();\nconst serializer = new XditaSerializer(outputStream, indentXmlOutput, indentation, indentationSize);\nconst xdita = serializer.serialize(ast);\n\nconsole.log(xdita);\n```\n\n* You can replace `InMemoryTextSimpleOutputStreamCollector` with your own OutputStream implementation by implementing the interface `SimpleOutputStream`.\n\n* The serialized XML will faithfully contain all XML node types.\n\n## Development\n\n### Prerequisites\n\nFor development, you will need Node.js and a node package manager to be installed in your environment.\n\n* Minimal Node version: v20.1.0\n* [Yarn](https://yarnpkg.com/) version v4.2.2.\n* Optional: This project uses Yarn as its build system. Although we don't support it, if you prefer, it should also be possible to use `npm` instead of `yarn`.\n\n### Installation\n\nClone the lwdita repository:\n\n```shell\ngit clone https://github.com/evolvedbinary/lwdita.git\n```\n\nChange to the lwdita directory:\n\n```shell\ncd lwdita\n```\n\nInstall all packages:\n\n```shell\nyarn install\n```\n\n### Packages\n\nThis project uses [Yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces).\nThe current packages, aka. \"workspaces\" are `lwdita-xdita` and `lwdita-ast` and can be found in folder `packages/`.\n\nPackage `lwdita-xdita` contains all files and modules for parsing and serializing XDITA documents.\nPackage `lwdita-ast` contains all files and modules for creating the AST (Abstract Syntax Tree) of the parsed document, provided by package `lwdita-xdita`.\n\nBoth packages depend on each other, as indicated by the `dependency` in their respective package.json files, and they share the same global node modules and commands as declared in the `package.json` file in the root of the project.\n\nIf in the future different node modules or commands should be defined for the packages, then you are able to address the packages directly with command\n\n```shell\nyarn workspace \u003cworkspace_name\u003e \u003ccommand\u003e\n```\n\nIn the global package.json you can e.g. define specific commands for each package like following pattern:\n\n```json\n\"scripts\": {\n  \"start:package-a\": \"yarn workspace package-a start\",\n  \"start:package-b\": \"yarn workspace package-b start\"\n}\n```\n\nTo get more information about contained workspaces, run command\n\n```shell\nyarn workspaces info\n```\n\n### Build\n\nTo build the project, run:\n\n```shell\nyarn run build\n```\n\nThis will create a `./dist` folder in the root of each sub-module, which contains binaries that can be copied to your own project.\n\n### Generate the TSDoc Documentation\n\nYou can generate the documentation by running\n\n```shell\nyarn run generate-docs\n```\n\nThis will generate a new folder `docs` containing an HTML file with the entire TSDoc lwdita documentation.\nOpen this file in a browser to navigate through the documentation.\n\n### Test\n\nThis project also has tests which are written using the Mocha framework.\nTo execute the test suite and view the code coverage, run:\n\n```shell\nyarn run test\nyarn run coverage\n```\n\n### Example\n\nWe have an example file to test the conversion: `example.ts`.\nThis file contains a small example in `XDITA` format.\n\nIf you want to test this library and its conversion from `XDITA` to `JDita`, run:\n\n```shell\nyarn run example\n```\n\n## How it Works\n\nlwdita-xdita takes in documents in LwDITA XDITA (XML) format, and produces an AST (Abstract Syntax Tree).\n\nXDITA is the LwDITA representation that uses XML to structure information. LwDITA is a subset of DITA, with new multimedia element types added to support interoperability with HTML5.\n[Source: https://www.dita-ot.org/4.1/topics/lwdita-input](https://www.dita-ot.org/4.1/topics/lwdita-input)\n\nThe conversion process starts by building a tree whose root node represents the XDITA Document Node, then appending each XDITA Element Node as a child node node in the tree.\n\nThis will generate a full document tree that represents the original XDITA document as a JavaScript object.\n\n![Diagram of converter.ts](diagrams/lwdita-diagram-conversion.svg \"Diagram of converter.ts\")\n\nHere's how the nodes are created:\n\n![Diagram the node creation](diagrams/lwdita-diagram-node-creation.svg \"Diagram the node creation\")\n\nExamples of the nodes `\u003ctitle\u003e` and `\u003ctopic\u003e`:\n\n![Diagram of example nodes](diagrams/lwdita-diagram-nodes.svg \"Diagram of example nodes\")\n\n## Publishing a Release\nTo publish a new release of lwdita please follow these instructions:\n\n**NOTE** The project uses [Semantic Versioning](https://semver.org/), and you should make sure to choose the appropriate next version number to supply to `yarn release`.\n\n```shell\ncd lwdita\nyarn release 1.2.3\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevolvedbinary%2Flwdita","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevolvedbinary%2Flwdita","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevolvedbinary%2Flwdita/lists"}