UNPKG

2.04 kBMarkdownView Raw
1# Markdown Transform API
2
3High-level API to transform markdown into different formats.
4
5## Installation
6
7```
8npm install -g @accordproject/markdown-transform
9```
10
11## Basic Usage
12
13```
14const transform = require('@accordproject/markdown-transform').transform;
15
16// convert a markdown string to an html string
17// first argument is the markdown string to be converted
18// second argument is the source format
19// third argument is an array of destination formats to pass through
20const htmlString = await transform(markdownString, 'markdown', ['html']);
21console.log(htmlString);
22```
23
24Note that the call to `transform` returns a `Promise`.
25
26The third argument to the `transform` function can be used to force the transform to visit an optional
27intermediate format. For example, passing `['ciceromark_noquotes','html']` will transform the source
28to `ciceromark_noquotes` followed by all the transformations necessary to transform from `ciceromark_noquotes` to `html`.
29
30The example below transforms input markdown, stripping quotes from around variables, and then converts to HTML.
31
32```
33const result = await transform(acceptanceCiceroEdit, 'markdown', ['ciceromark_noquotes','html']);
34```
35
36## Transformation Graph
37
38You can generate a PlantUML state diagram for the supported transformations using the following code:
39
40```
41const generateTransformationDiagram = require('@accordproject/markdown-transform').generateTransformationDiagram;
42const plantUMLStateDiagram = generateTransformationDiagram();
43```
44
45The diagram below (showing all supported transformations) is automatically generated by `./scripts/generateDiagram.js`.
46
47![Transforms](transformations.png)
48
49## License <a name="license"></a>
50Accord Project source code files are made available under the Apache License, Version 2.0 (Apache-2.0), located in the LICENSE file. Accord Project documentation files are made available under the Creative Commons Attribution 4.0 International License (CC-BY-4.0), available at http://creativecommons.org/licenses/by/4.0/.
51
52© 2017-2019 Clause, Inc.