1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3 ;; Muse Poem Publishing
5 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 ;; I use a very particular for recording poetry. It is:
17 ;; Annotations, history, notes, etc.
19 ;; The `muse-poem' module makes it easy to attractively publish and
20 ;; reference poems in this format, using the "memoir" module for LaTeX
21 ;; publishing. It will also markup poems for every other output
22 ;; style, though none are nearly as pretty.
24 ;; Once a poem is written in this format, just publish it to PDF using
25 ;; the "poem-pdf" style. To make an inlined reference to a poem that
26 ;; you've written -- for example, from a blog page -- there is a
27 ;; "poem" tag defined by this module:
29 ;; <poem title="name.of.poem.page">
31 ;; Let's assume the template above was called "name.of.poem.page";
32 ;; then the above tag would result in this inclusion:
38 ;; I use this module for publishing all of the poems on my website,
39 ;; which are at: http://www.newartisans.com/johnw/poems.html.
42 (require 'muse-project
)
44 (defgroup muse-poem nil
45 "Rules for marking up a Muse file as a LaTeX article."
48 (defcustom muse-poem-latex-header
49 "\\documentclass[14pt,oneside]{memoir}
51 \\usepackage[english]{babel}
52 \\usepackage[latin1]{inputenc}
53 \\usepackage[T1]{fontenc}
55 \\setlength{\\beforepoemtitleskip}{-5.0ex}
61 \\renewcommand{\\poemtoc}{section}
62 \\settocdepth{section}
67 \\poemtitle{<lisp>(muse-publishing-directive \"title\")</lisp>}
69 \\settowidth{\\versewidth}{<lisp>muse-poem-longest-line</lisp>}\n\n"
70 "Header used for publishing LaTeX poems."
71 :type
'(choice string file
)
74 (defcustom muse-poem-latex-footer
"\n\\vfill
78 "Footer used for publishing LaTeX files."
79 :type
'(choice string file
)
82 (defvar muse-poem-markup-strings
83 '((begin-verse .
"\\begin{verse}[\\versewidth]\n")
84 (verse-space .
"\\vin "))
85 "Redefine the section heads, to match my private LaTeX setup.")
87 (defcustom muse-chapbook-latex-header
88 "\\documentclass{book}
90 \\usepackage[english]{babel}
91 \\usepackage[latin1]{inputenc}
92 \\usepackage[T1]{fontenc}
94 \\setlength{\\beforepoemtitleskip}{-5.0ex}
98 \\title{<lisp>(muse-publishing-directive \"title\")</lisp>}
99 \\author{<lisp>(muse-publishing-directive \"author\")</lisp>}
100 \\date{<lisp>(muse-publishing-directive \"date\")</lisp>}
106 \\renewcommand{\\poemtoc}{section}
107 \\settocdepth{section}\n"
108 "Header used for publishing books to LaTeX."
109 :type
'(choice string file
)
112 (defcustom muse-chapbook-latex-footer
"\n\\end{document}"
113 "Footer used for publishing books to LaTeX."
114 :type
'(choice string file
)
117 (defvar muse-poem-longest-line
"")
119 (defvar muse-poem-chapbook-strings
120 '((begin-verse .
"\\newpage
124 \\poemtitle{<lisp>(muse-publishing-directive \"title\")</lisp>}
126 \\settowidth{\\versewidth}{<lisp>muse-poem-longest-line</lisp>}
128 \\begin{verse}[\\versewidth]\n")
129 (end-verse .
"\n\\end{verse}\n\\vfill\n\\mbox{}")
130 (verse-space .
"\\vin "))
131 "Redefine the section heads, to match my private LaTeX setup.")
133 (defun muse-poem-prepare-buffer ()
134 (goto-char (point-min))
137 (delete-region (point) (1+ (line-end-position)))
139 (let ((beg (point)) end line
)
140 (if (search-forward "\n\n\n" nil t
)
142 (setq end
(copy-marker (match-beginning 0) t
))
143 (replace-match "\n</verse>\n")
144 (delete-region (point) (point-max)))
145 (goto-char (point-max))
147 (insert "</verse>\n"))
149 (set (make-local-variable 'muse-poem-longest-line
) "")
150 (while (< (point) end
)
151 (setq line
(buffer-substring-no-properties (point)
152 (line-end-position)))
153 (if (> (length line
) (length muse-poem-longest-line
))
154 (setq muse-poem-longest-line line
))
159 (defvar muse-current-project
))
161 (defvar muse-poem-tag
'("poem" nil t muse-poem-markup-tag
))
163 (defun muse-poem-markup-tag (beg end attrs
)
164 "This markup tag allows a poem to be included from another project page.
165 The form of usage is:
166 <poem title=\"page.name\">"
167 (let ((page (cdr (assoc (cdr (assoc "title" attrs
))
168 (muse-project-file-alist))))
171 (insert " *Reference to\n unknown poem \""
172 (cdr (assoc "title" attrs
)) "\".*\n")
176 (insert-file-contents page
)
177 (goto-char (point-min))
178 (if (assoc "nohead" attrs
)
181 (delete-region (point-min) (point)))
183 (search-forward "\n\n\n")
184 (replace-match "\n\n"))
185 (if (search-forward "\n\n\n" nil t
)
186 (setq end
(match-beginning 0))
187 (setq end
(point-max)))
188 (buffer-substring-no-properties (point-min) end
)))
189 (setq end
(point-marker))
191 (unless (assoc "nohead" attrs
)
193 (while (< (point) end
)
197 (add-to-list 'muse-publish-markup-tags muse-poem-tag
)
199 (unless (assoc "poem-latex" muse-publishing-styles
)
200 (muse-derive-style "poem-latex" "latex"
201 :before
'muse-poem-prepare-buffer
202 :strings
'muse-poem-markup-strings
203 :header
'muse-poem-latex-header
204 :footer
'muse-poem-latex-footer
)
206 (muse-derive-style "poem-pdf" "pdf"
207 :before
'muse-poem-prepare-buffer
208 :strings
'muse-poem-markup-strings
209 :header
'muse-poem-latex-header
210 :footer
'muse-poem-latex-footer
)
212 (muse-derive-style "chapbook-latex" "latex"
213 :before
'muse-poem-prepare-buffer
214 :strings
'muse-poem-chapbook-strings
215 :header
'muse-chapbook-latex-header
216 :footer
'muse-chapbook-latex-footer
)
218 (muse-derive-style "chapbook-pdf" "pdf"
219 :before
'muse-poem-prepare-buffer
220 :strings
'muse-poem-chapbook-strings
221 :header
'muse-chapbook-latex-header
222 :footer
'muse-chapbook-latex-footer
))
226 ;;; muse-poem.el ends here