emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Matt Price <moptop99@gmail.com>
To: Matt Price <moptop99@gmail.com>, Org Mode <emacs-orgmode@gnu.org>
Subject: Re: modify citation links in a derived HTML backend
Date: Sat, 3 Jul 2021 17:32:50 -0400	[thread overview]
Message-ID: <CAN_Dec8UembfTARoOchXVzqEgmUv0sz+HHS-50ObX+-+MCx8Dw@mail.gmail.com> (raw)
In-Reply-To: <87r1gfx27r.fsf@wi.uni-muenster.de>

[-- Attachment #1: Type: text/plain, Size: 5017 bytes --]

Thanks Jens!

I've added some comments in the issue you linked to, but in the meantime
I've also come up with what seems to be at least a semi-viable hack for
adding native CSL citation support to org-re-reveal. It involves creating
two new variables and then let-setting `citeproc-fmt--formatters-alist` in
`org-re-reveal-export-to-html`. Something similar could presumably be done
in other derived backends.

I find it quite hackish and I don't know whether perhaps some more general
solution could be found, but in any case here is the code, which I have
inserted into org-re-reveal.el locally:

Something to note here is that `oc-csl.el` hard-codes the output format
options in org-cite-csl--output-formats. I wonder if it would be worth
having an extensible variable "org-cite-csl--output-format-alist" that
backends could modify if they have special needs. For instance, I am
thinking about website exporters like Hugo where authors might want to have
separate bibliography pages rather than endnotes, or add "title" attributes
to citations, or possibly even modal tooltips with formatted text.  It
probably doesn't make sense to build all of that in to citeproc.el, but
assing some additional information seems worthwhile.
-------------
(defvar org-re-reveal-citeproc-fmt-alist
  `((unformatted . citeproc-fmt--xml-escape)
    (cited-item-no . ,(lambda (x y) (concat "<a
href=\"#slide-bibliography""\">"
   x "</a>")))
    (bib-item-no . ,(lambda (x y) (concat "<a name=\"citeproc_bib_item_" y
"\"></a>"
 x)))
    (font-style-italic . ,(lambda (x) (concat "<i>" x "</i>")))
    (font-style-oblique . ,(lambda (x)
    (concat "<span style=\"font-style:oblique;\"" x "</span>")))
    (font-variant-small-caps . ,(lambda (x)
 (concat
  "<span style=\"font-variant:small-caps;\">" x "</span>")))
    (font-weight-bold . ,(lambda (x) (concat "<b>" x "</b>")))
    (text-decoration-underline .
                               ,(lambda (x)
                         (concat
                          "<span style=\"text-decoration:underline;\">" x
"</span>")))
    (rendered-var-url . ,(lambda (x) (concat "<a href=\"" x "\">" x
"</a>")))
    (rendered-var-doi . ,(lambda (x) (concat "<a href=\"" x "\">" x
"</a>")))
    ;;(rendered-var-title . ,(lambda (x) (concat "<a href=\"" x "\">" x
"</a>")))
    (vertical-align-sub . ,(lambda (x) (concat "<sub>" x "</sub>")))
    (vertical-align-sup . ,(lambda (x) (concat "<sup>" x "</sup>")))
    (vertical-align-baseline . ,(lambda (x) (concat "<span
style=\"baseline\">" x "</span>")))
    (display-left-margin . ,(lambda (x) (concat "\n    <div
class=\"csl-left-margin\">"
x "</div>")))
    (display-right-inline . ,(lambda (x) (concat "<div
class=\"csl-right-inline\">"
x "</div>\n  ")))
    (display-block . ,(lambda (x) (concat "\n\n    <div
class=\"csl-block\">"
 x "</div>\n")))
    (display-indent . ,(lambda (x) (concat "<div class=\"csl-indent\">" x
"</div>\n  ")))))

(defvar org-re-reveal-formatters-alist
  `((html . ,(citeproc-formatter-create
           :rt (citeproc-formatter-fun-create
org-re-reveal-citeproc-fmt-alist)
           :bib #'citeproc-fmt--html-bib-formatter))))

(defun org-re-reveal-export-to-html
    (&optional async subtreep visible-only body-only ext-plist backend)
  "Export current buffer to a reveal.js HTML file.
Optional ASYNC, SUBTREEP, VISIBLE-ONLY, BODY-ONLY, EXT-PLIST are passed
to `org-export-to-file'.
Optional BACKEND must be `re-reveal' or a backend derived from it."
  (interactive)
  (let* ((backend (or backend 're-reveal))
         (extension (concat "." org-html-extension))
         (client-ext (concat org-re-reveal-multiplex-client-ext extension))
         (file (org-export-output-file-name extension subtreep))
         (clientfile (org-export-output-file-name client-ext subtreep))
         (org-html-container-element "div")
         (citeproc-fmt--formatters-alist org-re-reveal-formatters-alist))

    (setq org-re-reveal-client-multiplex nil)
    (org-export-to-file backend file
      async subtreep visible-only body-only ext-plist)

    ;; Export the client HTML file if org-re-reveal-client-multiplex is set
true
    ;; by previous call to org-export-to-file
    (if org-re-reveal-client-multiplex
        (org-export-to-file backend clientfile
          async subtreep visible-only body-only ext-plist))
    file))
------------------------

On Sat, Jul 3, 2021 at 3:53 AM Jens Lechtenboerger <
lechten@wi.uni-muenster.de> wrote:

> On 2021-07-02, Matt Price wrote:
>
> > Hi,
> >
> > (cc:ing Jens L. in case this is relevant for his dev work on
> org-re-reveal).
>
> Hi Matt,
>
> just a quick reply: Yes, that is certainly relevant for me, but I do
> not have the time to investigate this at the moment.  Note that I
> use references with org-ref and org-re-reveal-ref (for which Bruce
> opened an issue for org-cite support [1]).  Currently, I configure
> org-ref-ref-html (although its doc string suggests otherwise).
>
> Best wishes
> Jens
>
> [1] https://gitlab.com/oer/org-re-reveal-ref/-/issues/2
>

[-- Attachment #2: Type: text/html, Size: 6788 bytes --]

  reply	other threads:[~2021-07-03 21:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-02 17:53 modify citation links in a derived HTML backend Matt Price
2021-07-03  7:53 ` Jens Lechtenboerger
2021-07-03 21:32   ` Matt Price [this message]
2021-07-04 12:56     ` Jens Lechtenboerger
2021-07-04 16:12       ` Matt Price

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  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=CAN_Dec8UembfTARoOchXVzqEgmUv0sz+HHS-50ObX+-+MCx8Dw@mail.gmail.com \
    --to=moptop99@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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

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