-
Notifications
You must be signed in to change notification settings - Fork 317
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
Yet another Brew Variables PR #3199
Conversation
How would one assign the string "https://example.com/" to a variable and then have it rendered as (literally) For an authoring system that produces print-destined output, being unable to print a url sounds like a problem. I don't want printed documents that read as "For more details, visit our website at PublisherWebsite." |
I'm a bit worried that double-interpolation might be setting us up for some recursion headaches. |
first line is just assignment, second is assignment and output, third is just output for clarification:
|
Just use The $ indicates that it should be output as a string instead of a link. |
I'm not sure what you mean by double-interpolation. Recursion would be handled by tracking a list of the variables you are currently inside and stop processing if we try to enter a nested variable already on that list. |
Interpolation is replacing variable references in a string with the value of those variables. Double interpolation is replacing variable references in a string with the value of the variable named in those variables.
(I've also worked with systems which supported stuff like |
Ah ok. This PR isn't doing any double-interpolation by that definition so that shouldn't be a concern. I dont think it's even possible the way the code is set up. Every example I listed above is "single interpolation". |
Error list:
|
Added hoisting, math, fixed several bugs
|
Should be fixed. Now has same behavior as |
Building on #3173, I think this is a pretty good syntax that does everything everyone wants.
Deployed to https://homebrewery-pr-3199.herokuapp.com/
Notes:
Three syntaxes:
[var]:content
[var](content)
[var]
Examples:
[var]: Variable Contents
var
on two
or three
or more lines
var
| h1 | h2 |
|----|----|
| c1 | c2 |
var
(and can later be rendered as a table)var
and outputs that value$[var](I love $[var2] and $[var3])
var
and outputs that value$[var]
[var]
![var]
$[var]: Variable Contents
or
![var]: Variable Contents
[var]: Variable Contents
. Links, images, and variables all share the same global list. The!
or$
prefix only matters when the variable is being expressed[var](Variable Contents)
or
![var](Variable Contents)
$[var](Variable Contents)
, but outputs as a link or image if contents are a valid link format$[num1 + num2 * (num3 - round(5.5))]
+
,-
,*
,/
,^
,(
, or)
are found in the variable name, the whole variable is parsed mathematically with correct order of operations. Only parses if every variable is defined (hoisting works), and evaluate to a number, and the expression is valid. Supportsround(x)
.Math
Math currently supports the following function names:
round()
,floor()
,ceil()
.It also allows for
()
nesting operations.So yes, you can do incrementing tables like this: