-
Notifications
You must be signed in to change notification settings - Fork 66
Accept callback for formatting tokens #170
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
Conversation
This feature enables a superset of the use cases addressed by the |
Added a formatToken option to compile, getWayName, and tokenize that gives the client an opportunity to manipulate a road name or other token value after any transformations built into this library but before the value is inserted into the overall instruction string.
return that.grammarize(language, name, grammar); | ||
} | ||
var startedWithToken = false; | ||
var output = instruction.replace(/\{(\w+)(?::(\w+))?\}/g, function(token, tag, grammar, offset) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, non-capturing group 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@1ec5 - I think this is a big step up on tokenizedInstruction
and I agree we should drop that.
Lets merge and roll.
7903e28 removes |
…ize` that allows you to manipulate any token value after any grammar or capitalization rules are applied but before the value is inserted into the instruction. [#170](#170) - Removed the `options` parameter to this module, including the `tokenizedInstruction` hook. Use the `formatToken` option instead. [#170](#170) - Added `namedistance` option to the depart instructions and added tests for `namedistance` in depart and continue instructions. Some typo fixes. [#177](#177 (comment))
Added a
formatToken
option tocompile
,getWayName
, andtokenize
that gives the client an opportunity to manipulate a road name or other token value after any transformations built into this library but before the value is inserted into the overall instruction string. This feature is based on a similar feature built into the Swift version of this library.Serving suggestion:
Fixes #52.
/cc @mcwhittemore @allierowan @bsudekum