[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-dev] w3m filter for p tags and whatnot



I understand we'll have to live with the various p.* class for some time
in the docs.  The cludge below makes w3m filter the odd p.n tags in the
existing help-files dynamically.  Include this somewhere down in
sclang-help.el or run it after loading sclang-mode.

If there are some files which actually needs a p.7 class or somesuch to
behave semantically correct it should be possible to extend this idea to
suit.

Please tell me if it improves things, and i or someone may commit a
modified sclang-help.el

-anders

;; dynamically change certain html-tags when displaying in w3m-browser:

(defcustom sclang-help-filters
  '(("p\\.p\\([0-9]+\\)" . "#p\\1")
    ("<p class=\"\\(.*\\)\">\\(.*\\)</p>" . "<div id=\"\\1\">\\2</div>"))
  "list of pairs of (regexp . filter) defining html-tags to be replaced by the function sclang-help-substitute-for-filters"
  :group 'sclang-interface
  :type '(repeat (cons (string :tag "match") (string :tag "replacement"))))

(defun sclang-help-substitute-for-filters (&rest args)
  "substitute various tags in SCs html-docs"
  (mapcar #'(lambda (filter)
	      (let ((regexp (car filter))
		    (to-string (cdr filter)))
		(goto-char (point-min))
		(while (re-search-forward regexp nil t)
		  (replace-match to-string nil nil))))
	  sclang-help-filters))


(eval-after-load "w3m-filter"
  '(add-to-list 'w3m-filter-rules
		;; run on all files read by w3m...
                '(".*" sclang-help-substitute-for-filters)))

;; w3m's content-filtering system
(setq w3m-use-filter t)


_______________________________________________
sc-dev mailing list

info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-dev/
search: https://listarc.bham.ac.uk/lists/sc-dev/search/