Re: [Orgmode] Export issue of URL when the text begins with a date
At Mon, 31 Jan 2011 19:45:29 +0100, Bastien wrote: David Maus dm...@ictsoc.de writes: Attached patch factors out the link handling part of `org-export-as-html' in a separat function which takes the processed line and the exporting options as arguments and returns the possibly modified line. Having the link handling in a separate function makes it way easier to test this specific behaviour of export. Quite useful indeed -- I hope org-export-as-html looks a bit less daunting now :) Indeed. I've also defined a factory function in test-org-html.el that can be used to define link export texts in a property list. Best, -- David -- OpenPGP... 0x99ADB83B5A4478E6 Jabber dmj...@jabber.org Email. dm...@ictsoc.de pgpsUDyYbJc5p.pgp Description: PGP signature ___ 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
[Accepted] [Orgmode] Export issue of URL when the text begins with a date
Patch 565 (http://patchwork.newartisans.com/patch/565/) is now Accepted. Maintainer comment: none This relates to the following submission: http://mid.gmane.org/%3C87sjwae2ar.wl%25dmaus%40ictsoc.de%3E Here is the original message containing the patch: Content-Type: text/plain; charset=utf-8 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Orgmode] Export issue of URL when the text begins with a =?UTF-8?B?ZGF0ZeKAjw==?= Date: Sun, 30 Jan 2011 22:20:28 - From: David Maus dm...@ictsoc.de X-Patchwork-Id: 565 Message-Id: 87sjwae2ar.wl%dm...@ictsoc.de To: Bastien bastien.gue...@wikimedia.fr Cc: David Maus dm...@ictsoc.de, Vincent =?UTF-8?B?QmVsYcOvY2hl?= vincent@hotmail.fr, Org mode emacs-orgmode@gnu.org At Mon, 17 Jan 2011 18:55:54 +0100, Bastien wrote: David Maus dm...@ictsoc.de writes: 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. 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. I've just added testing/links.org to the testing framework. Vincent, feel free to suggest any addition to testing/ so that we can enrich our test-base with various examples! Being able to reproduce errors on those files will help people feel confident the error does not come from their configuration. Attached patch factors out the link handling part of `org-export-as-html' in a separat function which takes the processed line and the exporting options as arguments and returns the possibly modified line. Having the link handling in a separate function makes it way easier to test this specific behaviour of export. Best, -- David --- OpenPGP... 0x99ADB83B5A4478E6 Jabber dmj...@jabber.org Email. dm...@ictsoc.de From ea1c1e8528af0490c03133a09575e72fa4d0f352 Mon Sep 17 00:00:00 2001 From: David Maus dm...@ictsoc.de Date: Sun, 30 Jan 2011 18:12:06 +0100 Subject: [PATCH] Factor out link Handling during export * org-html.el (org-html-handle-links): New function. Factor out link Handling during export. (org-export-as-html): Use new function. Putting the entire logic of link handling in a separate function makes it easier to test the link creation during html export and maybe refactor the function in the future. The body of the function is a 1:1 copy of the original code in `org-export-as-html', symbols which were used by the link handling exclusively are removed from `org-export-as-html'. --- lisp/org-html.el | 332 -- 1 files changed, 171 insertions(+), 161 deletions(-) diff --git a/lisp/org-html.el b/lisp/org-html.el index 9a5d225..2216852 100644 --- a/lisp/org-html.el +++ b/lisp/org-html.el @@ -795,6 +795,173 @@ MAY-INLINE-P allows inlining it as an image. (org-export-html-format-desc desc) /a) +(defun org-html-handle-links (line opt-plist) + Return LINE with markup of Org mode links. +OPT-PLIST is the export options list. + (let ((start 0) + (current-dir (if buffer-file-name + (file-name-directory buffer-file-name) + default-directory)) + (link-validate (plist-get opt-plist :link-validation-function)) + type id-file fnc + rpl path attr desc descp desc1 desc2 link) +(while (string-match org-bracket-link-analytic-regexp++ line start) + (setq start (match-beginning 0)) + (setq path (save-match-data (org-link-unescape +(match-string 3 line + (setq type (cond + ((match-end 2) (match-string 2 line)) + ((save-match-data + (or (file-name-absolute-p path) + (string-match ^\\.\\.?/ path))) +file) + (t internal))) + (setq path (org-extract-attributes (org-link-unescape path))) + (setq attr (get-text-property 0 'org-attributes path)) + (setq desc1 (if (match-end 5) (match-string 5 line)) + desc2 (if (match-end 2) (concat type : path) path) + descp (and desc1 (not (equal desc1 desc2))) + desc (or desc1 desc2)) + ;; Make an image out of the description if that is so wanted + (when (and descp (org-file-image-p + desc org-export-html-inline-image-extensions)) + (save-match-data + (if (string-match ^file: desc) + (setq desc (substring desc (match-end 0) + (setq desc (org-add-props +(concat img src=\ desc \/) +'(org-protected t
Re: [Orgmode] Export issue of URL when the text begins with a date
David Maus dm...@ictsoc.de writes: Attached patch factors out the link handling part of `org-export-as-html' in a separat function which takes the processed line and the exporting options as arguments and returns the possibly modified line. Having the link handling in a separate function makes it way easier to test this specific behaviour of export. Quite useful indeed -- I hope org-export-as-html looks a bit less daunting now :) -- Bastien ___ 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
Re: [Orgmode] Export issue of URL when the text begins with a date
At Mon, 17 Jan 2011 18:55:54 +0100, Bastien wrote: David Maus dm...@ictsoc.de writes: 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. 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. I've just added testing/links.org to the testing framework. Vincent, feel free to suggest any addition to testing/ so that we can enrich our test-base with various examples! Being able to reproduce errors on those files will help people feel confident the error does not come from their configuration. Attached patch factors out the link handling part of `org-export-as-html' in a separat function which takes the processed line and the exporting options as arguments and returns the possibly modified line. Having the link handling in a separate function makes it way easier to test this specific behaviour of export. Best, -- David -- OpenPGP... 0x99ADB83B5A4478E6 Jabber dmj...@jabber.org Email. dm...@ictsoc.de From ea1c1e8528af0490c03133a09575e72fa4d0f352 Mon Sep 17 00:00:00 2001 From: David Maus dm...@ictsoc.de Date: Sun, 30 Jan 2011 18:12:06 +0100 Subject: [PATCH] Factor out link Handling during export * org-html.el (org-html-handle-links): New function. Factor out link Handling during export. (org-export-as-html): Use new function. Putting the entire logic of link handling in a separate function makes it easier to test the link creation during html export and maybe refactor the function in the future. The body of the function is a 1:1 copy of the original code in `org-export-as-html', symbols which were used by the link handling exclusively are removed from `org-export-as-html'. --- lisp/org-html.el | 332 -- 1 files changed, 171 insertions(+), 161 deletions(-) diff --git a/lisp/org-html.el b/lisp/org-html.el index 9a5d225..2216852 100644 --- a/lisp/org-html.el +++ b/lisp/org-html.el @@ -795,6 +795,173 @@ MAY-INLINE-P allows inlining it as an image. (org-export-html-format-desc desc) /a) +(defun org-html-handle-links (line opt-plist) + Return LINE with markup of Org mode links. +OPT-PLIST is the export options list. + (let ((start 0) + (current-dir (if buffer-file-name + (file-name-directory buffer-file-name) + default-directory)) + (link-validate (plist-get opt-plist :link-validation-function)) + type id-file fnc + rpl path attr desc descp desc1 desc2 link) +(while (string-match org-bracket-link-analytic-regexp++ line start) + (setq start (match-beginning 0)) + (setq path (save-match-data (org-link-unescape + (match-string 3 line + (setq type (cond + ((match-end 2) (match-string 2 line)) + ((save-match-data +(or (file-name-absolute-p path) +(string-match ^\\.\\.?/ path))) + file) + (t internal))) + (setq path (org-extract-attributes (org-link-unescape path))) + (setq attr (get-text-property 0 'org-attributes path)) + (setq desc1 (if (match-end 5) (match-string 5 line)) + desc2 (if (match-end 2) (concat type : path) path) + descp (and desc1 (not (equal desc1 desc2))) + desc (or desc1 desc2)) + ;; Make an image out of the description if that is so wanted + (when (and descp (org-file-image-p + desc org-export-html-inline-image-extensions)) + (save-match-data + (if (string-match ^file: desc) + (setq desc (substring desc (match-end 0) + (setq desc (org-add-props + (concat img src=\ desc \/) + '(org-protected t + (cond + ((equal type internal) + (let + ((frag-0 + (if (= (string-to-char path) ?#) + (substring path 1) + path))) + (setq rpl + (org-html-make-link +opt-plist + + +(org-solidify-link-text + (save-match-data (org-link-unescape frag-0)) + nil) +desc attr nil + ((and (equal type id) +(setq id-file (org-id-find-id-file path))) + ;; This is an id: link to another file (if it was the same file, + ;; it would have become an internal link...) + (save-match-data + (setq id-file (file-relative-name +id-file +
Re: [Orgmode] Export issue of URL when the text begins with a date
David Maus dm...@ictsoc.de writes: 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. 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. I've just added testing/links.org to the testing framework. Vincent, feel free to suggest any addition to testing/ so that we can enrich our test-base with various examples! Being able to reproduce errors on those files will help people feel confident the error does not come from their configuration. Best, -- Bastien ___ 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
RE: [Orgmode] Export issue of URL when the text begins with a date
[...] My understanding is that the bug resides in this very expression. Thanks for the investigation. As it turned out the problem was not with the regular expression but with the order in which different pieces of Org mode markup were processed by `org-export-as-html'. First the exporter processed possible timestamps, (falsely) recognized the ISO date as part of an ISO timestamp, and replaced it with the timestamp span. The replacement included the square brackets what destroyed the link markup. I've just checked in a patch to master that changes the order of processing links and timestamps: Now links are processed before timestamps what fixes this problem. Thanks for bringing this problem up again, Best, -- David -- [...] 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 testNN.org testNN.tex testNN.html etc... so that to check that to carry out non regression tests from testNN.org exported to reference testNN.tex and testNN.html. 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. Is that something that is considered for future ? Vincent. ___ 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
Re: [Orgmode] Export issue of URL when the text begins with a date
At Fri, 14 Jan 2011 22:12:07 +0100, Vincent Belaïche 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 testNN.org testNN.tex testNN.html etc... so that to check that to carry out non regression tests from testNN.org exported to reference testNN.tex and testNN.html. 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. 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. Best, -- David [1] Introduced Oct 2010, http://article.gmane.org/gmane.emacs.orgmode/31307 -- OpenPGP... 0x99ADB83B5A4478E6 Jabber dmj...@jabber.org Email. dm...@ictsoc.de pgpUf1kkPNH7u.pgp Description: PGP signature ___ 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
[Orgmode] Export issue of URL when the text begins with a date
Hello, I have made some invesitgation, and I found that the problem happens in the call of function org-export-as-html. On line 522 of this function, this is the following line: (while (string-match org-bracket-link-analytic-regexp++ line start) When the line containing the link is processed, the variable line is equal to the following [[file://localhost/c%3A/msys/1.0/temp/example.html][2011-01-01 example]] In that case the expression (string-match org-bracket-link-analytic-regexp++ line start) returns nil. Now assume that I modify slightly the line so that there is not longer any ISO timestamp in it, like this (I just replaced the first `-' by a `+', so the string is : [[file://localhost/c%3A/msys/1.0/temp/example.html][2011+01-01 example]] ) with that change the expression (string-match org-bracket-link-analytic-regexp++ line start) returns 0. My understanding is that the bug resides in this very expression. VBR, Vincent. ___ 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
Re: [Orgmode] Export issue of URL when the text begins with a date
At Thu, 13 Jan 2011 23:00:30 +0100, Vincent Belaïche wrote: Hello, I have made some invesitgation, and I found that the problem happens in the call of function org-export-as-html. On line 522 of this function, this is the following line: (while (string-match org-bracket-link-analytic-regexp++ line start) When the line containing the link is processed, the variable line is equal to the following [[file://localhost/c%3A/msys/1.0/temp/example.html][2011-01-01 example]] In that case the expression (string-match org-bracket-link-analytic-regexp++ line start) returns nil. Now assume that I modify slightly the line so that there is not longer any ISO timestamp in it, like this (I just replaced the first `-' by a `+', so the string is : [[file://localhost/c%3A/msys/1.0/temp/example.html][2011+01-01 example]] ) with that change the expression (string-match org-bracket-link-analytic-regexp++ line start) returns 0. My understanding is that the bug resides in this very expression. Thanks for the investigation. As it turned out the problem was not with the regular expression but with the order in which different pieces of Org mode markup were processed by `org-export-as-html'. First the exporter processed possible timestamps, (falsely) recognized the ISO date as part of an ISO timestamp, and replaced it with the timestamp span. The replacement included the square brackets what destroyed the link markup. I've just checked in a patch to master that changes the order of processing links and timestamps: Now links are processed before timestamps what fixes this problem. Thanks for bringing this problem up again, Best, -- David -- OpenPGP... 0x99ADB83B5A4478E6 Jabber dmj...@jabber.org Email. dm...@ictsoc.de pgpE9UptYkWR3.pgp Description: PGP signature ___ 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