ponzu-cms / ponzu

Headless CMS with automatic JSON API. Featuring auto-HTTPS from Let's Encrypt, HTTP/2 Server Push, and flexible server framework written in Go.
https://docs.ponzu-cms.org
BSD 3-Clause "New" or "Revised" License
5.68k stars 387 forks source link

em dash (—) and en dash (–) are replaced by hyphen (-) in the richtext editor after save. #271

Closed sangeetk closed 5 years ago

sangeetk commented 6 years ago

Hi,

I am finding lots of difficulties in inserting em-dash character into the body section of a blog which uses richtext editor. Both em dash and en dash characters are replaced by hyphen character after save. I think there is some function (either Go or JS) that does this conversion, which I couldn't find it out. Any help is highly appreciated.

Thanks, Sangeet

nilslice commented 6 years ago

Hi,

Would you take a look at: https://github.com/ponzu-cms/ponzu/blob/52226ad2351dd2d3bd4191c1d9cb7cc43939a8d7/system/item/item.go#L316

It may contain the conversion you mention. We use this mainly to keep the slug URL-friendly.

sangeetk commented 6 years ago

Hi nilslice,

I understand and it makes perfect sense to replace these characters while generating the slug, but for me they are even replaced from the other fields of the content that uses richtext editor, for eg the body section of a blog. Is there any other similar function that is called for user-defined fields ?

Regards, Sangeet

nanohard commented 6 years ago

I'll take a look tonight to see if I can find out.

nilslice commented 6 years ago

@nanohard @sangeetk - while we're looking at this, if anyone would like to, we could benefit from a PR that makes the calls to MustCompile once in an init func within this file and then appends a slice of the regex's returned for the stringToSlug func to iterate through.

Currently, each MustCompile call is needlessly made each invocation.

nanohard commented 6 years ago

It's happening here: cmd/ponzu/vendor/github.com/ponzu-cms/ponzu/system/admin/static/common/js/util.js:12

Will see what happens when I remove that line; might take a few days to test and push PR.

nanohard commented 6 years ago

@sangeetk If you can remove that line and report back, even better.

nanohard commented 6 years ago

Seems to be saving and loading okay via the backend GUI. If that's enough proof, I'll PR at request. image