Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
123 lines (99 sloc) 3.24 KB
;;; o-blog-alert.el --- Publish alert in o-blog
;; Copyright © 2012 Sébastien Gross <seb•ɑƬ•chezwam•ɖɵʈ•org>
;; Author: Sébastien Gross <seb•ɑƬ•chezwam•ɖɵʈ•org>
;; Keywords: emacs,
;; Created: 2012-01-23
;; Last changed: 2012-02-09 10:42:07
;; Licence: WTFPL, grab your copy here:
;; This file is NOT part of GNU Emacs.
;;; Commentary:
;;; Code:
(require 'org nil t))
(defcustom o-blog-alert-header
"<div class=\"alert alert-%s\">"
"HTML fragment header to be used when publishing an alert
using `o-blog-publish-alert' using `format' with alert
type as parameter. The alert should be closed with
:type 'string
:group 'o-blog)
(defcustom o-blog-alert-footer
"HTML fragment header to be used when publishing an alert
using `o-blog-publish-alert' as it. This closes
:type 'string
:group 'o-blog)
(defcustom o-blog-alert-title
"<p class=\"alert-heading\">%s</p>"
"HTML fragment header to be used when publishing an alert
tile \(if defined\) `o-blog-publish-alert' using `format'
with alert tile as parameter."
:type 'string
:group 'o-blog)
(defun o-blog-publish-alert ()
"Publish an alert in HTML mode.
Admonitions are specially marked topics that can appear
anywhere an ordinary body element can. They contain arbitrary
body elements. Typically, an alert is rendered as an offset
block in a document, sometimes outlined or shaded, with a title
matching the alert type. For example:
#+BEGIN_O_BLOG_ALERT type title
Some text inside the alert
Where type can be on of:
- info
- success
- warning
- error
This directive might be rendered something like this:
| Title |
| |
| Some text inside the alert |
In an HTML context, previous directive would be expanded as:
<div class=\"alert alert-type\">
<p class=\"alert-heading\">Title</p>
Some text inside the alert
The default replacement text could be changed using variables
`o-blog-alert-header', `o-blog-alert-footer' and
(goto-char (point-min))
(let ((case-fold-search t))
(while (re-search-forward "^#\\+BEGIN_O_BLOG_ALERT:?[ \t]+\\(info\\|success\\|warning\\|error\\)[ \t]*\\(.*\\)" nil t)
(let* ((admo-type (match-string 1))
(admo-title (match-string 2)))
(format o-blog-alert-header admo-type)
(when admo-title
(format o-blog-alert-title admo-title))
(delete-region (point) (point-at-eol))
(re-search-forward "^#\\+END_O_BLOG_ALERT" nil t)
(error "#+END_ALERT not found in %s@%s." (buffer-file-name)
(delete-region (point) (point-at-eol))))))))
'("oa" "#+begin_o_blog_alert ?\n\n#+end_o_blog_alert"))
(add-hook 'o-blog-html-plugins-hook 'o-blog-publish-alert)
(provide 'o-blog-alert)
Jump to Line
Something went wrong with that request. Please try again.