galaxykate / tracery

Tracery: a story-grammar generation library for javascript
Apache License 2.0
2.11k stars 246 forks source link

Add uppercase and lowercase modifiers #24

Closed hugovk closed 2 years ago

hugovk commented 8 years ago

There's already capitalize and capitalizeAll modifiers which produce output like "Black unicorns" and "Black Unicorns" respectively.

How about upper and lower (or uppercase/lowercase or something) to produce "BLACK UNICORNS" and "black unicorns"?

mycaule commented 6 years ago

Hello you can reuse a string libary to do most common operations:

https://www.npmjs.com/package/string https://www.npmjs.com/package/voca

Here is a sample implementation using voca.js, I just merge the modifier object with the voca object to get all the voca functions for free to use in the grammar syntax of tracery. https://github.com/mycaule/epures/tree/master/modifiers

hugovk commented 6 years ago

Thanks for the tip, that's useful for using it as a JS library!

My main reason for opening this was to be able to use it in @v21's excellent Cheap Bots, Done Quick! where end users can only enter the Tracery grammar.

See https://github.com/v21/tracery/pull/4