emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Anthony Carrico <acarrico@memebeam.org>
To: emacs-orgmode@gnu.org
Subject: ISSUE: org publish document processor silently inserts licensed content into targets by default
Date: Mon, 18 May 2020 20:38:27 -0400	[thread overview]
Message-ID: <450d0a78-2316-28b6-9781-0935053831bf@memebeam.org> (raw)

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 

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 

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:


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 

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.


;;; 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) {
  function CodeHighlightOff(elem, id)
    const target = document.getElementById(id);
    if(null != target) {

;; patch globally:
(setq org-html-scripts public-domain-scripts)

;; or patch locally:
;; (let ((org-html-scripts public-domain-scripts)) (org-publish-all))

Anthony Carrico

             reply	other threads:[~2020-05-19  0:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-19  0:38 Anthony Carrico [this message]
2020-05-22 15:10 ` Bastien
2020-05-27  0:06   ` Anthony Carrico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=450d0a78-2316-28b6-9781-0935053831bf@memebeam.org \
    --to=acarrico@memebeam.org \
    --cc=emacs-orgmode@gnu.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


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).