emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* New exporter problem with #+AUTHOR
@ 2013-04-07 19:40 Bernt Hansen
  2013-04-08  7:01 ` Nicolas Goaziou
  2013-04-08 20:33 ` Nicolas Goaziou
  0 siblings, 2 replies; 4+ messages in thread
From: Bernt Hansen @ 2013-04-07 19:40 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

Hi Nicolas,

I have the following line in my org-mode document

#+AUTHOR: Bernt Hansen (IRC:BerntH on freenode)

On the old exporter this became

<meta name="author" content="Bernt Hansen (IRC:BerntH on freenode)"/>

I just tried exporting this with the new exporter and I get this

<meta name="author" content="Bernt Hansen (<a href="BerntH">BerntH</a>
on freenode)"/>

which isn't legal HTML.  The quotes on the href="BerntH" close the
previous context= quote.

Adding a space after IRC: seems to work

<meta name="author" content="Bernt Hansen (IRC: BerntH on freenode)"/>

Regards,
Bernt

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: New exporter problem with #+AUTHOR
  2013-04-07 19:40 New exporter problem with #+AUTHOR Bernt Hansen
@ 2013-04-08  7:01 ` Nicolas Goaziou
  2013-04-08 19:27   ` Bastien
  2013-04-08 20:33 ` Nicolas Goaziou
  1 sibling, 1 reply; 4+ messages in thread
From: Nicolas Goaziou @ 2013-04-08  7:01 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: emacs-orgmode

Hello,

Bernt Hansen <bernt@norang.ca> writes:

> I have the following line in my org-mode document
>
> #+AUTHOR: Bernt Hansen (IRC:BerntH on freenode)
>
> On the old exporter this became
>
> <meta name="author" content="Bernt Hansen (IRC:BerntH on freenode)"/>
>
> I just tried exporting this with the new exporter and I get this
>
> <meta name="author" content="Bernt Hansen (<a href="BerntH">BerntH</a>
> on freenode)"/>
>
> which isn't legal HTML.  The quotes on the href="BerntH" close the
> previous context= quote.
>
> Adding a space after IRC: seems to work
>
> <meta name="author" content="Bernt Hansen (IRC: BerntH on freenode)"/>

Well, technically, irc:BerntH is a plain link, like http://orgmode.org,
since irc: is a valid protocol. That may bite you in other parts of the
document.

Of course, the anchor shouldn't appear in the attribute. I'll have
a look at it. Thanks for reporting it.


Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: New exporter problem with #+AUTHOR
  2013-04-08  7:01 ` Nicolas Goaziou
@ 2013-04-08 19:27   ` Bastien
  0 siblings, 0 replies; 4+ messages in thread
From: Bastien @ 2013-04-08 19:27 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: Bernt Hansen, emacs-orgmode

Hi Bernt,

Nicolas Goaziou <n.goaziou@gmail.com> writes:

> Well, technically, irc:BerntH is a plain link, like http://orgmode.org,
> since irc: is a valid protocol. That may bite you in other parts of the
> document.

As a workaround, you can also remove org-irc.el from `org-modules' so
that irc:... is not recognized as a link protocol.

HTH,

-- 
 Bastien

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: New exporter problem with #+AUTHOR
  2013-04-07 19:40 New exporter problem with #+AUTHOR Bernt Hansen
  2013-04-08  7:01 ` Nicolas Goaziou
@ 2013-04-08 20:33 ` Nicolas Goaziou
  1 sibling, 0 replies; 4+ messages in thread
From: Nicolas Goaziou @ 2013-04-08 20:33 UTC (permalink / raw)
  To: Bernt Hansen; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 649 bytes --]

Hello,

Bernt Hansen <bernt@norang.ca> writes:

> I have the following line in my org-mode document
>
> #+AUTHOR: Bernt Hansen (IRC:BerntH on freenode)
>
> On the old exporter this became
>
> <meta name="author" content="Bernt Hansen (IRC:BerntH on freenode)"/>
>
> I just tried exporting this with the new exporter and I get this
>
> <meta name="author" content="Bernt Hansen (<a href="BerntH">BerntH</a>
> 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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-html-Fix-invalid-syntax-in-html-attributes.patch --]
[-- Type: text/x-patch, Size: 3937 bytes --]

From 6d8c48145ffd00ce82f2f19d1fd223a6a1c13a15 Mon Sep 17 00:00:00 2001
From: Nicolas Goaziou <n.goaziou@gmail.com>
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
+   "\"" "&quot;"
+   (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 "<title>%s</title>\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 "<meta name=\"generator\" content=\"Org-mode\"/>\n")
-     (and author (format "<meta name=\"author\" content=\"%s\"/>\n" author))
-     (and description
+     (and (org-string-nw-p author)
+	  (format "<meta name=\"author\" content=\"%s\"/>\n" author))
+     (and (org-string-nw-p description)
 	  (format "<meta name=\"description\" content=\"%s\"/>\n" description))
-     (and keywords
+     (and (org-string-nw-p keywords)
 	  (format "<meta name=\"keywords\" content=\"%s\"/>\n" keywords)))))
 
 (defun org-html--build-head (info)
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-04-08 20:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-07 19:40 New exporter problem with #+AUTHOR Bernt Hansen
2013-04-08  7:01 ` Nicolas Goaziou
2013-04-08 19:27   ` Bastien
2013-04-08 20:33 ` Nicolas Goaziou

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).