Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: 2317551a5a
Fetching contributors…
Cannot retrieve contributors at this time
136 lines (111 sloc) 3.64 KB
;;; jo-exporter-grid.el --- Publish grid in jo-exporter
;; Copyright © 2012 eggcaker
;; Author: eggcaker <>
;; Original Author: Sébastien Gross <seb•ɑƬ•chezwam•ɖɵʈ•org>
;; Keywords: emacs, publishing
;; Version: 1.2
;; URL:
;; Created: 2012-07-10
;; Last changed: 2012-07-10 16:57:20
;; Licence: WTFPL, grab your copy here:
;; Based on: jo-exporter.el by Sébastien Gross <seb•ɑƬ•chezwam•ɖɵʈ•org>
;; This file is NOT part of GNU Emacs.
;;; Code:
(require 'org nil t))
(defcustom jo-exporter-grid-header
"<div class=\"row %s\"><div class=\"%s\">"
"HTML fragment header to be used when publishing a grid using
`jo-exporter-publish-grid' using `format' with grid options as
parameter. The grid should be closed with `jo-exporter-grid-footer'."
:type 'string
:group 'jo-exporter)
(defcustom jo-exporter-grid-footer
"HTML fragment footer to be used when publishing a grid using
`jo-exporter-publish-grid' as it. This closes `jo-exporter-grid-header'."
:type 'string
:group 'jo-exporter)
(defcustom jo-exporter-grid-column
"</div><div class=\"%s\">"
"HTML middle fragment to be used when publishing a grid. This
string is used for next column in `jo-exporter-publish-grid' using
`format' with column configuration as parameter."
:type 'string
:group 'jo-exporter)
(defun jo-exporter-grig-compute-args (a1 a2)
"Compute A1 and A2."
(let* ((i2c (lambda (x)
(let ((x (if x (string-to-int x) 0)))
((= 0 x) "")
((< 0 x) (format "span%d" x))
((> 0 x) (format "offset%d" (- x))))))))
(format "%s %s"
(funcall i2c a1)
(funcall i2c a2))))
(defun jo-exporter-publish-grid ()
"Publish a grid in HTML mode.
The default replacement text could be changed using variables
`jo-exporter-grid-header', `jo-exporter-grid-footer' and
(goto-char (point-min))
(let ((case-fold-search t))
(while (re-search-forward
"^#\\+BEGIN_JO_EXPORTER_ROW:?[ \t]+\\(.*\\)"
nil t)
(goto-char (point-at-bol))
(let* ((args (when (stringp (match-string 1))
(split-string (match-string-no-properties 1)))))
(format jo-exporter-grid-header
(or (nth 2 args) "")
(nth 0 args)
(nth 1 args)))
(delete-region (point) (point-at-eol))
(re-search-forward "^#\\+END_JO_EXPORTER_ROW" nil t)
(error "#+END_JO_EXPORTER_ROW not found in %s@%s." (buffer-file-name)
(delete-region (point) (point-at-eol))
(setq end (point)))
(while (re-search-forward
"^#\\+JO_EXPORTER_ROW_COLUMN:?[ \t]+\\(-?[0-9]+\\)\\([ \t]+\\(-?[0-9]+\\)\\)?"
nil t)
(goto-char (point-at-bol))
(format jo-exporter-grid-column
(match-string 1)
(match-string 2)))
(delete-region (point) (point-at-eol)))))
'("jog" "#+begin_jo_exporter_row ?\n\n#+end_jo_exporter_row"))
'("jogr" "#+jo_exporter_row_column ?\n\n"))
(add-hook 'jo-exporter-html-plugins-hook 'jo-exporter-publish-grid)
(provide 'jo-exporter-grid)
Jump to Line
Something went wrong with that request. Please try again.