Create  Edit  Diff  FrontPage  Index  Search  Changes  History  Source  RSS  Login

emptDiaryStyle - plugins can recieve arguments with empty lines

What is emptDiary style?

emptDiary is an abbreviation for 'empty line permitted tDiary style'. Very long, isn't it? This style is an extension to the tDiaryStyle which allows plug-in arguments to have empty lines. In short, this style preserves empty lines between <% and %> when splltting the input into sections.

Sometimes, you would want to include your program list in your diary. In the case, the tDiaryStyle rule gets in the way: an empty line in the program list makes a second section. emptDiary style permits empty lines in the arguments of plug-ins. Thus, using e.g. pre.rb plugin, you can show your program list without modifying your it.

You can use the following as an example for pre.rb:

def pre (text, escape = true, attr='')
  attr = ' ' + attr unless attr.empty?
  "<pre#{attr}>#{escape ? CGI::escapeHTML(text) : text}</pre>"


Please copy the file emptdiary_style.rb into the tdiary/ directory under the top directory where tdiary.rb sits. Add the following line into tdiary.conf:

 @style = 'emptDiary'

You can write your diaries in almost the same manner as you have done with the tDiary style as described in the file HOWTO-write-tDiary.html. In short:

  • A line beginning without a space becomes a section title with a section anchor,
  • Lines following the section title become the body of the section,
  • An empty line changes sections, but
  • You can create a section with a section anchor but a section title with the first line beginning with a space.

emptDiary style adds the follwing rules:

  • Empty lines between <% and %> are ignored when parsing your text into sections. Thus, you can include empty lines between <% and %>.

And asa side effect,

  • You have to keep <% and %>'s in pairs.

Thus, using pre.rb plugin, you can write a section like:

 title of the section
<p>Descriptino of the program</p>

 <%=pre <<'_PRE'
 #include <stdio.h>

 /* above is an empty line */
 main (int argc, char *argv[])
   puts ("Hello world.");

Please note that the <, >, and & charactors are escaped by the pre plugin.


This style is realized using TdiarySection? and TdiaryDiary? as super-classes. The authors of the style thank the authors of tdiary_style.rb for providing such flexible classes.

Copyright notice for the style and this document

Please edit this document to make better.

Copyright 2003 zunda <zunda at>

Permission is granted for use, copying, modification, distribution, and distribution of modified versions of this work under the terms of GPL version 2 or later. Kirchhausen Biewer Wanne

Last modified:2003/12/05 04:13:46