unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Kevin Rodgers <ihs_4664@yahoo.com>
Subject: Re: narrow-to-here-document
Date: Wed, 25 Jun 2003 10:58:51 -0600	[thread overview]
Message-ID: <3EF9D4CB.5010103@yahoo.com> (raw)
In-Reply-To: 20030625.151015.68035851.jet@gyve.org

Masatake YAMATO wrote:

> I've reflected suggestions to my code.
...
> Kevin Rodgers:
> 3. 
>     Would INCLUDE/IGNORE/CDATA marked sections in SGML/XML/HTML qualify?
> 
>     <![CDATA[
>     No <tag>s or &entity; references are recognized here.
>     ]]>
...
> ;;
> ;; sgml-mode
> ;;
> (defvar sgml-here-document-beginning-regexp "<!\\[\\([A-Z]+\\)\\[")


SGML actually allows zero or more status keywords (separated by one or
more parameter separators, and followed by zero or more parameter
separators) between the marked section start (<![) and the declaration
subset open ([).  The status keywords are CDATA, IGNORE, INCLUDE,
and RCDATA, and TEMP.  A parameter separator is a whitespace character
(space, linefeed, carriage return, or tab), a parameter entity
reference, or a comment:

(defvar sgml-status-keyword-regexp
   ;; 10.4.2 Status Keyword Specification [100]
   "CDATA\\|IGNORE\\|INCLUDE\\|RCDATA")

(defvar sgml-s-regexp "[ \r\n\t]")	; 6.2.1 s Separator [5]

(defvar sgml-parameter-entity-reference-regexp
   ;; 9.4.4 Named Entity References [60]
   "%[a-zA-Z][a-zA-Z0-9---.]*[;\r\n]")

(defvar sgml-comment-regexp "--.*--")	; 10.3 Comment Declaration [92]

(defvar sgml-parameter-separator	; 10.1.1 Parameter Separator [65]
   (format "%s\\|%s\\|\\%s"
	  sgml-s-regexp
	  sgml-parameter-entity-reference-regexp
	  sgml-comment-regexp))

(defvar sgml-here-document-beginning-regexp
   ;; 10.4 Marked Section Declaration [93], [94]
   ;; 10.4.2 Status Keyword Specification [97]
   (format "<!\\[\\(\\(%s\\)+\\(%s\\|TEMP\\)\\)*\\(%s\\)*\\["
	  sgml-parameter-separator-reference-regexp
	  sgml-status-keyword-regexp
	  sgml-parameter-separator-reference-regexp))

XML only allows "<![CDATA[" (with no intervening characters at all):

(defvar xml-here-document-beginning-regexp ; 2.1 CDATA Sections [18], [19]
  "<!\\[\\(CDATA\\)\\[")

> (defvar sgml-here-document-end-regexp "]]>")
> (defun sgml-here-document-region ()
>   (let (beginning end)
>     (save-excursion
>       (save-match-data
> 	(when (re-search-backward
> 	       sgml-here-document-beginning-regexp
> 	       (point-min) t)
> 	  (setq beginning (match-end 0))
> 	  (when (re-search-forward 
> 		 sgml-here-document-end-regexp
> 		 (point-max) t)
> 	    (setq end (match-beginning 0))))))    
>     (if (and beginning end (<= (point) end))
> 	(cons beginning end))))


-- 
<a href="mailto:&lt;kevin.rodgers&#64;ihs.com&gt;">Kevin Rodgers</a>

  parent reply	other threads:[~2003-06-25 16:58 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-20 13:59 narrow-to-here-document Masatake YAMATO
2003-06-20 14:10 ` narrow-to-here-document Ilya Zakharevich
2003-06-20 16:26   ` narrow-to-here-document Masatake YAMATO
2003-06-21  7:15     ` narrow-to-here-document Stephen J. Turnbull
2003-06-21  8:01       ` narrow-to-here-document David Kastrup
2003-06-21 14:19         ` narrow-to-here-document Ilya Zakharevich
2003-06-21 14:48           ` narrow-to-here-document David Kastrup
2003-06-22  8:33             ` narrow-to-here-document Ilya Zakharevich
2003-06-23 17:10     ` narrow-to-here-document Kevin Rodgers
2003-06-25  6:10       ` narrow-to-here-document Masatake YAMATO
2003-06-25  8:04         ` narrow-to-here-document David Kastrup
2003-06-25  8:21           ` narrow-to-here-document Masatake YAMATO
2003-06-26  0:34             ` narrow-to-here-document Kim F. Storm
2003-06-26  5:30             ` narrow-to-here-document Richard Stallman
2003-06-25 23:18           ` narrow-to-here-document Stefan Daschek
2003-06-26  5:59             ` mmm-mode.el(Re: narrow-to-here-document) Masatake YAMATO
2003-06-26  6:12             ` narrow-to-here-document David Kastrup
2003-06-26 13:00               ` narrow-to-here-document Alan Shutko
2003-06-30  0:34                 ` narrow-to-here-document Miles Bader
2003-06-30  6:13                 ` narrow-to-here-document Kai Großjohann
2003-06-30 17:19                   ` narrow-to-here-document David Kastrup
2003-06-30 20:11                     ` narrow-to-here-document Kai Großjohann
2003-07-04  0:07                       ` narrow-to-here-document Stefan Monnier
2003-07-04  6:46                         ` narrow-to-here-document Kai Großjohann
2003-07-01 15:17                   ` narrow-to-here-document Richard Stallman
2003-07-04  0:32                     ` narrow-to-here-document Stefan Monnier
2003-07-07 23:45                       ` [MMM] narrow-to-here-document Michael A. Shulman
2003-07-08  7:19                         ` Kai Großjohann
2003-07-10 16:44                           ` Richard Stallman
2003-07-08 14:12                         ` mmm-mode needs (was: narrow-to-here-document) Stefan Monnier
2003-07-08 20:02                         ` [MMM] Re: narrow-to-here-document Richard Stallman
2003-06-25 16:58         ` Kevin Rodgers [this message]
     [not found] ` <20030625.143750.116352160.jet@gyve.org>
2003-06-26  5:29   ` narrow-to-here-document Richard Stallman
2003-06-26  7:19     ` narrow-to-here-document Miles Bader
2003-06-26 17:45       ` narrow-to-here-document Tak Ota
2003-06-26 23:10         ` narrow-to-here-document David Kastrup
2003-06-27  2:07         ` narrow-to-here-document Miles Bader
2003-06-27  2:49       ` narrow-to-here-document Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3EF9D4CB.5010103@yahoo.com \
    --to=ihs_4664@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).