From e490f79284f678a4a4be78e6e068e0eca14f3f4b Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Thu, 30 Jun 2011 23:54:09 +0530 Subject: [PATCH] Merge ngz's footnote changes from master. * lisp/org-odt.el (org-odt-get): Modified * lisp/org-lparse.el (org-do-lparse): Modified * lisp/org-html.el (org-xhtml-get): Modified --- contrib/odt/tests/test.org | 177 ++++++++++++++++++++++++++------------------- lisp/org-html.el | 1 + lisp/org-lparse.el | 19 ++++- lisp/org-odt.el | 1 + 4 files changed, 120 insertions(+), 78 deletions(-) diff --git a/contrib/odt/tests/test.org b/contrib/odt/tests/test.org index 292d97192..762e52812 100644 --- a/contrib/odt/tests/test.org +++ b/contrib/odt/tests/test.org @@ -10,14 +10,17 @@ #+EXPORT_SELECT_TAGS: export #+EXPORT_EXCLUDE_TAGS: noexport -#+LINK_UP: -#+LINK_HOME: +#+LINK_UP: +#+LINK_HOME: #+XSLT: #+STARTUP: overview # Use C-c C-e O or C-c C-e o to export this buffer to OpenDocumentText + +Some text before first headline[fn:1]. + * ODT Exporter :project:hacking: ** Online References - [[http://docs.oasis-open.org/office/v1.1/OS/OpenDocument-v1.1-html/OpenDocument-v1.1.html][ODF Specification]] @@ -39,7 +42,7 @@ styles.xml etc are left staying around. Need to clean these up using unwind-protect? *** TODO Fix all interactive commands - org-export-region-as-odt, org-export-as-odt-to-buffer etc. + org-export-region-as-odt, org-export-as-odt-to-buffer etc. #+begin_src sh emacs --batch -L "~/src/org-jambu/lisp" --eval "(progn (require 'org-odt) (setq org-export-headline-levels 3) (toggle-debug-on-error))" --visit=draftcopy.org --funcall org-export-as-odt-batch #+end_src @@ -66,19 +69,19 @@ **** TODO Export of test.org with LaTeX:verbatim option Equations under [[LaTeX Fragments]] go invisible -**** TODO Broken link within [[References to Dedicated Target]] +**** TODO Broken link within [[References to Dedicated Target]] *** TODO Support for MathML [2011-03-29 Tue] MathToWeb could be used for this. See [[http://lists.gnu.org/archive/html/emacs-orgmode/2011-03/msg01755.html][following post]]. -*** TODO Validation failures with =HTML_CONTAINER_CLASS= +*** TODO Validation failures with =HTML_CONTAINER_CLASS= [2011-04-02 Sat] :PROPERTIES: :HTML_CONTAINER_CLASS: custom :END: - This section introduces two issues. + This section introduces two issues. - A text:span element cannot occur within text:bookmark-ref. How to handle this. - text:style-name attribute for text:section cannot have @@ -110,7 +113,7 @@ - L2.3 - L1.3 - + *** DONE Support for Custom Styles CLOSED: <2011-03-24 Thu> :LOGBOOK: @@ -135,23 +138,23 @@ *** Bold *This is bold text* - + *** Italic /This is an italicized text/ - + *** Underline _This is an underlined text_ - + *** Code =This is a code text= - + *** Verbatim ~This is a verbatim text~ - + *** Strikethrough +This is a strikethorugh text+ @@ -160,26 +163,26 @@ Y = a_{0}X^{2}+a_{1}X^{1}+a_{2} ** Miscellaneous - + Here is a ndash --, a mdash ---, an ellipsis .... - + and a horizontal line --------------------- ** Special entities \alpha^{n} = \beta^{n} + \gamma^{n} - + ** Paragraph Styles *** Quotation - + **** Style1 #+BEGIN_QUOTE Everything should be made as simple as possible, but not any simpler -- Albert Einstein #+END_QUOTE - + **** QUOTE Style2 Everything should be made as simple as possible, @@ -191,47 +194,47 @@ Great clouds overhead Tiny black birds rise and fall Snow covers Emacs - + -- AlexSchroeder #+END_VERSE - + *** Centered #+BEGIN_CENTER This is a centered paragraph. #+END_CENTER - + *** Example **** Example Style 1 #+begin_example First line of the example. Second line of the example. -#+end_example - +#+end_example + **** Example Style 2 : First line of the example. : Second line of the example. - - + + *** Source Block -**** Emacs Lisp Block +**** Emacs Lisp Block #+begin_src emacs-lisp - (defun helloworld () + (defun helloworld () "" (message "hello world")) -#+end_src - +#+end_src + **** Org Source Block - + #+begin_src org ,* Some Appointment , SCHEDULED: <2010-11-17 Wed> -#+end_src +#+end_src -**** Advanced Source Blocks - Advanced source blocks takes the following options +**** Advanced Source Blocks + Advanced source blocks takes the following options - [-+]n: restart or continue numbering - r: remove labels - k: keep @@ -258,13 +261,13 @@ ** Native HTML and ODT *** Handcrafted Para - + #+begin_html -

+

This is a handwritten html para

#+end_html - + #+begin_odt This is a handwritten odt para @@ -273,7 +276,7 @@ #+HTML:
*English Alphabets* - A - - B + - B - C *Greek Alphabets* - Alpha @@ -338,22 +341,22 @@ ** Lists *** Simple Lists **** Numbered List - + This is a numbered list. - + 1. L1N1 2. L1N2 3. L1N3 - + **** Bulleted List - + This is a bulleted list. - L1B1 - L1B2 - L1B3 - + **** Description List - + There is a nested description list down below - Term-1 :: This is a definition for Term-1 which wraps around to the next line @@ -361,9 +364,9 @@ the next line - Term-2.1 :: Definition for Term-2.1 - Term-2.2 :: Definition for Term-2.2 - + **** A Complex List - + 1. L1N1 1. L2N2 2. L2N3 @@ -371,11 +374,11 @@ * L2B1 * L2B2 - L3B3 - + First paragraph. - + Second paragraph. - + - L3B4 3. L1N5 1. L2N6 @@ -402,7 +405,7 @@ The Goonies - Embedded Definition 1 :: Embedded Description 1 - Embedded Definition 2 :: Embedded Description 2 - + ** Images *** Image URLs See the You can see the official logo of Orgmode here: @@ -412,9 +415,9 @@ **** A simple inlined image [[./org-mode-unicorn.png]] - + **** A simple image with caption and label - + #+CAPTION: Unicorn Logo #+LABEL: fig:1024 [[./org-mode-unicorn.png]] @@ -431,28 +434,28 @@ *** Thumbnails This is a clickable image [[http://orgmode.org][./org-mode-unicorn.png]] - + *** Reference to an Image Please refer to \ref{fig:1024} for further information. - -*** LaTeX Fragments + +*** LaTeX Fragments **** LaTeX Fragment1 # See org-format-latex-options - + There is a equation down below. \begin{equation} e = \frac{1}{2}mv^2 \end{equation} - + **** LaTeX Fragment2 - + \begin{equation} - x=\sqrt{b} + x=\sqrt{b} \end{equation} - + If $a^2=b$ and \( b=2 \), then the solution must be either $$ a=+\sqrt{2} $$ or \[ a=-\sqrt{2} \]. @@ -470,33 +473,33 @@ :PROPERTIES: :CUSTOM_ID: aabbccddeeff :END: - + **** Dedicated Target Style1 -# <> - +# <> + **** Dedicated Target Style2 There is a dedicated target at the end of this sentence - <>. - + **** <<>> - + *** References **** References to Fuzzy Target This is a link to [[Fuzzy Target]]. - + **** References to CUSTOMID links This is a link to [[#aabbccddeeff][Target with CUSTOMID]]. This is nodesc link to [[#aabbccddeeff]]. - + **** References to Dedicated Target There is a link to nodesc [[Dedicated Target]] here. There is a link to [[Dedicated%20Target][Jump to Dedicated Target]] here. - + There is a link to [[Dedicated%20Target1][Dedicated Target1]] here. - + **** References to Radioed Links This section has references to Radioed Target. One more reference @@ -504,7 +507,7 @@ ** Tables *** A simple Orgmode Table - + | EST | New York | -5:00 | | IST | Madras | +5:30 | | AST | Bahrain | | @@ -548,9 +551,9 @@ |Full |100% | |Whole | | +---------------+---------------+ - + *** Table.el Table with Spanning - + +----------+---------------------+----------+ |Name |cmd calls |Percentage| +----------+ +----------+ @@ -560,7 +563,7 @@ +----------+ +----------+ |total |203 118 |100% | +----------+---------------------+----------+ - + *** Another Table.el Table with Spanning +-----------+----------+ @@ -587,7 +590,7 @@ This paragraph has multiple references to the same footnote. This is the first reference to a footnote [1]. This is a second reference to the same footnote [1]. - + *** Named Footnotes Footnote named XYZ [fn:XYZ]. @@ -595,15 +598,36 @@ *** Inlined Footnote Inlined footnote [fn:: inline definition] - + *** Named and Inlined Footnote Named and Inlined footnote [fn:name: named definition] - # Footnote Definitions (Part 2) + [1] Quick brown fox jumps over the lazy dog. Quick brown fox jumps ove -the lazy dog. +the lazy dog. + +** Back-to-back footnotes + + Sample examples down below are taken from + http://lists.gnu.org/archive/html/emacs-orgmode/2011-05/msg00426.html. + +*** First headline + +# [fn::fake footnote + + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do + eiusmod tempor incididunt ut labore et dolore magna + aliqua[fn::inline1][1]. + +*** Second headline + + Duis aute irure dolor in reprehenderit in voluptate velit esse + cillum dolore eu fugiat nulla pariatur[fn:inlabel:an inline + footnote][fn:inlabel2:[[http://www.google.com][google]] this]. + + Call an already defined inline footnote[fn:inlabel]. ** About Orgmode Org is a mode for keeping notes, maintaining TODO lists, and doing @@ -659,3 +683,6 @@ the lazy dog. questions (FAQ), links to tutorials, etc. This page is located at http://orgmode.org. +* Footnotes + +[fn:1] This footnote referenced before first headline. diff --git a/lisp/org-html.el b/lisp/org-html.el index 79e61561e..25339b73e 100644 --- a/lisp/org-html.el +++ b/lisp/org-html.el @@ -1644,6 +1644,7 @@ lang=\"%s\" xml:lang=\"%s\"> org-export-html-table-use-header-tags-for-first-column) (TODO-KWD-CLASS-PREFIX org-export-html-todo-kwd-class-prefix) (TAG-CLASS-PREFIX org-export-html-tag-class-prefix) + (FOOTNOTE-SEPARATOR org-export-html-footnote-separator) (t (error "Unknown property: %s" what)))) (defun org-xhtml-get-coding-system-for-write () diff --git a/lisp/org-lparse.el b/lisp/org-lparse.el index ece835b6f..5e8f5abc0 100755 --- a/lisp/org-lparse.el +++ b/lisp/org-lparse.el @@ -631,13 +631,15 @@ version." (if region-p (region-beginning) (point-min)) (if region-p (region-end) (point-max)))) (org-export-have-math nil) + (org-export-footnotes-seen nil) + (org-export-footnotes-data (org-footnote-all-labels 'with-defs)) (org-footnote-insert-pos-for-preprocessor 'point-min) (lines (org-split-string (org-export-preprocess-string region :emph-multiline t - :for-backend (if (equal org-lparse-backend 'xhtml) ; hack + :for-backend (if (equal org-lparse-backend 'xhtml) ; hack 'html org-lparse-backend) :skip-before-1st-heading @@ -896,7 +898,10 @@ version." (when org-export-with-footnotes (setq start 0) (while (string-match "\\([^* \t].*?\\)[ \t]*\\[\\([0-9]+\\)\\]" line start) - (if (get-text-property (match-beginning 2) 'org-protected line) + ;; Discard protected matches not clearly identified as + ;; footnote markers. + (if (or (get-text-property (match-beginning 2) 'org-protected line) + (not (get-text-property (match-beginning 2) 'org-footnote line))) (setq start (match-end 2)) (let ((n (match-string 2 line)) refcnt a) (if (setq a (assoc n footref-seen)) @@ -912,7 +917,15 @@ version." (org-lparse-format 'FOOTNOTE-REFERENCE n (cdr (assoc n org-lparse-footnote-definitions)) - refcnt)) + refcnt) + ;; If another footnote is following the + ;; current one, add a separator. + (if (save-match-data + (string-match "\\`\\[[0-9]+\\]" + (substring line (match-end 0)))) + (ignore-errors + (org-lparse-get 'FOOTNOTE-SEPARATOR)) + "")) t t line)))))) (cond diff --git a/lisp/org-odt.el b/lisp/org-odt.el index 85bb92fc7..1a496322a 100644 --- a/lisp/org-odt.el +++ b/lisp/org-odt.el @@ -1373,6 +1373,7 @@ MAY-INLINE-P allows inlining it as an image." (INLINE-IMAGE-EXTENSIONS '("png" "jpeg" "jpg" "gif" "svg")) (PLAIN-TEXT-MAP '(("&" . "&") ("<" . "<") (">" . ">"))) (TABLE-FIRST-COLUMN-AS-LABELS nil) + (FOOTNOTE-SEPARATOR (org-lparse-format 'FONTIFY "," 'superscript)) (t (error "Unknown property: %s" what)))) (defun org-odt-parse-label (label) -- 2.11.4.GIT