emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] Bug: HTML export fails to set source IDs correctly [8.3.4 (8.3.4-elp


From: Aaron Miller
Subject: [O] Bug: HTML export fails to set source IDs correctly [8.3.4 (8.3.4-elpa @ /Users/aaron/.emacs.d/elpa/org-20160222/)]
Date: Wed, 24 Feb 2016 20:43:41 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.5.0

Expected: When exporting an Org document with named source blocks to HTML, each <pre> generated to contain a source block has an ID attribute matching the source block's name.

Actual: Instead, ID attributes come out with values like "orgsrcblock1".

Test case:
--- >8 cut here ---
#+TITLE: bug test case

#+NAME: a-source-block
#+BEGIN_SRC emacs-lisp :eval never
;; hi
#+END_SRC
--- 8< cut here ---

Expected result (its salient subset):
--- >8 cut here ---
<pre class="src src-emacs-lisp" id="a-source-block">
;; hi
</pre>
--- 8< cut here ---

Actual result (its likewise):
--- >8 cut here ---
<pre class="src src-emacs-lisp" id="orgsrcblock1">
;; hi
</pre>
--- 8< cut here ---

Note the erroneous ID attribute value.

The issue here is that, in `org-html-src-block' and `org-html-inline-src-block', the fallback behavior for ID attribute value is implemented in terms of `and', rather than `or'. Since `and' short-circuits only when it encounters a null argument, the desired behavior is effectively inverted. Replacing `and' with `or' in the two affected locations solves the problem, as reflected in the following diff:

--- >8 cut here ---
--- broke/ox-html.el    2016-02-24 20:15:22.000000000 -0500
+++ fixed/ox-html.el    2016-02-24 20:10:37.000000000 -0500
@@ -2533,7 +2533,7 @@
   (let ((lang (org-element-property :language inline-src-block))
     (code (org-html-format-code inline-src-block info))
     (label
-     (let ((lbl (and (org-element-property :name inline-src-block)
+     (let ((lbl (or (org-element-property :name inline-src-block)
              (org-export-get-reference inline-src-block info))))
        (if (not lbl) "" (format " id=\"%s\"" lbl)))))
     (format "<code class=\"src src-%s\"%s>%s</code>" lang label code)))
@@ -3213,7 +3213,7 @@
     (let ((lang (org-element-property :language src-block))
       (caption (org-export-get-caption src-block))
       (code (org-html-format-code src-block info))
-      (label (let ((lbl (and (org-element-property :name src-block)
+      (label (let ((lbl (or (org-element-property :name src-block)
                  (org-export-get-reference src-block info))))
            (if lbl (format " id=\"%s\"" lbl) ""))))
(if (not lang) (format "<pre class=\"example\"%s>\n%s</pre>" label code)
--- 8< cut here ---

Hope this helps.

`org-submit-bug-report' details follow:

Emacs : GNU Emacs 24.4.1 (x86_64-apple-darwin13.4.0, Carbon Version 157 AppKit 1265.21)
 of 2016-02-19 on teeny
Package: Org-mode version 8.3.4 (8.3.4-elpa @ /Users/aaron/.emacs.d/elpa/org-20160222/)

current state:
==============
(setq
org-tab-first-hook '(org-hide-block-toggle-maybe org-babel-hide-result-toggle-maybe
                      org-babel-header-arg-expand)
 org-log-note-clock-out t
org-speed-command-hook '(org-speed-command-default-hook org-babel-speed-command-hook)
 org-ellipsis "…"
 org-occur-hook '(org-first-headline-recenter)
 org-metaup-hook '(org-babel-load-in-session-maybe)
 org-html-format-drawer-function '(lambda (name contents) contents)
org-latex-format-inlinetask-function 'org-latex-format-inlinetask-default-function
 org-confirm-shell-link-function 'yes-or-no-p
 org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-default
 org-fontify-emphasized-text nil
 org-pretty-entities t
 org-support-shift-select 'always
 org-export-with-sub-superscripts nil
org-latex-format-headline-function 'org-latex-format-headline-default-function org-todo-keyword-faces '(("TODO" . "white") ("ALYS" . "magenta2") ("DVLP" . "CadetBlue1") ("TEST" . "yellow1") ("DONE" . "green1") ("REWK" . "red")
                          ("NOPE" . "gray60"))
 org-after-todo-state-change-hook '(org-clock-out-if-current)
 org-latex-format-drawer-function '(lambda (name contents) contents)
 org-from-is-user-regexp "\\<Aaron Miller\\>"
org-src-mode-hook '(org-src-babel-configure-edit-buffer org-src-mode-configure-edit-buffer)
 org-agenda-before-write-hook '(org-agenda-add-entry-text)
 org-pretty-entities-include-sub-superscripts nil
 org-babel-pre-tangle-hook '(save-buffer)
 org-mode-hook '((lambda nil
(org-add-hook (quote change-major-mode-hook) (quote org-show-block-all)
                   (quote append) (quote local))
                  )
                 (lambda nil
                  (org-add-hook (quote change-major-mode-hook)
(quote org-babel-show-result-all) (quote append) (quote local))
                  )
                 visual-line-mode
                 #[nil "\300\301\302\303\304$\207"
[org-add-hook change-major-mode-hook org-show-block-all append local] 5]
                 #[nil "\300\301\302\303\304$\207"
[org-add-hook change-major-mode-hook org-babel-show-result-all append
                    local]
                   5]
                 org-babel-result-hide-spec org-babel-hide-all-hashes)
 org-archive-hook '(org-attach-archive-delete-maybe)
 org-ascii-format-drawer-function '(lambda (name contents width) contents)
 org-replace-disputed-keys t
org-ctrl-c-ctrl-c-hook '(org-babel-hash-at-point org-babel-execute-safely-maybe)
 org-insert-mode-line-in-empty-file t
 org-enforce-todo-dependencies t
 org-cycle-hook '(org-cycle-hide-archived-subtrees org-cycle-hide-drawers
org-cycle-show-empty-lines org-optimize-window-after-visibility-change) org-html-creator-string "<a href=\"http://www.gnu.org/software/emacs/\";>Emacs</a> 24.4.1 (<a href=\"http://orgmode.org\";>Org</a> mode 8.3.3)" org-todo-keywords '((sequence "TODO" "ALYS" "DVLP" "TEST" "DONE" "REWK" "NOPE"))
 org-confirm-elisp-link-function 'yes-or-no-p
 org-metadown-hook '(org-babel-pop-to-session-maybe)
 org-blocker-hook '(org-block-todo-from-children-or-siblings-or-parent)
org-html-format-headline-function 'org-html-format-headline-default-function
 org-cycle-separator-lines 1
 org-export-creator-string "Emacs 24.4.1 (Org mode 8.3.3)"
org-html-format-inlinetask-function 'org-html-format-inlinetask-default-function
 org-agenda-files '("~/list-files-todo")
 org-clock-out-hook '(org-clock-remove-empty-clock-drawer)
 org-confirm-babel-evaluate '(lambda (lang body)
                              (cond
                               ((string-match
(concat org-babel-suppress-evaluation-prompt-token
                                  "\\s-*\n")
                                 body)
                                nil)
                               (t t))
                              )
 )




reply via email to

[Prev in Thread] Current Thread [Next in Thread]