Open lambdafu opened 4 years ago
Hi @lambdafu I guess there are a couple of things going on there:
{{#...}} ... {{/...}}
syntax from other kind of template notations. I am assuming in your comment that you mean block from a markdown point of view? (i.e., as opposed to inlines?). We may need to review the terminology choices there.{{#clause}}
{{#ulist}}
and {{#olist}}
are markdown blocks while {{#if}}
{{#with}}and
{{% formula %}}` are markdown inlinesSo you will be able to do this:
Hello
{{#if flag}}Bye{{/if}}
But not:
Hello
{{#if flag}}
Bye
Really bye
{{/if}}
Because from a markdown perspective you really have two paragraphs.
We could possibly handle both (the same way markdown distinguishes between html inlines and html blocks).
For reference:
bash-3.2$ more test/data/testIfBlock/grammar.tem.md
Hello
{{#if flag}}Bye{{/if}}
bash-3.2$ more test/data/testIfBlock/sample.md
Hello
bash-3.2$ ../markdown-cli/index.js transform --from markdown --to data --grammar test/data/testIfBlock/grammar.tem.md --ctoFiles test/data/testIfBlock/model.cto --input test/data/testIfBlock/sample.md
10:54:53 AM - info:
{
"$class": "org.test.MyClause",
"flag": false,
"clauseId": "b9f1dc19-4ace-4ade-b6c2-81ed8ef14d30"
}
bash-3.2$ more test/data/testIfBlock/sample-true.md
Hello
Bye
bash-3.2$ ../markdown-cli/index.js transform --from markdown --to data --grammar test/data/testIfBlock/grammar.tem.md --ctoFiles test/data/testIfBlock/model.cto --input test/data/testIfBlock/sample-true.md
10:55:15 AM - info:
{
"$class": "org.test.MyClause",
"flag": true,
"clauseId": "466668b0-50a3-4289-b736-5c643ff451e5"
}
bash-3.2$
Some details about your use case would help.
Hi Jerome, thanks for your response. The terminology is confusing to me, and yes, I was interpreting block elements typographically (or at a markdown level, whatever you prefer). Thanks for the clarification. Although I appreciate the effort to create a specification that allows bidirectional parsing without being intrusive, I also have to say that I was surprised more than once. This violates a little bit the "principle of least surprise" that a good toolchain should have. On the one hand, I understand that this allows dropping some markup in the rendered result (as long as the grammar is prefix-free), but on the other hand, even that is not consistent, as the all-important string type needs double-quotes anyway. Not really sure what to recommend here, though. It's a tight design space.
As for the use case, I am working in a project that is looking at legal certainty issues surrounding smart contracts, and we are very interested in Accord and integration in Hyperledger Fabric. As part of our efforts to educate ourselves, I have given an in-depth 4h workshop on Accord and HLF integration, and during my research for the material I have poked at Accord a little bit and found these issues, and thought I would report them. We are still designing the system, so my examples are artificial and just the result from playing around with the tools. But my main concern here is usability: If non-programmers are expected to be able to draft contract grammars and data models, such weird edge cases can be a real bummer.
Thanks for working on Accord, btw!
Describe the bug The block expression
{{#if flag}}...{{/if}}
only works on a single line, and thus is not a block expression after all. :disappointed:To Reproduce Grammar:
Sample.md:
Model:
Output of cicero parse:
Expected behavior A block expression should be able to hold, uhm, blocks? What's up with that? :cat2: Also, error message is not helpful. This also seems like a bug that a fuzzer could find very quickly.