-
Notifications
You must be signed in to change notification settings - Fork 6
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
Provide method of escaping values containing lookup
identifiers
#14
Comments
I like the control character from a usability perspective. but would probably need to be added to the parser |
was poking at this a bit. The parser has the concept of modes which define a set of valid tokens that can be lexed. We do this in a round about way with the String token - anything between quotes. The simple case of an escape char would need a closing char if we wanted to use the high level API createToken({
name: 'escapestart'
, pattern: /\/-/
, push_mode: 'literal'
})
createToken({
name: 'escapestop'
, pattern: /-\//
, pop_mode: 'literal'
}) defaults = {
color: '\#cccccc\'
} At this point, its not much better than quoting it defaults = {
color: '"#cccccc"'
} The idea of a literal function is interesting, but thats an even longer way of quoting (our current literal mechanism) defaults = {
color: '!literal:#cccccc'
} class Chain {
$literal(value) {
if (value == null) return ''
return `"${value}"`
}
} Another thing to consider is where the sane logical boundaries. Can the escape character be used anywhere?
|
or rather than a parsing problem maybe its just a logical lookup problem class Chain {
lookup(value) {
if (typeOf(value) === 'string' && value.startsWith('\\')) {
return value.replace('\\', '')
}
}
} |
@esatterwhite I took a brief look at this as well, and that's sort of where I landed too The escape char is included in the tokens there, but it doesn't need to be. Moving it to strictly a |
Actually I think we could define this as a subrule.
Then the escape is a child of the lookup fn. if (fn.children[0].escape) {
return this.wrapLiteral(fn.children.slice(1))
} |
This is an edge case (and there are ways around it) but consider the following example of a value that starts with a
#
:A couple of options offhand would be:
\#foo
,\!bar
!literal("#ccc")
lookup
The text was updated successfully, but these errors were encountered: