Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
-- -*- coding: raw-text-unix -*- -- This is part of blogme3 - but it's just notes and test scripts... -- You are not expected to understand this. -- This file: http://anggtwu.net/blogme3/notes.e.lua -- http://anggtwu.net/blogme3/notes.e.lua.html -- Author and version: [email protected] 2007mar26 -- (find-evariable 'eejump-plist-3) -- (eejump 3999) -- Index: -- «.time-text2html» (to "time-text2html") -- «.defs_as_lua» (to "defs_as_lua") -- «.defs-tests» (to "defs-tests") * (eepitch-shell) rm -Rv /tmp/blogme/ mkdir /tmp/blogme/ cd ~/TH/; for i in index emacs; do cp -v $i.blogme3 /tmp/blogme/; done cd /tmp/blogme/ lua51 ~/blogme3/blogme3.lua -o emacs.html -i emacs.blogme3 lua51 ~/blogme3/blogme3.lua -o index.html -i index.blogme3 lua51 ~/blogme3/blogme3.lua -o /tmp/blogme/index.blogme3.html -a2html index.blogme3 # file:///tmp/blogme/index.html # file:///tmp/blogme/index.blogme3.html -- (find-anggfile "TH/index.blogme3" "DEF EEVRELEASE") doblogme [=[ [DEF DHREF 2 url,text <a href="[$ url]">[$ str]</a>] ]=] doblogme [=[ [DDEF FBHREF 2 url,text foo[HREF $url $text]bar ] ]=] dooption_dd("/tmp/dd.lua") -- (find-fline "/tmp/dd.lua") dooption_dd("/tmp/dd.lua") -- (find-fline "/tmp/dd.lua" "LIST2") PP(filter {"bar", "plic"}) = doblogme [==[ _[HLIST2 foo bar plic]_ ]==] = doblogme [==[ _[HLIST2 foo bar [#] plic]_ ]==] = doblogme [==[ _[NAME foo bar]_ ]==] = doblogme [==[ _[NAME foo]_ ]==] = NAME("foo", "bar") = NAME("foo") = withsubj("foo bar", readvrest) = withsubj("foo bar", readvlist) PP(withsubj("foo bar", readvlist)) PP(withsubj("foo bar plic", readvvlist)) PP(withsubj("", readvvlist)) PP(withsubj("", readvlist)) = withsubj("", readvrest) = withsubj("", readvword) -- (find-blogme3file "brackets.lua" 190) = doblogme [=[ DEF defed 2 foo,bar _A["DEF"] = _AA["4Q"] or _G["4Q"] _G["DEF"] = function (name,apspec,arglist,body) return def_set_AG(name, apspec, wrap_fr(arglist, format("doblogme %q", body))) end _S["DEF"] = [=[function (name,apspec,arglist,body) return def_set_AG(name, apspec, wrap_fr(arglist, format("doblogme %q", body))) end]=] # (find-angg "TH/index.blogme3") # (find-blogme3file "definers.lua") # (find-blogme3file "defs.lua") # (find-blogme3file "speedbar.lua") -- 322 (find-blogme3file "brackets.lua") -- 323 (find-blogme3file "text2html.lua") -- 324 (find-blogme3file "tests.e") -- «time-text2html» (to ".time-text2html") -- (find-blogme3 "text2html.lua") * (eepitch-lua51) dofile "text2html.lua" htmlizefile("/tmp/emacs.e") htmlizefile("$ES/lua5.e") --[=[ * (eepitch-shell) #* # (eev-bounded) cd ~/TH/L/ time tclsh ~/TH/Generate e/emacs.e.html "e2html e/emacs.e" cd ~/blogme3/ cp -v $ES/emacs.e /tmp/ time lua51 -e ' dofile(ee_expand "~/blogme3/text2html.lua") htmlizefile("/tmp/emacs.e", "/tmp/emacs.e.html") ' #* --]=] -- «defs_as_lua» (to ".defs_as_lua") -- (find-blogme3 "defs.lua") * (eepitch-lua51) dofile "brackets.lua" -- (find-blogme3file "brackets.lua") dofile "definers.lua" -- (find-blogme3file "definers.lua") dofile "defs.lua" -- (find-blogme3file "defs.lua") print(defs_as_lua()) -- «defs-tests» (to ".defs-tests") -- (find-blogme3 "defs.lua") * (eepitch-lua51) dofile "brackets.lua" -- (find-blogme3file "brackets.lua") dofile "definers.lua" -- (find-blogme3file "definers.lua") dofile "defs.lua" -- (find-blogme3file "defs.lua") dofile "speedbar.lua" -- (find-blogme3file "speedbar.lua") fname_stem = "emacs" fname_input = ee_expand("~/TH/"..fname_stem..".blogme") fname_output = "/tmp/"..fname_stem..".html" pathtoroot = getpathtoroot(fname_stem..".html") def [[ INCLUDE 0 _ "" ]] input = readfile(fname_input) output = doblogme(input) writefile(fname_output, output) = "file://"..fname_output -- file:///tmp/emacs.html = html_all("TiTLE", "BoDY") = htmlize("TiTLE", "BoDY") def [[ foo 2 _,_ error("a") ]] def [[ bar 2 a,b foo(2,3) ]] = bar(99) = foo(99) = _S["foo"] error() error("a") -- (find-blogme3 "defs.lua") -- (find-luafile "src/lib/lstrlib.c" "case 's' : res = isspace(c)") -- (find-node "(libc)Classification of Characters" "int isspace") -- (find-sh0 "cp -v $ES/emacs.e /tmp/") -- (find-sh0 "cp -v ~/TH/L/eev-article.html /tmp/") -- (find-sh0 "rm -v /tmp/ee.html") -- file:///tmp/ee.html -- (find-fline "/tmp/ee.html") -- (eev "Scp /tmp/ee.html [email protected]:public_html/e/emacs.enew.html") -- http://anggtwu.net/e/emacs.enew.html -- (find-blogmefile "blogme2-outer.lua" "relativepathto =") = htmlizeline [[# (find-efaqnode "Top")]] = htmlizeline [[# (to "Top")]] -- assexplink = function (all, funname) -- return format("<a href=\"%s\">%s</a>", funname, all) --< temporary -- end -- headsymbols["find-efunction"] = nil --> do not htmlize -- headsymbols["find-bashnode"] = true --> htmlization not yet implemented yet -- headsymbols["to"] = all,fn,a1,a2|->"#"..a1 --> a "real" htmlization -- headlinks["to"] = -- up = function (s) s = string.gsub(s, "<", "\171") s = string.gsub(s, ">", "\187") return s end down = function (s) s = string.gsub(s, "\171", "<") s = string.gsub(s, "\187", ">") return s end = htmlizeline(up [[# <foo> (to "foo")]]) subj = up [[<foo> (to "foo")]] lpeg.match( Anchor / PP, subj) = lpeg.match( Anchor, subj) AlphaNumeric = lpeg.R("AZ", "az", "09") Anchor = "\171" * lpeg.C(AlphaNumeric^1) * "\187" headsymbols = { ["find-node"]=true, ["find-man"]=true, ["find-angg"]=true, ["to"]=true } headsymbols_str = [[ eeman eevnow-at find-angg find-angghtml find-deblistsw3 find-eev find-es find-fline find-flua find-flua find-fluafile find-luamanualw3m find-luamanualw3m+ find-man find-node find-shttpfile find-shttpw3 to ]] for _,name in ipairs(split(headsymbols_str)) do headsymbols[name] = true end headlinks["find-angg"]="blah!" headsymbols["find-angg"] = function (all, fn, a1, a2) return dequote(a1) or "" end for i=1,#subj do print(string.sub(subj,i,i)) end = subj = M(Anchor, subj) = assexplink( [[(find-angg "foo" "bar")]], "find-angg", [["foo"]], [["bar"]] ) = assexplink( [[(to "bletch")]], "to", [["bletch"]] ) = htmlizeline "# \171foo\187 bletch" * (eepitch-lua51) = string.sub("(foo !)", -2, -2) = string.sub("(foo !)", 2, -2) -- SexpLinkEol = SexpLink * Eol --------[ Tests ]-------- = htmlizeline "(find-angg \".emacs\" \"foo\")" = htmlizeline " http://foo.bar/ http://foo.bar/ foo (find-angg \".emacs\" \"foo\")" = htmlizeline " \171-anch-\187 foo (find-angg \".emacs\" \"foo\")" = M(SexpLinkT, "(find-angg \".emacs\" \"foo\")") = M(SpecialT, "(find-angg \".emacs\" \"foo\")") PP(split("a\nb\n", "\n")) [[<html> <head> <title>%s (htmlized) </title> </head> <body> <pre> %s </pre> </body> </html> ]] readfile(ee_expand(fname)) PP(split("foo\nbar\n", "([^\n]*)\n?")) PP(split("foo\nbar", "([^\n]*)\n?")) PP(split("foo\nbar\n\n", "([^\n]*)\n?")) PP(split("\n", "([^\n]*)\n?")) PP(split("", "([^\n]*)\n?")) PP(splitlines("foo\nbar\n")) PP(splitlines("foo\nbar")) PP(splitlines("foo\nbar\n\n")) PP(splitlines("\n")) PP(splitlines("")) splitlines = function (str) local arr = {} string.gsub(str, pat or "([^%s]+)", function (word) table.insert(arr, word) end) return arr end M (SexpLink) M2(SexpLink) M (SexpLink, "(find-angg \".emacs\" \"foo\")\n ") M (SexpLinkT, "(find-angg \".emacs\" \"foo\")\n ") M (lpeg.Ct(lpeg.Cc("sexplink") * lpeg.C(lpeg.Ct(SSexpLink)))) = lpeg.match(SHeadSymbol, "find-angg") = lpeg.match(lpeg.C(SHeadSymbol), "find-angg") = lpeg.match(SHeadSymbol * Eol, "find-angg ") = lpeg.match(SHeadSymbol * Eol, "find-angg\nj") = lpeg.match(lpeg.C(SHeadSymbol), "find-angg") PP(lpeg.match(lpeg.C(AlphaNumeric^0) * (#(lpeg.P("\n")) + Eos), "foobar")) PP(lpeg.match(lpeg.C(AlphaNumeric^0) * Eol, "foobar")) PP(lpeg.match(lpeg.C(AlphaNumeric^0) * Eol, "foobar ")) PP(lpeg.match(lpeg.C(AlphaNumeric^0) * Eol, "foobar\n")) Eol = #(lpeg.S "\n") + Eos -- Subj = lpeg.P(function (subj, pos) return pos end) * somethingthatreturnssubj() -- / PPP("EtcSpecialT:") --< change this (to asetcspecial) -- asetc = function (etc) -- return sgmlify(etc) -- end -- asetcspecial = function (subj, ebeg, eend, str) -- return asetc(string.sub(subj, ebeg, eend)) .. str -- --< where does subj come from? -- end -- EtcT = lpeg.C(EtcChar^1) / asetc -- EtcSpecialTs = EtcSpecialT^0 -- EtcSpecialsEtcT = lpeg.Ct(EtcSpecialTs * EtcT) / table.concat -- no sgmilification yet --------[ Readers ]-------- -- SSexpLinkR = lpeg.C(lpeg.Ct(SSexpLink)) -- {"sexplink", "(find-angg ...)", {"find-angg", ...}} --------[ Full Lines ]-------- -- (find-lpegw3m "doc.html" "function anywhere (p)") -- NonNewline = 1 - lpeg.S "\n"