emacs-wiki-discuss
[Top][All Lists]
Advanced

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

[emacs-wiki-discuss] Re: bad HTML publish


From: Michael Olson
Subject: [emacs-wiki-discuss] Re: bad HTML publish
Date: Mon, 20 Mar 2006 13:44:39 -0500
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

Richard Klinda <address@hidden> writes:

> Hello, I like this change!:) But literal isn't enough for me so I
> implemented a solution for myself (extremely hackish etc but it
> works, extensively tested), maybe someone finds it useful.
>
> Unfortunately it redefines a muse function:
> MUSE-PUBLISH-ESCAPE-SPECIALS.

I've just committed a change that makes it easier to specify a
different function to use for escaping regions.  Better now would be
to redefine `muse-xml-decide-specials' with something like the
following.

;; I would test this, but I don't have the `group-list' function from
;; your example code.

(defun muse-xml-decide-specials (context)
  "Determine the specials to escape, depending on CONTEXT."
  (cond ((memq context '(email url))
         'muse-xml-escape-url)
        ((eq context 'url-extra)
         muse-xml-markup-specials-url-extra)
        ((eq context 'document)
         'rk-muse-xml-escape-document)
        (t muse-xml-markup-specials)))

;; and then:

(defun rk-muse-xml-escape-document (beg end &optional ignore-read-only)
  "Escape specials from BEG to END using style-specific :specials.
If IGNORE-READ-ONLY is non-nil, ignore the read-only property."
  (let ((specials muse-xml-markup-specials))
    (save-excursion
      (save-restriction
        (narrow-to-region beg end)
        (goto-char (point-min))
        (while (< (point) (point-max))
          (if (and (not ignore-read-only)
                   (get-text-property (point) 'read-only))
              (goto-char (or (next-single-property-change (point) 'read-only)
                             (point-max)))
            (let ((repl (or (assoc (char-after) specials)
                            (assoc (char-after)
                                   muse-publish-markup-specials))))
              (if (null repl)
                  (forward-char 1)
                  ;; v- modified part!
                  (let ((char (char-after))
                        html-p)
                    (when (eq char ?<)
                      (dolist (ele rk-muse-html-commands)
                        (save-excursion
                          (forward-char 1)
                          (when (or (looking-at (concat ele "[ >]"))
                                    (looking-at (concat "/" ele "[ >]"))
                                    )
                            (setq html-p t)
                            (setq prev-html-p t)
                            ))))

                    (when (eq char ?<)
                      (unless html-p
                        (setq prev-html-p nil)))

                    (when (and (eq char ?>)
                               prev-html-p)
                      (setq html-p t)
                      (setq prev-html-p nil))

                    (when (eq char ?&)
                      (save-excursion
                        (forward-char 1)
                        (when (looking-at "gt;\\|lt;")
                          (setq html-p t))))

                    (if html-p
                        (forward-char 1)
                        (progn
                          (delete-char 1)
                          (insert-before-markers (cdr repl)))))))))))))


-- 
Michael Olson -- FSF Associate Member #652 -- http://www.mwolson.org/
Interests: Emacs Lisp, text markup, IRC, EMMS, anime, manga, Debian
  /` |\ | | | IRC: mwolson on freenode.net: #hcoop, #muse, #PurdueLUG
 |_] | \| |_| Jabber: mwolson_at_hcoop.net

Attachment: pgpAPuy3vDAEq.pgp
Description: PGP signature


reply via email to

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