diff options
author | Adam Borowski <kilobyte@angband.pl> | 2011-06-28 14:44:42 +0200 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2011-06-29 00:52:04 +0200 |
commit | ffa7a02ef0a3e37a1184e7b5ed9c78dbb890bd2b (patch) | |
tree | 7e425ba93644a150d15e44ea95768763105d4107 /crawl-ref/source/util/unrest.pl | |
parent | 3ebe9e62483c13f8bf800d09688dd282332566b8 (diff) | |
download | crawl-ref-ffa7a02ef0a3e37a1184e7b5ed9c78dbb890bd2b.tar.gz crawl-ref-ffa7a02ef0a3e37a1184e7b5ed9c78dbb890bd2b.zip |
Build the manual from reST source.
To update it from the wiki, please run "make rest" by hand. It does web
scraping and thus might be vulnerable to changes in doku, beware!
Diffstat (limited to 'crawl-ref/source/util/unrest.pl')
-rwxr-xr-x | crawl-ref/source/util/unrest.pl | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/crawl-ref/source/util/unrest.pl b/crawl-ref/source/util/unrest.pl new file mode 100755 index 0000000000..a3fd4fc9a5 --- /dev/null +++ b/crawl-ref/source/util/unrest.pl @@ -0,0 +1,51 @@ +#! /usr/bin/env perl +use warnings; + +undef $/; +$_=<>; + +# URLs have damn inconsistent handling in reST. +s|:http: ``(.+)``|$1|g; +s|:telnet: ``(.+)``|telnet: $1|g; +s|:ssh: ``(.+)``|ssh: $1|g; + +# Local references. +s/`(.)\.\s+(.*?)`_/$1. "$2"/sg; # added "" for a nicer look + +# HTML and reST escapes. +s/</</g; +s/>/>/g; +s/"/"/g; +s/�*39;/'/g; +s/&/&/g; +s/\\(.)/$1/g; + +# Table of contents. +my $contents = "Contents\n--------\n"; +for(/\*{9,}\n(.\. .+)\n\*{9,}/g) +{ + /(.)\. (.+)/; + $contents .= "\nAppendices\n" if $1 eq "1"; + $contents .= "$1. $2\n"; +} +s/\.\. contents::\n :depth: 5/$contents/; + +# Main headers. +my $DCSShead = <<END; + DUNGEON CRAWL Stone Soup + - the manual - +END +s/\+{9,}\nDungeon Crawl Stone Soup manual\n\+{9,}\n/$DCSShead/; +s/#{9,}\nManual\n#{9,}\n\n//; + +# Make section headers nice and centered. +my $dashes = "-"x72; +my $spaces = " "x36; +s/\*{9,}\n(.)\. (.*)\n\*{9,}/$dashes\n$1.$spaces\ca$2\cb\U$2\n$dashes/g; +1 while s/ \ca[^\cb]{2}/\ca/g; +s/\ca[^\cb]?\cb//g; + +# Final whitespace. +s/\r//g; +s/ +$//g; +print; |