/usr/share/emacs/site-lisp/w3m/shimbun/sb-text.el is in w3m-el 1.4.569+0.20170110-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | ;;; sb-text.el -- shimbun backend class for text content -*- coding: iso-2022-7bit; -*-
;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2009
;; Yuuichi Teranishi <teranisi@gohome.org>
;; Author: Yuuichi Teranishi <teranisi@gohome.org>
;; Keywords: news
;; This file is a part of shimbun.
;; This program 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 2, or (at your option)
;; any later version.
;; This program 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 this program; see the file COPYING. If not, write to
;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.
;;; Commentary:
;; Original code was nnshimbun.el written by
;; TSUCHIYA Masatoshi <tsuchiya@namazu.org>.
;;; Code:
(require 'shimbun)
(luna-define-class shimbun-text (shimbun) ())
;; Fast fill-region function
(defvar shimbun-fill-column (min 80 (- (frame-width) 4)))
(defconst shimbun-kinsoku-bol-list
(append "!)-_~}]:;',.?$B!"!#!$!%!&!'!(!)!*!+!,!-!.!/!0!1!2!3!4!5!6!7(B\
$B!8!9!:!;!<!=!>!?!@!A!B!C!D!E!G!I!K!M!O!Q!S!U!W!Y![!k!l!m!n$!$#$%$'$)(B\
$B$C$c$e$g$n%!%#%%%'%)%C%c%e%g%n%u%v(B" nil))
(defconst shimbun-kinsoku-eol-list
(append "({[`$B!F!H!J!L!N!P!R!T!V!X!Z!k!l!m!x(B" nil))
(defun shimbun-fill-line ()
(forward-line 0)
(let ((top (point)) chr)
(while (if (>= (move-to-column shimbun-fill-column)
shimbun-fill-column)
(if (memq (char-before) shimbun-kinsoku-eol-list)
(prog1
t
(backward-char)
(while (memq (char-before) shimbun-kinsoku-eol-list)
(backward-char))
(insert "\n"))
(while (memq (setq chr (char-after)) shimbun-kinsoku-bol-list)
(forward-char))
(if (looking-at "\\s-+")
(or (eolp) (delete-region (point) (match-end 0)))
(or (not chr)
(> (char-width chr) 1)
(re-search-backward "\\<" top t)
(end-of-line)))
(if (eolp)
nil
(insert "\n")
t)))
(setq top (point))))
(forward-line 1)
(not (eobp)))
(defun shimbun-shallow-rendering ()
(goto-char (point-min))
(while (search-forward "<p>" nil t)
(insert "\n\n"))
(goto-char (point-min))
(while (re-search-forward "<br\\(:? /\\)?>" nil t)
(insert "\n"))
(shimbun-remove-markup)
(shimbun-decode-entities)
(goto-char (point-min))
(while (shimbun-fill-line))
(goto-char (point-min))
(when (skip-chars-forward "\n")
(delete-region (point-min) (point)))
(while (re-search-forward "\n\n\n+" nil t)
(replace-match "\n\n"))
(goto-char (point-max))
(when (skip-chars-backward "\n")
(delete-region (point) (point-max)))
(insert "\n"))
(defun shimbun-make-text-contents (shimbun header)
(shimbun-header-insert-and-buffer-string
shimbun header nil
;; When cleaning has been succeeded, this article is treated as a
;; text/plain message. Otherwise, it is treated as a text/html
;; message.
(if (shimbun-clear-contents shimbun header)
(shimbun-shallow-rendering)
t)))
(luna-define-method shimbun-make-contents ((shimbun shimbun-text)
header)
(shimbun-make-text-contents shimbun header))
(provide 'sb-text)
;;; sb-text.el ends here
|