#!/usr/bin/perl # The purpose of this script is to: # - make it easy to maintain BOTH a .txt and .html version of the book (as well as making other formats possible) # - automatically provide hooks for chapters and footnotes; automatically link footnote references to those s # - automatically provide any additional HTML markup needed (when necessary, by making adjustments to the .txt formats, # to add more and more features along the lines of wikitext/markdown syntax # - insert additional web links, but WITHOUT having to put them in the .txt version (because the ultimately are my own additions, # and putting them in the .txt version might make it seem like they're the original author's work) # TODO: # - break the .html version out into one-page-per-chapter (just to give it a feeling of a book # that the reader has to put some time and effort into fully processing... because that's what # it really is) (this would also help with Google-bait... from what I've heard, there's # some limit to document length, after which Google stops parsing... while that length may be # very long, this document is getting pretty friggin huge) # - separate stylesheets out # - separate TOC out # - have a semi-universal HTML header # - get utf-8 working (both in vim, as well as when we're reading the file. Examples of problems: # - Pinochet closed down Chile's young democracy in a classic Latin American military coup *splat* # - Because of the *splat* I was starting to feel when I read the newspaper use strict; use warnings; use CGI; use Data::Dumper; open FOUT, ">EndOfAmerica.html" or die; print FOUT &html_header; # Only the first instance of each text is linked. The patterns are actually full Perl # regular expressions, so you can play tricks with (?= ) or (?<= ) to make it link the # second or third mention rather than the first, if that's needed. # Also note that these are case-sensitive. my %autolinks = ( "(?<=about the )1917 Espionage Act" => "http://en.wikipedia.org/wiki/Espionage_Act_of_1917", "Heimat" => "http://en.wikipedia.org/wiki/Heimat", "USA PATRIOT Act" => "http://en.wikipedia.org/wiki/USA_PATRIOT_Act", "Leni Riefenstahl" => "http://en.wikipedia.org/wiki/Leni_Riefenstahl", "William Shirer" => "http://en.wikipedia.org/wiki/William_L._Shirer", "Umer Hayat, and his son, Hamid Hayat" => "http://en.wikipedia.org/wiki/Hamid_and_Umer_Hayat", "four Muslim men in Detroit" => "http://en.wikipedia.org/wiki/Detroit_Sleeper_Cell", "Richard Convertino" => "http://en.wikipedia.org/wiki/Richard_Convertino", "2006 terrorist plot against U.S.-bound planes" => "http://en.wikipedia.org/wiki/2006_transatlantic_aircraft_plot", "Alien and Sedition Act of 1798" => "http://en.wikipedia.org/wiki/Alien_and_Sedition_Acts", "(?<=President Lincoln )suspended habeas corpus" => "http://en.wikipedia.org/wiki/Ex_parte_Merryman#Circumstances", "Eugene Debs" => "http://en.wikipedia.org/wiki/Debs_v._United_States", "rounded up 110,000 innocent Japanese-Americans" => "http://en.wikipedia.org/wiki/Japanese_American_internment", "McCarthy hearings" => "http://en.wikipedia.org/wiki/McCarthyism", "intellectual etiquette, an unwritten rule" => "http://en.wikipedia.org/wiki/Godwin's_law", "March on Rome" => "http://en.wikipedia.org/wiki/March_on_Rome", "Night of the Long Knives" => "http://en.wikipedia.org/wiki/Night_of_the_Long_Knives", "September 2006, military leaders staged a coup in Thailand" => 'http://en.wikipedia.org/wiki/2006_Thai_coup_d%27%C3%A9tat', "Joseph Goebbels" => "http://en.wikipedia.org/wiki/Joseph_Goebbels", "Military Commissions Act" => "http://en.wikipedia.org/wiki/Military_Commissions_Act_of_2006", "designate any American citizen he chooses" => "http://en.wikipedia.org/wiki/Military_Commissions_Act_of_2006#The_Act_may_apply_to_U.S._citizens", "It Can Happen Here", "http://en.wikipedia.org/wiki/It_Can_Happen_Here", "(?<=compared )Huey Long" => "http://en.wikipedia.org/wiki/Huey_Long", "It Can't Happen Here" => "http://en.wikipedia.org/wiki/It_Can%27t_Happen_Here", "Common Sense" => "http://en.wikipedia.org/wiki/Common_Sense_%28pamphlet%29", "The Rights of Man" => "http://en.wikipedia.org/wiki/Rights_of_Man", "School of the Americas" => "http://en.wikipedia.org/wiki/Western_Hemisphere_Institute_for_Security_Cooperation", "Chile in 1973" => 'http://en.wikipedia.org/wiki/1973_Chilean_coup_d%27%C3%A9tat', "(?<=, )Chile in 1973" => 'http://en.wikipedia.org/wiki/1973_Chilean_coup_d%27%C3%A9tat', "Czechoslovakia in 1968" => "http://en.wikipedia.org/wiki/Prague_Spring", "China in 1989" => "http://en.wikipedia.org/wiki/Tiananmen_Square_protests_of_1989", "arditi" => "http://en.wikipedia.org/wiki/Arditi", "Anschluss" => "http://en.wikipedia.org/w/index.php?title=Anschluss", "law to legitimate virtually everything he did" => "http://en.wikipedia.org/wiki/German_election%2C_1933", "election in 1932" => "http://en.wikipedia.org/wiki/German_presidential_election,_1932", "Magna Carta" => "http://en.wikipedia.org/wiki/Magna_Carta", "(?<=by the concept of )habeas corpus" => "http://en.wikipedia.org/wiki/Habeas_corpus", "Heinrich Bruning" => 'http://en.wikipedia.org/wiki/Heinrich_Br%C3%BCning', "Reichstag was set on fire" => "http://en.wikipedia.org/wiki/Reichstag_fire", "Enabling Act" => "http://en.wikipedia.org/wiki/Enabling_Act_of_1933", "Sergei Kirov" => "http://en.wikipedia.org/wiki/Sergey_Kirov", "mass arrests of 1937 to 1938" => "http://en.wikipedia.org/wiki/Great_Purge", "General Pinochet's military junta" => 'http://en.wikipedia.org/wiki/1973_Chilean_coup_d%27%C3%A9tat', "bombing of the USS Cole" => "http://en.wikipedia.org/wiki/USS_Cole_bombing", "(?<=first )attack on the World Trade Center" => "http://en.wikipedia.org/wiki/World_Trade_Center_1993_bombings", "Manichean view" => "http://en.wikipedia.org/wiki/Manichaeism#The_Manichaean_cosmogony", "Bybee-Gonzales August 1, 2002 memo" => "http://en.wikipedia.org/wiki/Bybee_memo", "Critical Mass" => "http://en.wikipedia.org/wiki/Critical_Mass", "Talon created a database" => "http://en.wikipedia.org/wiki/TALON_(database)", "All Saints Episcopal Church(?= in Pasadena, California)" => "http://en.wikipedia.org/wiki/All_Saints_Episcopal_Church_(Pasadena,_California)", ); my $autolinks_re = update_autolinks_re(); my @files = qw[ 0__prePreface.txt a__Preface.txt b__Introduction.txt Chapter1.txt Chapter2.txt Chapter3.txt Chapter4.txt Chapter5.txt Chapter6.txt Chapter7.txt Chapter8.txt Chapter9.txt Chapter10.txt Chapter11.txt w__Conclusion.txt x__Acknowledgements.txt y__Notes.txt z__Bibliography.txt ]; foreach my $file (@files) { next unless -e "text/$file"; open FIN, "; if ($firstline =~ /^status:/si) { # if there's a STATUS: line up top, ignore it $firstline = ; } my ($chapter, $title) = split ' -- ', $firstline; if ($title) { $title =~ s/\s+$//s; } elsif ($file eq '0__prePreface.txt') { # don't show the title for this one $chapter = undef; } else { ($chapter = $file) =~ s/^\w_+//; $chapter =~ s/\.txt$//i; } my $anchor; if ($chapter) { ($anchor = $chapter) =~ s/\s/_/g; print FOUT "\n"; } $chapter && print FOUT "
— $chapter —
\n"; $title && print FOUT "
$title
\n"; my $fn_chapter; while () { s/\s+$//s; next unless /\S/; ## escape it so things like < and > don't have to be < or > in the text $_ = CGI::escapeHTML($_); s/'/'/g; # undo over-escaping s/"/"/gi; ## convert -- to — s/(?$1#g; ## any time text is indented by four spaces, add another level of

The End of America

Letter of Warning to a Young Patriot

-Naomi Wolf

Text version available here.

Note: Only the Preface, Introduction, Chapters 1, 2, 6, and 7, and the Conclusion sections are complete. If you wish to work on producing a more complete version of this document, consider using a similar text file format so new additions can be more easily incorporated at some point. Also consider using the included script, which does the text→HTML conversion and adds the footnote links.



EOF sub html_footer {return <<"EOF" }
EOF