Releases: accordproject/markdown-transform
Markdown Transform v0.12.2
🐜 This is a patch release with some minor improvements.
TemplateMark
- accordproject/template-archive#572 formula names generation should now always be a proper identifier
Dingus
- inline template blocks are properly rendered as HTML spans
- some styling was added
Markdown Transform v0.12.1
🐜 This is a patch release with some minor improvements.
Dependencies
- Switches to latest Concerto
0.82.8
markdown-it plugins
- #270 The markdown-it plugins for contracts and template better renders natively into HTML
Slate transform
- Now provides a convenience API call
SlateTransformer.toMarkdownCicero
Markdown Transform v0.12.0
This is a major new release of the Markdown Transform library, which powers Accord Project's markdown-based templates and contracts, as well as its rich text editing components. It includes several new packages, better support for commonmark parsing, a new template parsing engine which replaces the one in Cicero, the ability to generate pdf documents, and more.
🏗️ New parser for markdown, Accord Project contracts and Templates
We have switched the underlying markdown parser to the markdown-it library. Parsing for Accord Project templates and contract text is now implemented as proper markdown extensions.
This release includes three new packages:
@accordproject/markdown-it-cicero
: a plugin formarkdown-it
which supports Accord Project contract parsing.@accordproject/markdown-it-template
: a plugin formarkdown-it
which supports Accord Project template grammar parsing.@accordproject/markdown-template
: includes support for Accord Project templates, including: the ability to create a proper document object model and new transforms for parsing and drafting contracts according to that template.
🌲 CommonMark, CiceroMark and TemplateMark models
This release is based on revisions and extensions to the underlying document object models for markdown (CommonMark), contract text (CiceroMark) and on a new document object model for templates (TemplateMark).
- The CommonMark model has been switched to version
0.2.0
with some adjustments to line numbers information to account for the new parser. - The CiceroMark model has been switched to version
0.3.0
which includes some new nodes, and additional information useful for rich-text editing, including the type of variable and the source code for formulas. - The new TemplateMark model version
0.1.0
captures the information contained in a template grammar, including variables, template blocks, and formulas.
📝 New parsing and drafting engine for Cicero
The @accordproject/markdown-template
package includes a full redesign and reimplementation of the Accord Project template parser, replacing the one originally included in Cicero. The new implementation is based on parser combinators, using the parsimmon library and has several benefits:
- It ensures consistency with the commonmark specification
- It offers an new extension API which lets users easily change the parser behaviour
- It improves runtime performances and memory footprint
- It is more portable, avoiding issues when using the parser in a browser environment (see accordproject/template-archive#278 and accordproject/template-archive#556)
New Transforms
The transforms have been completely overhauled to account for the new formats and models. The full set of transforms supported can be found in the new diagram:
Transforming templates requires access to the underlying Concerto model. For instance, to obtain the new TemplateMark DOM from a template grammar:
bash-3.2$ markus transform --from markdown_template --to templatemark --model model.cto --input grammar.tem.md
Parsing (i.e., transforming markdown to data) and drafting (i.e., transforming data back to markdown) requiree access to the underlying Concerto model and template. For instance:
bash-3.2$ markus transform --from markdown --to data --model model.cto --template grammar.tem.md --input sample.md
9:59:46 AM - info:
{
"$class": "org.accordproject.helloworld.HelloWorldClause",
"name": "Fred Blogs",
"clauseId": "eecef85e-3f14-4b22-9aab-5105842a591c"
}
bash-3.2$ markus transform --from data --to markdown --model model.cto --template grammar.tem.md --input data.json
10:01:05 AM - info:
Name of the person to greet: "Fred Blogs".
Thank you!
Template parser plugins
The extension API allows to specify a custom parser for a given type (e.g., an address, a purchase order) either as: a template fragment, a template AST (in TemplateMark format). That custom parser can be passed to the command line interface using the --plugin
option.
bash-3.2$ more grammar.tem.md
This contract is for {{friend}}. This is a contract between {{seller}} and {{buyer}} for the amount of {{amount}} {{currency}}{{#if forceMajeure}}, *even* in the presence of force majeure{{else}}, *except* in the presence of force majeure{{/if}}.
bash-3.2$ more sample.md
This contract is for <First Name: "Steve" Last Name: "Doe"\>. This is a contract between "Steve" and "Betty" for the amount of 3131.0 EUR, _except_ in the presence of force majeure.
bash-3.2$ more plugin.js
module.exports = {
'org.test.Person' : { 'inline' : '<First Name: {{firstName}} Last Name: {{lastName}}>' }
};
bash-3.2$ markus transform --from markdown_cicero --to data --template grammar.tem.md --model model.cto --input sample.md --plugin plugin.js
12:40:37 PM - info:
{
"$class": "org.test.MyClause",
"seller": "Steve",
"buyer": "Betty",
"amount": 3131,
"friend": {
"$class": "org.test.Person",
"firstName": "Steve",
"lastName": "Doe"
},
"currency": "EUR",
"forceMajeure": false,
"clauseId": "f9b574c6-f463-46e9-8deb-78a7a826187d"
}
📜 CiceroMark to PDF Transformation
A new transform has been added to convert a CiceroMark DOM to a PDF document, using pdfmake
(which itself uses pdfkit
). The options for the transformation provide fine-grained control over PDF document metadata, page settings such as page size, margins, orientation, headers, footers, fonts and styles.
🧺 Other improvements
- The
markus
command line includes a--via
option which can be used to specify intermediate formats during a transform. - Improved formatting for monetary amounts, which now handle arbitrary numbers of digits after the decimal point (or no digits after the decimal point)
- Better whitespace handling in the HTML transfor
🐛 Issues and Bug Fixes
This release also addresses the following issues:
Markdown Transform v0.11.3
🐛 This is a bug fix release, addressing issues with empty markdown headings. (#224).
Markdown Transform v0.11.2
This is a release focused on incremental improvements for Slate 0.57.
📝 Slate
- Avoid sharing empty text nodes, breaking React rendering through Slate.
Markdown Transform v0.11.1
This is a release focused on incremental improvements for Slate 0.57.
📝 Slate
- adjusts the Slate DOM so it complies with Slate requirements to always surround inlines with text nodes
- clones the input JSON when transforming from Slate DOM since it could be immutable
Markdown Transform v0.11.0
🚀 This is a major release with two exciting new features: a new package @accordproject/markdown-transform
which helps compose available transforms together and support for the latest version of Slate.
📝 Slate 0.57
- This version of the Markdown Transform introduces support for the latest version of Slate! Slate has undergone major changes recently, notably including a new document object model. For more details about the latest version of Slate please consult the Slate website.
*Warning: Slate 0.47 or earlier is no longer supported
🧙Transform Composition
- A new package
@accordproject/markdown-transform
is available to simply create transformations from any supported input to any supported output. It finds paths available within the transform graph for you so you don't have to build them by hand! It also includes a fully revised and simplified command line which takes advantage of this new capability. (contribution by @dselman with support code by @jeromesimeon)
💻 CLI
- A new command line interface takes advantage of the ability to easily compose transforms.
markus transform
transform between two formats
Options:
--version Show version number [boolean]
--verbose, -v verbose output [boolean] [default: false]
--help Show help [boolean]
--input path to the input [string]
--from source format [string] [default: "markdown"]
--to target format [string] [default: "commonmark"]
--output path to the output file [string]
--roundtrip roundtrip transform [boolean] [default: false]
🐛 Bug fixes
- Addresses issues when transforming markdown emphasis and bold annotations to Slate DOM (#215)
Markdown Transform v0.10.4
This release adds support for new drafting options, including the ability to remove quotes on CiceroMark variables, and fixes a critical bug for variables with a formatting option.
📜 Drafting
You can now use the --noQuote
option on the draft
and normalize
commands. This option will remove quoting around string variables and computed variables. For instance:
bash-3.2$ ../markdown-cli/index.js normalize --sample test/data/demandforecast.md --cicero
11:38:51 AM - info:
On or before the <variable id="effectiveDate" value="2018%2F04%2F02" format="YYYY%2FMM%2FDD"/>, and thereafter on or before the last day of each calendar quarter, the Purchaser <variable id="purchaser" value="%22PETER%22"/> shall send the Supplier <variable id="supplier" value="%22DAN%22"/> a Supply Forecast. The Supply Forecast will be a binding commitment on the Purchaser’s behalf to purchase during the first quarter included in each Supply Forecast at least <variable id="minimumPercentage" value="85.0"/>% of the quantity of the listed Product.
bash-3.2$ ../markdown-cli/index.js normalize --sample test/data/demandforecast.md --cicero --noQuote
11:38:56 AM - info:
On or before the 2018/04/02, and thereafter on or before the last day of each calendar quarter, the Purchaser PETER shall send the Supplier DAN a Supply Forecast. The Supply Forecast will be a binding commitment on the Purchaser’s behalf to purchase during the first quarter included in each Supply Forecast at least 85.0% of the quantity of the listed Product.
🐛 Bug fixes
- #210 CiceroMark variables with a format option (e.g.,
{{effectiveDate as "YYYY/MM/DD"}}
) are now handled properly through the transform.
Markdown Transform v0.10.3
📜 #195 This release features a new option that can be passed to the CiceroMarkTransformer to remove all formatting nodes (including inside clauses) when converting from CiceroMark to CommonMark (@dselman).
Usage
ciceroMarkTransformer.toCommonMark(json, 'json', { removeFormatting: true });
This feature is based on a new CommonMark to CommonMark transform available as a new API call: CommonMarkTransformer.removeFormatting in the @accordproject/markdown-common package.
Markdown Transform v0.10.2
📜 This release features a brand new --plainText
option for the markdown transform, which can be used to strip rich text annotations and generate plain text when using the draft
or normalize
command.
This feature is based on a new CommonMark to CommonMark transform available as a new API call: CommonMarkTransformer.removeFormatting
in the @accordproject/markdown-common
package.