;-*- coding: utf-8 -*- ; some elisp string replacement functions ; used for regex replace operations ; 2007-06 ; Xah Lee ; ∑ http://xahlee.org/ (defun wikipedia-link-replacement () "Returns a canonical form of Wikipedia link from a regex match. This function is used for query-replace-regexp, to turn the following forms of links: event Middle_distance↗ Middle_distance_track_event↗ Sapir-Whorf_Hypothesis↗ into a cannonical form. Basically, the link text needs to have “_” replaced by space, and should have a “↗” at the end. Also, it shouldn't match links that's already in canonical form, nor matching non-wikipedia link texts. The regex to be used for this function is: \\(\\([-.A-Za-z0-9]+_\\)+[-.A-Za-z0-9]+ ?↗*\\) To use a function in query-replace-regexp, do “\\,(wikipedia-link-replacement)”. ." (let (langCode articlePath linkText linkText2 returnText) (setq langCode (buffer-substring (match-beginning 1) (match-end 1))) (setq articlePath (buffer-substring (match-beginning 2) (match-end 2))) (setq linkText (buffer-substring (match-beginning 3) (match-end 3))) (setq linkText2 (concat (replace-regexp-in-string "_" " " articlePath) "↗")) (setq returnText (concat "" linkText2 "" )) returnText ) ) (defun get-html-h1 () "Returns the current buffer's first
tag content. This function is used to get a set of HTML page's