* Bug: HTML export fails to set source IDs correctly [8.3.4 (8.3.4-elpa @ /Users/aaron/.emacs.d/elpa/org-20160222/)]
@ 2016-02-25 1:43 Aaron Miller
2016-02-25 20:19 ` Nicolas Goaziou
0 siblings, 1 reply; 6+ messages in thread
From: Aaron Miller @ 2016-02-25 1:43 UTC (permalink / raw)
To: emacs-orgmode
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))
)
)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Bug: HTML export fails to set source IDs correctly [8.3.4 (8.3.4-elpa @ /Users/aaron/.emacs.d/elpa/org-20160222/)]
2016-02-25 1:43 Bug: HTML export fails to set source IDs correctly [8.3.4 (8.3.4-elpa @ /Users/aaron/.emacs.d/elpa/org-20160222/)] Aaron Miller
@ 2016-02-25 20:19 ` Nicolas Goaziou
2016-02-25 21:38 ` Aaron Miller
0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2016-02-25 20:19 UTC (permalink / raw)
To: Aaron Miller; +Cc: emacs-orgmode
Hello,
Aaron Miller <me@aaron-miller.me> writes:
> 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 attribute is intended.
> 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.
Actually this is the desired behaviour: when a label is specified, make
sure to replace it with our internal unique and safe label. Hence the
`and'.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Bug: HTML export fails to set source IDs correctly [8.3.4 (8.3.4-elpa @ /Users/aaron/.emacs.d/elpa/org-20160222/)]
2016-02-25 20:19 ` Nicolas Goaziou
@ 2016-02-25 21:38 ` Aaron Miller
2016-02-27 8:38 ` Nicolas Goaziou
0 siblings, 1 reply; 6+ messages in thread
From: Aaron Miller @ 2016-02-25 21:38 UTC (permalink / raw)
To: Nicolas Goaziou; +Cc: emacs-orgmode@gnu.org
[-- Attachment #1: Type: text/plain, Size: 2157 bytes --]
The difficulty here is that ID attribute values are not easily predictable, and dependent on the source block's position in the document. This complicates tasks like styling a specific source block -- with the previous ID generation method, this could be reliably done with an ID selector; with the current behavior, that's no longer true.
Can you provide some insight on why the behavior was changed? I'd be happy to expand the scope of my bug report to cover whatever code relies on the change. Thanks!
--
Aaron Miller
Mobile: (443) 902-4702
me@aaron-miller.me
http://aaron-miller.me
> On Feb 25, 2016, at 15:19, Nicolas Goaziou <mail@nicolasgoaziou.fr> wrote:
>
> Hello,
>
> Aaron Miller <me@aaron-miller.me> writes:
>
>> 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 attribute is intended.
>
>> 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.
>
> Actually this is the desired behaviour: when a label is specified, make
> sure to replace it with our internal unique and safe label. Hence the
> `and'.
>
>
> Regards,
>
> --
> Nicolas Goaziou
[-- Attachment #2: Type: text/html, Size: 5213 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Bug: HTML export fails to set source IDs correctly [8.3.4 (8.3.4-elpa @ /Users/aaron/.emacs.d/elpa/org-20160222/)]
2016-02-25 21:38 ` Aaron Miller
@ 2016-02-27 8:38 ` Nicolas Goaziou
2016-02-28 16:00 ` Aaron Miller
0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Goaziou @ 2016-02-27 8:38 UTC (permalink / raw)
To: Aaron Miller; +Cc: emacs-orgmode@gnu.org
Hello,
Aaron Miller <me@aaron-miller.me> writes:
> Can you provide some insight on why the behavior was changed?
You needed to conform your labels to the target language, i.e, make sure
the label didn't contain any forbidden characters, which you were
expected to know.
`org-latex-prefer-user-labels' explains it very well. It is for `latex'
back-end only, however.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Bug: HTML export fails to set source IDs correctly [8.3.4 (8.3.4-elpa @ /Users/aaron/.emacs.d/elpa/org-20160222/)]
2016-02-27 8:38 ` Nicolas Goaziou
@ 2016-02-28 16:00 ` Aaron Miller
2016-02-28 16:24 ` Nicolas Goaziou
0 siblings, 1 reply; 6+ messages in thread
From: Aaron Miller @ 2016-02-28 16:00 UTC (permalink / raw)
To: emacs-orgmode@gnu.org
Can you comment on the likelihood of a patch being accepted that gives
HTML export a parallel option, with all the associated caveats? It seems
like the use case is pretty clear, and I don't mind taking the time to
write up the change.
On 2/27/16 3:38, Nicolas Goaziou wrote:
> Hello,
>
> Aaron Miller <me@aaron-miller.me> writes:
>
>> Can you provide some insight on why the behavior was changed?
> You needed to conform your labels to the target language, i.e, make sure
> the label didn't contain any forbidden characters, which you were
> expected to know.
>
> `org-latex-prefer-user-labels' explains it very well. It is for `latex'
> back-end only, however.
>
>
> Regards,
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Bug: HTML export fails to set source IDs correctly [8.3.4 (8.3.4-elpa @ /Users/aaron/.emacs.d/elpa/org-20160222/)]
2016-02-28 16:00 ` Aaron Miller
@ 2016-02-28 16:24 ` Nicolas Goaziou
0 siblings, 0 replies; 6+ messages in thread
From: Nicolas Goaziou @ 2016-02-28 16:24 UTC (permalink / raw)
To: Aaron Miller; +Cc: emacs-orgmode@gnu.org
Hello,
Aaron Miller <me@aaron-miller.me> writes:
> Can you comment on the likelihood of a patch being accepted that gives
> HTML export a parallel option, with all the associated caveats? It
> seems like the use case is pretty clear, and I don't mind taking the
> time to write up the change.
Patch welcome!
There one noticeable difference between HTML and LaTeX export back-ends.
In the former, CUSTOM-ID property is always exported as-is, so I assume
the variable should be a no-op for this.
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-02-28 16:22 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-25 1:43 Bug: HTML export fails to set source IDs correctly [8.3.4 (8.3.4-elpa @ /Users/aaron/.emacs.d/elpa/org-20160222/)] Aaron Miller
2016-02-25 20:19 ` Nicolas Goaziou
2016-02-25 21:38 ` Aaron Miller
2016-02-27 8:38 ` Nicolas Goaziou
2016-02-28 16:00 ` Aaron Miller
2016-02-28 16:24 ` 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).