Overriding removal of surrounding spaces for em dashes (with smart-dashes)
#235
Closed
opened 4 years ago by larsmaxfield
·
3 comments
Loading…
Reference in New Issue
There is no content yet.
Delete Branch '%!s(<nil>)'
Deleting a branch is permanent. It CANNOT be undone. Continue?
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 withsmart-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.)
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:
I have never experienced any downside to this approach, and can’t envision any in a world where everything understands UTF-8!
Great solution! And thank you for the advice on directly using dashes and characters in the source. Another best-practice in my toolkit 👍
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.