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

Skip to content

Commit 4254363

Browse files
committed
&do_cmd_rfc: New function. Handles \rfc{}.
$STRIP_INDEX_TT: New flag. If set, the <tt>...</tt> around stuff in the index is dropped. This is more O'Reilly-like. &make_str_index_entry: Honor $STRIP_INDEX_TT. &make_mod_index_entry: Honor $STRIP_INDEX_TT.
1 parent 526467c commit 4254363

1 file changed

Lines changed: 41 additions & 7 deletions

File tree

Doc/myformat.perl

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@ sub do_cmd_manpage{
7272
$_;
7373
}
7474

75+
sub do_cmd_rfc{
76+
local($_) = @_;
77+
s/$next_pair_pr_rx//;
78+
local($br_id,$rfcnumber) = ($1, $2);
79+
80+
# Save the reference
81+
local($nstr) = &gen_index_id("RFC!RFC $rfcnumber", '');
82+
$index{$nstr} .= &make_half_href("$CURRENT_FILE#$br_id");
83+
"<a name=\"$br_id\">RFC $rfcnumber<\/a>" .$_;
84+
}
85+
7586
sub do_cmd_kbd{
7687
local($_) = @_;
7788
s/$any_next_pair_pr_rx/<kbd>\2<\/kbd>/;
@@ -112,6 +123,15 @@ sub do_cmd_strong{
112123

113124
# index commands
114125

126+
$INDEX_SUBITEM = "";
127+
128+
sub do_cmd_setindexsubitem{
129+
local($_) = @_;
130+
s/$any_next_pair_pr_rx//;
131+
$INDEX_SUBITEM = $2;
132+
$_;
133+
}
134+
115135
sub do_cmd_indexii{
116136
local($_) = @_;
117137
s/$next_pair_pr_rx//o;
@@ -177,6 +197,15 @@ sub my_parword_index_helper{
177197
&make_index_entry($br_id, "$str ($word)") . $_;
178198
}
179199

200+
201+
# Set this to true to strip out the <tt>...</tt> from index entries;
202+
# this is analogous to using the second definition of \idxcode{} from
203+
# myformat.sty.
204+
#
205+
# It is used from &make_mod_index_entry() and &make_str_index_entry().
206+
#
207+
$STRIP_INDEX_TT = 0;
208+
180209
sub make_mod_index_entry {
181210
local($br_id,$str,$define) = @_;
182211
local($halfref) = &make_half_href("$CURRENT_FILE#$br_id");
@@ -189,6 +218,9 @@ sub make_mod_index_entry {
189218
$Modules{$nstr} .= $halfref;
190219
}
191220
$str = &gen_index_id($str, $define);
221+
if ($STRIP_INDEX_TT) {
222+
$str =~ s/<tt>(.*)<\/tt>/\1/;
223+
}
192224
$index{$str} .= $halfref;
193225
"<a name=\"$br_id\">$anchor_invisible_mark<\/a>";
194226
}
@@ -204,7 +236,6 @@ sub my_module_index_helper{
204236
sub do_cmd_bifuncindex{ &my_parword_index_helper('built-in function', @_); }
205237
sub do_cmd_bimodindex{ &my_module_index_helper('built-in', @_, 'DEF'); }
206238
sub do_cmd_stmodindex{ &my_module_index_helper('standard', @_, 'DEF'); }
207-
sub do_cmd_bifuncindex{ &my_parword_index_helper('standard module', @_); }
208239

209240
sub do_cmd_refbimodindex{ &my_module_index_helper('built-in', @_, 'REF'); }
210241
sub do_cmd_refstmodindex{ &my_module_index_helper('standard', @_, 'REF'); }
@@ -244,6 +275,9 @@ sub make_str_index_entry {
244275
$TITLE = $ref_before unless $TITLE;
245276
# Save the reference
246277
local($nstr) = &gen_index_id($str, '');
278+
if ($STRIP_INDEX_TT) {
279+
$nstr =~ s/<tt>(.*)<\/tt>/\1/;
280+
}
247281
$index{$nstr} .= &make_half_href("$CURRENT_FILE#$br_id");
248282
"<a name=\"$br_id\">$str<\/a>";
249283
}
@@ -258,7 +292,7 @@ sub do_env_cfuncdesc{
258292
$function_name = "$4";
259293
$arg_list = "$6";
260294
$idx = &make_str_index_entry($3,
261-
"<tt>$function_name</tt>" . &get_indexsubitem);
295+
"<tt>$function_name()</tt>" . &get_indexsubitem);
262296
}
263297
"<dl><dt>$return_type <b>$idx</b>" .
264298
"(<var>$arg_list</var>)\n<dd>$'\n</dl>"
@@ -298,7 +332,7 @@ sub do_env_funcdesc{
298332
$function_name = "$2";
299333
$arg_list = "$4";
300334
$idx = &make_str_index_entry($3,
301-
"<tt>$function_name</tt>" . &get_indexsubitem);
335+
"<tt>$function_name()</tt>" . &get_indexsubitem);
302336
}
303337
"<dl><dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>$'\n</dl>";
304338
}
@@ -309,7 +343,7 @@ sub do_cmd_funcline{
309343

310344
s/$funcdesc_rx//o;
311345
local($br_id, $function_name, $arg_list) = ($3, $2, $4);
312-
local($idx) = &make_str_index_entry($br_id, "<tt>$function_name</tt>");
346+
local($idx) = &make_str_index_entry($br_id, "<tt>$function_name()</tt>");
313347

314348
"<dt><b>$idx</b> (<var>$arg_list</var>)\n<dd>" . $_;
315349
}
@@ -321,9 +355,9 @@ sub do_env_opcodedesc{
321355
if (/$opcodedesc_rx/o) {
322356
$opcode_name = "$2";
323357
$arg_list = "$4";
324-
$idx = &make_str_index_entry($3,
325-
"<tt>$opcode_name</tt> (byte code instruction)");
326-
$idx =~ s/ \(byte code instruction\)//;
358+
# $idx = &make_str_index_entry($3,
359+
# "<tt>$opcode_name</tt> (byte code instruction)");
360+
# $idx =~ s/ \(byte code instruction\)//;
327361
}
328362
$stuff = "<dl><dt><b>$idx</b>";
329363
if ($arg_list) {

0 commit comments

Comments
 (0)