]> granicus.if.org Git - docbook-dsssl/commitdiff
Switched to using PIs instead of comments, because osx and
authorMichael Smith <xmldoc@users.sourceforge.net>
Wed, 15 Jun 2005 09:56:37 +0000 (09:56 +0000)
committerMichael Smith <xmldoc@users.sourceforge.net>
Wed, 15 Jun 2005 09:56:37 +0000 (09:56 +0000)
sgml2xml don't preserve comments by default.

contrib/tools/cloak/cloak

index d4171f2096840c370a77ea2847ed9927d5568abf..83d4f3ddc01d6763a68d4ff47216071095e1b261 100755 (executable)
@@ -33,33 +33,33 @@ my $lines = <$handle>;
 # if the document has already been cloaked, uncloak it
 if ($lines =~ m/$comment/ || $0 =~ m/uncloak/) {
 
-    $lines =~ s/<!--$comment-->//;                      # remove comment added by cloak
-    $lines =~ s/<!--ENT_(.*?)_ENT-->/$1/g;              # uncloak all cloaked entities
-    $lines =~ s/--DOCTYPE(.*)_END_SUBSET--/DOCTYPE$1/s; # uncloak DOCTYPE, subset
+    $lines =~ s/<\?$comment \?>//;                         # remove comment added by cloak
+    $lines =~ s/<\?ENT_ (.*?)_ENT\?>/$1/g;                 # uncloak all cloaked entities
+    $lines =~ s/\?DOCTYPE(.*)_END_SUBSET\?/!DOCTYPE$1/s; # uncloak DOCTYPE, subset
 
 } else {
 
 # otherwise, cloak the document
 
-    $lines = $lines . "\n<!--" . $comment . "-->\n";
+    $lines = $lines . "\n<?" . $comment . " ?>\n";
 
-    $lines =~ s/(\w*&\w+;\w*)/<!--ENT_$1_ENT-->/g;      # cloak all entities
+    $lines =~ s/(\w*&\w+;\w*)/<?ENT_ $1_ENT?>/g;      # cloak all entities
 
     # uncloak entities in subset
-    while ($lines =~ /(<!ENTITY[^']*?'[^']*?)<!--ENT_(.+?)_ENT-->(.*?'\s*>)/s) {
-        $lines =~ s/(<!ENTITY[^']*?'[^']*?)<!--ENT_(.+?)_ENT-->(.*?'\s*>)/$1$2$3/s
+    while ($lines =~ /(<!ENTITY[^']*?'[^']*?)<\?ENT_ (.+?)_ENT\?>(.*?'\s*>)/s) {
+        $lines =~ s/(<!ENTITY[^']*?'[^']*?)<\?ENT_ (.+?)_ENT\?>(.*?'\s*>)/$1$2$3/s
                           }
-                     while ($lines =~ /(<!ENTITY[^']*?'[^']*?)<!--ENT_(.+?)_ENT-->(.*?'\s*>)/s) {
-                         $lines =~ s/(<!ENTITY[^"]*?'[^"]*?)<!--ENT_(.+?)_ENT-->(.*?"\s*>)/$1$2$3/s
+                     while ($lines =~ /(<!ENTITY[^']*?'[^']*?)<\?ENT_ (.+?)_ENT\?>(.*?'\s*>)/s) {
+                         $lines =~ s/(<!ENTITY[^"]*?'[^"]*?)<\?ENT_ (.+?)_ENT\?>(.*?"\s*>)/$1$2$3/s
 }
 # test to see if there is an internal subset or not, then
 # cloak DOCTYPE declaration and internal subset (if there is one)
 
     if ($lines =~ /<!DOCTYPE(.*]\s*)>/s) {
-        $lines =~ s/<!DOCTYPE(.*]\s*)>/<!--DOCTYPE$1_END_SUBSET-->/s
+        $lines =~ s/<!DOCTYPE(.*]\s*)>/<\?DOCTYPE$1_END_SUBSET\?>/s
 
     } else { 
-        $lines =~ s/<!DOCTYPE([^>]*)>/<!--DOCTYPE$1_END_SUBSET-->/s
+        $lines =~ s/<!DOCTYPE([^>]*)>/<\?DOCTYPE$1_END_SUBSET\?>/s
     }
 }