Overriding removal of surrounding spaces for em dashes (with smart-dashes) #235

Closed
opened 4 years ago by larsmaxfield · 3 comments
larsmaxfield commented 4 years ago (Migrated from github.com)

My house style has spaces surrounding em dashes. Dash politics aside, I'm looking to override the removal of surrounding spaces for em dashes with smart-dashes. (Don't worry — I still keep en dashes space-free.)

I've tried directly using actual em dashes in the source file (instead of ---), but the spaces I place around them are still removed. (And though I've been successful for two years with a hotkey to insert em dashes, my limited Spidey sense says using an actual em dash character in the source file could lead to an issue in the future.)

Issue #138 shows how smart-quotes can be updated to override quotation behavior, but I haven't been able to derive a solution for my issue with smart-dashes. Is there a similar approach that I can take to get those spaces removed?

(I'm finally letting go of the drag-and-drop days of Google Sites and making the leap to coding my own site with Pollen. Your tutorials are not only educational, they're funny. I appreciate that.)

My house style has spaces surrounding em dashes. Dash politics aside, I'm looking to override the removal of surrounding spaces for em dashes with `smart-dashes`. (Don't worry — I still keep en dashes space-free.) I've tried directly using actual em dashes in the source file (instead of `---`), but the spaces I place around them are still removed. (And though I've been successful for two years with a hotkey to insert em dashes, my limited Spidey sense says using an actual em dash character in the source file could lead to an issue in the future.) Issue #138 shows how `smart-quotes` can be updated to override quotation behavior, but I haven't been able to derive a solution for my issue with `smart-dashes`. Is there a similar approach that I can take to get those spaces removed? (I'm finally letting go of the drag-and-drop days of Google Sites and making the leap to coding my own site with Pollen. Your tutorials are not only educational, they're funny. I appreciate that.)
otherjoel commented 4 years ago (Migrated from github.com)

You can’t really “extend” smart-dashes in the same way since it doesn't take any arguments other than the string itself.

But the source for smart-dashes is available here in the repo and isn’t too complicated, so you could just copy/paste it into your own project and customize it how you want it!


By the way, for what it’s worth, after twenty years of having to port markup between CMSs and document processors and each of them handling this kind of thing differently, I absolutely do advocate using the actual em dash in the source. I put the following bullet point in the style guide whenever I have can:

  • Em- and en-dashes, “smart” quotes and apostrophes, emoji, and math symbols should be stored as such in the original text source. Do not rely on smartypants-style text processing at any step after writing to produce typographically correct punctuation.

I have never experienced any downside to this approach, and can’t envision any in a world where everything understands UTF-8!

You can’t really “extend” `smart-dashes` in the same way since it doesn't take any arguments other than the string itself. But the source for `smart-dashes` is [available here in the repo][1] and isn’t *too* complicated, so you could just copy/paste it into your own project and customize it how you want it! --- By the way, for what it’s worth, after twenty years of having to port markup between CMSs and document processors and each of them handling this kind of thing differently, I absolutely do advocate using the actual em dash in the source. I put the following bullet point in the style guide whenever I have can: > * Em- and en-dashes, “smart” quotes and apostrophes, emoji, and math symbols should be stored as such in the original text source. Do not rely on smartypants-style text processing at any step after writing to produce typographically correct punctuation. I have never experienced any downside to this approach, and can’t envision any in a world where everything understands UTF-8! [1]: https://github.com/mbutterick/pollen/blob/bd154d2a2dc1612b7ce3a7e535247cbfe118d4cd/pollen/unstable/typography.rkt#L15-L28
larsmaxfield commented 4 years ago (Migrated from github.com)

Great solution! And thank you for the advice on directly using dashes and characters in the source. Another best-practice in my toolkit 👍

Great solution! And thank you for the advice on directly using dashes and characters in the source. Another best-practice in my toolkit 👍
mbutterick commented 4 years ago (Migrated from github.com)

I’m open to smart-dashes getting a new keyword argument (e.g., #:surrounding-spaces) that accepts a boolean value to alter the default behavior. Leaving aside the programming details, some thought would be required — I am not volunteering to do it — to specify what this should do in the presence of no spaces (add one? or leave it alone?) or multiple spaces (collapse to one? or leave it alone?) and weird edge cases like em dash followed by punctuation (gets a surrounding space? or not?) And of course, the keyword should be optional, and not change any of the current default behavior.

I’m open to `smart-dashes` getting a new keyword argument (e.g., `#:surrounding-spaces`) that accepts a boolean value to alter the default behavior. Leaving aside the programming details, some thought would be required — I am not volunteering to do it — to specify what this should do in the presence of no spaces (add one? or leave it alone?) or multiple spaces (collapse to one? or leave it alone?) and weird edge cases like em dash followed by punctuation (gets a surrounding space? or not?) And of course, the keyword should be optional, and not change any of the current default behavior.
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mbutterick/pollen#235
Loading…
There is no content yet.