OSDN Git Service

Version 5.91
[vbslib/main.git] / GPL_bin_fullset / NaturalDocs / Modules / NaturalDocs / NDMarkup.pm
1 ###############################################################################
2 #
3 #   Package: NaturalDocs::NDMarkup
4 #
5 ###############################################################################
6 #
7 #   A package of support functions for dealing with <NDMarkup>.
8 #
9 #   Usage and Dependencies:
10 #
11 #       The package doesn't depend on any Natural Docs packages and is ready to use right away.
12 #
13 ###############################################################################
14
15 # This file is part of Natural Docs, which is Copyright © 2003-2010 Greg Valure
16 # Natural Docs is licensed under version 3 of the GNU Affero General Public License (AGPL)
17 # Refer to License.txt for the complete details
18
19
20 use strict;
21 use integer;
22
23 package NaturalDocs::NDMarkup;
24
25 #
26 #   Function: ConvertAmpChars
27 #
28 #   Substitutes certain characters with their <NDMarkup> amp chars.
29 #
30 #   Parameters:
31 #
32 #       text - The block of text to convert.
33 #
34 #   Returns:
35 #
36 #       The converted text block.
37 #
38 sub ConvertAmpChars #(text)
39     {
40     my ($self, $text) = @_;
41
42     $text =~ s/&/&amp;/g;
43     $text =~ s/</&lt;/g;
44     $text =~ s/>/&gt;/g;
45     $text =~ s/\"/&quot;/g;
46
47     return $text;
48     };
49
50
51 #
52 #   Function: RestoreAmpChars
53 #
54 #   Replaces <NDMarkup> amp chars with their original symbols.
55 #
56 #   Parameters:
57 #
58 #       text - The text to restore.
59 #
60 #   Returns:
61 #
62 #       The restored text.
63 #
64 sub RestoreAmpChars #(text)
65     {
66     my ($self, $text) = @_;
67
68     $text =~ s/&quot;/\"/g;
69     $text =~ s/&gt;/>/g;
70     $text =~ s/&lt;/</g;
71     $text =~ s/&amp;/&/g;
72
73     return $text;
74     };
75
76
77 1;