Mercurial > hg > octave-lyh
changeset 14763:154c150f6a21
get_first_help_sentence: use period followed by non-word character to indentify end of sentence
author | Carnë Draug <carandraug+dev@gmail.com> |
---|---|
date | Mon, 11 Jun 2012 18:25:14 +0100 |
parents | 8d3ab19f8599 |
children | 461d268b10eb |
files | scripts/help/get_first_help_sentence.m |
diffstat | 1 files changed, 5 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/help/get_first_help_sentence.m +++ b/scripts/help/get_first_help_sentence.m @@ -80,10 +80,11 @@ ## This function extracts the first sentence from a plain text help text function [text, status] = first_sentence_plain_text (help_text, max_len) - ## Extract first line by searching for a period or a double line-end. - period_idx = find (help_text == '.', 1); - line_end_idx = strfind (help_text, "\n\n"); - text = help_text (1:min ([period_idx(:); line_end_idx(:); max_len; length(help_text)])); + ## Extract first line by searching for a period (followed by a non-word + ## character to support periods in numbers or words) or a double line-end. + period_idx = regexp (help_text, '\.\W', "once"); + line_end_idx = regexp (help_text, "\n\n", "once"); + text = help_text (1:min ([period_idx; line_end_idx; max_len; length(help_text)])); status = 0; endfunction