From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?iso-8859-1?Q?Vincent_Bela=EFche?= Subject: RE: Export issue of URL when the text begins with a date Date: Sun, 16 Jan 2011 22:02:20 +0100 Message-ID: <80oc7gbm03.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from [140.186.70.92] (port=56204 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PeZk0-0000F8-Py for emacs-orgmode@gnu.org; Sun, 16 Jan 2011 16:02:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PeZjz-000685-Dz for emacs-orgmode@gnu.org; Sun, 16 Jan 2011 16:02:24 -0500 Received: from smtp05.smtpout.orange.fr ([80.12.242.127]:34788 helo=smtp.smtpout.orange.fr) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PeZjy-00067H-UT for emacs-orgmode@gnu.org; Sun, 16 Jan 2011 16:02:23 -0500 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Org mode , David Maus Cc: =?iso-8859-1?Q?Vincent_Bela=EFche?= --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > > >Date: Sat, 15 Jan 2011 07:40:35 +0100 >From: dmaus@ictsoc.de >To: vincent.b.1@hotmail.fr >Subject: Re: [Orgmode] Export issue of URL when the text begins with a dat= e=E2=80=8F >CC: dmaus@ictsoc.de; emacs-orgmode@gnu.org > >At Fri, 14 Jan 2011 22:12:07 +0100, >Vincent Bela=C3=AFche wrote: >> Thank-you David again for carrying out this correction. By the way, I >> noticed in the source tree that has a test base, that there is some >> testing sub-directory. I was expecting that there would be a list of >>=20 >> testNN.org >> testNN.tex=20 >> testNN.html >>=20 >> etc... >>=20 >> so that to check that to carry out non regression tests from testNN.org >> exported to reference testNN.tex and testNN.html. >>=20 >> It seems that such a non-regression test base and script do not >> exist. However that would be good to have in order to check that any >> correction does not break anything.=20 >=20 >That's exactly what the testing framework[1] could and should do. >I've just not figured out how to best write tests for entire export >operations. Thinking of it: We could create an input file dedicated >to test link exporting, put in different kinds of links, export and >then use regexps to check if the links have been exported fine. >=20 >Best, > -- David >=20 [...] Hello David and al., I sketched some test script, herein attached. It allows to make a few export tests. I hope that this is what you had in view... Vincent. --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=test-export.el Content-Transfer-Encoding: quoted-printable (require 'org)=0D (defvar test-ext-plist nil)=0D (defvar test-export-arg 0)=0D (defvar test-start-regexp-ocurrence 1)=0D (defvar test-log-buffer nil)=0D (defvar test-temp-buff-1 nil)=0D (defvar test-temp-buff-2 nil)=0D (defvar test-number 0)=0D (defvar test-debug nil=0D "Set to non `nil' in order to debug on first error met")=0D (defvar test-ignore-space t=0D "\=0D * `nil' to keep output as it is =0D =0D * `:par' when all white space must bit ignored in output, but a=0D skipped lined in remained=0D =0D * `t' when all white space must be ignored in output")=0D =0D (defvar test-exporter (symbol-function 'org-export-as-html)=0D "Exporter under test")=0D =0D (defvar test-exporter 'org-export-as-html=0D "Exporter under test")=0D =0D (defvar test-from-start-re "")=0D (defvar test-upto-end-re "")=0D (defvar test-delimiter-detecter nil)=0D =0D (defun test-export (org-code export-code)=0D "\=0D Return nil in case of export OK, error code in case or error.=0D =0D ORG-CODE is some string, EXPORT-CODE is the expected export=0D string, `test-exporter' is exported, `test-from-start-re' and=0D `test-up-to-end-re' are regexp to extract export-code from the=0D exported code."=0D =0D (setq test-number (1+ test-number))=0D (let (p1 p2 exported-string)=0D (with-current-buffer test-temp-buff-2 (erase-buffer))=0D (with-current-buffer test-temp-buff-1=0D (erase-buffer)=0D (insert org-code)=0D (funcall test-exporter=0D test-export-arg nil test-ext-plist test-temp-buff-2=0D (plist-get test-ext-plist :body-only))=0D (when (functionp test-delimiter-detecter)=0D (funcall test-delimiter-detecter export-code))=0D (with-current-buffer test-temp-buff-2=0D (goto-char (point-min))=0D (let ((found test-start-regexp-ocurrence))=0D (while (and (re-search-forward test-from-start-re nil t) =0D (> (setq found (1- found)) 0)))=0D (if (=3D 0 found)=0D (progn=0D (setq p1 (match-beginning 0))=0D (if (re-search-forward test-upto-end-re nil t)=0D (progn=0D (setq p2 (match-end 0)=0D exported-string (buffer-substring-no-properties p1 p2))=0D (cond=0D ((null test-ignore-space) )=0D ((eq t test-ignore-space) =0D (setq exported-string =0D (mapconcat 'identity=0D (split-string exported-string "\s-+\\(\ns-*\\)*")=0D " ")))=0D ((eq :par test-ignore-space)=0D (setq exported-string (split-string exported-string "\\s-\n\\s-*"))=0D (let (prev-lines prev-prev-lines (lines exported-string) line)=0D (while lines=0D (setq line lines=0D lines (cdr lines))=0D (when (string-match "\\`\\s-*\\'" (car line))=0D (setcar line ""))=0D (if (and prev-prev-line=0D (string=3D (car prev-prev-line) "")=0D (string=3D (car prev-line) "")=0D (string=3D (car line) ""))=0D (setcdr prev-line lines)=0D (setq prev-prev-line prev-line=0D prev-line line))))=0D (setq exported-string (mapconcat 'identity exported-string "\n")=0D exported-string (split-string exported-string "\\s-\\{2,\\}")=0D exported-string (mapconcat 'identity exported-string " ")))=0D (t (error "Unexpected `test-ignore-space' =3D %S" test-ignore-spac= e)))=0D =0D (if (string=3D exported-string export-code)=0D nil ; test is OK=0D (when test-debug (debug))=0D (list=0D "Error unexpected gotten thing"=0D org-code export-code exported-string )))=0D (when test-debug (debug))=0D (list =0D "Can't find upto-end-re" =0D org-code export-code ""=0D )))=0D (when test-debug (debug))=0D (list "Can't find from-start-re"=0D org-code export-code "")))))))=0D =0D (defun test-html-delimeter-detecter (export-code)=0D (string-match "\\`<\\([a-z]+\\)" export-code)=0D (setq test-from-start-re (concat (regexp-quote (match-string 0 export-cod= e))=0D "\\_>")=0D test-upto-end-re (regexp-quote (concat ""))))=0D =0D =0D (defun test-log (x)=0D (with-current-buffer test-log-buffer=0D (when x=0D (insert "\n=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= \n" (car x)=0D ".\nTest number: " (number-to-string test-number)=0D ".\nOrg code:\n =3D>" (cadr x)=0D ".\nExpected code:\n =3D>" (caddr x)=0D ".\nGotten code:\n =3D>" (cadddr x) "." ))))=0D =0D =0D (defun test-start ()=0D (setq test-number 0)=0D (with-current-buffer (setq=0D test-temp-buff-2 (get-buffer-create " org-tmp2 ")=0D test-temp-buff-1 (get-buffer-create " org-tmp1 "))=0D (org-mode)=0D (erase-buffer))=0D (with-current-buffer (setq test-log-buffer (get-buffer-create "*Org Test*= "))=0D (erase-buffer)) )=0D =0D (defun test-end ()=0D (switch-to-buffer test-log-buffer)=0D ;; output content of current buffer for batch mode testing=0D (when noninteractive=0D (message "%s" (buffer-substring-no-properties (point-min) (point-max)))= ))=0D =0D =0D =0D ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =0D ;;; Starting the export tests=0D ;;;=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =0D (test-start)=0D =0D (plist-put test-ext-plist :body-only t)=0D (setq test-start-regexp-ocurrence 1=0D test-delimiter-detecter (symbol-function 'test-html-delimeter-detecte= r))=0D =0D (test-log (test-export "* some test\n[[http:/some/link][xxx]]" =0D "xxx" ))=0D (test-log (test-export "* some test\n[[http:/some/link][2010-11-01 xxx]]" = =0D "2010-11-01 xxx" ))=0D (test-log (test-export "* some test\n*Bold thing*" =0D "Bold thing" ))=0D (test-log (test-export "* some test\nSome^{superscript thing}" =0D "superscript thing" ))=0D =0D =0D (test-end) --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --=-=-=--