From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: New exporter problem with #+AUTHOR Date: Mon, 08 Apr 2013 22:33:45 +0200 Message-ID: <8738v0vk2e.fsf@gmail.com> References: <87zjxa3zal.fsf@norang.ca> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:33676) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPIlU-0001aw-RR for emacs-orgmode@gnu.org; Mon, 08 Apr 2013 16:34:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UPIlD-0008RE-Ok for emacs-orgmode@gnu.org; Mon, 08 Apr 2013 16:34:08 -0400 Received: from mail-we0-x233.google.com ([2a00:1450:400c:c03::233]:56419) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPIlD-0008Qm-DX for emacs-orgmode@gnu.org; Mon, 08 Apr 2013 16:33:51 -0400 Received: by mail-we0-f179.google.com with SMTP id p43so4842341wea.24 for ; Mon, 08 Apr 2013 13:33:50 -0700 (PDT) In-Reply-To: <87zjxa3zal.fsf@norang.ca> (Bernt Hansen's message of "Sun, 07 Apr 2013 15:40:02 -0400") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Bernt Hansen Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Hello, Bernt Hansen writes: > I have the following line in my org-mode document > > #+AUTHOR: Bernt Hansen (IRC:BerntH on freenode) > > On the old exporter this became > > > > I just tried exporting this with the new exporter and I get this > > BerntH > on freenode)"/> > > which isn't legal HTML. The quotes on the href="BerntH" close the > previous context= quote. Here is a suggested patch to fix export of data meant to appear as an attribute value. WDYT? Regards, -- Nicolas Goaziou --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-ox-html-Fix-invalid-syntax-in-html-attributes.patch >From 6d8c48145ffd00ce82f2f19d1fd223a6a1c13a15 Mon Sep 17 00:00:00 2001 From: Nicolas Goaziou Date: Mon, 8 Apr 2013 22:24:29 +0200 Subject: [PATCH] ox-html: Fix invalid syntax in html attributes * lisp/ox-html.el (org-html--export-attribute): New function. (org-html--build-meta-info): Use new function. --- lisp/ox-html.el | 62 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 53 insertions(+), 9 deletions(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 39b0ec9..6b964da 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -1265,6 +1265,48 @@ ELEMENT is either a src block or an example block." (or (plist-get attr :height) (org-count-lines code)) code))) +(defun org-html--export-attribute (data info) + "Export DATA as a string suitable for an attribute value. + +DATA is an object, a secondary string or a string. INFO is +a plist used as a communication channel. + +To make output suitable as an attribute value, every markup is +removed and special characters, including quotes, are escaped." + (replace-regexp-in-string + "\"" """ + (org-export-data + (org-export-data-with-translations + data + (append + (mapcar + (lambda (type) + (cond ((eq type 'link) + (cons type + (lambda (link contents info) + (or (org-string-nw-p contents) + (org-element-property :raw-link link))))) + ((eq type 'subscript) + (cons type + (lambda (super contents info) (format "_%s" contents)))) + ((eq type 'superscript) + (cons type + (lambda (super contents info) (format "^%s" contents)))) + ((eq type 'plain-text) (cons type (lambda (text info) text))) + ((memq type '(code verbatim)) + (cons type (lambda (obj contents info) + (org-element-property :value obj)))) + ((memq type org-element-recursive-objects) + (cons type (lambda (obj contents info) contents))) + ((memq type '(export-snippet + footnote-reference latex-fragment line-break + statistics-cookie target)) + (cons type 'ignore)))) + org-element-all-objects) + (org-export-backend-translate-table 'html)) + info) + info))) + ;;;; Bibliography (defun org-html-bibliography () @@ -1423,12 +1465,13 @@ INFO is a plist used as a communication channel." (defun org-html--build-meta-info (info) "Return meta tags for exported document. INFO is a plist used as a communication channel." - (let* ((title (org-export-data (plist-get info :title) info)) - (author (and (plist-get info :with-author) - (let ((auth (plist-get info :author))) - (and auth (org-export-data auth info))))) - (description (plist-get info :description)) - (keywords (plist-get info :keywords))) + (let ((title (org-export-data (plist-get info :title) info)) + (author (and (plist-get info :with-author) + (let ((auth (plist-get info :author))) + (and auth (org-html--export-attribute auth info))))) + (description (org-html--export-attribute + (plist-get info :description) info)) + (keywords (org-html--export-attribute (plist-get info :keywords) info))) (concat (format "%s\n" title) (format @@ -1442,10 +1485,11 @@ INFO is a plist used as a communication channel." (coding-system-get org-html-coding-system 'mime-charset)) "iso-8859-1")) (format "\n") - (and author (format "\n" author)) - (and description + (and (org-string-nw-p author) + (format "\n" author)) + (and (org-string-nw-p description) (format "\n" description)) - (and keywords + (and (org-string-nw-p keywords) (format "\n" keywords))))) (defun org-html--build-head (info) -- 1.8.2.1 --=-=-=--