;+
; NAME:
; www_help_check
; PURPOSE:
; Check for miscellaneous links to be created in the headers
; - substrings of the form 'href=entry=' are converted to a link to 'entry'
; - email addresses are converted to mailto links
; CATEGORY:
; gen/idl
; CALLING SEQUENCE:
PRO www_help_check, header, mask, style, email, crosslinks
; INPUTS:
; header array; type: structure
; all the headers
; mask array; type: integer
; list of indices into 'header'. Only the headers on
; this list are processed
; style array[1]; type: structure
; defined in www_help, passed to www_help_check_marker
; email array; type: string
; list of email addresses to search for
; crosslinks
; OUTPUTS:
; header array; type: structure
; updated headers
; INCLUDE:
@compile_opt.pro ; On error, return to caller
; CALLS:
; www_help_check_marker, www_help_mailto
; RESTRICTIONS:
; This procedure should only make fixes to individual header line
; (in particularly, the order of the headers processed should not matter)
; PROCEDURE:
; Three types of links are created.
; 1. Entries in the 'email' list are turned into a 'mailto' hyperlink.
; 2. Strings of type 'href=entry=' are replaced by an html link.
; If the first letter of 'entry' is the same as 'letter' (case-insensitive)
; the the replacement string 'entry'
; If the first letter is not the same then the replacement string is
; 'entry' where 'file' is constructed from htm and letter:
; file = html_name_'letter'.html_type
;
; Only the first links are created in this procedure. The others are done
; by calling www_help_check_marker.
; MODIFICATION HISTORY:
; JAN-2001, Paul Hick (UCSD/CASS)
; DEC-2006, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
; Encoded email address.
;-
help, calls=this_routine
this_routine = (strtok(this_routine[0], ' ', /extract))[0]
FOR ithis=0L,n_elements(mask)-1 DO BEGIN
subject = header[mask[ithis]].name+' ('+strjoin(header[mask[ithis]].origin,' ')+')'
; This routine contains several href=entry= strings in the header,
; so we better skip it.
IF strupcase(header[mask[ithis]].name) eq this_routine THEN $
message, /info, 'skipping '+header[mask[ithis]].name $
ELSE BEGIN
nline = header[mask[ithis]].nline
lines = *header[mask[ithis]].lines
FOR iline=0L,nline-1 DO BEGIN
line = lines[iline]
; Check for 'href' markers
line = www_help_check_marker(line, 'href', style, subject, header, crosslinks)
; Convert email addresses to links
FOR i=0L,n_elements(email)-1 DO BEGIN
tmp = strpos(line, email[i])
IF tmp NE -1 THEN $
line = strmid(line,0,tmp)+ $
www_help_mailto(email[i],/href,subject='www_help, '+subject)+ $
strmid(line,tmp+strlen(email[i]))
ENDFOR
lines[iline] = line
ENDFOR
*header[mask[ithis]].lines = lines
ENDELSE
ENDFOR
RETURN & END