Do look at the notebook posted above, but for others that want a quick copy and paste of the final example code here it is:
ClearAll[modifyWords];
modifyWords[{word1_String, word2_String}, {style1_, style2_}] :=
Switch[{style1, style2},
{None, None},
{word1, word2},
{None, _},
{word1, Style[word2, style2]},
{_, None},
{Style[word1, style1], word2},
{_, _},
{Style[word1, style1], Style[word2, style2]}
];
ClearAll[PsychoSentence];
Options[PsychoSentence] = {ReplacementCharacter -> "-"};
PsychoSentence[sentence_String, {style1_, style2_},
OptionsPattern[]] :=
Module[{splitSentence, dashedTemplate, stringTable,
processedSentences, replacementCharacter},
replacementCharacter = OptionValue[ReplacementCharacter];
splitSentence = Partition[StringSplit[sentence], 2, 2, 1, ""];
dashedTemplate =
Map[StringReplace[#, _ -> replacementCharacter] &,
splitSentence, {2}];
splitSentence = modifyWords[#, {style1, style2}] & /@ splitSentence;
stringTable = Table[
Riffle[Flatten[
ReplacePart[dashedTemplate, i -> splitSentence[[i]]]],
" "], {i, Length[splitSentence]}];
processedSentences = Row /@ stringTable;
processedSentences = Riffle[processedSentences, "\n"];
CellPrint[
TextCell[Row[processedSentences], "Text", FontFamily -> "Courier",
FontSize -> 11, ShowStringCharacters -> False]]
];
PsychoSentence[sentence_String] :=
PsychoSentence[sentence, {None, None}]
And here is an example of it's use (it prints out a formatted Cell as its output):
PsychoSentence["The time has come for all good iguanas to have some kelp", {LightPurple, Green}]
