Skip to content

Commit

Permalink
Fix makeinfo errors for comment block keywords (bug #66428)
Browse files Browse the repository at this point in the history
* __makeinfo__.m: Change regexp pattern to find text within @Seealso macro so
that it ignores escaped curly brace '\}'.  Change regexprep pattern so that
'@' is escaped to '@@' unless '@\' escape pattern is used.
  • Loading branch information
Rik committed Nov 25, 2024
1 parent 9ac06ca commit d1edd0b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions scripts/help/__makeinfo__.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,22 @@
endif
## Texinfo crashes if @end tex does not appear first on the line.
text = regexprep (text, '^ +@end tex', '@end tex', 'lineanchors');
## Replace @seealso with Octave specific @xseealso macro, and escape '@'
[s, e] = regexp (text, '@seealso{[^}]*}');
## Replace @seealso with Octave specific @xseealso macro.
## Also escape '@' to '@@' for Texinfo, unless '@\' pattern used.
[s, e] = regexp (text, '@seealso{(?:.|\\})*}');
cum_rep = 0;
for (i_match = 1:numel (s))
esc_text = strrep (text(((s(i_match)+8:e(i_match))+i_match-1)+cum_rep), '@', '@@');
esc_text = regexprep (text(((s(i_match)+8:e(i_match))+i_match-1)+cum_rep), '@(?!\\)', '@@');
text = [text(1:s(i_match)+i_match+cum_rep-1), 'xseealso', esc_text, ...
text(e(i_match)+1+i_match+cum_rep-1:end)];
cum_rep += numel (esc_text) - (e(i_match)-(s(i_match)+8)+1);
endfor

## We don't want *ref macros to clutter plain text output with "Note ..."
if (strcmp (output_type, "plain text"))
text = regexprep (text, '@ref{(?:[^}]*?),?(?:XREF)?([^,}]+)}', '$1');
text = regexprep (text, '@xref{(?:[^}]*?),?(?:XREF)?([^,}]+)}', 'See $1');
text = regexprep (text, '@pxref{(?:[^}]*?),?(?:XREF)?([^,}]+)}', 'see $1');
text = regexprep (text, '@ref{(?:[^}]*?),?(?:XREF)?([^,}]+)}', '$1');
text = regexprep (text, '@xref{(?:[^}]*?),?(?:XREF)?([^,}]+)}', 'See $1');
text = regexprep (text, '@pxref{(?:[^}]*?),?(?:XREF)?([^,}]+)}', 'see $1');
endif

file = texi_macros_file ();
Expand Down

0 comments on commit d1edd0b

Please sign in to comment.