Skip to content

Instantly share code, notes, and snippets.

@ConradIrwin
Created August 24, 2015 06:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ConradIrwin/d78c9895c0989d143a4d to your computer and use it in GitHub Desktop.
Save ConradIrwin/d78c9895c0989d143a4d to your computer and use it in GitHub Desktop.
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