-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Component Syntax #1
base: main
Are you sure you want to change the base?
Conversation
I neither love it nor hate it. For my own edification I did some googling on transclusion (which was a term I didn't know I needed in my life) for Markdown files and ran across this interesting thread which discusses various options for "including" transclusion in the commonmark spec. The discussion didn't move anywhere but there were a few proposals.
For our purposes, it may be sufficient to leverage existing markdown heuristics and recycle them as has happened with code -> blanks. Two additional options come to mind:
The above have the advantage that we get syntax highlighting for free as we do with code->blanks, bold->definitions, etc. It also potentially helps since the parser is hooking into commonmark anyway. I sketched out the options in my editor just to see what they looked like. |
@compleatang I'd note whatever CommonMark might end up, transclusion-wise, it isn't going to be exactly what we're after. Common Form components need substitution and upgrades. Do you think any of the alternatives you proposed are easier to read? FWIW, I originally implemented components in the syntax with custom HTML tags. That was far more verbose, and looked far more programmer-ish. |
Fair point on what components give us within the CF context. I was simply using that as a jumping off point. For me there is no clear winner which is likely indicative that this is new territory. I think that the syntax highlighting on the replacements is nicer than that whole string being interpreted by highlighters. Which is a long way to say ++ for Option 1 from me. |
HTML tags would be quite precise and perhaps easier on the parsing to the detriment of an easy on ramp. To enhance readability it shouldn't be too hard to enhance the additional components features in a syntax highlighter if we assume:
|
Note: Most Web platforms that render Markdown/CommonMark drop custom HTML tags. They disappear: https://github.com/commonform/commonform-commonmark/blob/f5eaaab3503c84c747c9c8359ab6ce6d33438794/test/examples/parse/valid/component.md |
@compleatang and @anseljh: This PR adds a syntax for reusable contract components to type.commonform.org. I've quoted the examples from the patch below. I already have a parser for this syntax in commonform-commonmark. It should be even easier to stringify.
Simple
With Substitutions