mirror of
https://git.sr.ht/~magic_rb/website
synced 2024-11-21 07:44:22 +01:00
Htmlize code block highlighting
Signed-off-by: Magic_RB <magic_rb@redalder.org>
This commit is contained in:
parent
2edfef83b3
commit
f34d6fa4fa
|
@ -1,2 +1,3 @@
|
|||
# website
|
||||
|
||||
To update the `org.css` file, you need to run `nix build .#generateCss.x86_64-linux && ./result` in the project root. This is only necessary when `modus-themes` is updated, not when a new major mode is added.
|
||||
|
|
1287
assets/css/org.css
Normal file
1287
assets/css/org.css
Normal file
File diff suppressed because it is too large
Load diff
53
flake.lock
53
flake.lock
|
@ -16,6 +16,38 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"hcl-mode": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1594425120,
|
||||
"narHash": "sha256-Ai3OpQPmEQg96Q4JRJJM7vUY8G23l0FUGb1lQsU7SRY=",
|
||||
"owner": "purcell",
|
||||
"repo": "emacs-hcl-mode",
|
||||
"rev": "e12b1df2ca28d2b06c471cd709c038a2dc0bcdbd",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "purcell",
|
||||
"repo": "emacs-hcl-mode",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"modus-themes": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1621753731,
|
||||
"narHash": "sha256-HFYsSPJWAY2/lYk8u1UxHMoe2l8taI6BvDZDfIO0pnE=",
|
||||
"owner": "protesilaos",
|
||||
"repo": "modus-themes",
|
||||
"rev": "11006063c2f294adad827d42ab04ee239e85eb64",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "protesilaos",
|
||||
"repo": "modus-themes",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixng": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
|
@ -78,9 +110,28 @@
|
|||
"root": {
|
||||
"inputs": {
|
||||
"emacs-htmlize": "emacs-htmlize",
|
||||
"hcl-mode": "hcl-mode",
|
||||
"modus-themes": "modus-themes",
|
||||
"nixng": "nixng",
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"org-thtml": "org-thtml"
|
||||
"org-thtml": "org-thtml",
|
||||
"web-mode": "web-mode"
|
||||
}
|
||||
},
|
||||
"web-mode": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1612115905,
|
||||
"narHash": "sha256-wZ+Sneh+vulcSs+n9fXHG321k9BauBiQvVJ6zw+cWrM=",
|
||||
"owner": "fxbois",
|
||||
"repo": "web-mode",
|
||||
"rev": "8ef47935d638902ba35a557cae5edd6ab6ab1346",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "fxbois",
|
||||
"repo": "web-mode",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
81
flake.nix
81
flake.nix
|
@ -1,17 +1,24 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "nixpkgs";
|
||||
org-thtml = {
|
||||
url = "github:juanjosegarciaripoll/org-thtml";
|
||||
flake = false;
|
||||
};
|
||||
emacs-htmlize = {
|
||||
url = "github:hniksic/emacs-htmlize";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
org-thtml = { url = "github:juanjosegarciaripoll/org-thtml"; flake = false; };
|
||||
emacs-htmlize = { url = "github:hniksic/emacs-htmlize"; flake = false; };
|
||||
modus-themes = { url = "github:protesilaos/modus-themes"; flake = false; };
|
||||
web-mode = { url = "github:fxbois/web-mode"; flake = false; };
|
||||
hcl-mode = { url = "github:purcell/emacs-hcl-mode"; flake = false; };
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, nixng, org-thtml, emacs-htmlize, ... }@inputs:
|
||||
outputs = { self
|
||||
, nixpkgs
|
||||
, nixng
|
||||
, org-thtml
|
||||
, emacs-htmlize
|
||||
, modus-themes
|
||||
, web-mode
|
||||
, hcl-mode
|
||||
, ...
|
||||
}@inputs:
|
||||
let
|
||||
supportedSystems = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
|
||||
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f system);
|
||||
|
@ -20,13 +27,23 @@
|
|||
name = which;
|
||||
version = "0.1";
|
||||
src = ./.;
|
||||
nativeBuildInputs = [ pkgs.emacs ];
|
||||
nativeBuildInputs = [ pkgs.utillinux pkgs.emacs ];
|
||||
|
||||
buildPhase = ''
|
||||
cp ${org-thtml}/ox-thtml.el ./ox-thtml.el
|
||||
cp ${emacs-htmlize}/htmlize.el ./htmlize.el
|
||||
mkdir tmp && export HOME=$(pwd)/tmp
|
||||
emacs --script ./make.el -- ${which}
|
||||
export TMPDIR="$(mktemp -d)" HOME=$(pwd)/tmp
|
||||
emacs -nw --fg-daemon &
|
||||
|
||||
timeout 10 bash -c 'until [ -e $TMPDIR/emacs$(id -u) ] ; do sleep 0.1 ; done'
|
||||
|
||||
emacsclient -e $'(add-to-list \'load-path "${org-thtml}")'
|
||||
emacsclient -e $'(add-to-list \'load-path "${modus-themes}")'
|
||||
emacsclient -e $'(add-to-list \'load-path "${emacs-htmlize}")'
|
||||
emacsclient -e $'(add-to-list \'load-path "${web-mode}")'
|
||||
emacsclient -e $'(add-to-list \'load-path "${hcl-mode}")'
|
||||
|
||||
emacsclient -e '(load-file "./make.el")'
|
||||
emacsclient -e '(magic_rb/publish-website "${which}")'
|
||||
emacsclient -e '(kill-emacs)'
|
||||
|
||||
find public_html -name 'sitemap.*' -exec rm {} \;
|
||||
'';
|
||||
|
@ -64,6 +81,42 @@
|
|||
''
|
||||
);
|
||||
|
||||
generateCss = forAllSystems (system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
|
||||
script = pkgs.writeText "init.el"
|
||||
''
|
||||
(add-to-list 'load-path "${modus-themes}")
|
||||
(add-to-list 'load-path "${emacs-htmlize}")
|
||||
|
||||
(require 'org)
|
||||
(require 'ox)
|
||||
(require 'ox-html)
|
||||
(require 'modus-themes)
|
||||
|
||||
(load-theme 'modus-operandi t nil)
|
||||
|
||||
(org-html-htmlize-generate-css)
|
||||
(with-current-buffer "*html*"
|
||||
(write-file (getenv "OUTFILE")))
|
||||
|
||||
(kill-emacs)
|
||||
'';
|
||||
in
|
||||
pkgs.writeShellScript "generate-css"
|
||||
''
|
||||
export PATH=$PATH:${pkgs.emacs}/bin
|
||||
|
||||
export OUTFILE="$(mktemp)" TMPDIR="$(mktemp -d)" HOME=$TMPDIR
|
||||
emacs -l ${script}
|
||||
|
||||
mv $OUTFILE ./assets/css/org.css
|
||||
|
||||
rm -r $TMPDIR
|
||||
''
|
||||
);
|
||||
|
||||
defaultPackage = forAllSystems (system:
|
||||
self.website.${system}
|
||||
);
|
||||
|
|
23
make.el
23
make.el
|
@ -3,9 +3,10 @@
|
|||
;;;
|
||||
|
||||
;;; Code:
|
||||
(load-file "./ox-thtml.el")
|
||||
;; (load-file "./htmlize.el")
|
||||
(package-initialize)
|
||||
|
||||
(require 'org)
|
||||
|
||||
(require 'ox)
|
||||
(require 'ox-html)
|
||||
|
||||
|
@ -13,6 +14,10 @@
|
|||
(unless (file-exists-p d)
|
||||
(make-directory d)))
|
||||
|
||||
(require 'web-mode)
|
||||
(require 'hcl-mode)
|
||||
(ignore-errors (require 'ox-thtml))
|
||||
|
||||
;; https://alhassy.github.io/AlBasmala.html#Floating-TOC
|
||||
(advice-add 'org-html--translate :before-until 'display-toc-as-toc)
|
||||
(defun display-toc-as-toc (phrase info)
|
||||
|
@ -27,9 +32,9 @@
|
|||
org-export-headline-levels 6
|
||||
; emacs-htmlize does not work when Emacs is ran in =script= mode unfortunately
|
||||
;; org-html-html5-fancy t
|
||||
;; org-html-htmlize-output-type 'inline-css
|
||||
)
|
||||
org-html-htmlize-output-type 'css)
|
||||
|
||||
|
||||
(defvar magic_rb/asset-include
|
||||
"\\(ttf\\|svg\\|jpg\\|gif\\|png\\|css\\|js\\|el\\|nb\\|ipynb\\|pdf\\|xml\\)")
|
||||
|
||||
|
@ -171,10 +176,12 @@
|
|||
:components ("nixng-assets"
|
||||
"nixng-examples"))))
|
||||
|
||||
(cond ((member "redalder.org" command-line-args-left)
|
||||
(org-publish "redalder-publish" t))
|
||||
((member "nixng.org" command-line-args-left)
|
||||
(org-publish "nixng-publish")))
|
||||
(defun magic_rb/publish-website (website)
|
||||
"Publish WEBSITE."
|
||||
(cond ((string= website "redalder.org")
|
||||
(org-publish "redalder-publish" t))
|
||||
((string= website "nixng.org")
|
||||
(org-publish "nixng-publish"))))
|
||||
|
||||
(provide 'make)
|
||||
;;; make.el ends here
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<title>{{title}}</title>
|
||||
|
||||
<link rel="stylesheet" href="/css/style.css"/>
|
||||
<link rel="stylesheet" href="/css/org.css"/>
|
||||
|
||||
<link rel="icon" href="/icons/favicon-512x512.png" type="image/png" sizes="512x512">
|
||||
</head>
|
||||
|
|
Loading…
Reference in a new issue