Still on Drupal 7? Security support for Drupal 7 ended on 5 January 2025. Please visit our Drupal 7 End of Life resources page to review all of your options.
Haiku is a silly module that provides a way for end-users and developers to parse haikus out of any arbitrary text. Likely it's not very useful or practical in any way, but hopefully it's at least a little fun.
Features
A page with a basic form (located at /parse-haikus) that returns haikus parsed from user-entered text.
A field formatter "Haiku" which prints a haiku parsed from a text fields' contents.
A simple, extendable interface for developers to parse any arbitrary text into haikus.
Developers
Here is some sample code to get you started.
// Instantiating a HaikuSource object parses haikus from within text you pass in.
$haiku_text = new HaikuSource($node->body[LANGUAGE_NONE][0]['value']);
// The getHaikus method returns an array of Haiku objects.
$haikus = $haiku_text->getHaikus();
// Haiku objects have a toString method that takes a delimiter.
echo $haikus[0]->toString('<br />');
// Simply echo'ing a haiku also works, but it defaults to a newline delimiter.
echo $haikus[0];
For more details, see /includes/haiku.inc. If you're interested in the algorithm itself, extending it, or implementing your own, in addition to haiku.inc, see haiku_default.inc for full implementation details.
Have you ever used a slideshow nodetype that you need to be published but don't want the node be accessible by itself using then node/XXX path? This module is for you!