Closed afragen closed 8 years ago
When you mention "Sometimes..." can you give examples of when they are and when they aren't?
I want to try to reproduce it on my end, too.
If you have something like the following in your post body.
### the quick brown fox jumps over the lazy dog
after processing it will be
### the Quick Brown Fox Jumps Over the Lazy Dog
This is because the toTitleCase()
strips the surrounding html tags, title cases the string and then adds the html tags back. The function is set to capitalize the first word of a sentence.
Without the modification to the regex looking for the html tags the first work looks like ### the
instead of the
. Consequently it's not capitalized.
This would occur only with markdown headers and only if the first word is one of those usually excluded for being capitalized.
Eventually, I want to create an interface
that will allow us to plug in different rulesets for locales or capitalization types. The library I'm currently using is fair but obviously leaves something to be desired.
Since it's open source, I don't mind:
That's probably the first step to what I'd like to do with the interface
in 2.0.0.
It's fairly good, efficient code but hasn't been updated in 6 years. I put in a couple of PRs back to it with my mods.
It may be more efficient to fork it and maintain it ourselves or just include it directly in the plugin. That way we can create whatever interface of filter hook into the regents.
I haven't looked to see if there's a multilingual title case repo.
So I refactored TitleCase
a bit, removed the nested ternary functions and generally made it easier to read. It should still work and now be a little easier to extend. #28
Fixed in #28
Because the title case script doesn't recognize markdown headers the first word of a header wasn't capitalized if it was one of the excluded words, ( a, the, on, and, etc)
See #24