1 ;;; planner-publish.el --- planner-specific publishing
3 ;; Copyright (C) 2005, 2006 Peter K. Lee
4 ;; Parts copyright (C) 2005 Chris McMahan
5 ;; Parts copyright (C) 2005, 2006 Free Software Foundation, Inc.
6 ;; Parts copyright (C) 2005 Dale P. Smith
8 ;; Author: Peter K. Lee <saint@ c o r e n o v a .com>
9 ;; Keywords: planner publish
10 ;; Timestamp: 20 Jul 2005 10:05:29
11 ;; X-URL: http://www.corenova.com/...
13 ;; This file is part of Planner. It is not part of GNU Emacs.
15 ;; Planner is free software; you can redistribute it and/or modify it
16 ;; under the terms of the GNU General Public License as published by
17 ;; the Free Software Foundation; either version 2, or (at your option)
20 ;; Planner is distributed in the hope that it will be useful, but
21 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 ;; General Public License for more details.
25 ;; You should have received a copy of the GNU General Public License
26 ;; along with Planner; see the file COPYING. If not, write to the
27 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
28 ;; Boston, MA 02110-1301, USA.
32 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
36 ;; Muse Styles for Planner: planner-xml, planner-html, planner-xhtml, etc.
38 ;; Handles publishing of planner files. Works with Muse to generate
43 ;; 2005-07-15 (0.1) : creation date
44 ;; 2005-07-20 (0.2) : first public release
45 ;; 2005-07-21 (0.3) : added planner-html-style-sheet customize option
46 ;; 2005-08-09 : added to Planner, see ChangeLog for further changes
50 ;; add support for various PLANNER specific sections such as Diary,
51 ;; Accomplishments, Timeclock, etc.
55 ;; Chris McMahan (cmcmahan AT one.net) helped notes to publish correctly.
57 ;; Jim Ottaway fixed several bugs.
59 ;; David Smith fixed a few bugs.
61 ;; Dale Smith implemented a new version of the "notes" tag and
62 ;; provided several patches.
64 ;; Andrew J. Korty enabled multiple links with the "categories"
70 (require 'muse-publish
)
71 (require 'muse-html
) ;;; allow derive style from "html" and "xhtml"
72 (require 'muse-xml
) ;;; allow derive style from "xml"
74 (unless (featurep 'muse-nested-tags
)
75 (error (concat "Your version of Muse is too old. Please upgrade to"
76 " at least Muse 3.03.")))
78 (defgroup planner-publish nil
79 "Options controlling the behavior of PLANNER publishing.
80 See `planner-publish' for more information."
83 (defcustom planner-publish-markup-regexps
84 '((1275 "^#\\([A-C]\\)\\([0-9]*\\)\\s-*\\([_oXDCP]\\)\\s-*\\(.+\\)" 0 task
)
85 (1280 "^\\.#[0-9]+\\s-*" 0 note
)
86 (3200 planner-date-regexp
0 link
))
87 "List of markup rules for publishing PLANNER.
88 For more on the structure of this list, see `muse-publish-markup-regexps'."
89 :type
'(repeat (choice
90 (list :tag
"Markup rule"
92 (choice regexp symbol
)
94 (choice string function symbol
))
96 :group
'planner-publish
)
98 (defcustom planner-publish-markup-functions
99 '((task . planner-publish-markup-task
)
100 (note . planner-publish-markup-note
))
101 "An alist of style types to custom functions for that kind of text.
102 For more on the structure of this list, see
103 `muse-publish-markup-functions'."
104 :type
'(alist :key-type symbol
:value-type function
)
105 :group
'planner-publish
)
107 (defcustom planner-publish-markup-tags
108 '(("nested-section" t nil t planner-publish-nested-section-tag
)
109 ("title" t t nil planner-publish-title-tag
)
110 ("content" t nil nil planner-publish-content-tag
)
111 ("diary-section" t nil nil planner-publish-diary-section-tag
)
112 ("tasks-section" t nil nil planner-publish-tasks-section-tag
)
113 ("notes-section" t nil nil planner-publish-notes-section-tag
)
114 ("notes" nil nil nil planner-publish-notes-tag
)
115 ("past-notes" nil t nil planner-publish-past-notes-tag
)
116 ("task" t t nil planner-publish-task-tag
)
117 ("note" t t nil planner-publish-note-tag
))
118 "A list of tag specifications, for specially marking up PLANNER.
119 See `muse-publish-markup-tags' for more information."
120 :type
'(repeat (list (string :tag
"Markup tag")
121 (boolean :tag
"Expect closing tag" :value t
)
122 (boolean :tag
"Parse attributes" :value nil
)
123 (boolean :tag
"Nestable" :value nil
)
125 :group
'planner-publish
)
127 ;;;_ + XML specific customizations
129 (defcustom planner-xml-markup-strings
130 '((planner-begin-nested-section .
"<section>")
131 (planner-end-nested-section .
"</section>")
132 (planner-begin-title .
"<title>")
133 (planner-end-title .
"</title>")
134 (planner-begin-content .
"")
135 (planner-end-content .
"")
136 (planner-begin-body .
"")
137 (planner-end-body .
"")
138 (planner-begin-diary-section .
"<diary>")
139 (planner-end-diary-section .
"</diary>")
140 (planner-begin-task-section .
"<tasks>")
141 (planner-end-task-section .
"</tasks>")
142 (planner-begin-task-body .
"")
143 (planner-end-task-body .
"")
144 (planner-begin-note-section .
"<notes>")
145 (planner-end-note-section .
"</notes>")
146 (planner-begin-task .
"<task status=\"%s\" priority=\"%s\">")
147 (planner-end-task .
"</task>")
148 (planner-begin-note .
"<note number=\"%s\">")
149 (planner-end-note .
"</note>")
150 (planner-begin-note-details .
"<details><timestamp>%s</timestamp>")
151 (planner-end-note-details .
"</details>")
152 (planner-begin-note-link .
"<references>")
153 (planner-end-note-link .
"</references>")
154 (planner-begin-note-categories .
"<categories>")
155 (planner-end-note-categories .
"</categories>"))
156 "Strings used for marking up text as XML.
157 These cover the most basic kinds of markup, the handling of which
158 differs little between the various styles.
160 If a markup rule is not found here, `muse-xml-markup-strings' is
162 :type
'(alist :key-type symbol
:value-type string
)
163 :group
'planner-publish
)
165 (defcustom planner-xml-header
166 "<?xml version=\"1.0\" encoding=\"<lisp>(muse-xml-encoding)</lisp>\"?>
169 <title><lisp>(muse-publishing-directive \"title\")</lisp></title>
170 <author><lisp>(muse-publishing-directive \"author\")</lisp></author>
171 <maintainer><lisp>(muse-style-element :maintainer)</lisp></maintainer>
172 <pubdate><lisp>(muse-publishing-directive \"date\")</lisp></pubdate>
174 <!-- Page published by Emacs Muse begins here -->\n"
175 "Header used for publishing PLANNER XML files.
176 This may be text or a filename."
178 :group
'planner-publish
)
180 (defcustom planner-xml-footer
"
181 <!-- Page published by Emacs Muse ends here -->
183 "Footer used for publishing PLANNER XML files.
184 This may be text or a filename."
186 :group
'planner-publish
)
188 ;;;_ + HTML specific customizations
190 (defcustom planner-html-markup-strings
191 '((planner-begin-nested-section .
"<div class=\"section\">")
192 (planner-end-nested-section .
"</div>")
193 (planner-begin-title .
"<h%s>")
194 (planner-end-title .
"</h%s>")
195 (planner-begin-content .
"<div class=\"content\">")
196 (planner-end-content .
"</div>")
197 (planner-begin-body .
"<div class=\"body\">")
198 (planner-end-body .
"</div>")
199 (planner-begin-diary-section .
"<div id=\"diary\" class=\"section\">")
200 (planner-end-diary-section .
"</div>")
201 (planner-begin-task-section .
"<div id=\"tasks\" class=\"section\">")
202 (planner-end-task-section .
"</div>")
203 (planner-begin-task-body .
"<ul class=\"body\">")
204 (planner-end-task-body .
"</ul>")
205 (planner-begin-note-section .
"<div id=\"notes\" class=\"section\">")
206 (planner-end-note-section .
"</div>")
207 (planner-begin-task .
"<li class=\"task\"><span class=\"%s\"><span class=\"%s\">%s</span>")
208 (planner-end-task .
"</span></li>")
209 (planner-begin-note .
"<div class=\"note\"><a name=\"%s\"></a><span class=\"anchor\">%s</span>")
210 (planner-end-note .
"</div>")
211 (planner-begin-note-details .
"<div class=\"details\"><span class=\"timestamp\">%s</span>")
212 (planner-end-note-details .
"</div>")
213 (planner-begin-note-link .
" <span class=\"link\">")
214 (planner-end-note-link .
"</span>")
215 (planner-begin-note-categories .
" <span class=\"categories\">")
216 (planner-end-note-categories .
"</span>"))
217 "Strings used for marking up text as HTML.
218 These cover the most basic kinds of markup, the handling of which
219 differs little between the various styles.
221 If a markup rule is not found here, `muse-html-markup-strings' is
223 :type
'(alist :key-type symbol
:value-type string
)
224 :group
'planner-publish
)
226 (defcustom planner-html-style-sheet
227 "<style type=\"text/css\">
229 background: white; color: black;
230 margin-left: 3%; margin-right: 3%;
233 p { margin-top: 3px; margin-bottom: 3px; }
234 p.verse { margin-left: 3% }
236 h1,h2,h3,h4,h5 { margin:0; padding:0; }
238 h1 { padding: 10px; margin-bottom: 10px; }
240 table.muse-table { margin: 0; font-size: 11px;
241 border-collapse: collapse;
243 border: 1px solid #aadeed; }
245 table.muse-table tbody td { border: 1px solid #ccdeed; }
247 .example { margin-left: 5px; padding: 3px;
249 border: 1px solid #ccdeed; }
251 /* nested sections */
252 .section { margin: 0; padding: 10px;
256 .section .section { margin: 0; margin-left: 5px;
259 .title { margin: 0; padding; 0 }
261 /* optional calendar section */
262 .calendar { float: right; }
263 table.month-calendar { font-size: 9px; }
266 #diary p { margin-top: 1em; }
269 .task .A { color: red }
270 .task .B { color: green }
271 .task .C { color: navy }
272 .task .done { color: gray; text-decoration: line-through; }
273 .task .cancelled { color: gray; text-decoration: italic; }
276 .note { margin-top: 1.5em; }
277 .note .anchor { float: left; margin-right: 5px; }
278 .note .details { margin-top: .5em; }
281 "Store your stylesheet definitions here. The provided default
282 is for reference only. You definitely want to customize this for
283 your particular needs & wants. This is used in
284 `planner-html-header' and `planner-xhtml-header'. Refer to
285 `muse-html-style-sheet' for details on usage. You may simply
286 override the above by specifying an explicit link to a CSS file."
288 :group
'planner-publish
)
290 (defcustom planner-html-header
291 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">
295 (concat (muse-publishing-directive \"title\")
296 (let ((author (muse-publishing-directive \"author\")))
297 (if (not (string= author (user-full-name)))
298 (concat \" (by \" author \")\"))))</lisp></title>
299 <meta name=\"generator\" content=\"muse.el\">
300 <meta http-equiv=\"<lisp>muse-html-meta-http-equiv</lisp>\"
301 content=\"<lisp>muse-html-meta-content-type</lisp>\">
303 (let ((maintainer (muse-style-element :maintainer)))
305 (concat \"<link rev=\\\"made\\\" href=\\\"\" maintainer \"\\\">\")))
307 <lisp>planner-html-style-sheet</lisp>
312 (concat (muse-publishing-directive \"title\")
313 (let ((author (muse-publishing-directive \"author\")))
314 (if (not (string= author (user-full-name)))
315 (concat \" (by \" author \")\"))))</lisp></span></h1>
316 <div id=\"inner-header\">
317 <lisp>planner-html-inner-header</lisp>
319 <div id=\"muse-sections\">
320 <!-- Page published by Emacs Muse begins here -->\n"
321 "Header used for publishing PLANNER HTML files.
322 This may be text or a filename."
324 :group
'planner-publish
)
326 (defcustom planner-html-footer
"
327 <!-- Page published by Emacs Muse ends here -->
329 <div id=\"inner-footer\">
330 <lisp>planner-html-inner-footer</lisp>
335 "Footer used for publishing PLANNER HTML files.
336 This may be text or a filename."
338 :group
'planner-publish
)
340 (defcustom planner-xhtml-header
341 "<?xml version=\"1.0\" encoding=\"<lisp>
342 (muse-html-encoding)</lisp>\"?>
343 <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
344 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
345 <html xmlns=\"http://www.w3.org/1999/xhtml\">
348 (concat (muse-publishing-directive \"title\")
349 (let ((author (muse-publishing-directive \"author\")))
350 (if (not (string= author (user-full-name)))
351 (concat \" (by \" author \")\"))))</lisp></title>
352 <meta name=\"generator\" content=\"muse.el\" />
353 <meta http-equiv=\"<lisp>muse-html-meta-http-equiv</lisp>\"
354 content=\"<lisp>muse-html-meta-content-type</lisp>\" />
356 (let ((maintainer (muse-style-element :maintainer)))
358 (concat \"<link rev=\\\"made\\\" href=\\\"\" maintainer \"\\\" />\")))
360 <lisp>planner-html-style-sheet</lisp>
365 (concat (muse-publishing-directive \"title\")
366 (let ((author (muse-publishing-directive \"author\")))
367 (if (not (string= author (user-full-name)))
368 (concat \" (by \" author \")\"))))</lisp></span></h1>
369 <div id=\"inner-header\">
370 <lisp>planner-html-inner-header</lisp>
372 <div id=\"muse-sections\">
373 <!-- Page published by Emacs Muse begins here -->\n"
374 "Header used for publishing PLANNER XHTML files.
375 This may be text or a filename."
377 :group
'planner-publish
)
379 (defcustom planner-xhtml-footer
"
380 <!-- Page published by Emacs Muse ends here -->
382 <div id=\"inner-footer\">
383 <lisp>planner-html-inner-footer</lisp>
388 "Footer used for publishing PLANNER XHTML files.
389 This may be text or a filename."
391 :group
'planner-publish
)
393 (defcustom planner-html-inner-header
""
394 "Extra header section that can be embedded within
395 `planner-html-header' and `planner-xhtml-header'."
397 :group
'planner-publish
)
399 (defcustom planner-html-inner-footer
""
400 "Extra footer section that can be embedded within
401 `planner-html-footer' and `planner-xhtml-footer'."
403 :group
'planner-publish
)
405 ;;;_ + Publishing hooks
407 (defcustom planner-publish-prepare-regexps
408 '((100 "^\\(\\*+\\)\\s-+" 0 planner-publish-section
))
409 "List of markup rules to apply before publishing a page with Planner.
410 See `muse-publish-markup-regexps' for details on the syntax used."
411 :type
'(repeat (choice
412 (list :tag
"Markup rule"
414 (choice regexp symbol
)
416 (choice string function symbol
))
418 :group
'planner-publish
)
420 (defcustom planner-publish-finalize-regexps
422 "List of markup rules to apply after publishing a page with Planner.
423 See `muse-publish-markup-regexps' for details on the syntax used."
424 :type
'(repeat (choice
425 (list :tag
"Markup rule"
427 (choice regexp symbol
)
429 (choice string function symbol
))
431 :group
'planner-publish
)
433 (defun planner-publish-prepare-buffer ()
434 (goto-char (point-min))
435 (muse-publish-markup "preparing Planner page"
436 planner-publish-prepare-regexps
)
437 ;; indicate that we are to continue preparing the buffer
440 (defun planner-publish-finalize-buffer ()
441 (goto-char (point-min))
442 (muse-publish-markup "finalizing Planner page"
443 planner-publish-finalize-regexps
)
444 ;; indicate that we are to continue finalizing the buffer
449 (defvar planner-publish-ignore-url-desc-specials nil
450 "If non-nil, do not escape specials in URL descriptions.")
452 (defun planner-publish-decide-specials (context)
453 "Determine the specials to escape for Planner, depending on CONTEXT."
454 (if (and (eq context
'url-desc
)
455 planner-publish-ignore-url-desc-specials
)
457 (muse-xml-decide-specials context
)))
459 (defun planner-publish-markup-task ()
460 "Replace tasks with XML representation of task data."
463 (planner-line-beginning-position)
464 (planner-line-end-position))
465 (let ((info (planner-current-task-info)))
466 (delete-region (point-min) (point-max))
469 (format (concat "<task id=\"%s\" priority=\"%s\" status=\"%s\""
470 " link=\"%s\" plan=\"%s\" date=\"%s\">")
471 (or (planner-task-number info
) "")
472 (or (planner-task-priority info
) "")
473 (or (planner-publish-task-status-expand
474 (planner-task-status info
)) "")
475 (or (planner-task-link-text info
) "")
476 (or (planner-task-plan info
) "")
477 (or (planner-task-date info
) "")))
478 ;; mark this area read only for safety's sake
479 (planner-insert-markup (planner-task-description info
))
480 (insert "</task>"))))
482 (defun planner-publish-markup-note ()
483 "Replace note with XML representation of note data. Borrowed
484 heavily from Sacha's personal configs."
487 (save-excursion (beginning-of-line) (point))
489 (and (re-search-forward "^\\(\\.#\\|* \\|</notes-section>\\)" nil t
)
490 (match-beginning 0)))
492 (let ((info (planner-current-note-info t
)))
493 (delete-region (point-min) (point-max))
494 (insert (format (concat "<note anchor=\"%s\" timestamp=\"%s\""
495 " link=\"%s\" categories=\"%s\">")
496 (planner-note-anchor info
)
497 (or (planner-note-timestamp info
) "")
498 (or (planner-note-link info
) "")
499 (or (planner-note-link-text info
) ""))
500 "<title level=\"3\">" (planner-note-title info
) "</title>\n"
502 (planner-insert-markup (planner-note-body info
))
503 (insert "\n\n</content>\n</note>\n"))))
508 (defun planner-insert-markup (&rest args
)
509 (if (fboundp 'muse-insert-markup
)
510 (apply 'muse-insert-markup args
)
513 (muse-publish-mark-read-only beg
(point)))))
515 (defun planner-publish-nested-section-tag (beg end
)
516 "Generated by `planner-publish-section', the nested section tag
517 now takes in TITLE and LEVEL attributes.
519 This is related to the Muse concept of sections, but done before
520 marking up the buffer, and with special actions done on the title
524 (planner-insert-markup (muse-markup-text 'planner-begin-nested-section
))
526 (planner-insert-markup (muse-markup-text 'planner-end-nested-section
))))
528 (defun planner-publish-title-tag (beg end attrs
)
529 (let ((level (cdr (assoc "level" attrs
))))
532 (planner-insert-markup (muse-markup-text 'planner-begin-title level
))
534 (planner-insert-markup (muse-markup-text 'planner-end-title level
)))))
536 (defun planner-publish-content-tag (beg end
)
539 (planner-insert-markup (muse-markup-text 'planner-end-content
))
541 (planner-insert-markup (muse-markup-text 'planner-begin-content
))))
543 (defun planner-publish-diary-section-tag (beg end
)
546 (planner-insert-markup (muse-markup-text 'planner-begin-diary-section
))
548 (muse-publish-verse-tag (point) end
)
550 (planner-insert-markup (muse-markup-text 'planner-end-diary-section
))))
552 (defun planner-publish-tasks-section-tag (beg end
)
555 (planner-insert-markup (muse-markup-text 'planner-begin-task-section
))
557 (planner-insert-markup (muse-markup-text 'planner-begin-task-body
))
559 (planner-insert-markup (muse-markup-text 'planner-end-task-body
))
560 (planner-insert-markup (muse-markup-text 'planner-end-task-section
))))
562 (defun planner-publish-task-tag (beg end attrs
)
564 (let ((number (cdr (assoc "id" attrs
)))
565 (status (cdr (assoc "status" attrs
)))
566 (priority (cdr (assoc "priority" attrs
)))
567 (link (cdr (assoc "link" attrs
)))
568 (plan (cdr (assoc "plan" attrs
)))
569 (date (cdr (assoc "date" attrs
))))
570 (remove-text-properties beg end
571 '(read-only nil rear-nonsticky nil
))
574 (insert " (" (planner-make-link link
) ")"))
575 (planner-insert-markup (muse-markup-text 'planner-end-task
))
577 (planner-insert-markup
578 (muse-markup-text 'planner-begin-task
581 (concat priority number
" "
582 (planner-publish-task-status-collapse status
)
585 (defun planner-publish-notes-section-tag (beg end
)
586 "Replace the region BEG to END with the notes for this page."
588 (planner-insert-markup (muse-markup-text 'planner-begin-note-section
))
590 (planner-insert-markup (muse-markup-text 'planner-begin-body
))
593 (planner-insert-markup (muse-markup-text 'planner-end-body
))
594 (planner-insert-markup (muse-markup-text 'planner-end-note-section
))))
596 (defun planner-publish-notes-tag (beg end
)
597 "Replace the region BEG to END with an index of the notes for this page."
598 (delete-region beg end
)
602 (insert (format " - [[%s%s][%s]]\n"
605 (planner-remove-links (cdr item
)))))
607 (find-file muse-publishing-current-file
)
608 (planner-notes-get-headlines)))
611 (defun planner-publish-past-notes-tag (beg end attrs
)
612 "Replace the region BEG to END with an index of past notes.
613 If ATTRS is non-nil, it is an alist containing values for
614 DIRECTORY and START."
615 (let ((files (save-excursion
616 (find-file muse-publishing-current-file
)
617 (planner-get-day-pages nil nil t
)))
618 (earliest (cdr (assoc "start" attrs
))))
620 (when (or (null earliest
)
621 (not (string-lessp (caar files
) earliest
)))
622 (let ((title-lines (list t
)))
624 (insert-file-contents (cdar files
))
625 (while (re-search-forward "^\\.#\\([0-9]+\\)\\s-+\\(.+\\)" nil t
)
626 (nconc title-lines
(list (cons (match-string 1)
627 (match-string 2))))))
628 (setq title-lines
(cdr title-lines
))
630 (insert (planner-make-link (planner-page-name (caar files
)))
632 (planner-insert-markup " <dl class=\"contents\">\n")
634 (planner-insert-markup " <dt class=\"contents\">")
635 (insert (format "[[%s#%s][%s]]"
636 (planner-page-name (caar files
))
637 (caar title-lines
) (cdar title-lines
)))
638 (planner-insert-markup "</dt>\n")
639 (setq title-lines
(cdr title-lines
)))
640 (planner-insert-markup " </dl>\n\n"))))
641 (setq files
(cdr files
)))))
643 (defun planner-publish-note-tag (beg end attrs
)
645 (let ((anchor (or (cdr (assoc "anchor" attrs
)) ""))
646 (timestamp (or (cdr (assoc "timestamp" attrs
)) ""))
647 (link (or (cdr (assoc "link" attrs
)) ""))
648 (categories (or (cdr (assoc "categories" attrs
)) "")))
649 (remove-text-properties beg end
650 '(read-only nil rear-nonsticky nil
))
652 (planner-insert-markup (muse-markup-text 'planner-begin-note
654 (concat "#" anchor
)))
656 (planner-insert-markup (muse-markup-text 'planner-begin-note-details
658 (muse-markup-text 'planner-begin-note-link
))
660 (planner-insert-markup (muse-markup-text 'planner-end-note-link
))
661 ;; remove link item from categories to avoid duplicates
662 (unless (or (string= link
"") (string= categories
""))
663 (setq categories
(planner-replace-regexp-in-string
664 (regexp-quote link
) "" categories t t
)))
665 (planner-insert-markup (muse-markup-text 'planner-begin-note-categories
))
667 (planner-insert-markup (muse-markup-text 'planner-end-note-categories
))
669 (planner-insert-markup (muse-markup-text 'planner-end-note-details
))
670 (planner-insert-markup (muse-markup-text 'planner-end-note
)))))
672 ;;;_ + helper routine
674 (defun planner-publish-task-status-expand (status)
676 ((string= status
"_") "open")
677 ((string= status
"o") "in-progress")
678 ((string= status
"D") "delegated")
679 ((string= status
"P") "pending")
680 ((string= status
"X") "done")
681 ((string= status
"C") "cancelled")
684 (defun planner-publish-task-status-collapse (status)
686 ((string= status
"open") "_")
687 ((string= status
"in-progress") "o")
688 ((string= status
"delegated") "D")
689 ((string= status
"pending") "P")
690 ((string= status
"done") "X")
691 ((string= status
"cancelled") "C")
694 (defun planner-publish-section-close (depth text
)
695 "Find where the closing tag of DEPTH should go, and insert TEXT."
698 (while (and (setq not-end
(re-search-forward
699 (concat "^\\*\\{1," (number-to-string depth
)
702 (get-text-property (match-beginning 0) 'read-only
)))
705 (goto-char (point-max)))
706 (cond ((not (eq (char-before) ?
\n))
708 ((not (eq (char-before (1- (point))) ?
\n))
713 (defvar planner-section-tagnames
714 '(("Diary" .
"diary-section")
715 ("Tasks" .
"tasks-section")
716 ("Notes" .
"notes-section"))
717 "Alist of sections and their tag name.")
719 (defun planner-publish-section-tagname (text)
720 "A routine that checks `planner-section-tagnames' for tagname."
721 (let ((tagname (cdr (assoc text planner-section-tagnames
))))
726 (defun planner-publish-section ()
727 "Publish the current heading as a section."
728 (let* ((depth (length (match-string 1)))
729 (title (buffer-substring (match-end 0) (planner-line-end-position)))
730 (tagname (planner-publish-section-tagname title
)))
731 (delete-region (match-beginning 0) (match-end 0))
732 (insert (format "<%s level=\"%s\"><title level=\"%s\">"
733 tagname depth
(1+ depth
)))
736 (planner-publish-section-close depth
(format "</%s>" tagname
))))
738 ;;;_ + Planner Style Definitions
740 (muse-derive-style "planner-xml" "xml"
741 :regexps
'planner-publish-markup-regexps
742 :functions
'planner-publish-markup-functions
743 :tags
'planner-publish-markup-tags
744 :specials
'planner-publish-decide-specials
745 :strings
'planner-xml-markup-strings
746 :before
'planner-publish-prepare-buffer
747 :after
'planner-publish-finalize-buffer
748 :header
'planner-xml-header
749 :footer
'planner-xml-footer
)
751 (muse-derive-style "planner-html" "html"
752 :regexps
'planner-publish-markup-regexps
753 :functions
'planner-publish-markup-functions
754 :tags
'planner-publish-markup-tags
755 :specials
'planner-publish-decide-specials
756 :strings
'planner-html-markup-strings
757 :before
'planner-publish-prepare-buffer
758 :after
'planner-publish-finalize-buffer
759 :header
'planner-html-header
760 :footer
'planner-html-footer
)
762 (muse-derive-style "planner-xhtml" "xhtml"
763 :regexps
'planner-publish-markup-regexps
764 :functions
'planner-publish-markup-functions
765 :tags
'planner-publish-markup-tags
766 :specials
'planner-publish-decide-specials
767 :strings
'planner-html-markup-strings
768 :before
'planner-publish-prepare-buffer
769 :after
'planner-publish-finalize-buffer
770 :header
'planner-xhtml-header
771 :footer
'planner-xhtml-footer
)
773 (provide 'planner-publish
)
775 ;;; planner-publish.el ends here