;; Markup. ;; Emacs-Time-stamp: "2007-08-07 23:08:00" (setq file-stamp "Emacs-File-stamp: \"/home/ysverdlov/leninist.biz/lb-mu.el\"") ;; (defun lb-mu-while-insert-tabindex nil "" ;; (let (lb-flag lb-pt-resume lb-cnt-scroll2next lb-cnt-next-arrow lb-cnt-prev-arrow (lb-tabindex 0) _rc) ;; 1. visit webpage; 2. press [TAB]; 3. press [ENTER] to start scrolling. (goto-char (point-min)) (if (search-forward-string "tabindex=" nil t) (error "%s: %s" "Not expecting" (match-string-no-properties 0))) ;; (setq lb-cnt-scroll2next (setq lb-cnt-next-arrow (setq lb-cnt-prev-arrow 0))) (while (or (and (= 0 lb-cnt-next-arrow) (search-forward-regexp "class=.\\(scroll2next\\)." nil t)) ;; Keep going. ;; fix! - could break if name in CSS changed. ;; fix! - assuming all scroll2next's are *ABOVE* navigation table. (and (= 0 lb-cnt-prev-arrow) (search-forward-regexp "class=.\\(next-arrow\\)." nil t)) ;; Now look back. (search-backward-regexp "class=.\\(prev-arrow\\)." nil t) ) (progn (if (string= "a" (_-sgml-what-element)) (setq lb-flag (match-beginning 0))) (setq lb-type (match-string-no-properties 1)) (setq lb-pt-resume (cond ((string= "scroll2next" lb-type) (setq lb-cnt-scroll2next (1+ lb-cnt-scroll2next)) ;; FORWARD. (match-end 0)) ((string= "next-arrow" lb-type) (setq lb-cnt-next-arrow (1+ lb-cnt-next-arrow)) ;; FORWARD. (match-end 0)) ((string= "prev-arrow" lb-type) (setq lb-cnt-prev-arrow (1+ lb-cnt-prev-arrow)) ;; BACKWARD. (match-beginning 0))))) ;; next- and prev-arrow are in TD in same TR as A. (when (or (string= "next-arrow" lb-type) (string= "prev-arrow" lb-type)) (setq lb-flag nil) (save-excursion ;; (when (string= "next-arrow" lb-type) ;; Go back two TDs. (search-backward-string "")) t) (if (search-forward-regexp "href=\"[^\"]+\"" (save-excursion (search-forward-string ">")) t) (setq lb-flag (match-beginning 0)))))) ;; (when lb-flag (goto-char lb-flag) (insert "" "tabindex=\"" (int-to-string (setq lb-tabindex (1+ lb-tabindex))) "\" ")) (goto-char lb-pt-resume)) ;; Everything else. (setq lb-tabindex 0) (goto-char (point-min)) (while (search-forward-regexp " at end of page but not end of paragraph. SEE ALSO: lb-mu-insert-pound-anchors-at-beg-of-blocks SEE ALSO: Function without trailing '-'" ;; (let (lb-str-href lb-pt lb-re-a-class-id lb-str-a-scroll2next _bound _while-bound _cdata-bound _rc) (setq lb-str-a-scroll2next " found, skip to

if next open tag? (goto-char (point-max)) (while (and (sbr (concat "<" arg1tag "[^a-z]") nil t) (progn (goto-char (setq _while-bound (match-beginning 0))) (sfs ">") (setq lb-str-href nil) t)) ;; Move to beginning of CDATA. (while (or (_-move-forward-whitespace) (and (looking-at "")) (and (looking-at "")) (and (looking-at "__") (goto-char (cdr (_-where-double-newlines)))))) ;; Try to insert anchor pointing to beginning of next block. (setq _cdata-bound (point)) ;;If

before

, may find

before

!!!!! (if (sfr (concat "<" arg1tag "[^a-z]") (setq _bound (save-excursion (sfs (concat "") nil t) (match-end 0))) t) (goto-char (match-beginning 0)) (goto-char _bound) (_-move-forward-whitespace)) ;; Maybe looking at

before

due to blockquote inside P. ;; Maybe after

and whitespace. ;; Ignore close tags (blockquotes), comments and stuff like PG#'s. (while (or (_-move-forward-whitespace) (and (looking-at "")) (and (looking-at "")) (and (looking-at "")) (and (looking-at " ;; (if lb-significant-words (insert "\n\n" lb-significant-words " \n\n"))) ;; (goto-char lb-bound-upper)) ;; Process bread crumbs left behind from above. ;; Each block has one LARGE bread crumb. (goto-char (point-min)) (setq lb-pt-%%data%% (search-forward-string "%%data%%")) ;; (while (search-forward-string "" nil t) (replace-match "") (progn (setq lb-significant-words (_-current-line t t)) (delete-region (save-excursion (beginning-of-line) (point)) (save-excursion (end-of-line) (point))) (setq lb-significant-words (split-string lb-significant-words "[.]")) (setq lb-candidate nil) (setq lb-inserted-flag nil) (setq lb-list-dupes-curr-block nil)) ;; (loop for i from 1 to (length lb-significant-words) do (setq lb-candidate (concat lb-candidate (setq lb-word (nth (1- i) lb-significant-words)) ".")) ;; (when (and (>= i lb-min-number-of-significant-words) ;; 2006.12.07 (not (member lb-word lb-list-skip-candidate-words)) (if (not (member lb-candidate lb-global-list-dupes)) t (setq lb-list-dupes-curr-block (append lb-list-dupes-curr-block (list lb-candidate))) nil)) (insert (progn (setq lb-inserted-flag t) "") ;; 2007.04.11 ;; "
" "\">" "\n"))) ;; loop ;; (if (not lb-inserted-flag) (insert ;; 2007.04.11 ;; "" "\n"))) lb-rc)) ;; fix! ;; Must use "." in place of 8-bit ASCII character in regexp! ;; (lb-mu-get-element ">T.tulosTítulosTitlesTítulosTitles") (point)))) lb-rc)) ;; (lb-mu-template-get- "html") => "~/leninist.biz/en/HTML" ;; (lb-mu-template-get- "t") => "~/leninist.biz/en/T" ;; (lb-mu-template-get- "text") => "~/leninist.biz/es/texto" ;; (lb-mu-template-get- "text" "en") => "~/leninist.biz/en/text" (defun lb-mu-template-get- (arg1type &optional arg2lang) " Optional ARG2 is language" (let ( lb-rc) (if (not arg2lang) (setq arg2lang lb-lang)) (string-match-substitute "[.]htmm$" ;; 2006.11.17 ;; ".html" "" (lb-get-diskfilename arg1type arg2lang t)))) (defun lb-sgml-scrub-local-variables nil "Change Emacs Local Variables - Delete Local Variable section if only: mode:fundamental " (_-dfun-hook "lb-sgml-scrub-local-variables") ;; (let (my) (save-excursion (goto-char (point-min)) (while (search-forward (concat "\n" "\n" "\n") nil t) (replace-match ""))))) (defun lb-sgml-scrub (&optional arg1letter arg2lang) "Scrub SGML - Standardize:
Translated - Modify A element with CDATA equal to one letter: ARG1 - Say how many books online - lb-sgml-scrub-local-variables " (_-dfun-hook "lb-sgml-scrub") ;; (if (not arg2lang) (setq arg2lang lb-lang)) (save-match-data (let (_-pf lb-str lb-pt lb-msnp1 lb-msnp2) ;; fix? context? (save-excursion (goto-char (point-min)) (while (search-forward-regexp "Transl:[ \t]*Translated" nil t) (replace-match "
Translated"))) ;; Modify ARG1 (save-excursion (goto-char (point-min)) (if (member arg1letter (split-string lb-az "")) ;; fix? when? while? (when (search-forward-regexp (concat "" (upcase arg1letter) "") nil t) (replace-match (concat (match-string 1) "-backcolor") t t nil 1) (search-backward "<") (search-forward-regexp (concat ">\\(" (upcase arg1letter) "\\)")) (replace-match (concat " " (match-string 1) " ") t t nil 1)))) ;; How many books online? 8734 is infinity. (save-excursion (goto-char (point-min)) (when (search-forward-regexp "∞" nil t) (replace-match (_-comma-ify-int (lb-count- "titles" arg2lang))) (if (search-forward-regexp "∞" nil t) (replace-match (_-comma-ify-int (lb-count- "ebooks" arg2lang))) (error "%s: %s" "Expecting two" "∞")))) (lb-sgml-scrub-local-variables) ))) (defun lb-sgml-change-youarehere (arg1re arg2type &optional arg3lang) "Delete element with ARG1 and replace with one from ARG2's template" (_-dfun-hook "lb-sgml-change-youarehere") ;; fix! Should be able to auto-detect arg2type somehow. ;; (let ( lb-rc) (if (not arg3lang) (setq arg3lang lb-lang)) (goto-char (car (setq lb-cons (lb-mu-get-element-bounds arg1re)))) (delete-region (car lb-cons) (cdr lb-cons)) (insert (lb-mu-get-element arg1re (lb-mu-template-get- arg2type arg3lang))) lb-rc)) ;; (lb-mu-set-n-return-buffer-x arg1type i) ;; (lb-mu-set-n-return-buffer-x "t" "a" "en") ;; (set-buffer (lb-mu-set-n-return-buffer-x arg1type i)) (defun lb-mu-set-n-return-buffer-x (arg1type &optional arg2i arg3lang) "Return a buffer with beginning of web page. For titles, authors and years, ARG1 is 'T', 'A' and '19'. For titles, authors and years, ARG2 is 'A' or 'B' or 'C' ... or 'z' [YEARS?!?!?!]. Optional ARG3 is language. ;; fix! For 'text' & 'html' & 'ps' & 'pdf' edits .html created from .htmm because ARG2 is nil" (_-dfun-hook "lb-mu-set-n-return-buffer-x") ;; (let (lb-pf lb-rc) (if (not arg3lang) (setq arg3lang lb-lang)) ;; fix! ;; use lb-home instead of (concat "~/" lb-domain) ALL OVER .elS! (setq lb-pf (if (member (upcase arg1type) (split-string "TAY" "")) ;; If arg1type is 't': ".../ta.html through tz.html (concat lb-home arg3lang "/" arg1type arg2i "" lb-ext-html) ;; When arg1type is "titl", "auth", ... use canonical filename. (string-match-substitute ;; 2006.11.17 ;; "m$" ".htmm$" ;; ;; "l" (if arg2i arg2i "") (lb-get-diskfilename arg1type nil t)))) (progn (if ;; delete file? (or (member arg1type (split-string "TAY" "")) (assoc arg1type lb-assoc-htmm)) (if (file-exists-p lb-pf) (delete-file lb-pf))) (find-file-literally lb-pf) (if ;; insert template? (or (member arg1type (split-string "TAY" "")) (assoc arg1type lb-assoc-htmm)) (_-ifcl (lb-mu-template-get- arg1type)))) (xml-mode) ;; Delete href= that points to this file. (goto-char (point-min)) (if (search-forward-regexp (concat "[ \t\n]+href=/ arg1type arg2i "" lb-ext-html "\"") nil t) (replace-match "")) ;; why? ;; Change "YOU ARE HERE" (cond ((string= arg1type "t") (lb-sgml-change-youarehere ;; fix? do not hardcode. (if (string= "en" arg3lang) ">TitlesT.tulosAuthorsAutorsYearsA.os (4226 . "~/leninist.biz/en/./1974/ETM165/.db") ;; (lb-search-sgml-comment t) => (3862 . "~/leninist.biz/en/./1966/ES187/.db") (save-match-data (let (lb-pf lb-pt lb-rc (lb-re-start (concat "") (setq lb-pt (point))) (cons lb-pt lb-pf)))))) (defun lb-mu-table-by-i-wrap-w-li (arg1i arg2table) "Return subset from table ARG2 if row starts with ARG1. ARG2 is something like ~/leninist.biz/en/.TITLE . Wrap results with LI tags. Preceed each observation with SGML comment containing source information NOTE: Does not include subtitle(s)...
  • Yellow Devil:, The
  • " ;; (lb-mu-table-by-i-wrap-w-li "b" (buffer-string)) (let (lb-pf lb-msnp0 lb-1st-char lb-rc) (save-match-data (with-temp-buffer (if (file-exists-p arg2table) (_-ifcl arg2table) (insert arg2table)) (goto-char (point-min)) ;; Delete titles that do not start with arg1i. (while (< (point) (point-max)) (if (and (not (string= (downcase arg1i) (downcase ;; In "es" titulo may start with ¿ ¿ (if (string= "?" (setq lb-1st-char (buffer-substring-no-properties (point) (1+ (point))))) (buffer-substring-no-properties (1+ (point)) (+ (point) 2)) lb-1st-char)))) ) (delete-region (point) (save-excursion (end-of-line) (1+ (point)))) (end-of-line) (forward-char 1))) ;; Wrap remaining titles, if any (starting with arg1i) with LI tag. (when (> (point-max) 1) (goto-char (point-min)) (while (< (point) (point-max)) (insert "\n") (save-excursion (insert "
  • ") (search-forward-regexp "[\t]\\([^\t\n]+\\)$") (setq lb-msnp0 (match-string-no-properties 0)) (replace-match "
  • ")) (insert "\n\n") (end-of-line) (forward-char 1))) (insert "\n\n") (setq lb-rc (buffer-string)))))) ;; (defun lb-mu-href-delete-pound-dead-ends nil " Deletes paragraphs like href='#...' - get list of href='#...' - get list of name='...' and id='...' - delete paragraphs using first list if no matching id= or name= " ;; (let (_pound-list _id-list _name-list _keep-list _str _re _rc) (goto-char (point-min)) (while (search-forward-regexp "href=\"#\\([^\"]+\\)\"" nil t) (if (not (_-sgml-comment-p)) (setq _pound-list (append _pound-list (list (match-string-no-properties 1)))))) ;; fix! isn't there a function that gets these? (goto-char (point-min)) (while (search-forward-regexp (concat "\\(name\\|id\\)" "=\"" "\\([^\"]+\\)\"") nil t) (setq _str (match-string-no-properties 1)) (if (not (_-sgml-comment-p)) (cond ((string= "name" _str) (setq _name-list (append _name-list (list (match-string-no-properties 2))))) ((string= "id" _str) (setq _id-list (append _id-list (list (match-string-no-properties 2)))))))) ;; Checks (loop for i in _id-list do (if (member i _name-list) (error "%s: %s" "In both lists" i))) (loop for i in _name-list do (if (member i _id-list) (error "%s: %s" "In both lists" i))) (loop for i in _pound-list do (if (or (member i _name-list) (member i _id-list)) (setq _keep-list (append _keep-list (list i))))) (loop for i in _pound-list do (if (not (member i _keep-list)) (while (or (search-backward-string (setq _re (concat "href=\"#" i "\"")) nil t) (search-forward-string _re nil t)) ;; Not removing whitespace to left! ;; (replace-match "") ;; Remove whole paragraph, to get "title=" too. (_-para-delete)))) _rc)) ;; (lb-mu-href-replace-uptree) (defun lb-mu-href-replace-uptree nil "If HREF= points to non-existing file, try to find one higher up in the tree. For example, when en/html/htmm/book.htmm is converted to .html must change titl.html to ../../titl.html ! No BASE element support (uses buffer-file-name for base)" ;; (_-dfun-hook "lb-mu-href-replace-uptree") (let (lb-pf lb-rc lb-str lb-str0 lb-str1 lb-list-midlings lb-href lb-mbeg lb-mend lb-test-link lb-missing-link lb-classvalue (lb-basedir (file-name-directory (bfn)))) (loop for i in '(".." "../.." "../../..") do (loop for j in (list "/" ;; Not logical: ;; (concat "/" lb-lang "/") ) do (setq lb-list-midlings (append lb-list-midlings (list (concat i j)))))) ;; Removed "edinplace-" (edit-in-place) from function names. ;; (unless (featurep 'lb-batch) (save-some-buffers)) (goto-char (point-min)) (while (and (search-forward-regexp (concat "href=/"\\([^#\"]+\\)") nil t) (progn (setq lb-mbeg (match-beginning 1)) (setq lb-mend (match-end 1)) (setq lb-href (match-string 1)) (setq lb-classvalue (_-sgml-attr-grab "class")) t)) (when (and (not (file-exists-p (concat lb-basedir lb-href))) (not (string-match "^\\(mailto\\|http\\):" lb-href)) ;; 2007.07.31 (not (_-sgml-comment-p)) ;; 2006.12.13 - htm/suggestion-box.en (not (looking-at "\"mailto")) ;; 2006.12.15 - ">" and ">>" and ">>>" files yet 2be created. (not (and lb-classvalue (or (string= "toc_page_number" lb-classvalue) (string= "sidebar-nav-arrow" lb-classvalue) (string= "footbar-nav-alpha" lb-classvalue)))) ) ;; Not found, and not a special case, so, keep going. (progn (setq lb-rc nil) (loop for lb-test-link in lb-list-midlings do (if (file-exists-p (setq lb-pf (concat lb-basedir lb-test-link lb-href))) (if (not (member lb-pf lb-rc)) (setq lb-rc (append lb-rc (list ;; MUST MAINTAIN SAME LENGTH (no collapse "..") ;; (command-line-normalize-file-name-then-some lb-pf))))))) (if (not lb-rc) (if (and (not (member lb-href lb-list-href-ok-not-file-exist)) (not (string-match "^__" lb-href))) (error "%s: %s" "Unable to resolve HREF (maybe touch it?)" (concat lb-href "\n" (_-buffer-substring-from-)) )) ;; Now lb-rc is a list, with one or more pathfiles... ;; ("~/leninist.biz/en/html/htmm/../../index.html" ;; "~/leninist.biz/en/html/htmm/../../../index.html") (if (and (> (length lb-rc) 1) (or ;; RETURN TRUE (error) if more than 2 in list. (not (= 2 (length lb-rc))) ;; If two items in list, maybe return one. ;; Get two items from list into variables. (and (setq lb-str0 (nth 0 lb-rc)) (setq lb-str (nth 1 lb-rc)) nil) ;; Swap if lb-str0 is not longer. (and (> (length lb-str) (length lb-str0)) (_-exchange-symbol-values 'lb-str 'lb-str0) nil) ;; RETURN NIL: ;; fix? (when nil ;; lb-str0 is longer. ;; If it has "/en/" will replacing that with "/" cause ;; both string to be equal? ;; If not, DONE (return TRUE). (or (not (string-match (concat "/" lb-lang "/") lb-str0)) (not (string= lb-str (replace-match "/" nil nil lb-str0)))) nil) )) (error "%s: %s" "More than one HREF found" (prin1-to-string lb-rc)) (goto-char lb-mbeg) (delete-region lb-mbeg lb-mend) (insert (substring (car lb-rc) (length lb-basedir))))))) )) ;; (defun lb-naletov-gen-html-includes (arg1pf) "" ;; (let (lb-str lb-pf) (goto-char (point-min)) (while (search-forward-regexp (concat "##" "\\([^ \t\n]+\\)" "##") nil t) (setq lb-pf (concat (file-name-directory arg1pf) (match-string 1))) (replace-match (with-temp-buffer (_-ifcl lb-pf) (lb-naletov-gen-html-includes lb-pf) ;; RECURSIVE. (buffer-string)))))) ;; (defun lb-mu-recursive-replace (arg1in &optional arg2implied-dot) " If ARG2 is non-nil, only process placeholders of type '##foo##' where 'foo' does not start with '.'" ;; (let ( lb-beg0 lb-beg01 lb-beg1 lb-end0 lb-end1 lb-fly-beg lb-fly-end lb-msnp1 lb-pf lb-pf-chunk lb-pf-chunk-dir lb-pf-chunk-dotdot lb-str _rc) ;; 2006.12.28 - lb-mu-recursive-replace _> lb-mu-recursive-replace-inplace ;; 2006.12.28 - guts moved here. (goto-char (point-max)) (while (and (search-backward-regexp lb-re-sgml-include-chunk nil t) (setq lb-beg0 (match-beginning 0)) (setq lb-end0 (match-end 0)) (setq lb-msnp1 (match-string-no-properties 1))) (when (not (_-sgml-comment-p)) ;; fixed! ;; In en/html/htmm/book.htmm changed: ;; ##../../../htm/ ;; to: ;; ##../htm/ ;; and this stopped working... SHOULD prepend "../" in effort to find it. ;; (setq arg1in "~/leninist.biz/en/html/htmm/book.htmm") ;; (setq lb-msnp1 "../htm/sidebar-ALL.en") (setq lb-pf-chunk-dotdot "") (while (and (not (file-exists-p (setq lb-pf-chunk (concat (unless (or (string= "/" (substring lb-msnp1 0 1)) (string= "~" (substring lb-msnp1 0 1))) (file-name-directory arg1in)) lb-pf-chunk-dotdot lb-msnp1)))) ;; Too many ../ will cause first member to be "..". (not (string= ".." (nth 0 (split-string (expand-file-name lb-pf-chunk) "/"))))) (setq lb-pf-chunk-dotdot (concat "../" lb-pf-chunk-dotdot))) ;; Cannot find it. (if (not (file-exists-p lb-pf-chunk)) (error "%s: %s" "File not found" lb-pf-chunk)) (setq lb-str (with-temp-buffer (_-ifcl lb-pf-chunk) ;; ON-THE-FLY. ;; Recursion inside of temporary buffer containing chunk. (while (lb-mu-recursive-replace lb-pf-chunk)) ;; Delete certain chunks. ;; E.g., htm/_multilingual-ledger.htmm ;; ;;2 lines matching "lb-mu" in buffer _multilingual-ledger.htmm. ;; 58: ;; 121: (progn (goto-char (point-max)) (when (search-backward-regexp (string-match-substitute "AAAAAAAA" "END" lb-re-lb-mu-recursive-replace) nil t) (setq lb-fly-end (match-beginning 0)) (if (not (search-backward-regexp (string-match-substitute "AAAAAAAA" "BEG" lb-re-lb-mu-recursive-replace) nil t)) (error "%s: %s" "ERROR" lb-re-lb-mu-recursive-replace) (setq lb-fly-beg (match-end 0)) (delete-region lb-fly-end (point-max)) (delete-region (point-min) lb-fly-beg)))) ;; Done with on-the-fly. (buffer-string))) ;; Substitution. (goto-char lb-beg0) (delete-region lb-beg0 lb-end0) (insert lb-str))) ;; Recurse? (goto-char (point-max)) (if (and (search-backward-regexp lb-re-sgml-include-chunk nil t) (not (_-sgml-comment-p))) ;; Recurse! (setq _rc t) ;; Delete "mode:fundamental" (otherwise some hooks may not work). (lb-sgml-scrub-local-variables)) _rc)) (defun lb-mu-recursive-replace-inplace (arg1in arg2out) "Inserts file ARG1 into temporary buffer. Substitutes strings matching lb-re-sgml-include-chunk in markup with contents of file named inbetween '##FILE##'. FYI: lb-re-sgml-include-chunk => ##\\([^#]+\\)## Writes buffer out to ARG2" ;; (_-dfun-hook "lb-mu-recursive-replace-inplace") (let ( _rc) (with-temp-buffer (_-ifcl arg1in) (lb-mu-recursive-replace arg1in) (write-region (point-min) (point-max) arg2out)) _rc)) (defun lb-mu-htmm-to-html-random (arg1pf) "" (_-dfun-hook "lb-mu-htmm-to-html-random") ;; ;; fix? ;; Just refresh if more than 24 hours old? (let (lb-pf) (if (string-match (substring (int-to-string (random)) 1 2) "13579") ;; "159" is 3 times out of 10. (lb-mu-make-webpage arg1pf)))) (defun lb-mu-spawn-finale (&optional arg1letter arg2lang arg3list-funcs arg4nosub) "Final SGML/HTML editing to a buffer associated with its disk file using (save-buffer/kill-buffer). Optional ARG1 is a letter to turn pink. Optional ARG2 is a language such as 'es', 'en'. Optional ARG3 is a list of functions to call: - lb-ht-gen-del-self-href - Optional ARG4, if non-nil, prevents lb-ht-subs-and-dels-__ " (_-dfun-hook "lb-mu-spawn-finale") ;; (lb-mu-spawn-finale i) ;; (lb-mu-spawn-finale) (let (lb-pf _rc) (if (not arg2lang) (setq arg2lang lb-lang)) (setq lb-pf (bfn)) ;; fix? ;; Do this each time? (_-sgml-scrub) ;; fix? ;; Do this each time? (lb-sgml-scrub arg1letter arg2lang) (progn (lb-time-stamp-format) ;; Suppress username from time-stamp. (run-hooks 'local-write-file-hooks)) ;; Always update time-stamp at top of file. ;; Always update file-stamp at bot of file. (progn (set-buffer-modified-p t) (lb-write-file-hook-sgml-stamps-visible t) (time-stamp)) ;; 2006.11.27 - Makes sense to call tex2html from here, but, can it wait? (_-tex2html) ;; (when (or ;; 2006.12.14 - when would (bfn) be nil? ;; (not lb-pf) ;; fix! what other templates go here? (not (string-match "/book" lb-pf)) ;; a template! ) (if (not arg4nosub) (lb-ht-subs-and-dels-__)) ;; ;; 2007.08.07 - OFF ;; (lb-ht-gen-del-self-href) ;; AFTER subs-and-dels ! (lb-ht-gen-wrap-arrows-without-hrefs-span-disappear) ;; Modify non-existing HREFs. (lb-mu-href-replace-uptree) ;; ;; Delete non-existing "#foo" HREFs. ;; 2007.08.07 - OFF ;; (lb-mu-href-delete-pound-dead-ends)) ) ;; (lb-mu-symbolic-link-alternator) ;; 2007.01.01 (lb-mu-error-if-string-found) ;; 2007.04.11 (goto-char (point-min)) (while (sfr "\\^\\^[0-9]+\\^\\^" nil t) (replace-match (concat "" (match-string-no-properties 0) ""))) ;; 2007.08.07 - This was too early; why _-highascii2html_entities didn't work. (loop for item in arg3list-funcs do (eval (list item))) (lb-mu-hey-rocky) ;; (cmn) (save-buffer 0) (kill-buffer nil) _rc)) ;; (lb-mu-error-if-string-found) (defun lb-mu-error-if-string-found nil " Impotent. " (_-dfun-hook "lb-mu-error-if-string-found") (let ( _rc) (loop for pair in (list (cons "tttttttttext/javascript" "SEE http://www.ietf.org/rfc/rfc4329.txt") ;; ) do (goto-char (point-min)) (if (search-forward-string (car pair) nil t) (error "%s: %s" (car pair) (cdr pair)))) _rc)) ;; (lb-mu-symbolic-link-alternator) (defun lb-mu-symbolic-link-alternator nil "Handle optional strings in symbolic linked files. Delete paragraphs where 'FN' in ->->FN->->text->-> does not match beginning of filename. If matched, delete everything surrounding text" ;; (let (_cnt (_fn (file-name-sans-directory (bfn))) _fn-starter _rc) (goto-char (point-min)) (while (search-forward-regexp (concat "\n" _-whitespace-wM "*" "\n" _-whitespace-wM "*" "->->") nil t) (when (= 2 (save-excursion (setq _cnt 0) (while (search-forward-string "->->" (cdr (_-where-double-newlines)) t) (setq _cnt (1+ _cnt))) _cnt)) (setq _fn-starter (buffer-substring-no-properties (point) (- (search-forward-string "->->") 4))) (if (or (> (length _fn-starter) (length _fn)) (not (string= _fn-starter (substring _fn 0 (length _fn-starter))))) (_-para-delete) ;; (delete-region (car (_-where-double-newlines t)) (point)) (search-forward-string "->->") (replace-match ""))) ;; May be two consecutive. (_-move-backward-whitespace)) _rc)) ;; (defun lb-mu-hey-rocky nil "" ;; (let (_rc) ;; 2006.12.06 (progn (goto-char (point-max)) (when (search-backward-regexp (concat "class=.self-url.>http://\\(leninist.biz\\)/") nil t) (replace-match (concat "" (match-string-no-properties 1) "") t t nil 1))) _rc)) (defun lb-mu-gen-del-all-but-first-letter nil "NOT IN USE. BAD IDEA. Shorten some links to first letter if before
    " ;; (let (lb-rc) ;; ;; '("MAIL" "FAQ" "NEWS" "HOME") (loop for lb-item in '("Titles" "Authors" "Years" "ASCII" "HTML" "PS" "PDF") do (goto-char (point-max)) (search-backward-regexp "
    ") (when (search-backward (concat ">" lb-item "<") nil t) (replace-match (concat ">" (substring lb-item 0 1) "<")) (search-backward-regexp (concat "")) (replace-match (concat "sidebar-1-letter") t t nil 1))))) ;; (lb-mu-htmm-to-html (concat "~/" lb-domain "/index.htmm")) ;; (lb-mu-htmm-to-html (concat "~/" lb-domain "/en/HTML.htmm")) ;; (lb-mu-htmm-to-html (concat "~/" lb-domain "/es/T.htmm") t) (defun lb-mu-htmm-to-html (&optional arg1pf arg2nosub) "Create X from X.htmm by inserting data that is subject to change. DO NOT USE THIS FUNCTION! ... use lb-mu-make-webpage instead" (_-dfun-hook "lb-mu-htmm-to-html") ;; (interactive) (let (lb-pf-out lb-msnp0 lb-msnp1 (lb-current-buffer (current-buffer)) lb-rc) (save-excursion (save-match-data ;; fix? when? [f2 f9] ? if so, revert buffer! (when (not arg1pf) ;; Interactive; (bsb) (setq lb-ht-__ nil) (setq arg1pf (bfn))) (save-some-buffers) (if (string-match (concat "[.]" lb-ext-htmm "$") (setq lb-pf-out arg1pf)) (setq lb-pf-out (concat (file-name-sans-extension lb-pf-out) "" lb-ext-html)) (error "%s: %s" "File must end with 'htmm'" lb-pf-out)) ;; 2006.11.17 (if (string-match "index$" lb-pf-out) (setq lb-pf-out (concat lb-pf-out ".html"))) ;; wdiff then delete. (progn ;; Prepare for wdiff. (if (lb-get-id-from-path lb-pf-out t) (lb-wdiff lb-pf-out "beg")) ;; Delete. (if (not (file-exists-p arg1pf)) (error "%s: %s" "File not found" arg1pf) (if (file-exists-p lb-pf-out) (delete-file lb-pf-out)))) ;; Create file and insert chunks recursively. (lb-mu-recursive-replace-inplace arg1pf lb-pf-out) ; RECURSION. ;; (find-file lb-pf-out) ;; -literally ;; Change href="#index.txt" to href="Text" (when (string-match (concat lb-re-lang "/[^/]+$") lb-pf-out) (goto-char (point-min)) (while (search-forward-regexp (concat "href=\"\\(#" lb-file-txt "\\)\"") nil t) (if (not (_-sgml-comment-p)) (replace-match ;; fix! cannot remember how to program this: (lb-get-diskfilename "Text" nil nil t) t t nil 1)))) ;; 2006.12.20 - we have general functions for this. (when nil ;; 2006.12.14 - delete 'href="../index.html"' (when (string-match (concat lb-domain "/index.html") lb-pf-out) (goto-char (point-min)) (while (search-forward-regexp "href=\"[^\"]*index.html\"" nil t) (_-para-delete)))) ;; fix? ;; BAD IDEA. ;; What is in ~/leninist.biz/htm/*.en should be it. (when nil (if (string-match (concat "/book[.]" lb-ext-htmm "$") arg1pf) (lb-mu-gen-del-all-but-first-letter)) ) (lb-mu-spawn-finale nil nil nil arg2nosub) ;; Wdiff. (if (lb-get-id-from-path lb-pf-out t) (lb-wdiff nil "end")) (setq lb-rc lb-pf-out))) (if arg1pf (set-buffer lb-current-buffer)) lb-rc)) (defun lb-mu-gen-link-AZ-19 (arg1pf) "" ;; (let (lb-year lb-title-abbrev _rc) (save-excursion (when (and (string-match lb-re-path-year+book arg1pf) (setq lb-year (match-string-no-properties 2 arg1pf)) (setq lb-title-abbrev (match-string-no-properties 3 arg1pf))) (goto-char (point-min)) ;; Titles (while (search-forward-string (concat "/" "T" ;; "t" "" lb-ext-html) nil t) (when (and (_-sgml-markup-p) (string= "a" (_-sgml-what-element))) (replace-match (concat "/T" ;; "/t" (downcase (substring lb-title-abbrev 0 1)) "" lb-ext-html "#" lb-title-abbrev "." lb-year)))) ) ) _rc)) (defun lb-sgml-insert-hyperlink-next-letter (arg1i) "Maybe insert hyperlink for next letter" ;; (let (lb-pf lb-re lb-cons lb-str) (when (< (string-to-char arg1i) 90) ;; z=122 ;; Z=90 ;; Grab paragraph for next letter from div id="header". (save-excursion (search-backward-regexp (setq lb-re (concat ">\\(" (upcase (char-to-string ;; Next letter: (1+ (string-to-char arg1i)))) "\\)<"))) (setq lb-str (buffer-substring-no-properties (car (setq lb-cons (_-where-double-newlines))) (cdr lb-cons)))) ;; Add space around letter (progn (string-match lb-re lb-str) (setq lb-str (replace-match (concat " " (match-string-no-properties 1 lb-str) " ") t t lb-str 1))) (insert "Next: " (if (string-match (concat "") lb-str) (setq lb-str (replace-match (concat (match-string 1 lb-str) "-backcolor") t t lb-str 1)) lb-str) "\n\n")))) ;; (lb-mu-insert-ascii) (defun lb-mu-insert-ascii nil "Insert human-readable table in place of %%data%%" ;; (lb-mu-spawn-formats "text") (let (lb-rc) (lb-mu-insert-human-readable-table "ascii" "TEXT"))) ;; (lb-mu-insert-html) (defun lb-mu-insert-html nil "foo" ;; (lb-mu-spawn-formats "html") (let (lb-rc) (lb-mu-insert-human-readable-table "html" "HTML"))) (defun lb-mu-insert-human-readable-table (arg1type arg2visible-type) "Insert
    foo" ;; (let ;; all these from: lb-mu-insert-titles-by-letter (lb-pf lb-re lb-cons lb-str lb-path lb-author lb-msnp0 lb-dir0 lb-dir1 lb-dir2 lb-lb-id lb-.index lb-href) (setq arg1type (upcase arg1type)) ;; ;; Position for insertion. (goto-char (point-min)) (if (not (setq lb-cons (_-flush-one-paragraph "%%data%%" t nil))) (error "%s: %s" "Not found" "%%data%%") (goto-char (car lb-cons))) ;; (insert "\n\n\n\n") (insert (with-temp-buffer (insert (cond ((string= "ASCII" arg1type) (lb-list-index-text lb-lang)) ((string= "HTML" arg1type) (lb-list-index-html lb-lang)) ((string= "PS" arg1type) (lb-list-index-ps lb-lang)) ((string= "PDF" arg1type) (lb-list-index-pdf lb-lang)) (t (error "%s: %s" "Unknown type" arg1type)))) ;;;/home/login/leninist.biz/en/1987/WHM294/index.html ;;;/home/login/leninist.biz/en/1989/HCM242/index.html ;;;/home/login/leninist.biz/en/1990/MCS295/index.html ;;; 2007.07.31 - weird error: ;;; lb-pf _> "find: /home/cymbala/leninist.biz/en/.#HTML: No such file or directory" (goto-char (point-min)) (while (< (point) (point-max)) (setq lb-pf (_-current-line)) (delete-region (point) (search-forward (concat "/"lb-lang"/"))) (setq lb-href (_-current-line)) (insert "\n\n\n" ;; "" "\n" ) (insert "\n") (insert "\n") (insert "\n\n") (end-of-line) (forward-char 1)) ;; END while. (buffer-string))) (insert "\n\n
    " (lb-get-year-from-path lb-pf) "" "" arg2visible-type "" "" ;; 2006.12.20 (with-temp-buffer (insert (lb-db-__-title-normalize (lb-db-__-get- "TITLE" (concat (file-name-directory lb-pf) lb-file-db) nil (list "<<")))) ;; Change <> to link to HTML. (when (string= "ASCII" arg1type) (goto-char (point-min)) (while (search-forward-string "<<" nil t) (replace-match (concat "")) (search-backward-regexp "[.][a-zA-Z]+") ;; Assuming it is "index.txt". (replace-match (concat "." lb-ext-html "html")) (search-forward-string ">>") (replace-match ""))) (buffer-string))) (if (setq lb-str (lb-db-__-get- "SUBTITLE" (concat (file-name-directory lb-pf) lb-file-db))) (insert " " (lb-db-__-title-normalize lb-str))) ;; 2006.12.05 (if (setq lb-str (lb-db-__-get- "SUBTITLE2" (concat (file-name-directory lb-pf) lb-file-db))) (insert " " (lb-db-__-title-normalize lb-str))) (insert "
    \n\n"))) ;; (lb-mu-insert-titles-by-letter "A" t) (defun lb-mu-insert-titles-by-letter (arg1i &optional arg1authors) "ARG1 is a letter, 'A' through 'Z'. This inserts TITLES and PERSON data into [AT]A through [AT]Z by finding '%%data%%' and replacing it with the data. Do titles first because authors can be ambiguous. ARG1 is passed to lb-mu-table-by-i-wrap-w-li. Optional ARG2 is a flag: lb-mu-spawn-authdata-by-letter ARG1" ;; (let (lb-pf lb-re lb-type lb-cons lb-str lb-path lb-author lb-msnp0 lb-dir0 lb-dir1 lb-dir2 lb-lb-id lb-.index lb-str-index-html lb-href lb-pt lb-rc) (setq lb-type "t") ;; Position for insertion. (goto-char (point-min)) (if (not (setq lb-pt (car (_-flush-one-paragraph (setq lb-str "%%data%%") t nil)))) (error "%s: %s" "Did not find" lb-str) (goto-char lb-pt) (insert "\n\n
      \n\n")) ;; Which HTML books exist? (setq lb-str-index-html (lb-list-index-html lb-lang)) ;; Insert titles, wrapped by LI element, that start with letter i. (insert ;; wrapper insert table. (with-temp-buffer (insert (lb-mu-table-by-i-wrap-w-li arg1i (lb-db-__-table "TITLE" (lb-get-diskfilename ".db.list" nil t) nil) ;; => ~/leninist.biz/en/.TITLE ;;; About Lenin: ~/leninist.biz/en/./1980/AL9/.db ;;; Across the Soviet Union: ~/leninist.biz/en/./1979/ASU9/.db ;;; Actors Without Makeup ~/leninist.biz/en/./1977/AWM9/.db ) ) (goto-char (point-min)) ;;; ;;; ;;;
    • Badges and Trophies in Soviet Sports
    • ;;; ;;; ;;; ;;;
    • Basic Economic Law of Modern Capitalism, The
    • (while (and (setq lb-cons (lb-search-sgml-comment)) (goto-char (car lb-cons)) (progn (setq lb-pf (cdr lb-cons)) (setq lb-dir0 (nth 0 (lb-db-__-get- "YEAR" lb-pf))) (setq lb-dir1 (nth 1 (lb-db-__-get- "YEAR" lb-pf))) (setq lb-dir2 (nth 2 (lb-db-__-get- "YEAR" lb-pf))) (setq lb-lb-id (concat ;; lb-dir0 "." (REDUNDANT.) ;; lb-dir1 "." lb-dir2 ;;; nsgmls:ta.html:183:8:E: value of attribute "id" invalid: "1" cannot start a name lb-dir2 "." lb-dir1 )) t)) (search-forward "
    • ") (replace-match (concat "
    • ")) (insert "") ;; Hyperlink title. ;; (setq lb-dir2 "AP470") ;; (setq lb-dir1 "1984") (if (string-match (concat "/" lb-lang "/" "\\(" ;; fix? ;; where is lb-file-indexhtml coming from? lb-dir1 "/" lb-dir2 "/" lb-file-indexhtml "\\)") lb-str-index-html) (insert "") (setq lb-href nil)) ;; ;; Discard
    • since subtitle(s) need to be added. (progn (search-forward "") (replace-match "\n") (if lb-href (save-excursion (search-backward "<") (insert "")))) (insert ;; wrapper0. (concat ;; wrapper1. ;; (if (setq lb-str (lb-db-__-get- "SUBTITLE" lb-pf)) (concat "\n
      " lb-str)) (if (setq lb-str (lb-db-__-get- "SUBTITLE2" lb-pf)) (concat "\n
      " lb-str)) ;; (concat "\n
      " ;; Align right. "" ;; Publisher. "" "
    " ;; ;; CHUNK - part a of B. (when nil ;; When book not online. "     " "" ;; "" (setq lb-path (concat "" "" ;; lb-dir0 " / " (REDUNDANT.) lb-dir1 " / " lb-dir2)) " /" "") ;; CHUNK - part b of B. (when nil ;; Link space after last "/" to .index " " ;; " ") "\n" (when t (concat "" "donated:")) " •" "   " ;; Current donation level (when t (concat "" " $0 " "")) "
    \n\n") ;; Name data, such as "Who" and "Transl". (progn (setq lb-cons (lb-db-__-get- "NAMEDATA" lb-pf)) ;; NO (when nil (setq lb-cons (cons (car lb-cons) (lb-db-__-namedatum-normalize (cdr lb-cons))))) (if (not (equal '("AUTHOR") (car lb-cons))) " " " ")) ;; ? (with-temp-buffer (insert (_-compress-delete-whitespaces (cdr lb-cons) nil)) (goto-char (point-max)) (insert "\n\n") (while (search-backward-regexp lb-re-__ nil t) (insert "\n\n")) (buffer-string)) "\n\n
     
    " "\n\n\n"))) (buffer-string))) ;; (insert "\n\n\n\n") (lb-sgml-insert-hyperlink-next-letter arg1i) ;; (if arg1authors (lb-mu-spawn-authdata-by-letter arg1i)) lb-rc)) (defun lb-mu-insert-authors-by-letter (arg1i) "This creates AA through AZ from files TA-authors.tab through TZ-authors.tab" (let ( lb-type lb-lag-person lb-list lb-str) (setq lb-type "a") ;; Position for insertion. (goto-char (point-min)) (goto-char (car (_-flush-one-paragraph "%%data%%" t nil))) (insert "\n\n\n\n") (insert (with-temp-buffer (_-ifcl (lb-db-__-table "PEOPLE" (lb-get-diskfilename ".db.list" nil t) nil)) (goto-char (point-min)) ;; fix! ;; What if first letter is accented in Spanish? (flush-lines (concat "^" "[" "^" (upcase arg1i) "]")) ;; Brezhnev (L.I.) WHO ~/leninist.biz/en/./1975/FLC9/.db ;; Brezhnev (L.~I.) WHO ~/leninist.biz/en/./1973/YR319/.db ;; Brezhnev, L. I. WHO ~/leninist.biz/en/./1975/CSU9/.db (while (< (point) (point-max)) (setq lb-list (split-string (_-current-line) "\t")) (delete-region (point) (search-forward "\n")) (insert "\n\n\n" ;; Width of 1st column determined by class= (default.css). ;; Width of 2nd column is padded with "~". ;; NOTE: AJ is a bit off. ;; Person. "" (if (and lb-lag-person (string= (nth 0 lb-list) lb-lag-person)) "  ”" ;; ditto (same author as above). (nth 0 lb-list)) "\n" ;; Type of person. "\n" ;; Title. "\n" "\n\n" ) (setq lb-lag-person (nth 0 lb-list))) (buffer-string))) (insert "\n\n
    " (progn (setq lb-str (nth 1 lb-list)) ;; Pad shorter strings with "~" ("~" changes to " "). (while (< (length lb-str) lb-max-chars-who-fields-names) (setq lb-str (if (oddp (length lb-str)) (concat "~" lb-str) (concat lb-str "~")))) lb-str) "" ;; fix? Will long titles wrap alot in 3rd column? (lb-db-__-title-normalize (lb-db-__-get- "TITLE" (expand-file-name (nth 2 lb-list))))) ;; ;; Could be nil, therefore, this cannot be inside (insert (if (setq lb-str (lb-db-__-get- "SUBTITLE" (expand-file-name (nth 2 lb-list)))) (insert " " (lb-db-__-title-normalize lb-str))) ;; 2006.12.05 (if (setq lb-str (lb-db-__-get- "SUBTITLE2" (expand-file-name (nth 2 lb-list)))) (insert " " (lb-db-__-title-normalize lb-str))) (insert "
    \n\n") ;; (insert "\n\n
     \n\n") ;; Matches one just before table. (lb-sgml-insert-hyperlink-next-letter arg1i))) ;; (lb-mu-make-webpage "book") ;; (lb-mu-make-webpage "volume") (defun lb-mu-make-webpage (arg1type &optional arg2lang arg3nosub) "Use .htmm of type ARG1 for language (lb-lang) to create a webpage --- with no .html extension. Returns return value from lb-mu-htmm-to-html" (let ( lb-rc) (if (not arg2lang) (setq arg2lang lb-lang)) ;; OLD METHOD: (when nil ;; 2006.11.17 - index.html is a symbolic link to (xxTAZxx) sitemap. (when nil (lb-mu-htmm-to-html (concat "~/" lb-domain "/index.htmm"))) ;; (lb-mu-make-webpage "aaaaaaaa" "es") (lb-mu-make-webpage "taz" "es") (lb-mu-make-webpage "index" "es") ;; (lb-mu-make-webpage "texto" "es") (lb-mu-make-webpage "html" "es") (lb-mu-make-webpage "pdf" "es") (lb-mu-make-webpage "ps" "es") ;; ;; ... ;; ... ;; ... ) ;; All .htmm should exist. (loop for cons in lb-assoc-htmm do (if (not (file-exists-p (setq lb-rc (concat "~/" lb-domain "/" (cdr (assoc arg2lang (cdr cons))))))) (error "%s: %s" "File not found" lb-rc))) ;; DEPENDENCIES. (if (string= "ledger" arg1type) (lb-mu-make-webpage "multilingual-ledger")) (setq lb-rc (lb-mu-htmm-to-html (lb-get-diskfilename arg1type arg2lang t) arg3nosub)) ;; fix! ;; These must be populated. ;; (lb-mu-spawn-formats "html") ;; (lb-mu-spawn-formats "text") lb-rc)) ;; (lb-mu-spawn-formats "html") ;; (lb-mu-spawn-formats "text") (defun lb-mu-spawn-formats (arg1type) "This creates HTML, Text, etc." (_-dfun-hook "lb-mu-spawn-formats") ;; ;; (lb-mu-spawn-formats "text") ;; (lb-mu-spawn-formats "html") (let (lb-pf _rc) (setq arg1type (upcase arg1type)) (lb-mu-make-webpage arg1type) (progn ;; Create new file and update stamps. (set-buffer (lb-mu-set-n-return-buffer-x arg1type)) ;; ;; HERE in lb-mu-spawn-x-by-letter: "Change TITLE element" ;; NOTHING TO CHANGE. No sub-files. ) ;; (cond ((string= "TEXT" arg1type) (lb-mu-insert-ascii)) ((string= "HTML" arg1type) (lb-mu-insert-html)) ((string= "PS" arg1type) (lb-mu-insert-ps)) ((string= "PDF" arg1type) (lb-mu-insert-pdf)) ((string= "AAAAAAAA" arg1type) (lb-mu-insert-x)) (t (error "%s: %s" "Invalid choice" arg1type))) ;; ;; (lb-mu-spawn-finale nil nil (list 'lb-ht-gen-del-%%notes%% )) _rc)) (defun lb-mu-spawn-x-by-letter-online-up-top (&optional arg1) "Arrange list of ebooks so ones with hyperlinks to HTML are on top" ;; (let (lb-pt-beg lb-pt-end lb-str-li-online _rc) ;; Harvest "records" with index.html . (goto-char (point-max)) (search-backward "" nil t) (progn (beginning-of-line) (point))))) (when (save-excursion (search-forward (concat "/" lb-file-index "" lb-ext-html) lb-pt-end t)) (setq lb-str-li-online (concat (buffer-substring-no-properties lb-pt-beg lb-pt-end) lb-str-li-online)) (delete-region lb-pt-beg lb-pt-end))) (progn (search-backward "\n" "\n" lb-str-li-online "\n" " \n" "\n"))) ;; ... (defun lb-mu-spawn-x-by-letter ;; ... ... (set-buffer (lb-mu-set-n-return-buffer-x arg1type i)) (lb-mu-recursive-replace (bfn))) _rc)) ;;; SEE SEE lb-batch.el: (lb-mu-spawn-x-by-letter "titl" lb-AZ) ;;; OR, just one letter: (lb-mu-spawn-x-by-letter "titl" "C") ;;; OR, just one letter: (lb-mu-spawn-x-by-letter "auth" "A") (defun lb-mu-spawn-x-by-letter (arg1type arg2az) "This creates XA (was xa.html) through XZ where 'X' is 'T' for titles, 'A' for authors, '19' for years, etc. ARG1 is type ('T' or 't' or 'titl' for titles, etc.) ARG2 is string of letters to process (see lb-az) Optional ARG3, if t, will execute lb-mu-spawn-authdata-by-letter also" (_-dfun-hook "lb-mu-spawn-x-by-letter") ;; (let (lb-x lb-pf lb-rc) (lb-assoc-__-PUBL) ;; fix? ;; What other dependent files should be emptied/erased? (lb-mu-make-webpage "TAZ") ;; Muy importante. ;; (lb-mu-htmm-to-html "~/leninist.biz/en/taz.htmm") ;SEE lb-mu-spawn-taz- (cond ;; Make template "T" before creating "TA" thru "TZ". ((string= "T" (upcase (substring arg1type 0 1))) (lb-mu-make-webpage "titl")) ((string= "A" (upcase (substring arg1type 0 1))) (lb-mu-make-webpage "auth")) ((or (string= "Y" (upcase (substring arg1type 0 1))) (string= "19" arg1type)) (lb-mu-make-webpage "year")) (t (error "%s: %s" "Invalid choice" arg1type))) (when (string= arg2az lb-AZ) ;; 2007.01.02 (setq lb-ht-__ nil) ;; TO-DO: (_-delete-paragraph-from-file "%%data%%" ;; (lb-mu-template-get- "y") (lb-mu-make-webpage "year") ) ;; fix! ;; Forgot to add "why". ;; So, loop over lb-assoc-htmm and run lb-mu-make-webpage on each one! ;; So, or, loop over list of *.htmm from disk. (lb-mu-make-webpage "a" nil t) (lb-mu-make-webpage "t" nil t) ;; fix! why "year" above? (lb-mu-make-webpage "19" nil t) (lb-mu-make-webpage "faq") (lb-mu-make-webpage "text") (lb-mu-make-webpage "html") (lb-mu-make-webpage "ps") (lb-mu-make-webpage "pdf") ;; (lb-mu-make-webpage "mail") (lb-mu-make-webpage "ledger") (lb-mu-make-webpage "links") (lb-mu-make-webpage "news") (lb-mu-make-webpage "why") (lb-mu-make-webpage "sitemap")) ;; (loop for i in (split-string arg2az "") ;; arg2az can be lb-AZ or lb-az. do ;; Create new file and update stamps. Insert data. (progn ;; Set buffer to, e.g., "TA" when 1starg="titl" and 2ndarg="A". (set-buffer (lb-mu-set-n-return-buffer-x arg1type i)) (setq lbg-path-from-lang (progn (setq lb-pf (bfn)) (string-match (concat ".*/" lb-lang "/") lb-pf) (setq _str (replace-match (concat lb-lang "/") t t lb-pf)))) (setq __TITLE__ "") (setq __SUBTITLE__ "") (setq __SUBTITLE2__ "") (lb-ht-common-__) (__handler "PUT" "TITLE_ELEMENT_SORT_BY_PATH" lbg-path-from-lang) (lb-wdiff (bfn) "beg") (when nil ;; fix! ;; Currently only handles English. ;; Change TITLE element. (progn (goto-char (point-min)) (search-forward-regexp (concat "\\(Titles\\|Authors\\)" "\\( \\)" ;; change this space. "(English)")) (replace-match (concat " ( " (upcase i) " ) ") t t nil 2)) ) (cond ((string= "titl" arg1type) (lb-mu-insert-titles-by-letter i t)) ((string= "auth" arg1type) (lb-mu-insert-authors-by-letter i)) (t (error "%s: %s" "Invalid" arg1type)))) ;; (when (string= "titl" arg1type) ;; 2006.12.28 (goto-char (point-min)) (while (search-forward-regexp (concat "href=\"[AT]" i "\"") nil t) (search-backward-string "")) (insert "•")) (goto-char (point-max)) (if (search-backward "")) (setq lb-pf (cdr (lb-search-sgml-comment t)))) (when (or (string= "author" lb-msnp1) (string= "namedata" lb-msnp1)) (while (and (goto-char (cdr (_-where-double-newlines))) (search-forward-regexp "[^ \t\n]") (or (forward-char -1) t) (looking-at (concat lb-re-__ "[ \t\n]+")) (setq lb-tag (match-string-no-properties 1)) ;; Delete __TAG__. (or (replace-match "") t)) (setq lb-cols23 (concat "\t" lb-tag "\t" lb-pf "\n")) (setq lb-pt nil) (goto-char (cdr (_-where-double-newlines))) (while (search-backward ">>" (car (_-where-double-newlines)) t) (replace-match "") (setq lb-pt (- (point) 2)) (search-backward "<<") (replace-match "") (setq lb-str (buffer-substring-no-properties (point) lb-pt)) (delete-region (point) lb-pt) (setq lb-pt (point)) (insert (lb-db-__-namedatum-normalize lb-str)) (_-append-to-buffer lb-buf lb-pt lb-cols23)) ;; This __FIELD__ does not have <<>> around name(s). (unless lb-pt (progn (goto-char (car (setq lb-cons (_-where-double-newlines)))) (setq lb-str (buffer-substring-no-properties (car lb-cons) (cdr lb-cons)))) ;; 1of2 (delete-region (car lb-cons) (cdr lb-cons)) (setq lb-pt (point)) (insert (lb-db-__-namedatum-normalize lb-str)) (_-append-to-buffer lb-buf lb-pt lb-cols23)) ;; Insert "Tag:" (unless (string= "AUTHOR" lb-tag) (goto-char (car (_-where-double-newlines))) (insert "" (upcase-initials (downcase lb-tag)) ": "))))) (save-excursion (setq lb-pf (current-buffer)) (set-buffer lb-buf) (save-buffer 0) ;; T[A-Z]-authors.tab (kill-buffer nil) (switch-to-buffer lb-pf)))) ;; (lb-mu-spawn-taz-) (defun lb-mu-spawn-taz- (&optional arg1lang) "Create taz.html" (_-dfun-hook "lb-mu-spawn-taz-") (let (my-href my-msnp-tz my-msnp1 lb-cons my-id lb-str lb-re lb-rc) (if (not arg1lang) (setq arg1lang lb-lang)) ;; fix! ;; Mimic
      with a 3-column table: ;; 1: dot ;; 2: first letter ;; 3: title BECAUSE SOME TITLES WRAP (need better indentation). (set-buffer (find-file-literally (setq lb-rc (lb-mu-make-webpage "taz" arg1lang)))) ;; Position for insertion. (progn (goto-char (point-min)) (goto-char (car (_-flush-one-paragraph "%%data%%" t nil)))) (insert (with-temp-buffer (shell-command (concat "egrep -Hi 'li id=\"" ;; Remove escaped parentheses from expression: (_-re-del-emacs lb-re-path-book-titlpgs) "[.]" (_-re-del-emacs lb-re-path-folder_year) "\"" "'" " " lb-home arg1lang "/" ;; "?" means any single character after "T". "T?" "" lb-ext-html ) t) ;; 2006.12.22 - sort. (goto-char (point-max)) (setq lb-re (concat "[^<]+" ;; Whole title "[<]")) (while (search-backward-regexp "[a-zA-Z]+" nil t) (if (not (_-sgml-cdata-p)) (search-backward-string "<") (search-backward-string ">") (forward-char 1) (looking-at lb-re) (setq lb-str (match-string 0)) (beginning-of-line) (insert lb-str) (beginning-of-line))) (sort-lines nil (point-min) (point-max)) ;; Remove sort field. (goto-char (point-min)) (while (search-forward-regexp (concat "^" lb-re) nil t) (replace-match "") (end-of-line)) ;; Chop it up. (goto-char (point-min)) (while (search-forward-regexp (concat ".*" "/" arg1lang "/" "\\(T[A-Z]\\)" ;; 2006.11.17 - Empty string! ;; "" "\\(" lb-ext-html "\\)" ":") nil t) (setq my-msnp-tz (match-string-no-properties 1)) ;; (setq my-href (concat my-msnp-tz "." my-msnp2)) (setq my-href my-msnp-tz) ;; Delete filename generated by "-H" switch of egrep. (replace-match "") ;; Delete ... (search-forward-regexp (concat "[ \t\n]+id=" "['\"]" "\\([^'\"]+\\)" "['\"]") nil t) (setq my-id (match-string-no-properties 1)) (setq my-href (concat my-href "#" my-id)) (replace-match "") ;; Delete ... (save-excursion (when (search-forward-regexp "]+>" (save-excursion (end-of-line) (point))) (replace-match "") (search-forward "") (replace-match ""))) (search-forward ">") (insert "   " " " "" ;; Use just first letter: "A" from "TA" (substring (upcase my-msnp-tz) 1 2) "" " " "   ") (end-of-line) (insert "")) (buffer-string))) ;; (save-buffer 0) (lb-lftp-dosomething-file (buffer-file-name)) (kill-buffer (current-buffer)) lb-rc)) (provide 'lb-mu) ;;; ;