[Top][All Lists]

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

Re: terminal escapes in Info files?

From: Oliver Scholz
Subject: Re: terminal escapes in Info files?
Date: Wed, 29 Oct 2003 13:20:25 +0100
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3.50 (windows-nt)

Stefan Monnier <address@hidden> writes:

>> Because, believe it or not, some people still use it,
> Of course I use it everyday.
>> there's a lot of history there, and just eradicating Info and replacing it
>> with HTML would not go over well.
> But by switching to something like enriched-mode, we're heading straight
> down that path and it isn't hard to see that sooner or later we'd want
> more than enriched-mode and ...
> I guess the question is: how much work would it require to take
> the subset of HTML generated by makeinfo and render it (both
> in M-x info and in the info program) ?

Just my 0.02 EUR:

The HTML for C-h i would not need to be “real” HTML, just something
which would look like HTML to a browser. What I mean is: It could be
like the text/enriched format (whitespace being significant, so that
you get a nice plain text when you just strip the markup), but with
tags borrowed from HTML:

<!-- [info file] -->
<h1>Defining Functions</h1>

<p>   We usually give a name to a function when it is first created.  This
is called "defining a function", and it is done with the `defun'
special form.</p>

<p> - Special Form: <b>defun</b> name argument-list body-forms
     `defun' is the usual way to define new Lisp functions.  It defines
     the symbol NAME as a function that looks like this:</p>

<code class="example"><pre>     
          (lambda ARGUMENT-LIST . BODY-FORMS)


<code class="lisp"><pre>
          (defun capitalize-backwards ()
            "Upcase the last letter of a word."
            (backward-word 1)
            (forward-word 1)
            (backward-char 1)
            (capitalize-word 1))


In that case it should be simple to use either format.el or
`write-region-annotate-functions' to strip the markup and put faces or
other text properties on the text. Proof of concept (works with the
example above):

(defconst info-translations
  '((face (Info-title-1-face "h1")
          (variable-pitch "p")
          (bold "b"))
    (nil (nil "code"))
    (nil (nil "pre"))))

(defun info-next-annotation ()
  (let ((found nil))
    (while (and (not found)
                (search-forward "<" nil t))
      (backward-char 1)
      (cond ((looking-at "</\\([[:alnum:]]+\\)>")
             (setq found (list (match-beginning 0)
                               (match-end 0)
                               (match-string 1)
            ((looking-at "<\\([[:alnum:]]+\\)\\(?:.*?\\)>")
             (setq found (list (match-beginning 0)
                               (match-end 0)
                               (match-string 1)
            ((looking-at "<!--")
             (let ((beg (point)))
               (when (search-forward "-->" nil t)
                 (skip-chars-forward "\n")
                 (delete-region beg (point)))))
            (t (forward-char 1))))

(defun info-deannotate-region (beg end)
  (interactive "r")
  (format-deannotate-region beg end info-translations

Oliver Scholz               8 Brumaire an 212 de la Révolution
Taunusstr. 25               Liberté, Egalité, Fraternité!
60329 Frankfurt a. M.       http://www.jungdemokratenhessen.de
Tel. (069) 97 40 99 42      http://www.jdjl.org

reply via email to

[Prev in Thread] Current Thread [Next in Thread]