summaryrefslogtreecommitdiff
path: root/journal.lisp
diff options
context:
space:
mode:
authorMatthias Benkard <code@mail.matthias.benkard.de>2007-05-29 01:48:30 +0200
committerMatthias Benkard <code@mail.matthias.benkard.de>2007-05-29 01:48:30 +0200
commitd0fbdea8a23739ae98ab2a30b43b46faaf22d6ae (patch)
tree29d48360219d0d86cb4975441b2d31b6110efdb6 /journal.lisp
parent9eddc7f9f6850ad426dd7af06e0ebb097ca8938d (diff)
A workaround for weird cl-markdown behaviour.
darcs-hash:7ec3b2f91645e9a4b1dbb28df1e4d394899fcce1
Diffstat (limited to 'journal.lisp')
-rwxr-xr-xjournal.lisp39
1 files changed, 32 insertions, 7 deletions
diff --git a/journal.lisp b/journal.lisp
index 35008ef..bfcfe4b 100755
--- a/journal.lisp
+++ b/journal.lisp
@@ -96,6 +96,30 @@
(call-next-method))
+(defun fixup-markdown-output (markup)
+ ;; No, cl-markdown is certainly not perfect.
+ ;;
+ ;; First, convert "<a ...> bla</a>" into " <a ...>bla</a>" (note the
+ ;; excess space to the right of the opening tag in the unprocessed
+ ;; string, which we move to the left of the same opening tag, where we
+ ;; expect it to make more sense in the general case).
+ (loop
+ for matches = (ppcre:all-matches "<a [^>]*?> " markup)
+ while (not (null matches))
+ do (progn
+ (setf markup #+nil
+ (delete-if (constantly t)
+ markup
+ :start (1- (second matches))
+ :end (second matches))
+ (replace markup markup :start1 (1+ (first matches))
+ :end1 (second matches)
+ :start2 (first matches)
+ :end2 (1- (second matches))))
+ (setf (elt markup (first matches)) #\Space)))
+ markup)
+
+
(defun journal-markup->html (markup)
(if (string= "" markup)
markup
@@ -109,13 +133,14 @@
(with-output-to-string (s)
(system::pretty-print-condition c s)))
(invoke-restart 'return nil))))
- (with-output-to-string (s)
- ;; Normally, we shouldn't need to create our own stream to
- ;; write into, but this is, of course, yet another
- ;; CLISP/Markdown hack, because Markdown's default
- ;; *OUTPUT-STREAM* seems to spontaneously close itself, making
- ;; everything break when Markdown tries to render more stuff.
- (markdown markup :stream s)))))
+ (fixup-markdown-output
+ (with-output-to-string (s)
+ ;; Normally, we shouldn't need to create our own stream to
+ ;; write into, but this is, of course, yet another
+ ;; CLISP/Markdown hack, because Markdown's default
+ ;; *OUTPUT-STREAM* seems to spontaneously close itself, making
+ ;; everything break when Markdown tries to render more stuff.
+ (markdown markup :stream s))))))
(defun read-journal-entry (filename)