summary refs log tree commit diff stats
path: root/trunk
diff options
context:
space:
mode:
Diffstat (limited to 'trunk')
-rw-r--r--trunk/backlink.sh29
-rw-r--r--trunk/forceascii.hs17
-rw-r--r--trunk/hapax.lua95
-rw-r--r--trunk/hapaxlink.sh26
-rw-r--r--trunk/lozenge.js2
-rw-r--r--trunk/lozenge.sh15
-rw-r--r--trunk/versify.exebin13686106 -> 13686106 bytes
7 files changed, 133 insertions, 51 deletions
diff --git a/trunk/backlink.sh b/trunk/backlink.sh new file mode 100644 index 0000000..7d143a8 --- /dev/null +++ b/trunk/backlink.sh
@@ -0,0 +1,29 @@
1#!/bin/bash
2
3# Command-line variables
4searchQuery="$1"; # .html file to backlink
5outFile="$2"; # .back file to create
6headerFile="$3"; # header information file
7shift 3;
8glob="$@"; # where to search for backlinks
9
10# Find backlinkers
11echo -n "Back-linking \"$searchQuery\""
12cat "$headerFile" > "$outFile";
13grep -ql "$searchQuery" $glob >> "$outFile";
14
15# Change title of $outFile
16inText="`basename $searchQuery .html`.txt";
17title=`grep '^title:' "$inText" | cut -d' ' -f2-`;
18sed -i "s/_TITLE_/$title/" "$outFile";
19echo -n "."
20
21# Link to backlinks
22for file in `grep '.html' "$outFile"`; do
23 fText="`basename $file .html`.txt";
24 title=`grep '^title:' $fText | cut -d' ' -f2-`;
25 sed -i "s/^$file$/- [$title](&)/" "$outFile";
26 echo -n "."
27done
28
29echo "Done."
diff --git a/trunk/forceascii.hs b/trunk/forceascii.hs new file mode 100644 index 0000000..b5f1645 --- /dev/null +++ b/trunk/forceascii.hs
@@ -0,0 +1,17 @@
1-- Preprocessor for hapax.lua writer
2-- because for some damn reason, UTF-8 confuses things
3
4import Text.Pandoc.JSON
5import Data.Char (isAscii)
6
7main :: IO ()
8main = toJSONFilter unFancy
9
10unFancy :: Inline -> Inline
11unFancy (Str s) = Str $ map makeAscii s
12unFancy x = x
13
14makeAscii :: Char -> Char
15makeAscii c
16 | isAscii c = c
17 | otherwise = ' '
diff --git a/trunk/hapax.lua b/trunk/hapax.lua index 7e8410c..af59e59 100644 --- a/trunk/hapax.lua +++ b/trunk/hapax.lua
@@ -1,8 +1,8 @@
1-- Pandoc River writer 1-- Pandoc Hapax writer
2-- it takes out all formatting, leaving only a river of text 2-- it takes out all formatting, leaving only a river of text
3-- running down the page: one word per line 3-- running down the page: one word per line, stripping all duplicates
4-- vim: fdm=marker 4-- vim: fdm=marker
5-- invoke with: pandoc -t river.lua 5-- invoke with: pandoc -t hapax.lua
6 6
7os.setlocale("en_US.UTF-8") 7os.setlocale("en_US.UTF-8")
8 8
@@ -40,36 +40,22 @@ function flow(s)
40end 40end
41 41
42function nude(s) 42function nude(s)
43 s = s:lower()
43 -- Expand contractions 44 -- Expand contractions
44 s = s:gsub("'%a+%s", function (x) 45 s = s:gsub("'ll", " will ")
45 if x == "'ll" then 46 s = s:gsub("'ve", " have ")
46 return " will " 47 s = s:gsub("'re", " are ")
47 elseif x == "'ve" then 48 s = s:gsub("i'm", " i am ")
48 return " have "
49 elseif x == "'re" then
50 return " are "
51 else
52 return x
53 end
54 end)
55 s = s:gsub("it's", "it is") 49 s = s:gsub("it's", "it is")
56 s = s:gsub("n't", " not ") 50 s = s:gsub("n't", " not ")
57 -- Get rid of quotes around words 51 s = s:gsub("&", " and ")
58 s = s:gsub('"', ' ') 52 -- -- Remove dashes (not hyphens)
59 s = s:gsub("%s'", ' ')
60 s = s:gsub("'%s", ' ')
61 -- Remove HTML entities
62 s = s:gsub('&.-;', ' ')
63 s = s:gsub('%b<>', ' ')
64 -- Remove end-of-line backslashes
65 s = s:gsub('\\$', ' ')
66 -- Remove dashes (not hyphens)
67 s = s:gsub('%-[%-%s]+', ' ') 53 s = s:gsub('%-[%-%s]+', ' ')
68 -- Remove everything that is not letters or numbers 54 -- Remove everything that is not letters or numbers
69 s = s:gsub('[%.!%?:;,%[%]%(%)<>]', ' ') 55 s = s:gsub('[^A-Za-z0-9/\'-]', ' ')
70 -- Remove extra spaces 56 -- Remove extra spaces
71 s = s:gsub('%s+', ' ') 57 s = s:gsub('%s+', ' ')
72 return s:lower() 58 return " "..s.." "
73end 59end
74 60
75-- This function is called once for the whole document. Parameters: 61-- This function is called once for the whole document. Parameters:
@@ -89,71 +75,72 @@ function Doc(body, metadata, variables)
89 end 75 end
90 add(body) 76 add(body)
91 return hapax(flow(buffer)) 77 return hapax(flow(buffer))
78 -- return flow(buffer)
92end 79end
93 80
94-- Remove all formatting {{{ 81-- Remove all formatting {{{
95function Note(s) 82function Note(s)
96 return nude(s) 83 return s
97end 84end
98 85
99function Blocksep() 86function Blocksep()
100 return "\n" 87 return "\n"
101end 88end
102function Emph(s) 89function Emph(s)
103 return nude(s) 90 return s
104end 91end
105 92
106function Strong(s) 93function Strong(s)
107 return nude(s) 94 return s
108end 95end
109 96
110function Subscript(s) 97function Subscript(s)
111 return nude(s) 98 return s
112end 99end
113 100
114function Superscript(s) 101function Superscript(s)
115 return nude(s) 102 return s
116end 103end
117 104
118function SmallCaps(s) 105function SmallCaps(s)
119 return nude(s) 106 return s
120end 107end
121 108
122function Strikeout(s) 109function Strikeout(s)
123 return nude(s) 110 return s
124end 111end
125 112
126function Code(s, attr) 113function Code(s, attr)
127 return nude(s) 114 return s
128end 115end
129 116
130function CodeBlock(s, attr) 117function CodeBlock(s, attr)
131 return nude(s) 118 return s
132end 119end
133 120
134function InlineMath(s) 121function InlineMath(s)
135 return nude(s) 122 return s
136end 123end
137 124
138function DisplayMath(s) 125function DisplayMath(s)
139 return nude(s) 126 return s
140end 127end
141 128
142function Span(s, attr) 129function Span(s, attr)
143 return nude(s) 130 return s
144end 131end
145 132
146function Cite(s) 133function Cite(s)
147 return nude(s) 134 return s
148end 135end
149 136
150function Plain(s) 137function Plain(s)
151 return nude(s) 138 return s
152end 139end
153 140
154-- Links only include the link text 141-- Links only include the link text
155function Link(s, src, tit) 142function Link(s, src, tit)
156 return nude(s) 143 return s
157end 144end
158 145
159-- Images have nothing to give us 146-- Images have nothing to give us
@@ -162,16 +149,24 @@ function Image(s, src, tit)
162 return "\n" 149 return "\n"
163end 150end
164 151
152function RawBlock(s)
153 return s
154end
155
156function RawInline(s)
157 return s
158end
159
165function CaptionedImage(s, src, tit) 160function CaptionedImage(s, src, tit)
166 return "\n" 161 return "\n"
167end 162end
168 163
169function Str(s) 164function Str(s)
170 return nude(s) 165 return s
171end 166end
172 167
173function Div(s, attr) 168function Div(s, attr)
174 return nude(s) 169 return s
175end 170end
176 171
177function Space(s) 172function Space(s)
@@ -183,15 +178,15 @@ function LineBreak()
183end 178end
184 179
185function Para(s) 180function Para(s)
186 return nude(s) 181 return s
187end 182end
188 183
189function Header(lev, s, attr) 184function Header(lev, s, attr)
190 return nude(s) 185 return s
191end 186end
192 187
193function BlockQuote(s) 188function BlockQuote(s)
194 return nude(s) 189 return s
195end 190end
196 191
197function HorizontalRule() 192function HorizontalRule()
@@ -201,7 +196,7 @@ end
201function BulletList(items) 196function BulletList(items)
202 local buffer = "" 197 local buffer = ""
203 for _, item in pairs(items) do 198 for _, item in pairs(items) do
204 buffer = buffer .. nude(item) .. "\n" 199 buffer = buffer .. " " .. item .. "\n"
205 end 200 end
206 return buffer .. "\n" 201 return buffer .. "\n"
207end 202end
@@ -209,7 +204,7 @@ end
209function OrderedList(items) 204function OrderedList(items)
210 local buffer = "" 205 local buffer = ""
211 for _, item in pairs(items) do 206 for _, item in pairs(items) do
212 buffer = buffer .. nude(item) .. "\n" 207 buffer = buffer .. " " .. item .. "\n"
213 end 208 end
214 return buffer .. "\n" 209 return buffer .. "\n"
215end 210end
@@ -218,7 +213,7 @@ function DefinitionList(items)
218 local buffer = "" 213 local buffer = ""
219 for _, item in pairs(items) do 214 for _, item in pairs(items) do
220 for k, v in pairs(item) do 215 for k, v in pairs(item) do
221 buffer = buffer .. nude(k) .. "\n" .. nude(v) .. "\n" 216 buffer = buffer .. " " .. k .. "\n" .. v .. "\n"
222 end 217 end
223 end 218 end
224 return buffer .. "\n" 219 return buffer .. "\n"
@@ -227,7 +222,7 @@ end
227function Table(caption, aligns, widths, headers, rows) 222function Table(caption, aligns, widths, headers, rows)
228 local buffer = "" 223 local buffer = ""
229 local function add(s) 224 local function add(s)
230 buffer = buffer .. nude(s) .. "\n" 225 buffer = buffer .. " " .. s .. "\n"
231 end 226 end
232 if caption ~= "" then 227 if caption ~= "" then
233 add(caption) 228 add(caption)
diff --git a/trunk/hapaxlink.sh b/trunk/hapaxlink.sh new file mode 100644 index 0000000..286c43d --- /dev/null +++ b/trunk/hapaxlink.sh
@@ -0,0 +1,26 @@
1#!/bin/bash
2
3file="$1";
4headFile="$2";
5shift 2;
6glob="$@"; # *.hapax
7
8tempFile="${RANDOM}.tmp"
9
10echo -n "Linking \"$file\""
11# Begin
12cat "$headFile" > "$tempFile";
13echo -n "."
14# Link words to files they appear in
15for word in `sort "$file"`; do
16 f=`grep -liwq "^$word$" $glob`;
17 link="`basename $f .hapax`.html"
18 echo "[$word]($link)" >> "$tempFile";
19 echo -n "."
20done
21
22# Make the changes happen
23rm "$file"
24mv "$tempFile" "$file"
25
26echo "Done."
diff --git a/trunk/lozenge.js b/trunk/lozenge.js index 4e6968b..171e251 100644 --- a/trunk/lozenge.js +++ b/trunk/lozenge.js
@@ -6,7 +6,7 @@
6function _lozenge() { 6function _lozenge() {
7 var lozenge = document.getElementById('lozenge'); 7 var lozenge = document.getElementById('lozenge');
8 // array with all files {{{ 8 // array with all files {{{
9 var files=["100-lines.html","about-the-author.html","about.html","about_author.html","abstract.html","amber-alert.html","and.html","angeltoabraham.html","apollo11.html","arspoetica.html","art.html","axe.html","big-dipper.html","boar.html","boy_bus.html","building.html","call-me-aural-pleasure.html","cereal.html","cold-wind.html","collage-instrument.html","common-titles.html","creation-myth.html","deadman.html","death-zone.html","deathstrumpet.html","dollywood.html","dream.html","early.html","elegyforanalternateself.html","epigraph.html","ex-machina.html","exasperated.html","father.html","feedingtheraven.html","finding-the-lion.html","fire.html","first-lines.html","found-typewriter-poem.html","hands.html","hapax.html","hard-game.html","hardware.html","howithappened.html","howtoread.html","hymnal.html","i-am.html","i-think-its-you.html","i-want-to-say.html","i-wanted-to-tell-you-something.html","in-bed.html","initial-conditions.html","january.html","joke.html","lappel-du-vide.html","largest-asteroid.html","last-bastion.html","last-passenger.html","leaf.html","leg.html","likingthings.html","listen.html","love-as-god.html","lovesong.html","man.html","manifesto_poetics.html","moon-drowning.html","moongone.html","mountain.html","movingsideways.html","music-433.html","no-nothing.html","notes.html","nothing-is-ever-over.html","on-genre-dimension.html","onformalpoetry.html","options.html","ouroboros_memory.html","paul.html","peaches.html","philosophy.html","phone.html","planks.html","plant.html","poetry-time.html","prelude.html","problems.html","process.html","proverbs.html","punch.html","purpose-dogs.html","question.html","real-writer.html","reports.html","riptide_memory.html","ronaldmcdonald.html","roughgloves.html","sapling.html","seasonal-affective-disorder.html","sense-of-it.html","serengeti.html","shed.html","shipwright.html","sixteenth-chapel.html","snow.html","something-simple.html","spittle.html","squirrel.html","stagnant.html","statements-frag.html","stayed-on-the-bus.html","stump.html","swansong-alt.html","swansong.html","swear.html","table_contents.html","tapestry.html","telemarketer.html","the-night-we-met.html","the-sea_the-beach.html","theoceanoverflowswithcamels.html","time-looks-up-to-the-sky.html","todaniel.html","toilet.html","toothpaste.html","treatise.html","underwear.html","walking-in-the-rain.html","wallpaper.html","weplayedthosegamestoo.html","what-we-are-made-of.html","when-im-sorry-i.html","window.html","words-irritable-reaching.html","words-meaning.html","worse-looking-over.html","writing.html","x-ray.html","yellow.html"] 9 var files=["100-lines.html","about-the-author.html","about.html","about_author.html","abstract.html","amber-alert.html","and.html","angeltoabraham.html","apollo11.html","arspoetica.html","art.html","axe.html","big-dipper.html","boar.html","boy_bus.html","building.html","call-me-aural-pleasure.html","cereal.html","cold-wind.html","collage-instrument.html","creation-myth.html","deadman.html","death-zone.html","deathstrumpet.html","dollywood.html","dream.html","early.html","elegyforanalternateself.html","epigraph.html","ex-machina.html","exasperated.html","father.html","feedingtheraven.html","finding-the-lion.html","fire.html","found-typewriter-poem.html","hands.html","hard-game.html","hardware.html","howithappened.html","howtoread.html","hymnal.html","i-am.html","i-think-its-you.html","i-want-to-say.html","i-wanted-to-tell-you-something.html","in-bed.html","initial-conditions.html","january.html","joke.html","lappel-du-vide.html","largest-asteroid.html","last-bastion.html","last-passenger.html","leaf.html","leg.html","likingthings.html","listen.html","love-as-god.html","lovesong.html","man.html","manifesto_poetics.html","moon-drowning.html","moongone.html","mountain.html","movingsideways.html","music-433.html","no-nothing.html","notes.html","nothing-is-ever-over.html","on-genre-dimension.html","onformalpoetry.html","options.html","ouroboros_memory.html","paul.html","peaches.html","philosophy.html","phone.html","planks.html","plant.html","poetry-time.html","prelude.html","problems.html","process.html","proverbs.html","punch.html","purpose-dogs.html","question.html","real-writer.html","reports.html","riptide_memory.html","ronaldmcdonald.html","roughgloves.html","sapling.html","seasonal-affective-disorder.html","sense-of-it.html","serengeti.html","shed.html","shipwright.html","sixteenth-chapel.html","snow.html","something-simple.html","spittle.html","squirrel.html","stagnant.html","statements-frag.html","stayed-on-the-bus.html","stump.html","swansong-alt.html","swansong.html","swear.html","table_contents.html","tapestry.html","telemarketer.html","the-night-we-met.html","the-sea_the-beach.html","theoceanoverflowswithcamels.html","time-looks-up-to-the-sky.html","todaniel.html","toilet.html","toothpaste.html","treatise.html","underwear.html","walking-in-the-rain.html","wallpaper.html","weplayedthosegamestoo.html","what-we-are-made-of.html","when-im-sorry-i.html","window.html","words-irritable-reaching.html","words-meaning.html","worse-looking-over.html","writing.html","x-ray.html","yellow.html"]
10 // }}} 10 // }}}
11 11
12 var index = Math.floor(Math.random() * files.length); 12 var index = Math.floor(Math.random() * files.length);
diff --git a/trunk/lozenge.sh b/trunk/lozenge.sh new file mode 100644 index 0000000..9f0cd55 --- /dev/null +++ b/trunk/lozenge.sh
@@ -0,0 +1,15 @@
1#!/bin/bash
2
3outFile="$1";
4shift;
5fileList="$@";
6
7echo -n "Updating \"lozenge.js\"..."
8
9list=`echo ${fileList[@]} |\
10 sed -e 's/\(\S\+.html\) \?/"\1",/g'\
11 -e 's/^\(.*\),$/var files=[\1]/'`
12
13sed -i "s/var files=.*/$list/" "$outFile";
14
15echo "Done."
diff --git a/trunk/versify.exe b/trunk/versify.exe index 59850a2..cf9809c 100644 --- a/trunk/versify.exe +++ b/trunk/versify.exe
Binary files differ