Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insert em-dashes when there are three hyphens #748

Open
mathisonian opened this issue Oct 1, 2021 · 2 comments
Open

Insert em-dashes when there are three hyphens #748

mathisonian opened this issue Oct 1, 2021 · 2 comments

Comments

@mathisonian
Copy link
Member

mathisonian commented Oct 1, 2021

Is your feature request related to a problem? Please describe.
It is common for CMSs to automatically replace three hyphens (e.g. ---) with an em-dash ().

Describe the solution you'd like
Similar to how Idyll will automatically insert smart quotes, it should also convert hyphens to em-dashes, possibly with an option for users to opt-in/out of this behavior.

This logic should be added to the compiler in the same spot the smartquote logic currently exists (https://github.com/idyll-lang/idyll/blob/master/packages/idyll-compiler/src/processors/post.js#L26-L32).

This can be added via a compiler plugin. It should be added to the list of default plugins; the smartquote plugin would be a good starting point to copy, as that also modifies an article's text.

@mathisonian mathisonian changed the title Insert em-dashes when there are three hyphns Insert em-dashes when there are three hyphens Mar 22, 2022
@jimidle
Copy link

jimidle commented Jul 9, 2022

I was going to have a go at this Matthew, but it seems that post.js is no longer in existence. I will read through the source of the compiler and see if I can make sense of the change logs etc. But if you have time to update the information about this issue, then it may make things a little quicker.

It looks like you moved to a set of plugins in the compiler, and so seemingly the correct way to this, would also be via a plugin?

@mathisonian
Copy link
Member Author

Thanks @jimidle! Yes - implementing this via a plugin makes sense, I just edited the issue to reflect the recent changes

jimidle pushed a commit to gatherstars-com/idyll that referenced this issue Jul 11, 2022
  - Any text that is not part of a RAW AST node converts 3 --- to em dash
  - Any text that is not part of a RAW AST node converts 2 -- to en dash
mathisonian added a commit that referenced this issue Jul 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants