[Emacs] Use github style link icons for heading links

This commit is contained in:
Ivan Malison 2016-12-28 18:27:49 -08:00
parent 355b81d9fe
commit 26a7daf053
No known key found for this signature in database
GPG Key ID: 62530EFBE99DC2F8

View File

@ -44,9 +44,8 @@ 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 *** [[Add link icons in headings that lead to themselves][Add link icons in headings that lead 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 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.
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]]
@ -3298,12 +3297,14 @@ 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 **** Add link icons in headings that lead to themselves
#+BEGIN_SRC emacs-lisp :tangle org-config.el #+BEGIN_SRC emacs-lisp :tangle org-config.el
(use-package ox-html (use-package ox-html
:ensure nil :ensure nil
:preface :preface
(progn (progn
(defvar imalison:link-svg-html
"<svg aria-hidden=\"true\" class=\"octicon octicon-link\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg>")
(defvar imalison:current-html-headline) (defvar imalison:current-html-headline)
(defun imalison:set-current-html-headline (headline &rest args) (defun imalison:set-current-html-headline (headline &rest args)
(setq imalison:current-html-headline headline)) (setq imalison:current-html-headline headline))
@ -3313,8 +3314,8 @@ alphanumeric characters only."
(let* ((reference (when imalison:current-html-headline (let* ((reference (when imalison:current-html-headline
(org-export-get-reference imalison:current-html-headline info))) (org-export-get-reference imalison:current-html-headline info)))
;; Don't do anything special if the current headline is not set ;; Don't do anything special if the current headline is not set
(new-text (if imalison:current-html-headline (new-text (if reference
(format "<a href=\"#%s\">%s</a>" reference text) (format "%s <a href=\"#%s\">%s</a>" text reference imalison:link-svg-html)
text))) text)))
(org-html-format-headline-default-function (org-html-format-headline-default-function
todo todo-type priority new-text tags info)))) todo todo-type priority new-text tags info))))