Mercurial > hg > octave-nkf
diff scripts/help/get_first_help_sentence.m @ 14764:461d268b10eb
get_first_help_sentence: do not capture the first newline when end of sentence is a double newline
author | Carnë Draug <carandraug+dev@gmail.com> |
---|---|
date | Mon, 11 Jun 2012 19:46:16 +0100 |
parents | 154c150f6a21 |
children | 1f1777cab828 |
line wrap: on
line diff
--- a/scripts/help/get_first_help_sentence.m +++ b/scripts/help/get_first_help_sentence.m @@ -81,9 +81,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 (followed by a non-word - ## character to support periods in numbers or words) or a double line-end. + ## character to support periods in numbers or words)... period_idx = regexp (help_text, '\.\W', "once"); - line_end_idx = regexp (help_text, "\n\n", "once"); + ## ... or a double line-end (we subtract 1 because we are not interested on + ## capturing the first newline) + line_end_idx = regexp (help_text, "\n\n", "once") -1; text = help_text (1:min ([period_idx; line_end_idx; max_len; length(help_text)])); status = 0; endfunction