[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
ISSUE: org publish document processor silently inserts licensed content
From: |
Anthony Carrico |
Subject: |
ISSUE: org publish document processor silently inserts licensed content into targets by default |
Date: |
Mon, 18 May 2020 20:38:27 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 |
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
- ISSUE: org publish document processor silently inserts licensed content into targets by default,
Anthony Carrico <=