forked from colonelpanic/dotfiles
[Emacs] Make headings in org exported html links to themselves
This commit is contained in:
parent
2ac6c50d83
commit
355b81d9fe
@ -30,7 +30,7 @@ are placed in a repository. The org-mode file that they target is set [[https://
|
|||||||
should be relatively easy to change.
|
should be relatively easy to change.
|
||||||
*** [[https://github.com/fniessen/org-html-themes][Read The Org]]
|
*** [[https://github.com/fniessen/org-html-themes][Read The Org]]
|
||||||
I use [[https://github.com/fniessen][fniessen]]'s ReadTheOrg theme which can be found at https://github.com/fniessen/org-html-themes.
|
I use [[https://github.com/fniessen][fniessen]]'s ReadTheOrg theme which can be found at https://github.com/fniessen/org-html-themes.
|
||||||
*** Heading Links
|
*** Predictable and Human Readable Heading Links
|
||||||
To make it so that internal heading links have names that correspond to the
|
To make it so that internal heading links have names that correspond to the
|
||||||
heading text, and don't change when new headings are added to the document, I
|
heading text, and don't change when new headings are added to the document, I
|
||||||
wrote a custom version of ~org-export-get-reference~.
|
wrote a custom version of ~org-export-get-reference~.
|
||||||
@ -44,6 +44,9 @@ this.
|
|||||||
|
|
||||||
I'm considering turning this snippet in to a package, so please let me know if
|
I'm considering turning this snippet in to a package, so please let me know if
|
||||||
that is something you are interested in.
|
that is something you are interested in.
|
||||||
|
*** Make Headings Link to Themselves
|
||||||
|
See the [[Make headings in exported html links to themselves][Make headings in exported html links to themselves]]. This is another pretty nasty hack. This is useful when you are browsing the document and you want to grab a link to
|
||||||
|
the current heading.
|
||||||
*** Set Background Color Source Blocks
|
*** Set Background Color Source Blocks
|
||||||
For some reason, org-mode uses all of your currently active fontification when exporting EXCEPT for background color. [[Set Background Color of Source Blocks for Export][This]] modification fixes this.
|
For some reason, org-mode uses all of your currently active fontification when exporting EXCEPT for background color. [[Set Background Color of Source Blocks for Export][This]] modification fixes this.
|
||||||
** [[framecontrol][Frame control]]
|
** [[framecontrol][Frame control]]
|
||||||
@ -3295,6 +3298,35 @@ alphanumeric characters only."
|
|||||||
(puthash datum new-name cache)
|
(puthash datum new-name cache)
|
||||||
new-name)))))
|
new-name)))))
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
**** Make headings in exported html links to themselves
|
||||||
|
#+BEGIN_SRC emacs-lisp :tangle org-config.el
|
||||||
|
(use-package ox-html
|
||||||
|
:ensure nil
|
||||||
|
:preface
|
||||||
|
(progn
|
||||||
|
(defvar imalison:current-html-headline)
|
||||||
|
(defun imalison:set-current-html-headline (headline &rest args)
|
||||||
|
(setq imalison:current-html-headline headline))
|
||||||
|
(defun imalison:clear-current-html-headline (&rest args)
|
||||||
|
(setq imalison:current-html-headline nil))
|
||||||
|
(defun imalison:org-html-format-heading-function (todo todo-type priority text tags info)
|
||||||
|
(let* ((reference (when imalison:current-html-headline
|
||||||
|
(org-export-get-reference imalison:current-html-headline info)))
|
||||||
|
;; Don't do anything special if the current headline is not set
|
||||||
|
(new-text (if imalison:current-html-headline
|
||||||
|
(format "<a href=\"#%s\">%s</a>" reference text)
|
||||||
|
text)))
|
||||||
|
(org-html-format-headline-default-function
|
||||||
|
todo todo-type priority new-text tags info))))
|
||||||
|
:config
|
||||||
|
(progn
|
||||||
|
;; This is set before and cleared afterwards, so that we know when we are
|
||||||
|
;; generating the text for the headline itself and when we are not.
|
||||||
|
(advice-add 'org-html-headline :before 'imalison:set-current-html-headline)
|
||||||
|
(advice-add 'org-html-headline :after 'imalison:clear-current-html-headline)
|
||||||
|
(setq org-html-format-headline-function
|
||||||
|
'imalison:org-html-format-heading-function)))
|
||||||
|
#+END_SRC
|
||||||
**** org-projectile
|
**** org-projectile
|
||||||
#+BEGIN_SRC emacs-lisp
|
#+BEGIN_SRC emacs-lisp
|
||||||
(use-package org-projectile
|
(use-package org-projectile
|
||||||
|
Loading…
Reference in New Issue
Block a user