--- module.orig 2008-02-11 01:09:47.000000000 +0100 +++ marksmarty.module 2008-02-11 01:59:52.000000000 +0100 @@ -1,5 +1,5 @@ geshi:$1|$3|$2', $text); + } + + if (variable_get("marksmarty_markdown_no_markup_$format", 0) == 1) { + // use special markdown parser to escape unwanted html tags + require_once(dirname(__FILE__).'/no-markup_markdown.php'); + + $text = MarkdownWithoutMarkup($text, variable_get("marksmarty_markdown_allowed_html_$format", '')); + + $text = filter_xss_admin($text); + } else { + // default markdown parser + $text = Markdown($text); + } + + if ($geshi_compliant) { + // redo what we reverted above so that the GeSHi module can do its work + $text = preg_replace('#
geshi:(([a-z]+)(?: [^|]*)?)\|(.+)\|\2#Us', + '[geshifilter-$1]$3[/geshifilter-$2]', $text); + // enable plaintext style for generic code blocks & spans + $text = str_replace( + array('
', '',
+ '', ''),
+ array('[geshifilter-blockcode]', '[/geshifilter-blockcode]',
+ '[geshifilter-code]', '[/geshifilter-code]'),
+ $text);
+ }
}
+
if (variable_get("marksmarty_is_smarty_on_$format", 1) == 1) {
+ require_once(dirname(__FILE__) .'/smartypants.php');
+
global $smartypants_attr;
$smartypants_attr = variable_get("marksmarty_smarty_hyphens_$format", 0) + 1;
+
$text = SmartyPants($text);
+
+ if ($geshi_compliant) {
+ // ” -> "
+ $text = preg_replace_callback('#\[geshifilter-[a-z]+ [^\]]+\]#U', '_marksmarty_geshipants', $text);
+ }
}
return $text;
}
+// callback to revert ” entities to double quotes
+function _marksmarty_geshipants($matches) {
+ return str_replace('”' , '"', $matches[0]);
+}
+
function _marksmarty_settings($format) {
require_once(dirname(__FILE__) .'/markdown.php');
require_once(dirname(__FILE__) .'/smartypants.php');
@@ -144,6 +190,25 @@ function _marksmarty_settings($format) {
'#default_value' => variable_get("marksmarty_is_markdown_on_$format", 1),
'#options' => array(0 => t('No'), 1 => t('Yes')),
);
+ $form['markdown_settings']["marksmarty_markdown_no_markup_$format"] = array(
+ '#type' => 'select',
+ '#title' => t('Disable HTML markup in Markdown?'),
+ '#default_value' => variable_get("marksmarty_markdown_no_markup_$format", 0),
+ '#options' => array(0 => t('No'), 1 => t('Yes')),
+ );
+ $form['markdown_settings']["marksmarty_markdown_allowed_html_$format"] = array(
+ '#type' => 'textfield',
+ '#title' => t('HTML tag whitelist'),
+ '#description' => t('only applies when markup is disabled (see above)'),
+ '#default_value' => variable_get("marksmarty_markdown_allowed_html_$format", ''),
+ );
+ $form['markdown_settings']["marksmarty_geshi_compliant_$format"] = array(
+ '#type' => 'select',
+ '#title' => t('Enable GeSHi support mode'),
+ '#description' => t('When you use GeSHi rearrange the filters so that marksmarty comes before GeSHi and enable this option. When you disable HTML markup, add pre to the HTML tag whitelist.'),
+ '#default_value' => variable_get("marksmarty_geshi_compliant_$format", 0),
+ '#options' => array(0 => t('No'), 1 => t('Yes')),
+ );
$form['markdown_settings']["marksmarty_is_smarty_on_$format"] = array(
'#type' => 'select',
'#title' => t('Enable SmartyPants?'),