emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Baoqiu Cui <cbaoqiu@yahoo.com>
To: emacs-orgmode@gnu.org
Subject: Re: #+LABEL: in HTML export
Date: Fri, 02 Apr 2010 15:51:38 -0700	[thread overview]
Message-ID: <bycmxxlxybp.fsf@yahoo-inc.com> (raw)
In-Reply-To: EFFF7165-7182-4B38-8379-B1B00609A29A@gmail.com

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

Hi Carsten,

I've made corresponding changes in org-docbook.el to support this
feature in the DocBook exporter.  Please check the attached patch, in
which I also fixed a minor bug that was introduced in your recent change
of "new and better support for entities".


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: table-label.diff --]
[-- Type: text/x-patch, Size: 2597 bytes --]

diff --git a/lisp/org-docbook.el b/lisp/org-docbook.el
index 7c43211..700f1db 100644
--- a/lisp/org-docbook.el
+++ b/lisp/org-docbook.el
@@ -1259,13 +1259,13 @@ string, don't modify these."
   (if org-export-with-sub-superscripts
       (setq s (org-export-docbook-convert-sub-super s)))
   (if org-export-with-TeX-macros
-      (let ((start 0) wd rep ass)
+      (let ((start 0) wd rep)
 	(while (setq start (string-match "\\\\\\([a-zA-Z]+\\)\\({}\\)?"
 					 s start))
 	  (if (get-text-property (match-beginning 0) 'org-protected s)
 	      (setq start (match-end 0))
 	    (setq wd (match-string 1 s))
-	    (if (setq ass (org-entity-get-representation wd 'html))
+	    (if (setq rep (org-entity-get-representation wd 'html))
 		(setq s (replace-match rep t t s))
 	      (setq start (+ start (length wd))))))))
   s)
@@ -1349,18 +1349,33 @@ string, don't modify these."
 	(replace-match ""))))
 
 (defun org-export-docbook-finalize-table (table)
-  "Change TABLE to informaltable if caption does not exist.
+  "Clean up TABLE and turn it into DocBook format.
+This function adds a label to the table if it is available, and
+also changes TABLE to informaltable if caption does not exist.
 TABLE is a string containing the HTML code generated by
 `org-format-table-html' for a table in Org-mode buffer."
-  (if (string-match
-       "^<table \\(\\(.\\|\n\\)+\\)<caption></caption>\n\\(\\(.\\|\n\\)+\\)</table>"
-       table)
-      (replace-match (concat "<informaltable "
-			     (match-string 1 table)
-			     (match-string 3 table)
+  (let ((table-with-label label))
+    ;; Get the label if it exists, and move it into the <table> element.
+    (setq table-with-label
+	  (if (string-match
+	       "^<table \\(\\(.\\|\n\\)+\\)<a name=\"\\(.+\\)\" id=\".+\"></a>\n\\(\\(.\\|\n\\)+\\)</table>"
+	       table)
+	      (replace-match (concat "<table xml:id=\"" (match-string 3 table) "\" "
+				     (match-string 1 table)
+				     (match-string 4 table)
+				     "</table>")
+			     nil nil table)
+	    table))
+    ;; Change <table> into <informaltable> if caption does not exist.
+    (if (string-match
+	 "^<table \\(\\(.\\|\n\\)+\\)<caption></caption>\n\\(\\(.\\|\n\\)+\\)</table>"
+	 table-with-label)
+	(replace-match (concat "<informaltable "
+			     (match-string 1 table-with-label)
+			     (match-string 3 table-with-label)
 			     "</informaltable>")
-		     nil nil table)
-    table))
+		       nil nil table-with-label)
+      table-with-label)))
 
 ;; Note: This function is very similar to
 ;; org-export-html-convert-sub-super.  They can be merged in the future.

[-- Attachment #3: Type: text/plain, Size: 856 bytes --]


Carsten Dominik <carsten.dominik@gmail.com> writes:

> Hi Thomas,
>
> Are you talking about figures or about tables?
>
> For figures, the label is attached to the figure as the id of
> the div surrounding figure plus caption.  However, this only
> works if you also specify a caption.  But I think that only
> figures with caption should be targets for links.
>
> For tables, I have just made a change so that the label
> is inserted as an anchor just as you propose:
>
>    <table border="2" cellspacing="0" cellpadding="6" rules="groups"
> frame="hsides">
>    <a name="tab:yyy" id="tab:yyy"></a>
>    <caption>This is a table</caption>
>
> Finally, I am now converting \ref{xxx} macros into links
> for the HTML backend.  One problem is that, so the same
> \ref macro will lead to the figure in both backends.
>
> Hope this helps.

Thanks,

-- 
Baoqiu

[-- Attachment #4: Type: text/plain, Size: 201 bytes --]

_______________________________________________
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

  reply	other threads:[~2010-04-02 22:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-28 20:29 #+LABEL: in HTML export Thomas S. Dye
2010-03-29 12:20 ` Carsten Dominik
2010-04-02 22:51   ` Baoqiu Cui [this message]
2010-04-03  6:33     ` Carsten Dominik
2010-04-03  7:15       ` Baoqiu Cui
2010-04-03  9:23         ` Carsten Dominik
2010-04-03 16:46           ` Baoqiu Cui
2010-04-04  6:53             ` Carsten Dominik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bycmxxlxybp.fsf@yahoo-inc.com \
    --to=cbaoqiu@yahoo.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).