1 | # Markdown Transform API
|
2 |
|
3 | High-level API to transform markdown into different formats.
|
4 |
|
5 | ## Installation
|
6 |
|
7 | ```
|
8 | npm install -g @accordproject/markdown-transform
|
9 | ```
|
10 |
|
11 | ## Basic Usage
|
12 |
|
13 | ```
|
14 | const 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
|
20 | const htmlString = await transform(markdownString, 'markdown', ['html']);
|
21 | console.log(htmlString);
|
22 | ```
|
23 |
|
24 | Note that the call to `transform` returns a `Promise`.
|
25 |
|
26 | The third argument to the `transform` function can be used to force the transform to visit an optional
|
27 | intermediate format. For example, passing `['ciceromark_noquotes','html']` will transform the source
|
28 | to `ciceromark_noquotes` followed by all the transformations necessary to transform from `ciceromark_noquotes` to `html`.
|
29 |
|
30 | The example below transforms input markdown, stripping quotes from around variables, and then converts to HTML.
|
31 |
|
32 | ```
|
33 | const result = await transform(acceptanceCiceroEdit, 'markdown', ['ciceromark_noquotes','html']);
|
34 | ```
|
35 |
|
36 | ## Transformation Graph
|
37 |
|
38 | You can generate a PlantUML state diagram for the supported transformations using the following code:
|
39 |
|
40 | ```
|
41 | const generateTransformationDiagram = require('@accordproject/markdown-transform').generateTransformationDiagram;
|
42 | const plantUMLStateDiagram = generateTransformationDiagram();
|
43 | ```
|
44 |
|
45 | The 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>
|
50 | Accord 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.
|