From mboxrd@z Thu Jan 1 00:00:00 1970 From: Aaron Miller Subject: 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 Message-ID: <56CE5C4D.5090100@aaron-miller.me> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49876) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYkxs-0004Gh-OC for emacs-orgmode@gnu.org; Wed, 24 Feb 2016 20:43:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aYkxo-0000Lt-LU for emacs-orgmode@gnu.org; Wed, 24 Feb 2016 20:43:36 -0500 Received: from acephalo.us ([70.85.31.34]:58986 helo=mail.acephalo.us) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYkxo-0000Ja-DX for emacs-orgmode@gnu.org; Wed, 24 Feb 2016 20:43:32 -0500 Received: from [10.0.4.83] (localhost [127.0.0.1]) (Authenticated sender: me@mail.acephalo.us) by mail.acephalo.us (Postfix) with ESMTPA id 46C991115E for ; Thu, 25 Feb 2016 01:43:28 +0000 (UTC) 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: emacs-orgmode@gnu.org Expected: When exporting an Org document with named source blocks to=20 HTML, each
 generated to contain a source block has an ID attribute=20
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 ---
;; hi
--- 8< cut here --- Actual result (its likewise): --- >8 cut here ---
;; hi
--- 8< cut here --- Note the erroneous ID attribute value. The issue here is that, in `org-html-src-block' and=20 `org-html-inline-src-block', the fallback behavior for ID attribute=20 value is implemented in terms of `and', rather than `or'. Since `and'=20 short-circuits only when it encounters a null argument, the desired=20 behavior is effectively inverted. Replacing `and' with `or' in the two=20 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=3D\"%s\"" lbl))))) (format "%s" 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=3D\"%s\"" lbl) "")))) (if (not lang) (format "
\n%s
"=20 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=20 AppKit 1265.21) of 2016-02-19 on teeny Package: Org-mode version 8.3.4 (8.3.4-elpa @=20 /Users/aaron/.emacs.d/elpa/org-20160222/) current state: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D (setq org-tab-first-hook '(org-hide-block-toggle-maybe=20 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=20 org-babel-speed-command-hook) org-ellipsis "=E2=80=A6" 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=20 'org-latex-format-inlinetask-default-function org-confirm-shell-link-function 'yes-or-no-p org-ascii-format-inlinetask-function 'org-ascii-format-inlinetask-defau= lt 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=20 'org-latex-format-headline-default-function org-todo-keyword-faces '(("TODO" . "white") ("ALYS" . "magenta2")=20 ("DVLP" . "CadetBlue1") ("TEST" . "yellow1") ("DONE" . "green1")=20 ("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 "\\" org-src-mode-hook '(org-src-babel-configure-edit-buffer=20 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=20 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)=20 (quote local)) ) visual-line-mode #[nil "\300\301\302\303\304$\207" [org-add-hook change-major-mode-hook=20 org-show-block-all append local] 5] #[nil "\300\301\302\303\304$\207" [org-add-hook change-major-mode-hook=20 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) content= s) org-replace-disputed-keys t org-ctrl-c-ctrl-c-hook '(org-babel-hash-at-point=20 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-drawer= s org-cycle-show-empty-lines=20 org-optimize-window-after-visibility-change) org-html-creator-string "Emacs 24.4.1 (Org mode 8.3.3)" org-todo-keywords '((sequence "TODO" "ALYS" "DVLP" "TEST" "DONE"=20 "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=20 '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=20 '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=20 org-babel-suppress-evaluation-prompt-token "\\s-*\n") body) nil) (t t)) ) )