Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6ca3377

Browse files
committed
Add a new environment for whole-paragraph (or longer) notes & warnings.
1 parent 615e250 commit 6ca3377

3 files changed

Lines changed: 47 additions & 4 deletions

File tree

Doc/doc/doc.tex

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,25 @@ \section{Special Markup Constructs \label{special-constructs}}
10101010
\end{macrodesc}
10111011

10121012

1013+
\subsection{Miscellaneous Text Markup \label{misc-text-markup}}
1014+
1015+
In addition to the inline markup, some additional ``block'' markup
1016+
is defined to make it easier to bring attention to various bits of
1017+
text. The markup described here serves this purpose, and is
1018+
intended to be used when marking one or more paragraphs or other
1019+
block constructs (such as \env{verbatim} environments).
1020+
1021+
\begin{envdesc}{notice}{\op{type}}
1022+
Label some paragraphs as being worthy of additional attention from
1023+
the reader. What sort of attention is warrented can be indicated
1024+
by specifying the \var{type} of the notice. The only values
1025+
defined for \var{type} are \code{note} and \code{warning}; these
1026+
are equivalent in intent to the inline markup of the same name.
1027+
If \var{type} is omitted, \code{note} is used. Additional values
1028+
may be defined in the future.
1029+
\end{envdesc}
1030+
1031+
10131032
\subsection{Module-specific Markup \label{module-markup}}
10141033

10151034
The markup described in this section is used to provide information

Doc/perl/python.perl

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,17 +236,36 @@ sub do_cmd_textbf{
236236
return use_wrappers(@_[0], '<b>', '</b>'); }
237237
sub do_cmd_textit{
238238
return use_wrappers(@_[0], '<i>', '</i>'); }
239+
# This can be changed/overridden for translations:
240+
%NoticeNames = ('note' => 'Note:',
241+
'warning' => 'Warning:',
242+
);
243+
239244
sub do_cmd_note{
245+
my $label = $NoticeNames{'note'};
240246
return use_wrappers(
241247
@_[0],
242-
"<span class=\"note\"><b class=\"label\">Note:</b>\n",
248+
"<span class=\"note\"><b class=\"label\">$label</b>\n",
243249
'</span>'); }
244250
sub do_cmd_warning{
251+
my $label = $NoticeNames{'warning'};
245252
return use_wrappers(
246253
@_[0],
247-
"<span class=\"warning\"><b class=\"label\">Warning:</b>\n",
254+
"<span class=\"warning\"><b class=\"label\">$label</b>\n",
248255
'</span>'); }
249256

257+
sub do_env_notice{
258+
local($_) = @_;
259+
my $notice = next_optional_argument();
260+
if (!$notice) {
261+
$notice = 'note';
262+
}
263+
my $label = $NoticeNames{$notice};
264+
return ("<div class=\"$notice\"><b class=\"label\">$label</b>\n"
265+
. $_
266+
. '</div>');
267+
}
268+
250269
sub do_cmd_moreargs{
251270
return '...' . @_[0]; }
252271
sub do_cmd_unspecified{

Doc/texinputs/python.sty

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -919,8 +919,13 @@
919919
\end{tabular}
920920
}
921921

922-
\newcommand{\note}[1]{\strong{Note:} #1}
923-
\newcommand{\warning}[1]{\strong{Warning:} #1}
922+
\newcommand{\py@noticelabel@note}{Note:}
923+
\newcommand{\py@noticelabel@warning}{Warning:}
924+
\newenvironment{notice}[1][note]{
925+
\par\strong{\csname py@noticelabel@#1\endcsname}
926+
}{}
927+
\newcommand{\note}[1]{\strong{\py@noticelabel@note} #1}
928+
\newcommand{\warning}[1]{\strong{\py@noticelabel@warning} #1}
924929

925930
% Deprecation stuff.
926931
% Should be extended to allow an index / list of deprecated stuff. But

0 commit comments

Comments
 (0)