From 7e3d259c9d39f11a3acf124e68876375042b5caa Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sat, 7 Nov 2020 15:41:49 +0100 Subject: [PATCH 1/5] Added emacs config file --- docs/config.el | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/docs/config.el b/docs/config.el index 4986182..2bf16e4 100755 --- a/docs/config.el +++ b/docs/config.el @@ -2,4 +2,69 @@ ;; https://emacs.stackexchange.com/questions/38437/org-mode-batch-export-missing-syntax-highlighting (package-initialize) +(require 'font-lock) +(require 'subr-x) ;; for `when-let' +(unless (boundp 'maximal-integer) + (defconst maximal-integer (lsh -1 -1) + "Maximal integer value representable natively in emacs lisp.")) + +(defun face-spec-default (spec) + "Get list containing at most the default entry of face SPEC. +Return nil if SPEC has no default entry." + (let* ((first (car-safe spec)) + (display (car-safe first))) + (when (eq display 'default) + (list (car-safe spec))))) + +(defun face-spec-min-color (display-atts) + "Get min-color entry of DISPLAY-ATTS pair from face spec." + (let* ((display (car-safe display-atts))) + (or (car-safe (cdr (assoc 'min-colors display))) + maximal-integer))) + +(defun face-spec-highest-color (spec) + "Search face SPEC for highest color. +That means the DISPLAY entry of SPEC +with class 'color and highest min-color value." + (let ((color-list (cl-remove-if-not + (lambda (display-atts) + (when-let ((display (car-safe display-atts)) + (class (and (listp display) + (assoc 'class display))) + (background (assoc 'background display))) + (and (member 'light (cdr background)) + (member 'color (cdr class))))) + spec))) + (cl-reduce (lambda (display-atts1 display-atts2) + (if (> (face-spec-min-color display-atts1) + (face-spec-min-color display-atts2)) + display-atts1 + display-atts2)) + (cdr color-list) + :initial-value (car color-list)))) + +(defun face-spec-t (spec) + "Search face SPEC for fall back." + (cl-find-if (lambda (display-atts) + (eq (car-safe display-atts) t)) + spec)) + +(defun my-face-attribute (face attribute &optional frame inherit) + "Get FACE ATTRIBUTE from `face-user-default-spec' and not from `face-attribute'." + (let* ((face-spec (face-user-default-spec face)) + (display-attr (or (face-spec-highest-color face-spec) + (face-spec-t face-spec))) + (attr (cdr display-attr)) + (val (or (plist-get attr attribute) (car-safe (cdr (assoc attribute attr)))))) + ;; (message "attribute: %S" attribute) ;; for debugging + (when (and (null (eq attribute :inherit)) + (null val)) + (let ((inherited-face (my-face-attribute face :inherit))) + (when (and inherited-face + (null (eq inherited-face 'unspecified))) + (setq val (my-face-attribute inherited-face attribute))))) + ;; (message "face: %S attribute: %S display-attr: %S, val: %S" face attribute display-attr val) ;; for debugging + (or val 'unspecified))) + +(advice-add 'face-attribute :override #'my-face-attribute) From 352679919e1331a28758e66b75a1fb854c8935c9 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sat, 7 Nov 2020 16:11:34 +0100 Subject: [PATCH 2/5] Fix GH workflow --- .github/workflows/gh-pages.yml | 12 +++++++++--- docs/config.el | 1 + src/create_doc.sh | 7 ++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index cbbe390..911bef1 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -10,16 +10,22 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - + - name: install extra repository run: sudo add-apt-repository ppa:kelleyk/emacs - + - name: refresh apt run: sudo apt-get update - + - name: install dependencies run: sudo apt-get install emacs26 + - name: install htmlize + run: git clone https://github.com/hniksic/emacs-htmlize && cp emacs-htmlize/htmlize.el src/ + + - name: install htmlize + run: git clone https://github.com/hniksic/emacs-htmlize + - name: make run: make -C src/ doc diff --git a/docs/config.el b/docs/config.el index 2bf16e4..093ee8c 100755 --- a/docs/config.el +++ b/docs/config.el @@ -2,6 +2,7 @@ ;; https://emacs.stackexchange.com/questions/38437/org-mode-batch-export-missing-syntax-highlighting (package-initialize) +(require 'htmlize) (require 'font-lock) (require 'subr-x) ;; for `when-let' diff --git a/src/create_doc.sh b/src/create_doc.sh index ea002d9..39327c8 100755 --- a/src/create_doc.sh +++ b/src/create_doc.sh @@ -1,7 +1,12 @@ #!/bin/bash INPUT=$1 -emacs --batch --load ../docs/config.el $INPUT -f org-html-export-to-html +if [[ -f ../docs/htmlize.el ]] +then + emacs --batch --load ../docs/htmlize.el --load ../docs/config.el $INPUT -f org-html-export-to-html +else + emacs --batch --load ../docs/config.el $INPUT -f org-html-export-to-html +fi mv index.html ../docs From f10b6336793f789308a0a999a24994c3ae166742 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sat, 7 Nov 2020 16:12:47 +0100 Subject: [PATCH 3/5] Fix GH workflow --- .github/workflows/gh-pages.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 911bef1..c45ae33 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -21,10 +21,10 @@ jobs: run: sudo apt-get install emacs26 - name: install htmlize - run: git clone https://github.com/hniksic/emacs-htmlize && cp emacs-htmlize/htmlize.el src/ + run: git clone https://github.com/hniksic/emacs-htmlize && cp emacs-htmlize/htmlize.el src/ - name: install htmlize - run: git clone https://github.com/hniksic/emacs-htmlize + run: git clone https://github.com/hniksic/emacs-htmlize - name: make run: make -C src/ doc From 22e0936a635c7f605929d2ed31ec6106429ed5c8 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sat, 7 Nov 2020 16:13:58 +0100 Subject: [PATCH 4/5] Fix GH workflow --- .github/workflows/gh-pages.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index c45ae33..f403819 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -23,9 +23,6 @@ jobs: - name: install htmlize run: git clone https://github.com/hniksic/emacs-htmlize && cp emacs-htmlize/htmlize.el src/ - - name: install htmlize - run: git clone https://github.com/hniksic/emacs-htmlize - - name: make run: make -C src/ doc From 8a53306a6332840a4f38e0a80747526a11997ee4 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sat, 7 Nov 2020 16:17:37 +0100 Subject: [PATCH 5/5] Fix GH workflow --- .github/workflows/gh-pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index f403819..45b9ebe 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -21,7 +21,7 @@ jobs: run: sudo apt-get install emacs26 - name: install htmlize - run: git clone https://github.com/hniksic/emacs-htmlize && cp emacs-htmlize/htmlize.el src/ + run: git clone https://github.com/hniksic/emacs-htmlize && cp emacs-htmlize/htmlize.el docs/ - name: make run: make -C src/ doc