93 lines
3.5 KiB
Perl
93 lines
3.5 KiB
Perl
# 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 <imacat@mail.imacat.idv.tw>
|
|
# 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>)/<abbr title="frequently asked questions">$1<\/abbr>/g;
|
|
# HTTP
|
|
s/\b(HTTP)\b(?!<\/abbr>|<\/acronym>)/<abbr title="HyperText Transfer Protocol">$1<\/abbr>/g;
|
|
# HTML
|
|
s/\b(HTML)\b(?!<\/abbr>|<\/acronym>)/<abbr title="HyperText Markup Language">$1<\/abbr>/g;
|
|
# CGI
|
|
s/\b(CGI)\b(?!<\/abbr>|<\/acronym>)/<abbr title="Common Gateway Interface">$1<\/abbr>/g;
|
|
# SSL
|
|
s/\b(SSL)\b(?!<\/abbr>|<\/acronym>)/<abbr title="Secure Socket Layer">$1<\/abbr>/g;
|
|
# PDF
|
|
s/\b(PDF)\b(?!<\/abbr>|<\/acronym>)/<abbr title="Portable Document Format">$1<\/abbr>/g;
|
|
# CSV
|
|
s/\b(CSV)\b(?!<\/abbr>|<\/acronym>)/<abbr title="Comma Separated Values">$1<\/abbr>/g;
|
|
# IP
|
|
s/\b(IP)\b(?!<\/abbr>|<\/acronym>)/<abbr title="Internet Protocol">$1<\/abbr>/g;
|
|
# S/N
|
|
s/\b(S\/N)\b(?!<\/abbr>|<\/acronym>)/<abbr title="serial number">$1<\/abbr>/g;
|
|
# No.
|
|
s/\b(No\.|Num\.)(?!<\/abbr>|<\/acronym>)/<abbr title="number">$1<\/abbr>/g;
|
|
# ID.
|
|
s/\bID\.(?!<\/abbr>|<\/acronym>)/<abbr title="identity">$1<\/abbr>/g;
|
|
# Pic.
|
|
s/\bPic\.(?!<\/abbr>|<\/acronym>)/<abbr title="picture">$1<\/abbr>/g;
|
|
# URL.
|
|
s/\b(URL\b\.?)(?!<\/abbr>|<\/acronym>)/<abbr title="Uniform Resource Locator">$1<\/abbr>/g;
|
|
# E-mail
|
|
s/\b(E-mail)\b(?!<\/abbr>|<\/acronym>)/<acronym title="electronic mail">$1<\/acronym>/gi;
|
|
# MIME
|
|
s/\b(MIME\b\.?)(?!<\/abbr>|<\/acronym>)/<acronym title="Multipurpose Internet Mail Extensions">$1<\/acronym>/g;
|
|
# Perl/PHP/GNU
|
|
s/\b(Perl)\b(?!<\/abbr>|<\/acronym>)/<acronym title="Practical Extraction and Reporting Language">$1<\/acronym>/gi;
|
|
s/\b(PHP)\b(?!<\/abbr>|<\/acronym>)/<abbr title="PHP: Hypertext Preprocessor">$1<\/abbr>/gi;
|
|
s/\b(GNU)\b(?!<\/abbr>|<\/acronym>)/<acronym title="GNU's Not UNIX">$1<\/acronym>/gi;
|
|
# KB/MB/GB/TB from report_size()
|
|
s/(\d+) KB\)/$1 <abbr title="kilobyte">KB<\/abbr>/g;
|
|
s/(\d+) KB\)/$1 <abbr title="megabyte">MB<\/abbr>/g;
|
|
s/(\d+) KB\)/$1 <abbr title="gigabyte">GB<\/abbr>/g;
|
|
s/(\d+) KB\)/$1 <abbr title="terabyte">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;
|