From d97f95be3f6ca4db546ed8cad9684edae9c57668 Mon Sep 17 00:00:00 2001 From: Lars Magne Ingebrigtsen Date: Sun, 29 Aug 2010 01:36:50 +0200 Subject: [PATCH] Start implementation. --- lisp/render-html.el | 53 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 lisp/render-html.el diff --git a/lisp/render-html.el b/lisp/render-html.el new file mode 100644 index 000000000..b8af630b2 --- /dev/null +++ b/lisp/render-html.el @@ -0,0 +1,53 @@ +;;; render-html.el --- Quoted-Printable functions + +;; Copyright (C) 2010 Free Software Foundation, Inc. + +;; Author: Lars Magne Ingebrigtsen +;; Keywords: html, web + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see . + +;;; Commentary: + +;; The idea is to provide a simple, fast and pretty minimal way to +;; render HTML (including links and images) in a buffer, based on an +;; external HTML renderer (i.e., w3m). + +;;; Code: + +(defun render-html-file (file) + (erase-buffer) + (let ((process (start-process "w3m" (current-buffer) + "w3m" "-halfdump" file))) + (set-process-sentinel process 'render-html-finished-rendering))) + +(defun render-html-finished-rendering (process event) + (when (string-match "finished" event) + (save-excursion + (set-buffer (process-buffer process)) + (render-html-wash-tags)))) + +(defun render-html-wash-tags () + (let (tag parameters string) + ;;(subst-char-in-region (point-min) (point-max) ?_ ? ) + (goto-char (point-min)) + (while (re-search-forward "<\\([^ ]+\\)\\([^>]*\\)>\\([^<]*\\)<[^>]*>" nil t) + (setq tag (match-string 1) + parameters (match-string 2) + string (match-string 3)) + (replace-match string)))) + +;;; render-html.el ends here -- 2.25.1