Compare commits

..

7 Commits

Author SHA1 Message Date
c0787f8ee1 feat: change initial key to capital G on org-export
All checks were successful
continuous-integration/drone/push Build is passing
The `g' key is already used by the more widely used ox-gfm. This
commit changes the initial key of ox-gemini to capital `G' which I
haven’t encountered yet.
2023-05-14 13:59:17 +02:00
28736ce6c0 docs: update readme
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-14 13:44:53 +02:00
1eadafd8e0 fix: remove trailing whitespace at the end of inline code
All checks were successful
continuous-integration/drone/push Build is passing
Closes #2
2023-05-14 13:34:37 +02:00
61f7a1fb28 docs: add CI badge, fix orgmode syntax
All checks were successful
continuous-integration/drone/push Build is passing
2023-05-14 13:13:07 +02:00
d851c7de92 chore: switch to Eask for package testing
All checks were successful
continuous-integration/drone/push Build is passing
This commit removes some files that are no longer needed for testing
the package, such as the files in the ./test directory which are
already covered by Eask itself.

BREAKING CHANGE: test files no longer exists
2023-05-14 13:07:35 +02:00
86f211ba50 style: fix indentation 2023-05-14 12:47:43 +02:00
8bec97a8a0 refactor: Move README.md to README.org, move todos to issues 2023-05-14 12:24:19 +02:00
12 changed files with 234 additions and 118 deletions

View File

@@ -1,11 +0,0 @@
image: alpine/edge
packages:
- emacs
- make
sources:
- https://git.sr.ht/~abrahms/ox-gemini
tasks:
- build: |
cd ox-gemini
make update
make compile

75
.drone.yml Normal file
View File

@@ -0,0 +1,75 @@
---
kind: pipeline
type: docker
name: emacs 26
steps:
- name: tests
image: silex/emacs:26-alpine
commands:
- apk add npm make
- npm install -g @emacs-eask/cli
- make clean
- make package
- make install
- make compile
- make checkdoc
- make lint
- make clean
---
kind: pipeline
type: docker
name: emacs 27
steps:
- name: tests
image: silex/emacs:27-alpine
commands:
- apk add npm make
- npm install -g @emacs-eask/cli
- make clean
- make package
- make install
- make compile
- make checkdoc
- make lint
- make clean
---
kind: pipeline
type: docker
name: emacs 28
steps:
- name: tests
image: silex/emacs:28-alpine
commands:
- apk add npm make
- npm install -g @emacs-eask/cli
- make clean
- make package
- make install
- make compile
- make checkdoc
- make lint
- make clean
---
kind: pipeline
type: docker
name: emacs master
steps:
- name: tests
image: silex/emacs:master-alpine
commands:
- apk add npm make
- npm install -g @emacs-eask/cli
- make clean
- make package
- make install
- make compile
- make checkdoc
- make lint
- make clean

17
.gitignore vendored
View File

@@ -1,2 +1,17 @@
# ignore these directories
/.git
/recipes
# ignore log files
/.log
# ignore generated files
*.elc
.elpa/
# eask packages
.eask/
dist/
# packaging
*-autoloads.el
*-pkg.el

14
Eask Normal file
View File

@@ -0,0 +1,14 @@
(package "ox-gemini"
"0.2.0"
"Output gemini formatted documents from org-mode")
(website-url "https://labs.phundrak.com/phundrak/ox-gemini")
(keywords "lisp" "org-mode")
(package-file "ox-gemini.el")
(script "test" "echo \"Error: no test specified\" && exit 1")
(source "gnu")
(depends-on "emacs" "26.1")

View File

