Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
takeokunn committed Jan 25, 2025
1 parent dfccc35 commit 8a07dbf
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 43 deletions.
3 changes: 3 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
hugo
nur-pkgs.tcardgen
(emacs.pkgs.withPackages (epkgs: (with epkgs.melpaPackages; [
ox-zenn
ox-hugo
org-roam
emacsql-sqlite
])))
];
Expand Down
8 changes: 0 additions & 8 deletions scripts/ox-roam.el
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
(require 'package)

(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-refresh-contents)
(package-initialize)
(package-install 'ox-hugo)
(package-install 'org-roam)

(require 'ox-hugo)
(require 'org-roam)

Expand Down
7 changes: 0 additions & 7 deletions scripts/ox-zenn.el
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
(require 'package)

(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-refresh-contents)
(package-initialize)
(package-install 'ox-zenn)

(require 'ox-zenn)

(defun export-org-zenn-articles-files ()
Expand Down
59 changes: 31 additions & 28 deletions typst/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,46 +32,49 @@
'';
};

buildTypstProject = { name, src, file }: pkgs.stdenv.mkDerivation {
inherit name src;
nativeBuildInputs = with pkgs; [
typst
migu
(emacs.pkgs.withPackages (epkgs: with epkgs; [ org ox-typst ]))
];
buildPhase = ''
emacs --batch \
--eval "(progn
(require 'ox-typst)
(find-file \"${file}.org\")
(setq org-export-with-toc nil)
(org-typst-export-to-typst))"
buildTypstProject = { name, type }:
let
_ = assert builtins.elem; type [ "article" "slide" ];
emacsBuildPhase = name: if type == "article"
then
"emacs --batch --load ox-typst.el --file ${name}/article.org --funcall org-typst-export-to-typst"
else
"emacs --batch --load ox-typst.el --file ${name}/article.org --funcall org-typst-slide-export-to-typst";
in
pkgs.stdenv.mkDerivation {
inherit name;
src = ./.;
nativeBuildInputs = with pkgs; [
typst
migu
(emacs.pkgs.withPackages (epkgs: with epkgs; [ org ox-typst ]))
];
buildPhase = ''
${emacsBuildPhase name}
export TYPST_FONT_PATHS="${pkgs.migu}/share/fonts/truetype/migu"
export TYPST_PACKAGE_PATH="${typstPackagesCache}/typst/packages"
typst compile ${file}.typ
'';
installPhase = ''
mkdir -p $out
cp ${file}.pdf $out/${name}.pdf
'';
};
export TYPST_FONT_PATHS="${pkgs.migu}/share/fonts/truetype/migu"
export TYPST_PACKAGE_PATH="${typstPackagesCache}/typst/packages"
typst compile ${name}/article.typ
'';
installPhase = ''
mkdir -p $out
cp ${name}/article.pdf $out/${name}.pdf
'';
};
in
{
devShells.default = pkgs.mkShell {
packages = with pkgs; [ typst migu ];
packages = with pkgs; [ typst ];
};

packages = {
phperkaigi-2025-pamphlet = buildTypstProject {
name = "phperkaigi-2025-pamphlet";
src = ./phperkaigi-2025-pamphlet;
file = "article";
type = "article";
};
phpcon-nagoya-2025 = buildTypstProject {
name = "phpcon-nagoya-2025";
src = ./phpcon-nagoya-2025;
file = "slide";
type = "slide";
};
};
}
Expand Down
32 changes: 32 additions & 0 deletions typst/ox-typst.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
(require 'ox-typst)

(setq org-export-with-toc nil)

(org-export-define-backend 'typst-slide
'((export-block . org-typst-export-block)
(headline . org-typst-headline)
(item . org-typst-item)
(keyword . org-typst-keyword)
(section . org-typst-section)
(src-block . org-typst-src-block))
:menu-entry
'(?y "Export to Typst"
((?F "As Typst buffer" org-typst-export-as-typst)
(?f "As Typst file" org-typst-export-to-typst)
(?p "As PDF file" org-typst-export-to-pdf)))
:options-alist
'((:typst-format-drawer-function nil nil #'(lambda (_ contents) contents))
(:typst-format-inlinetask-function nil
nil
#'(lambda (_ contents) contents))))

(defun org-typst-slide-export-as-typst (&optional async subtreep visible-only body-only ext-plist)
(interactive)
(org-export-to-buffer 'typst-slide "*Org Typst Slide Export*"
async subtreep visible-only body-only ext-plist))

(defun org-typst-slide-export-to-typst (&optional async subtreep visible-only body-only ext-plist)
(interactive)
(let ((outfile (org-export-output-file-name ".typ" subtreep)))
(org-export-to-file 'typst-slide outfile
async subtreep visible-only body-only ext-plist)))
File renamed without changes.

0 comments on commit 8a07dbf

Please sign in to comment.