accordproject/markdown-transform

Template Signature in `ciceromark_parsed`

Opened this issue · 5 comments

Feature Request 🛍️

Currently, the ciceromark_parsed does not contain the template signature. A template signature can be incorporated into the ciceromark_parsed to uniquely identify them.

Use Case

This issue was raised with respect to #432. The major use is to uniquely identify the conversions CiceroMark<->OOXML.
<w:sdt> requires a unique id to distinguish itself. The template identifier can be used as this id.

Context

While working on #432, there occurred a need to wrap the complete OOXML in <w:sdt> and hence an id was required. Randomly generating id causes test failure so this issue was created.

Detailed Description

A field template_signature in the ciceromark_parsed

We would probably need something like this. My suggestion may be wrong because I don' clearly understand the difference between a clause and a contract.

{
  "$class": "org.accordproject.commonmark.Document",
  "identfier": "org.accordproject.acceptance-of-delivery@0.15.0",
  "xmlns": "http://commonmark.org/xml/1.0",
  "nodes": [...]
}

The src attribute on the Clause node contains the identifier for the template for the Clause:
https://github.com/accordproject/models/blob/master/src/markdown/ciceromark%400.3.1.cto#L53

If you need to generate a stable id for a clause then I suggest you compute an SHA hash of the textual content of the clause (text or JSON data as a string), including the template src (see above).

See: https://www.nodejsera.com/snippets/nodejs/sha256-hash.html

@dselman
We need the identifier for a whole template.
I will try to explain in simple words.
Let us assume that a user uses cli to transform ciceromark_parsed to OOXML. In this case, we do not have an identifier present. Currently, from the templatemark-dingus also there is no identifier present.

The src attribute on the Clause node contains the identifier for the template for the Clause:

I see that this is optional, so how is there any flag which we need to pass.

I'm not sure I understand the requirement. What's an identifier in this context? If it's something specifically needed for OOXML, then Dan's suggestion to generate a hash from (ciceromark / the data / something else) makes sense to me.