FIXED? Discrepancy between script and menu command output

Report issues, odd behaviors or submit a detailed bug report.
Post Reply
User avatar
pjj
Posts: 1934
Joined: 13 Oct 2009 13:48
Location: Kraków, Poland

FIXED? Discrepancy between script and menu command output

Post by pjj »

Here's an exemplary text:

Code: Select all

one two
"one two"
(one two)
one-two
one_two
one+two
one,two
When I run RMC > Change Case > Capitalize command (or Edit > Format > Change Case > Capitalize), I get this:

Code: Select all

One Two
"One Two"
(One Two)
One-Two
One_two
One+Two
One,Two
However, with a Namecase function in my script I get this:

Code: Select all

One Two
"one Two"
(one Two)
One-two
One_two
One+two
One,two
I'd say the former output is almost correct -- IMO it should give One_Two. Can you please make Namecase work the way menu command does (with possible change for text with underscores)?

And to mitigate confusion, perhaps Namecase function should be renamed to Capitalize, with Namecase as an alias.
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus

User avatar
Rickard Johansson
Site Admin
Posts: 6167
Joined: 19 Jul 2006 14:29

Re: Discrepancy between script and menu command output

Post by Rickard Johansson »

Added script function "Document.Capitalize()" in next release (v14.73).

The function seems to be working correctly though. I've tested against different rules like:

* Chicago Manual of Style capitalization rules.
* NY Times style guidelines.

You can always write your own Capitalize function to use in scripts, you know :wink:

User avatar
pjj
Posts: 1934
Joined: 13 Oct 2009 13:48
Location: Kraków, Poland

Re: FIXED? Discrepancy between script and menu command output

Post by pjj »

:?

Perhaps I expressed myself not clearly enough. I didn't mean capitalization as in "title capitalization" (as covered by, among other similar style guides, Chicago Manual of Style); what I meant was converting a string to a so called title case (or proper case, cf. e.g. http://string-functions.com/case.aspx ):

Code: Select all

one two => One Two
"one two" => "One Two"
etc. This is done properly by menu command, while Namecase function does it differently. If Capitalize() is going to mimic menu command's behavior, I am happy and don't care about Namecase().
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus

User avatar
Rickard Johansson
Site Admin
Posts: 6167
Joined: 19 Jul 2006 14:29

Re: FIXED? Discrepancy between script and menu command output

Post by Rickard Johansson »

The script function "Document.Capitalize()" is the same as in the menus. There are many ways to capitalize and I might add some more to both the menus and the script engine at some point...

User avatar
pjj
Posts: 1934
Joined: 13 Oct 2009 13:48
Location: Kraków, Poland

Re: FIXED? Discrepancy between script and menu command output

Post by pjj »

Wonderful, thanks! As for the "title capitalization" (as opposed to string capitalization), I don't think it's worth it. First of all, it may be needed by editors rather than programmers; second of all, it should take into account string's language, because each one has its own rules, cf. e.g. TextInfo.ToTitleCase(String) Method. Just my 2 cc, though.
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus

Post Reply