util_make_href_and_mailto_links_and_convert_to_html textWhat it does:
util_make_href_and_mailto_links interferes badly with util_convert_to_html. That's why I had to write a special procedure that does both things correctly. See those two procs for details.Defined in: /web/philip/packages/acs-core/utilities-procs.tcl
Source code:
set text " $text"
# if something is " http://" or " https://"
# we assume it is a link to an outside source.
# (bd) The only purpose of thiese sTaRtUrL and
# eNdUrL markers is to get rid of trailing dots,
# commas and things like that. Note that there
# is a TAB before and after each marker.
regsub -nocase -all {([^a-zA-Z0-9]+)(http://[^\(\)"<>
]+)} $text {\1 sTaRtUrL\2eNdUrL } text
regsub -nocase -all {([^a-zA-Z0-9]+)(https://[^\(\)"<>
]+)} $text {\1 sTaRtUrL\2eNdUrL } text
regsub -nocase -all {([^a-zA-Z0-9]+)(ftp://[^\(\)"<>
]+)} $text {\1 sTaRtUrL\2eNdUrL } text
# email links have the form xxx@xxx.xxx
regsub -nocase -all {([^a-zA-Z0-9]+)([^\(\)
:;,@<>]+@[^\(\)
.:;,@<>]+[.][^\(\)
:;,@<>]+)} $text {\1 sTaRtEmAiL\2eNdEmAiL } text
# At this point, before inserting some of our own <, >, and "'s
# we quote the ones entered by the user:
set text [util_quotehtml $text]
# turn CRLFCRLF into <P>
if { [regsub -all "\015\012\015\012" $text "<p>" text] == 0 } {
# try LFLF
if { [regsub -all "\012\012" $text "<p><p>" text] == 0 } {
# try CRCR
regsub -all "\015\015" $text "<p><p>" text
}
}
# turn CRLF into <BR>
if { [regsub -all "\015\012" $text "<br>" text] == 0 } {
# try LF
if { [regsub -all "\012" $text "<br>" text] == 0 } {
# try CR
regsub -all "\015" $text "<br>" text
}
}
# Dress the links and emails with A HREF
regsub -all {([]!?.:;,<>\(\)\}-]+)(eNdUrL )} $text {\2\1} text
regsub -all {([]!?.:;,<>\(\)\}-]+)(eNdEmAiL )} $text {\2\1} text
regsub -all { sTaRtUrL([^ ]*)eNdUrL } $text {<a href="\1">\1</a>} text
regsub -all { sTaRtEmAiL([^ ]*)eNdEmAiL } $text {<a href="mailto:\1">\1</a>} text
return [string trimleft $text]