summaryrefslogtreecommitdiff
path: root/utils/markdown.php
diff options
context:
space:
mode:
Diffstat (limited to 'utils/markdown.php')
-rw-r--r--utils/markdown.php34
1 files changed, 27 insertions, 7 deletions
diff --git a/utils/markdown.php b/utils/markdown.php
index 89a85b2..eabd01d 100644
--- a/utils/markdown.php
+++ b/utils/markdown.php
@@ -38,7 +38,7 @@ define( 'MARKDOWNEXTRA_VERSION', "1.2.2" ); # Sat 21 Jun 2008
@define( 'MARKDOWN_PARSER_CLASS', 'MarkdownExtra_Parser' );
-function Markdown($text) {
+function Markdown($text, $simple = false) {
#
# Initialize the parser and return the result of its transform method.
#
@@ -47,6 +47,7 @@ function Markdown($text) {
if (!isset($parser)) {
$parser_class = MARKDOWN_PARSER_CLASS;
$parser = new $parser_class;
+ $parser->simple = $simple;
}
# Transform text using parser.
@@ -83,6 +84,7 @@ class Markdown_Parser {
var $predef_urls = array();
var $predef_titles = array();
+ public $simple;
function Markdown_Parser() {
#
@@ -2092,14 +2094,23 @@ class MarkdownExtra_Parser extends Markdown_Parser {
$level = $matches[3]{0} == '=' ? 1 : 2;
$attr = $this->_doHeaders_attr($id =& $matches[2]);
$class = strtolower(str_replace(" ", "_", $this->runSpanGamut($matches[1])));
- $block = "<div class=\"header\"><h$level$attr class=\"header_$class\"><span class=\"header_text\">".$this->runSpanGamut($matches[1])."</span></h$level></div>";
+ if($this->simple) {
+ $block = "<h$level$attr>".$this->runSpanGamut($matches[1])."</h$level>";
+ } else {
+ $block = "<div class=\"header\"><h$level$attr class=\"header_$class\"><span class=\"header_text\">".$this->runSpanGamut($matches[1])."</span></h$level></div>";
+ }
return "\n" . $this->hashBlock($block) . "\n\n";
}
function _doHeaders_callback_atx($matches) {
$level = strlen($matches[1]);
$attr = $this->_doHeaders_attr($id =& $matches[3]);
$class = strtolower(str_replace(" ", "_", $this->runSpanGamut($matches[2])));
- $block = "<div class=\"header\"><h$level$attr class=\"header_$class\"><span class=\"header_text\">".$this->runSpanGamut($matches[2])."</span></h$level></div>";
+ if($this->simple) {
+ $block = "<h$level$attr>".$this->runSpanGamut($matches[2])."</h$level>";
+ } else {
+ $block = "<div class=\"header\"><h$level$attr class=\"header_$class\"><span class=\"header_text\">".$this->runSpanGamut($matches[2])."</span></h$level></div>";
+ }
+
return "\n" . $this->hashBlock($block) . "\n\n";
}
@@ -2453,12 +2464,21 @@ class MarkdownExtra_Parser extends Markdown_Parser {
$centerr = "";
if(strlen($value) > 2 && $value[0] == '=' &&
$value[strlen($value)-1] == '=') {
- $centerl = "<div style=\"text-align: center;\">";
- $centerr = "</div>";
+ if($this->simple) {
+ $centerl = "<div style=\"text-align: center;\">";
+ $centerr = "</div>";
+ } else {
+ $centerl = "<center>";
+ $centerr = "</center>";
+ }
$value = substr($value, 1, strlen($value) - 2);
}
- $value = "<div class=\"paragraph\">" .
- $centerl . $value . $centerr . "</div>";
+ if($this->simple) {
+ $value = "<p>" . $centerl . $value . $centerr . "</p>";
+ } else {
+ $value = "<div class=\"paragraph\">" .
+ $centerl . $value . $centerr . "</div>";
+ }
}
$grafs[$key] = $value;
}