]> gitweb.factorcode.org Git - factor.git/commitdiff
help.html: change back to the old naming scheme because we have too many links to...
authorSlava Pestov <slava@factorcode.org>
Sun, 4 Dec 2011 21:46:13 +0000 (13:46 -0800)
committerSlava Pestov <slava@factorcode.org>
Sun, 4 Dec 2011 21:46:13 +0000 (13:46 -0800)
basis/help/html/html.factor

index 6834ba2e5114d4c57a4d02f24ecea62475b56594..82d66b2f0b6e4b37e3b592892246a175ffdf34aa 100644 (file)
@@ -1,16 +1,38 @@
 ! Copyright (C) 2008, 2011 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: checksums checksums.sha io.encodings.utf8
-io.encodings.binary io.encodings.string io.files io.files.temp
-io.directories html.streams help help.home kernel assocs
-sequences make words accessors arrays help.topics vocabs
-vocabs.hierarchy help.vocabs namespaces io vocabs.loader
-serialize fry memoize unicode.case math.order sorting debugger
-html xml.syntax xml.writer math.parser sets hashtables ;
+USING: io.encodings.utf8 io.encodings.binary io.files
+io.files.temp io.directories html.streams help help.home kernel
+assocs sequences make words accessors arrays help.topics vocabs
+vocabs.hierarchy help.vocabs namespaces prettyprint io
+vocabs.loader serialize fry memoize unicode.case math.order
+sorting debugger html xml.syntax xml.writer math.parser
+sets hashtables ;
 FROM: io.encodings.ascii => ascii ;
 FROM: ascii => ascii? ;
 IN: help.html
 
+: escape-char ( ch -- )
+    dup ascii? [
+        dup H{
+            { CHAR: " "__quo__" }
+            { CHAR: * "__star__" }
+            { CHAR: : "__colon__" }
+            { CHAR: < "__lt__" }
+            { CHAR: > "__gt__" }
+            { CHAR: ? "__que__" }
+            { CHAR: \\ "__back__" }
+            { CHAR: | "__pipe__" }
+            { CHAR: / "__slash__" }
+            { CHAR: , "__comma__" }
+            { CHAR: @ "__at__" }
+            { CHAR: # "__hash__" }
+            { CHAR: % "__percent__" }
+        } at [ % ] [ , ] ?if
+    ] [ number>string "__" "__" surround % ] if ;
+
+: escape-filename ( string -- filename )
+    [ [ escape-char ] each ] "" make ;
+
 GENERIC: topic>filename* ( topic -- name prefix )
 
 M: word topic>filename*
@@ -29,9 +51,10 @@ M: f topic>filename* drop \ f topic>filename* ;
     topic>filename* dup [
         [
             % "-" %
-            dup array? [ "," join ] when
-            utf8 encode sha1 checksum-bytes hex-string
-            % ".html" %
+            dup array?
+            [ [ escape-filename ] map "," join ]
+            [ escape-filename ]
+            if % ".html" %
         ] "" make
     ] [ 2drop f ] if ;