@@ -1,16 +1,64 @@
EMACS = emacs
EMACS ?= emacs
EASK ?= eask
compile: clean lint
${EMACS} --version
${EMACS} -batch -l test/elpa.el -l test/compile.el
.PHONY: clean package install compile test checkdoc lint
clean:
rm -f *.elc
# (Option 1): Basic for beginner, only tests for package's installation
ci: clean package install compile
# (Option 2): Advanced for a high-quality package
#ci: clean package install compile checkdoc lint test
# Build an package artefact, default to `dist` folder
#
# This is used to test if your package can be built correctly before the
# package installation.
package:
@echo "Packaging..."
$(EASK) package
# Install package
#
# If your package is a single file package, you generally wouldn't need to
install:
@echo "Installing..."
$(EASK) install
# Byte-compile package
#
# Compile all your package .el files to .elc
compile:
@echo "Compiling..."
$(EASK) compile
# Run regression tests
#
# The default test is `ert`; but Eask also support other regression test!
# See https://emacs-eask.github.io/Getting-Started/Commands-and-options/#-linter
test:
@echo "Testing..."
$(EASK) install-deps --dev
$(EASK) test ert ./test/*.el
# Run checkdoc
#
# See https://www.emacswiki.org/emacs/CheckDoc
checkdoc:
@echo "Checking documentation..."
$(EASK) lint checkdoc --strict
# Lint package metadata
#
# See https://github.com/purcell/package-lint
lint:
${EMACS} --batch -l test/lint.el
@echo "Linting..."
$(EASK) lint package
update:
${EMACS} -batch -l test/make-update.el
.PHONY: update compile test clean
# Clean up
#
# This will clean all the entire workspace including the following folders
# and files
#
# - .eask folder (sandbox)
# - all .elc files
clean:
$(EASK) clean all

View File

@@ -1,9 +0,0 @@
# ox-gemini
This adds support for exporting org files in gemini format. Many things in here were taken from the ascii exporter, from which this one derives.
- Read more about gemini here: https://gemini.circumlunar.space/
- Read more about org-mode here: https://orgmode.org/
## License
This software is licensed under GPLv3.

29
README.org Normal file
View File

@@ -0,0 +1,29 @@
#+title: ox-gemini
#+html: <a href="https://drone.phundrak.com/phundrak/ox-gemini"><img src="https://drone.phundrak.com/api/badges/phundrak/ox-gemini/status.svg" /></a>
Forked from Justin Abrahms [[https://git.sr.ht/~abrahms/ox-gemini][original ox-gemini]].
* =ox-gemini=
This adds support for exporting org files in gemini format. Many
things in here were taken from the ascii exporter, from which this one
derives.
- Read more about gemini here: https://gemini.circumlunar.space/
- Read more about org-mode here: https://orgmode.org/
* What this fork adds
Not much, really. For now, this is just a way for me to apply a fix in
gemini links as described in commit [[https://labs.phundrak.com/phundrak/ox-gemini/commit/94dd2f4a8e5ca50bbfb857395d98da88bf581b6c][94dd2f4]].
This forks fixes two issues the original =ox-gemini= has:
- link descriptions include a newline when the orgmode code also does,
which breaks things (see commit [[https://labs.phundrak.com/phundrak/ox-gemini/commit/94dd2f4a8e5ca50bbfb857395d98da88bf581b6c][94dd2f4]])
- inline code carries a trailing whitespace (see commit [[https://labs.phundrak.com/phundrak/ox-gemini/commit/1eadafd8e0f9848bb0119076cab15f0b5b23ed0c][1eadafd8e0]])
TODOs formerly in =ox-gemini.el= have also been moved to issues.
** Eask
This project is managed with [[https://github.com/emacs-eask/cli][Eask]].
* License
This software is licensed under GPLv3.

View File

@@ -1,12 +1,27 @@
;;; ox-gemini.el --- Output gemini formatted documents from org-mode -*- lexical-binding: t; -*-
;; Author: Justin Abrahms <justin@abrah.ms>
;; URL: https://git.sr.ht/~abrahms/ox-gemini
;; Keywords: lisp gemini
;; Version: 0
;; Maintainer: Lucien Cartier-Tilet <lucien@phundrak.com>
;; URL: https://labs.phundrak.com/phundrak/ox-gemini
;; Version: 0.2.0
;; Keywords: lisp org-mode
;; Package-Requires: ((emacs "26.1"))
;; SPDX-License-Identifier: GPL-3.0-or-later
;; This file is not part of GNU Emacs.
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;;
@@ -22,17 +37,11 @@
(require 'cl-lib)
(require 'url-util)
;; TODO:
;; Sublists aren't supported in gemini
;; There's a trailing space after inline code samples
;; If you link a file to an absolute path, the links break
;; bare links don't work (e.g. directly linking https://google.com)
;;; Code:
(org-export-define-derived-backend 'gemini 'ascii
:menu-entry
'(?g "Export to Gemini"
'(?G "Export to Gemini"
((?b "To buffer"
(lambda (a s v b)
(org-gemini-export-to-buffer a s v b nil)))
@@ -62,12 +71,12 @@ CONTENTS is the text of the individual item.
ITEM is the parsed-org element with all properties."
(concat "* "
;; vv Code from ox-md! vv
(pcase (org-element-property :checkbox item)
(`on "[X] ")
(`trans "[-] ")
(`off "[ ] "))
(let ((tag (org-element-property :tag item)))
(and tag (format "%s :: " (org-export-data tag info))))
(pcase (org-element-property :checkbox item)
(`on "[X] ")
(`trans "[-] ")
(`off "[ ] "))
(let ((tag (org-element-property :tag item)))
(and tag (format "%s :: " (org-export-data tag info))))
;; ^^ ^^
contents))
@@ -82,7 +91,9 @@ ITEM is the parsed-org element with all properties."
INPUT is either a \\='src-block\\=' or \\='example-block\\='
element. INFO is a plist."
;; there's a bug here where there's a trailing space in the ``
(format "`%s`" (org-export-format-code-default input info)))
(format "`%s`" (replace-regexp-in-string (rx (* whitespace) eot)
""
(org-export-format-code-default input info))))
(defun org-gemini-code-block (src-block _contents info)
"SRC-BLOCK is a codeblock. INFO is a plist."
@@ -109,10 +120,11 @@ INFO is a plist."
(concat (file-name-sans-extension (org-element-property :path link)) ".gmi")
raw-path))
(desc (org-element-contents link))
(anchor (string-replace "\n" " "
(org-export-data
(or desc (org-element-property :raw-link link))
info))))
(anchor (replace-regexp-in-string (regexp-quote "\n")
" "
(org-export-data
(or desc (org-element-property :raw-link link))
info))))
(format "=> %s %s\n" (url-encode-url path) anchor)))
links "")
(when (car links)
@@ -145,16 +157,15 @@ contextual information."
(org-ascii--current-text-width section info)
info))))
(org-remove-indentation
(if (not (org-string-nw-p links)) contents-str
(concat (org-element-normalize-string contents-str) "\n\n" links))
;; Do not apply inner margin if parent headline is low level.
(let ((headline (org-export-get-parent-headline section)))
(if (or (not headline) (org-export-low-level-p headline info)) 0
(plist-get info :ascii-inner-margin))))))
(if (not (org-string-nw-p links)) contents-str
(concat (org-element-normalize-string contents-str) "\n\n" links))
;; Do not apply inner margin if parent headline is low level.
(let ((headline (org-export-get-parent-headline section)))
(if (or (not headline) (org-export-low-level-p headline info)) 0
(plist-get info :ascii-inner-margin))))))
(defun org-gemini--build-title
(element info _text-width &optional _underline _notags toc)
"Build a title heading.
(defun org-gemini--build-title (element info _text-width &optional _underline _notags toc)
"Build a title heading.
ELEMENT is an org-element. TOC is whether to show the table of contents.
INFO is unimportant."

View File

@@ -1,8 +0,0 @@
;; bail out on compilation warnings and errors
(setq byte-compile-error-on-warn t)
(setq byte-compile--use-old-handlers nil)
;; compile *.el files
(dolist (file (file-expand-wildcards "*.el"))
(unless (byte-compile-file file)
(kill-emacs 1)))

View File

@@ -1,4 +0,0 @@
(setq package-user-dir
(expand-file-name (format ".elpa/%s/elpa" emacs-version)))
(package-initialize)
(add-to-list 'load-path default-directory)

View File

@@ -1,16 +0,0 @@
(message "Emacs version: %s" emacs-version)
(dolist (file (file-expand-wildcards "*.el"))
(let ((checkdoc-diagnostic-buffer "*warn*")
;; bail out on checkdoc warnings
(checkdoc-create-error-function (lambda (text start end &optional unfixable)
(message "%s:%s %s"
file
(line-number-at-pos start)
text)
(kill-emacs 1))))
(with-current-buffer (find-file-noselect file)
;; Eval the buffer first because otherwise checkdoc isn't smart
;; enough to recognize that some symbols are defined.
(eval-buffer)
(checkdoc-current-buffer t))))

View File

@@ -1,28 +0,0 @@
;; list of the all the dependencies, including the dev dependencies
(defvar dev-packages '(evil evil-test-helpers))
;; initialize package.el
(setq package-user-dir
(expand-file-name (format ".elpa/%s/elpa" emacs-version)))
(message "installing in %s ...\n" package-user-dir)
(package-initialize)
(setq package-archives
'(("melpa" . "http://melpa.org/packages/")
("gnu" . "http://elpa.gnu.org/packages/")))
(package-refresh-contents)
;; install dependencies
(dolist (package dev-packages)
(unless (package-installed-p package)
(ignore-errors
(package-install package))))
;; upgrade dependencies
(save-window-excursion
(package-list-packages t)
(condition-case nil
(progn
(package-menu-mark-upgrades)
(package-menu-execute t))
(error
(message "All packages up to date"))))