[ANN] Updated code -- Change Case to Title Case

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[ANN] Updated code -- Change Case to Title Case

Paul E. Merrell, J.D.
Hi, All,

I have updated Duncan Cross's code for converting an English string to
title case, adapted it for use in NoteCase Pro, and posted it online.
[1]

Although the script now makes some calls to the NoteCase Pro API, the
names of those calls are sufficiently Hungarian that you will likely
have no problems adapting it to your particular need.

The adapted script:

* Fixes a bug in Duncan's original code that was a showstopper in Lua
5.2 and 5.3;

* Works around another bug in that code by converting the string to
all lower case before converting to Title Case (didn't work on string
of all upper case characters).

* Expands the list of words that should not be capitalized.

The script has a dependency, the pure Lua utf8 library by Xavier Wang,
namespaced as "utf8ex"). [2] If you're not dealing with utf8 input you
can probably switch calls to that library, ("utf8ex.") with calls to
the equivalent Lua string library ("string.").

The code has been in heavy use for over 6 months without any new
issues emerging.

My modifications to Duncan's code are deeded to the public domain.

I decided to post and announce this because: [i] I haven't found a way
to contact Duncan Cross to offer him my revisions; [i] debugging the
original code took quite a bit of work and other code weaknesses
remain; [ii] I put quite a bit of research and refinement into the
expanded list of words that should be lower-cased; and [iii] I want to
save others the work I put in on it; and [iv] perhaps someone wiser
than me can fix the above-mentioned bug and/or otherwise improve upon
what I've done.

Best regards,

Paul E. Merrell

[1] <https://gist.github.com/Marbux/184ed6c310739460c8c040056d7b08ce>

[2] <https://github.com/starwing/luautf8>

--
[Notice not included in the above original message:  The U.S. National
Security Agency neither confirms nor denies that it intercepted this
message.]

Reply | Threaded
Open this post in threaded view
|

Re: [ANN] Updated code -- Change Case to Title Case

Paul E. Merrell, J.D.
On Thu, Apr 13, 2017 at 10:40 PM, Paul Merrell <[hidden email]> wrote:

> Hi, All,
>
> I have updated Duncan Cross's code for converting an English string to
> title case, adapted it for use in NoteCase Pro, and posted it online.
> [1]
>
> Although the script now makes some calls to the NoteCase Pro API, the
> names of those calls are sufficiently Hungarian that you will likely
> have no problems adapting it to your particular need.
>
> The adapted script:
>
> * Fixes a bug in Duncan's original code that was a showstopper in Lua
> 5.2 and 5.3;
>
> * Works around another bug in that code by converting the string to
> all lower case before converting to Title Case (didn't work on string
> of all upper case characters).
>
> * Expands the list of words that should not be capitalized.
>
> The script has a dependency, the pure Lua utf8 library by Xavier Wang,
> namespaced as "utf8ex"). [2] If you're not dealing with utf8 input you
> can probably switch calls to that library, ("utf8ex.") with calls to
> the equivalent Lua string library ("string.").
>
> The code has been in heavy use for over 6 months without any new
> issues emerging.
>
> My modifications to Duncan's code are deeded to the public domain.
>
> I decided to post and announce this because: [i] I haven't found a way
> to contact Duncan Cross to offer him my revisions; [i] debugging the
> original code took quite a bit of work and other code weaknesses
> remain; [ii] I put quite a bit of research and refinement into the
> expanded list of words that should be lower-cased; and [iii] I want to
> save others the work I put in on it; and [iv] perhaps someone wiser
> than me can fix the above-mentioned bug and/or otherwise improve upon
> what I've done.
>
> Best regards,
>
> Paul E. Merrell
>
> [1] <https://gist.github.com/Marbux/184ed6c310739460c8c040056d7b08ce>
>
> [2] <https://github.com/starwing/luautf8>

Hi, all,

The problem with my gists not being public has been fixed. GitHub
support says it's because there SPAM robots get a bit greedy at times.
You can now access the script at
<https://gist.github.com/Marbux/184ed6c310739460c8c040056d7b08ce>.

Best regards,

Paul


--
[Notice not included in the above original message:  The U.S. National
Security Agency neither confirms nor denies that it intercepted this
message.]