# Selima Website Content Management System # MarkAbbr.pm: The subroutine to mark the abbreviations. # Copyright (c) 2006-2018 imacat. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Author: imacat # First written: 2006-03-24 package Selima::MarkAbbr; use 5.008; use strict; use warnings; use base qw(Exporter); use vars qw(@EXPORT @EXPORT_OK); BEGIN { @EXPORT = qw(h_abbr markabbr); @EXPORT_OK = @EXPORT; # Prototype declaration sub h_abbr($); sub markabbr($); } use Selima::DataVars qw($MAIN); use Selima::ShortCut; # h_abbr: Shortcut to markabbr(h()) sub h_abbr($) { return markabbr(h($_[0])); } # markabbr: Mark the abbreviation sub markabbr($) { local ($_, %_); $_ = $_[0]; my $localext; # FAQ s/\b(FAQ)\b(?!<\/abbr>|<\/acronym>)/$1<\/abbr>/g; # HTTP s/\b(HTTP)\b(?!<\/abbr>|<\/acronym>)/$1<\/abbr>/g; # HTML s/\b(HTML)\b(?!<\/abbr>|<\/acronym>)/$1<\/abbr>/g; # CGI s/\b(CGI)\b(?!<\/abbr>|<\/acronym>)/$1<\/abbr>/g; # SSL s/\b(SSL)\b(?!<\/abbr>|<\/acronym>)/$1<\/abbr>/g; # PDF s/\b(PDF)\b(?!<\/abbr>|<\/acronym>)/$1<\/abbr>/g; # CSV s/\b(CSV)\b(?!<\/abbr>|<\/acronym>)/$1<\/abbr>/g; # IP s/\b(IP)\b(?!<\/abbr>|<\/acronym>)/$1<\/abbr>/g; # S/N s/\b(S\/N)\b(?!<\/abbr>|<\/acronym>)/$1<\/abbr>/g; # No. s/\b(No\.|Num\.)(?!<\/abbr>|<\/acronym>)/$1<\/abbr>/g; # ID. s/\bID\.(?!<\/abbr>|<\/acronym>)/$1<\/abbr>/g; # Pic. s/\bPic\.(?!<\/abbr>|<\/acronym>)/$1<\/abbr>/g; # URL. s/\b(URL\b\.?)(?!<\/abbr>|<\/acronym>)/$1<\/abbr>/g; # E-mail s/\b(E-mail)\b(?!<\/abbr>|<\/acronym>)/$1<\/acronym>/gi; # MIME s/\b(MIME\b\.?)(?!<\/abbr>|<\/acronym>)/$1<\/acronym>/g; # Perl/PHP/GNU s/\b(Perl)\b(?!<\/abbr>|<\/acronym>)/$1<\/acronym>/gi; s/\b(PHP)\b(?!<\/abbr>|<\/acronym>)/$1<\/abbr>/gi; s/\b(GNU)\b(?!<\/abbr>|<\/acronym>)/$1<\/acronym>/gi; # KB/MB/GB/TB from report_size() s/(\d+) KB\)/$1 KB<\/abbr>/g; s/(\d+) KB\)/$1 MB<\/abbr>/g; s/(\d+) KB\)/$1 GB<\/abbr>/g; s/(\d+) KB\)/$1 TB<\/abbr>/g; # Load the local extension # Load it at last to prevent mark-up recursion $_ = &$localext($_) if defined($localext = $MAIN->can("markabbr_site")); return $_; } return 1;