1# -*- perl -*- 2# 3# $Id: verbatim.perl,v 1.10 2001/11/29 21:44:13 RRM Exp $ 4# verbatim.perl 5# Jens Lippmann <lippmann@rbg.informatik.tu-darmstadt.de> 17-DEC-96 6# 7# Extension to LaTeX2HTML to support the verbatim.sty LaTeX2e package. 8# 9# Change Log: 10# =========== 11# jcl = Jens Lippmann 12# 13# $Log: verbatim.perl,v $ 14# Revision 1.10 2001/11/29 21:44:13 RRM 15# -- update to use &replace_all_html_special_chars if defined 16# 17# Revision 1.9 1999/10/15 09:17:16 RRM 18# -- enable link to stylesheet "verbatim" class 19# 20# Revision 1.8 1999/09/14 22:02:02 MRO 21# 22# -- numerous cleanups, no new features 23# 24# Revision 1.7 1999/04/09 18:15:17 JCL 25# changed my e-Mail address 26# 27# Revision 1.6 1998/12/02 01:25:19 RRM 28# -- preserve styles around the use of \verbatiminput 29# -- wrap the \verbatiminput command; i.e. treat as an environment 30# 31# Revision 1.5 1998/03/22 20:52:49 latex2html 32# reviewed for 98.1, works & is testable via devel/tests/regr/verbatim/run 33# 34# Revision 1.4 1998/02/19 22:24:33 latex2html 35# th-darmstadt -> tu-darmstadt 36# 37# Revision 1.3 1996/12/23 01:33:58 JCL 38# uses now shell variable TEXINPUTS (this is set up by LaTeX2HTML before) 39# to locate the input file 40# 41# Revision 1.2 1996/12/18 04:30:32 JCL 42# was formerly verbatimfiles.perl, however, its face changed 43# quite much 44# 45# 46# Note: 47# This module provides translation for the \verbatiminput command of 48# the verbatim.sty package. 49# The comment/verbatim environments are handled by LaTeX2HTML itself. 50# 51# The naming of verbatim.sty is a bit blurred. 52# Here are the versions which are available, together with their 53# identification: 54# o dbtex verbatim.sty by Rowley/Clark 55# Provides: 56# - \verbatimfile, \verbatimlisting 57# It is also named verbatimfiles.sty, and supported by 58# verbatimfiles.perl. 59# 60# o verbatim.sty 1.4a (jtex), 1.4d (ogfuda), 1.4i (AMS LaTeX), 61# 1.5i (LaTeX2e) by Sch"opf 62# Provides: 63# - verbatim environment, comment environment, \verbatiminput 64# Supported by this Perl module. 65# 66# o FWEB verbatim.sty 67# Provides: 68# - verbatim environment, \verbfile, \listing, \sublisting 69# Currently not supported by LaTeX2HTML. 70 71package main; 72 73sub do_cmd_verbatiminput { 74 local($outer) = @_; 75 local($_,$found,$file,$file2); 76 77 $file = &missing_braces unless ( 78 ($outer =~ s/$next_pair_pr_rx/$file=$2;''/eo) 79 ||($outer =~ s/$next_pair_rx/$file=$2;''/eo)); 80 81 $file2 = "$file.tex"; 82 if ($file !~ /\.tex$/) { 83 # 2nd choice is better than 1st - TeXnical quirk 84 ($file,$file2) = ($file2,$file); 85 } 86 foreach $dir ("$texfilepath", split(/:/,$ENV{'TEXINPUTS'})) { 87 if (-f ($_ = "$dir/$file") || -f ($_ = "$dir/$file2")) { 88 $found=1; 89 #overread $_ with file contents 90 &slurp_input($_); 91 last; 92 } 93 } 94 &write_warnings("No file <$file> for verbatim input.") 95 unless $found; 96 97 local($closures,$reopens) = &preserve_open_tags; 98 # pre_process file contents 99 if (defined &replace_all_html_special_chars) { 100 &replace_all_html_special_chars; 101 } else { 102 &replace_html_special_chars; 103 } 104 s/\n$//; # vertical space is contributed by </PRE> already. 105 # %verbatim not coupled to a dbm => will not work in subprocesses, but don't mind 106 $verbatim{++$global{'verbatim_counter'}} = $_; 107 108 my ($verb_pre, $verb_post) = ('<PRE>','</PRE>'); 109 if ($USING_STYLES) { 110 $env_id .= ' CLASS="verbatim"' unless ($env_id =~ /(^|\s)CLASS\s*\=/i); 111 $verb_pre =~ s/>/ $env_id>/; 112 } 113 join('', $closures, "<BR>\n", $verb_pre 114 , $verbatim_mark, 'verbatim', $global{'verbatim_counter'} 115 , '#', $verb_post, $reopens, $outer); 116} 117 118&process_commands_wrap_deferred (<<_RAW_ARG_DEFERRED_CMDS_); 119verbatiminput # {} 120_RAW_ARG_DEFERRED_CMDS_ 121 1221; # Must be last line 123