Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Smart quotes in an OpenType feature file.
# smart-quotes.
# quotes surrounded by spaces, just leave alone.
ignore sub space quotedbl' space;
# quotes after numers, assume are primes.
ignore sub [ one two three four five six seven eight nine zero ] quotedbl';
# quotes after opening characters are open-quotes.
sub [space
equal
less
parenleft parenleft.u
bracketleft bracketleft.u
braceleft braceleft.u
guillemotleft guillemotleft.u
guilsinglleft guilsinglleft.u
quotedblleft quoteleft quotesingle quotedbl] quotedbl' @All by quotedblleft;
# other quotes in the middle of the line are closing quotes.
sub @All quotedbl' by quotedblright;
# quotes at the start of the line are opening.
sub quotedbl' @All by quotedblleft;
# smart-quotes.
# quotes surrounded by spaces, just leave alone.
ignore sub space quotesingle' space;
# quotes after numers, assume are primes.
ignore sub [ one two three four five six seven eight nine zero ] quotesingle';
# quotes after opening characters are open-quotes.
sub [space
equal
less
parenleft parenleft.u
bracketleft bracketleft.u
braceleft braceleft.u
guillemotleft guillemotleft.u
guilsinglleft guilsinglleft.u
quotedblleft quoteleft quotesingle quotedbl] quotesingle' @All by quoteleft;
# other quotes in the middle of the line are closing quotes.
sub @All quotesingle' by quoteright;
# quotes at the start of the line are opening.
sub quotesingle' @All by quoteleft;
# replace exatly two hyphens by an em-dash, more are left as is.
ignore sub hyphen' hyphen' hyphen;
ignore sub hyphen hyphen' hyphen';
sub hyphen' hyphen' by emdash;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment