0

Background

Developers write JIRA tickets; developers do not style the ticket items consistently. We'd like to present the ticket summaries to clients, but with a consistent format.

Problem

We're using FreeMarker Pre-Processor (fmpp), which supports title case and first letter caps, but these simple functions lose information (e.g., "BCServices" becomes "Bcservices" and "iPhone" becomes "Iphone").

Examples

There is JavaScript code that does a great job of making the summaries uniform:

This formats the following summaries as expected:

  • On iPhone the Transcript Extends Outside of Screen Frame
  • PEAR And GNA Report Performance
  • BCMailPlusFTPClient sends document without document ID
  • JWebUnit: non-PEN orders main.xhtml meta refresh tag issue

Requirements

We're looking for something that can be run from the command line (as part of a batch program) that doesn't require a huge binary. Ideally:

@echo off
headline < "On iPhone the Transcript Extends Outside of Screen Frame" > case.txt
set /P title=<case.txt

Pie-in-the-sky would allow for issuing different styles on the command line:

@echo off
headline --style=CMS < "On iPhone the Transcript Extends Outside of Screen Frame" > case.txt
set /P title=<case.txt

We're not looking for NodeJS modules, Ruby code, Go programs, Perl scripts, and similar. Plain JavaScript is okay (not ideal as it requires something like Rhino).

Question

What Java, C, DOS batch, small Windows binary, free/unlimited REST API, or Unix shell utility allows processing of sentences to be "headline case" as per standard manual styles?

Addendum

It is overkill to include a JavaScript engine (Rhino) to run a regular expression. Although the my answer works as expected (including a Java class that performs the task), alternative suggestions are welcome.

0

Rhino

Since Java was included in the requirements:

Example

Run:

java -cp rhino\lib\rhino.jar org.mozilla.javascript.tools.shell.Main ^^
-e "load( 'to-title-case.js' ); ^^
print(""BCMailPlusFTPClient sends document without document ID"".toHeadlineCase())"

Output:

BCMailPlusFTPClient Sends Document Without Document ID

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.