From mboxrd@z Thu Jan 1 00:00:00 1970 From: r at rkm.id.au (Ruben Maher) Date: Tue, 14 Jul 2015 11:20:08 +0930 Subject: [PATCH] Add about-formatting filter for org-mode. Message-ID: <878uajld7z.fsf@ayanami.rkm.id.au> Hi list, I have two patches for your consideration. The first just adds an about-filter for .org files. It depends on Emacs and Org-mode[0]. I may have formatted this mail correctly. Please let me know otherwise. Kind regards, Ruben [0] http://orgmode.org/ --- filters/about-formatting.sh | 1 + filters/html-converters/org2html | 2 ++ filters/html-converters/resources/org2html.el | 43 +++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100755 filters/html-converters/org2html create mode 100755 filters/html-converters/resources/org2html.el diff --git a/filters/about-formatting.sh b/filters/about-formatting.sh index d024204..5801d8e 100755 --- a/filters/about-formatting.sh +++ b/filters/about-formatting.sh @@ -21,6 +21,7 @@ cd "$(dirname $0)/html-converters/" case "$(printf '%s' "$1" | tr '[:upper:]' '[:lower:]')" in *.markdown|*.mdown|*.md|*.mkd) exec ./md2html; ;; *.rst) exec ./rst2html; ;; + *.org) exec ./org2html; ;; *.[1-9]) exec ./man2html; ;; *.htm|*.html) exec cat; ;; *.txt|*) exec ./txt2html; ;; diff --git a/filters/html-converters/org2html b/filters/html-converters/org2html new file mode 100755 index 0000000..62fd136 --- /dev/null +++ b/filters/html-converters/org2html @@ -0,0 +1,2 @@ +#!/bin/sh +exec "$(dirname "$0")/resources/org2html.el" 2>/dev/null diff --git a/filters/html-converters/resources/org2html.el b/filters/html-converters/resources/org2html.el new file mode 100755 index 0000000..8cac096 --- /dev/null +++ b/filters/html-converters/resources/org2html.el @@ -0,0 +1,43 @@ +#!/usr/bin/emacs --script +;;; org2html.el --- + +;; Copyright (C) 2015 Ruben Maher + +;; Author: Ruben Maher +;; Keywords: tools + +;; 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 . + +;;; Commentary: + +;; Read an org file from stdin, convert it to html, and dump it on stdout. +;; You need a recent version of org-mode's htmlize if you want source code +;; highlighting in font blocks. Requires Emacs and Org-mode. +;; Example usage: ./org2html.el < README.org 2>/dev/null + +;;; Code: + +(require 'org) + +(condition-case nil + (let (line) + (with-output-to-temp-buffer "*org2html*" + (set-buffer-file-coding-system 'utf-8) + (while (setq line (read-from-minibuffer "")) + (princ (concat line "\n"))))) + (error nil)) + +(when (get-buffer "*org2html*") + (set-buffer "*org2html*") + (princ (org-export-as 'html nil t t))) -- 2.4.5