Skip to main content

Convert a generic DITA topic to a specialized concept, task, or reference.

Project description

DITA Custom XSLT

dita-custom-xslt is a set of XSLT stylesheets that convert a generic DITA topic to a specialized DITA concept, reference, or task. dita_convert is a Python 3 package that provides a convenient access to these stylesheets and a command-line utility to perform the conversions.

In combination with asciidoctor-dita-topic, this project can be used to rapidly convert AsciiDoc content to DITA.

Installation

Install the dita_convert Python package:

python3 -m pip install --upgrade dita_convert

Usage

Using the command-line interface

To convert a DITA topic to a specialized DITA content type, run the following command:

python3 -m dita.convert -t TYPE TOPIC_FILE

For convenience, the package also provides a wrapper script that you can run directly as follows:

dita-convert -t concept sample.dita

Available TYPE values are concept, reference, task, and task-generated for converting files generated by asciidoctor-dita-topic that follow the guidelines for procedure modules as defined in the Modular Documentation Reference Guide.

Using the Python interface

To convert a DITA topic to a specialized DITA content type, the dita_convert package exports the corresponding to_concept(), to_reference(), to_task(), and to_task_generated() functions that return an ElementTree object:

from lxml import etree
from dita.convert import to_task

# Parse the contents of a sample DITA topic file:
topic = etree.parse("topic.dita")

# Convert the DITA topic to a DITA task:
task  = to_task(topic)

# Print the resulting XML to standard output:
print(str(task))

If you prefer to work with the underlying XSLT stylesheets directly, you can access their Path objects as follows:

from dita.convert import xslt

# Print the full path to the XSLT stylesheet for DITA reference:
print(xslt.reference)

Available variables are concept, reference, task, and task_generated.

Copyright

Copyright © 2024 Jaromir Hradilek

This program is free software, released under the terms of the MIT license. It is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dita_convert-1.0.1.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dita_convert-1.0.1-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file dita_convert-1.0.1.tar.gz.

File metadata

  • Download URL: dita_convert-1.0.1.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for dita_convert-1.0.1.tar.gz
Algorithm Hash digest
SHA256 2c0bd39dbfd31f9ec4a2ef863d2fb73effc32723253b261a0d6e1cf4f2d32d8b
MD5 a398304e6408d5ed97b6f1d2001f2ac9
BLAKE2b-256 5acb66029a2f15e3484827127ec9f19ab0b31391d929f7097038172c757afbeb

See more details on using hashes here.

File details

Details for the file dita_convert-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: dita_convert-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for dita_convert-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b5c89beb78d41afe055ad0fb548ce2a36fcc2fa250d06194f27f25c8a039d428
MD5 6b74b25835198826e2f1ab66781ab826
BLAKE2b-256 1a3bbd70d74cfe6bb54e509786293c4c0ef9489a6f8adcfb28ba94c46128f1f8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page