From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michal Nazarewicz Newsgroups: gmane.emacs.bugs Subject: bug#17699: [PATCH 4/7] tildify.el: Better support for XML Date: Thu, 5 Jun 2014 13:27:33 +0200 Message-ID: <1401967656-16171-4-git-send-email-mina86@mina86.com> References: <1401967656-16171-1-git-send-email-mina86@mina86.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1401968504 11958 80.91.229.3 (5 Jun 2014 11:41:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 5 Jun 2014 11:41:44 +0000 (UTC) To: 17699@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jun 05 13:41:37 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WsW36-0005Wy-7O for geb-bug-gnu-emacs@m.gmane.org; Thu, 05 Jun 2014 13:41:36 +0200 Original-Received: from localhost ([::1]:40045 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsW35-0002Jj-QA for geb-bug-gnu-emacs@m.gmane.org; Thu, 05 Jun 2014 07:41:35 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40828) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsW2j-0001r5-4w for bug-gnu-emacs@gnu.org; Thu, 05 Jun 2014 07:41:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WsW2a-0005Nu-JT for bug-gnu-emacs@gnu.org; Thu, 05 Jun 2014 07:41:13 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:45944) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WsW2a-0005Mr-Gc for bug-gnu-emacs@gnu.org; Thu, 05 Jun 2014 07:41:04 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1WsVpz-0007me-Q3 for bug-gnu-emacs@gnu.org; Thu, 05 Jun 2014 07:28:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michal Nazarewicz Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 05 Jun 2014 11:28:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 17699 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 17699-submit@debbugs.gnu.org id=B17699.140196767829860 (code B ref 17699); Thu, 05 Jun 2014 11:28:03 +0000 Original-Received: (at 17699) by debbugs.gnu.org; 5 Jun 2014 11:27:58 +0000 Original-Received: from localhost ([127.0.0.1]:44808 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WsVps-0007lR-Ml for submit@debbugs.gnu.org; Thu, 05 Jun 2014 07:27:57 -0400 Original-Received: from mail-wg0-f74.google.com ([74.125.82.74]:43260) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1WsVpo-0007kR-33 for 17699@debbugs.gnu.org; Thu, 05 Jun 2014 07:27:53 -0400 Original-Received: by mail-wg0-f74.google.com with SMTP id x12so86134wgg.5 for <17699@debbugs.gnu.org>; Thu, 05 Jun 2014 04:27:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=e1je2C3XsVHRQr4YMy0Sk25+gm9uSXRCKI92HsVF7r4=; b=Gy0+lNnkXfJDiWGagVcA1G5rlJwkA60XnjVxrZjI50V+4JQrrfGW5jT6EErOF+1//q CCpNlNOPc2GMbLV9chQlHS4HwujnMq3On+i+pWmc0bcGM1D8Z2ScyHOneL5zn+0cZrBU iWVO5Wb5k93y09f215YkpT7Qx19Wr+V2I4pNVyz0yh2NBcpyDUl8LnID14NUS/4TuYrI jFF15Qgk72ouIOylX6FZbzUpnWWOzMSjtnRAR3uvqLRiM1t4stJYxvK6bp8h/mE+Y/Jh bjwmTqT3PxJYDK6zTjGvKMeLk8DWfpo7VPX1PsXPag63aK51uWm9xQV9Max1xjYWcAmp SYww== X-Gm-Message-State: ALoCoQmIoJUEruWSMonZIS64duYhd30UikCXlnt7SRDDDkb8JGacrBRXj8CXVoRH/IlpD+Gr8MGw2EDNDulwP2Z0M5PuFh8/90ke/YbGQBs4UxAvQbiH72TO7CPQQ6ISQ36qHHj9W7iQ X-Received: by 10.112.168.198 with SMTP id zy6mr3228123lbb.15.1401967666287; Thu, 05 Jun 2014 04:27:46 -0700 (PDT) Original-Received: from corp2gmr1-1.eem.corp.google.com (corp2gmr1-1.eem.corp.google.com [172.25.138.99]) by gmr-mx.google.com with ESMTPS id xk11si905540wib.0.2014.06.05.04.27.46 for <17699@debbugs.gnu.org> (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Jun 2014 04:27:46 -0700 (PDT) Original-Received: from hpgntag-ubiq62.eem.corp.google.com (hpgntag-ubiq62.eem.corp.google.com [172.25.135.103]) by corp2gmr1-1.eem.corp.google.com (Postfix) with ESMTP id 12AFA1CA358 for <17699@debbugs.gnu.org>; Thu, 5 Jun 2014 04:27:46 -0700 (PDT) Original-Received: by hpgntag-ubiq62.eem.corp.google.com (Postfix, from userid 126942) id E5CDF10B5A1; Thu, 5 Jun 2014 13:27:45 +0200 (CEST) X-Mailer: git-send-email 2.0.0.526.g5318336 In-Reply-To: <1401967656-16171-1-git-send-email-mina86@mina86.com> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:90040 Archived-At: * lisp/textmodes/tildify.el (tildify-string-alist) (tildify-ignored-environments-alist): Add `nxml-mode' to the list of supported modes since `xml-mode' is no longer a thing but just an alias to the former. Also include comments and insides of tags in `tildify-ignored-environments-alist' for XML modes. Finally, since XML does not define “ ”[1], use a numeric reference for a no-break space (namely “ ”) [1] XML specification defines only a handful of predefined entities. The list is at and includes only <, >, &, ' and " (meaning <, >, &, ' and " respectively). This is in contrast to HTML and even XHTML which defined a whole bunch of entities including “ ”. * automated/tildify-tests.el (tildify-test--example-html): Add support for generating XML code, so that… (tildify-test-xml) …test can be added to check handling of XML documents. --- lisp/ChangeLog | 14 ++++++++++++++ lisp/textmodes/tildify.el | 7 ++++++- test/ChangeLog | 5 +++++ test/automated/tildify-tests.el | 15 ++++++++++++--- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 487e21c..c662add 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,19 @@ 2014-06-05 Michal Nazarewicz + * textmodes/tildify.el (tildify-string-alist) + (tildify-ignored-environments-alist): Add `nxml-mode' to the list + of supported modes since `xml-mode' is no longer a thing but just + an alias to the former. Also include comments and insides of tags + in `tildify-ignored-environments-alist' for XML modes. Finally, + since XML does not define “ ”[1], use a numeric reference for + a no-break space (namely “ ”) + + [1] XML specification defines only a handful of predefined entities. + The list is at + and includes only <, >, &, ' and " (meaning <, + >, &, ' and " respectively). This is in contrast to HTML and even + XHTML which defined a whole bunch of entities including “ ”. + * textmodes/tildify.el (tildify-pattern-alist) (tildify-string-alist, tildify-ignored-environments-alist): Improve defcustom's types by adding more tags explaining what each diff --git a/lisp/textmodes/tildify.el b/lisp/textmodes/tildify.el index d61998a..6dd471d 100644 --- a/lisp/textmodes/tildify.el +++ b/lisp/textmodes/tildify.el @@ -90,8 +90,9 @@ mode, the item for the mode SYMBOL is looked up in the alist instead." (tex-mode . latex-mode) (plain-tex-mode . latex-mode) (sgml-mode . " ") - (xml-mode . sgml-mode) (html-mode . sgml-mode) + (xml-mode . " ") ; XML does not define  , use numeric reference + (nxml-mode . xml-mode) (t . " ")) "Alist specifying what is a hard space in the current major mode. @@ -149,6 +150,10 @@ mode, the item for the mode SYMBOL is looked up in the alist instead." ("") ("<" . ">")) (sgml-mode . html-mode) + (xml-mode + ("") + ("<" . ">")) + (nxml-mode . xml-mode) (t nil)) "Alist specifying ignored structured text environments. Parts of text defined in this alist are skipped without performing hard space diff --git a/test/ChangeLog b/test/ChangeLog index 93ef098..38a4feb 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,5 +1,10 @@ 2014-06-05 Michal Nazarewicz + * automated/tildify-tests.el (tildify-test--example-html): Add support + for generating XML code, so that… + (tildify-test-xml) …test can be added to check handling of XML + documents. + * automated/tildify-tests.el (tildify-test-find-env-group-index-bug): New test checking end-regex building when multiple environment pairs use integers to refer to capture groups. diff --git a/test/automated/tildify-tests.el b/test/automated/tildify-tests.el index 6fee28b..dd404fc 100644 --- a/test/automated/tildify-tests.el +++ b/test/automated/tildify-tests.el @@ -36,14 +36,15 @@ "consectetur adipiscing elit.")) -(defun tildify-test--example-html (sentence &optional with-nbsp) +(defun tildify-test--example-html (sentence &optional with-nbsp is-xml) "Return an example HTML code. SENTENCE is placed where spaces should not be replaced with hard spaces, and WITH-NBSP is placed where spaces should be replaced with hard spaces. If the -latter is missing, SENTENCE will be used in all placeholder positions." +latter is missing, SENTENCE will be used in all placeholder positions. +If IS-XML is non-nil,
 tag is not treated specially."
   (let ((with-nbsp (or with-nbsp sentence)))
     (concat "

" with-nbsp "

\n" - "
" sentence "
\n" + "
" (if is-xml with-nbsp sentence) "
\n" "\n" "

" with-nbsp "

\n" "<" sentence ">\n"))) @@ -77,6 +78,14 @@ after `tildify-buffer' is run." (tildify-test--example-html sentence sentence) (tildify-test--example-html sentence with-nbsp)))) +(ert-deftest tildify-test-xml () + "Tests tildification in an XML document" + (let* ((sentence (tildify-test--example-sentence " ")) + (with-nbsp (tildify-test--example-sentence " "))) + (tildify-test--test '(nxml-mode) + (tildify-test--example-html sentence sentence t) + (tildify-test--example-html sentence with-nbsp t)))) + (defun tildify-test--example-tex (sentence &optional with-nbsp) "Return an example (La)Tex code. -- 2.0.0.526.g5318336