Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add Component Syntax #1

wants to merge 1 commit into from

Conversation

kemitchell
Copy link
Member

@kemitchell kemitchell commented May 28, 2019

@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

# Work Made For Hire
<https://commonform.org/kemitchell/work-made-for-hire-unless-employment/1e1c>

With Substitutions

# Term	
<https://commonform.org/rxnda/term/1e> without upgrades, replacing _Confidential Information_ with _Trade Secrets_, and [Confidentiality Obligations](#Confidentiality_Obligations) with [Nondisclosure](#Nondisclosure)

@compleatang
Copy link
Member

compleatang commented May 28, 2019

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.

screenshot-40ee621e-881c-4cdd-8567-d1f6f72834da-2019 05 28-10-03-04

@kemitchell
Copy link
Member Author

@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.

@compleatang
Copy link
Member

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.

@compleatang
Copy link
Member

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:

^\<(.+)\>(.*)$ $2

@kemitchell
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants