| 1 |
<?php
|
| 2 |
// $Id: drutex_linebreak.inc,v 1.8 2006/09/06 02:25:41 dfg Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Provide line-breaking algorithms for DruTeX.
|
| 7 |
*
|
| 8 |
* There is currently the choice between Drupal-style linebreaking and
|
| 9 |
* LaTeX-style linebreaking.
|
| 10 |
*/
|
| 11 |
|
| 12 |
/**
|
| 13 |
* Implementation of subhook_info().
|
| 14 |
*/
|
| 15 |
function drutex_linebreak_info($format = -1) {
|
| 16 |
return (object) array(
|
| 17 |
'title' => t('Line break converter'),
|
| 18 |
'description' => check_plain(t('Converts line breaks into HTML (i.e. <br /> and <p> tags).')),
|
| 19 |
'toggle' => true,
|
| 20 |
'weight' => 12
|
| 21 |
);
|
| 22 |
}
|
| 23 |
|
| 24 |
/**
|
| 25 |
* Implementation of subhook_defaults().
|
| 26 |
*/
|
| 27 |
function drutex_linebreak_defaults() {
|
| 28 |
$D['drutex_linebreak_active'] = true;
|
| 29 |
$D['drutex_linebreak_behaviour'] = 'drupal';
|
| 30 |
|
| 31 |
return $D;
|
| 32 |
}
|
| 33 |
|
| 34 |
/**
|
| 35 |
* Implementation of subhook_node2html_postprocess().
|
| 36 |
*/
|
| 37 |
function drutex_linebreak_node2html_postprocess($text, $format = -1) {
|
| 38 |
$method = drutex_var_get("drutex_linebreak_behaviour_$format");
|
| 39 |
|
| 40 |
if ($method == 'drupal') {
|
| 41 |
$text =_filter_autop($text);
|
| 42 |
}
|
| 43 |
else if ($method == 'latex') {
|
| 44 |
$text = preg_replace('/(?<!\n)\n(?!\n)/s', ' ', $text);
|
| 45 |
$text = _filter_autop($text);
|
| 46 |
}
|
| 47 |
|
| 48 |
return $text;
|
| 49 |
}
|
| 50 |
|
| 51 |
/**
|
| 52 |
* Implementation of subhook_filter_settings().
|
| 53 |
*/
|
| 54 |
function drutex_linebreak_filter_settings($format = -1) {
|
| 55 |
$choices = array('drupal' => 'Drupal style',
|
| 56 |
'latex' => 'LaTeX style');
|
| 57 |
|
| 58 |
$form["drutex_linebreak_behaviour_$format"] = array(
|
| 59 |
'#type' => 'select',
|
| 60 |
'#title' => t('Linebreaking Method'),
|
| 61 |
'#options' => $choices,
|
| 62 |
'#default_value' => drutex_var_get("drutex_linebreak_behaviour_$format"),
|
| 63 |
'#description' => t('How to handle new and empty lines in your input.')
|
| 64 |
);
|
| 65 |
|
| 66 |
return $form;
|
| 67 |
}
|