* ISSUE: org publish document processor silently inserts licensed content into targets by default
@ 2020-05-19 0:38 Anthony Carrico
2020-05-22 15:10 ` Bastien
0 siblings, 1 reply; 3+ messages in thread
From: Anthony Carrico @ 2020-05-19 0:38 UTC (permalink / raw)
To: emacs-orgmode
ISSUE: An author should expect a compiler to avoid claiming authorship
over target code, however, currently the org-mode publish document
processor silently inserts licensed content into target documents by
default.
SOLUTION: The following script is a drop-in-replacement which provides
the same API as the original, without a license. It also opts not to
highlight code links, but only their targets, which seems less
distracting (it is a simple change to keep the original behavior if
preferred).
The public domain version works in a different way than the original,
fixing a potential bug. It adds(removes) highlighting rather than
replacing the original format. Ignoring the boilerplate, the new script is:
target.classList.add("code-highlighted")
The add method is idempotent. In contrast, the old version caches(restores):
elem.cacheClassTarget = target.className;
target.className = "code-highlighted";
Note that the cached value would be lost if this was called twice in
succession.
I've added the comment, "any content added to the source document by the
document processor, including this script, is in the public domain".
This statement may seem superfluous, since an author should expect the
compiler to avoid claiming authorship over target code anyway. I've only
added it in contrast with the original claim.
Assuming the org-mode authors agree with the goal of publish acting as
pure compiler, and if it seems more appropriate not to pass the notice
through to the target html, then feel free to remove this notice from
the org-html-scripts definition, perhaps retaining it above the
definition as an as an elisp comment and/or as a note in the documentation.
One last note: users can attempt to fix this issue by disabling
:html-head-include-scripts, but doing so will provoke an error when a
reader's browser attempts to highlight links to source code literal
lines, so it is probably better to patch the script.
Anyway here is my patch, you can adapt it to your emacs init, or call it
from the command line as "emacs --batch -l publish".
I declare that this patch is in the public domain.
Enjoy.
;;; publish.el --- publish project with org publish -*- lexical-binding:
t; -*-
;; To use this from the shell:
;;
;; emacs --batch -l publish
(require 'org)
(require 'ox-publish)
(defconst public-domain-scripts
"<script type=\"text/javascript\">
/* Any content added to the source document by the document
processor, including this script, are in the public domain */
function CodeHighlightOn(elem, id)
{
const target = document.getElementById(id);
if(null != target) {
target.classList.add(\"code-highlighted\");
}
}
function CodeHighlightOff(elem, id)
{
const target = document.getElementById(id);
if(null != target) {
target.classList.remove(\"code-highlighted\");
}
}
</script>")
;; patch globally:
(setq org-html-scripts public-domain-scripts)
(org-publish-all)
;; or patch locally:
;;
;; (let ((org-html-scripts public-domain-scripts)) (org-publish-all))
--
Anthony Carrico
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: ISSUE: org publish document processor silently inserts licensed content into targets by default
2020-05-19 0:38 ISSUE: org publish document processor silently inserts licensed content into targets by default Anthony Carrico
@ 2020-05-22 15:10 ` Bastien
2020-05-27 0:06 ` Anthony Carrico
0 siblings, 1 reply; 3+ messages in thread
From: Bastien @ 2020-05-22 15:10 UTC (permalink / raw)
To: Anthony Carrico; +Cc: emacs-orgmode
Hi Anthony,
Anthony Carrico <acarrico@memebeam.org> writes:
> ISSUE: An author should expect a compiler to avoid claiming authorship
> over target code, however, currently the org-mode publish document
> processor silently inserts licensed content into target documents by
> default.
>
> SOLUTION: The following script is a drop-in-replacement which provides
> the same API as the original, without a license. It also opts not to
> highlight code links, but only their targets, which seems less
> distracting (it is a simple change to keep the original behavior if
> preferred).
If you think it is useful as a patch against Org, not just as a way to
customize a setup, can you send a patch?
See https://orgmode.org/worg/org-contribute.html on how to contribute.
Thanks,
--
Bastien
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-05-27 0:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-19 0:38 ISSUE: org publish document processor silently inserts licensed content into targets by default Anthony Carrico
2020-05-22 15:10 ` Bastien
2020-05-27 0:06 ` Anthony Carrico
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).