Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor/
19 changes: 14 additions & 5 deletions Michelf/Markdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ public static function defaultTransform($text) {
# Change to ">" for HTML output.
public $empty_element_suffix = " />";
public $tab_width = 4;
public $heading_elements = array(
1 => 'h1',
2 => 'h2',
3 => 'h3',
4 => 'h4',
5 => 'h5',
6 => 'h6',
);

# Change to `true` to disallow markup or entities.
public $no_markup = false;
Expand All @@ -69,8 +77,7 @@ public static function defaultTransform($text) {
# Predefined urls and titles for reference links and images.
public $predef_urls = array();
public $predef_titles = array();



### Parser Implementation ###

# Regex to match balanced [brackets].
Expand Down Expand Up @@ -143,7 +150,7 @@ protected function teardown() {
}


protected function transform($text) {
public function transform($text) {
#
# Main function. Performs some preprocessing on the input text
# and pass it through the document gamut.
Expand Down Expand Up @@ -781,12 +788,14 @@ protected function _doHeaders_callback_setext($matches) {
return $matches[0];

$level = $matches[2]{0} == '=' ? 1 : 2;
$block = "<h$level>".$this->runSpanGamut($matches[1])."</h$level>";
$element = $this->heading_elements[$level];
$block = "<$element>".$this->runSpanGamut($matches[1])."</$element>";
return "\n" . $this->hashBlock($block) . "\n\n";
}
protected function _doHeaders_callback_atx($matches) {
$level = strlen($matches[1]);
$block = "<h$level>".$this->runSpanGamut($matches[2])."</h$level>";
$element = $this->heading_elements[$level];
$block = "<$element>".$this->runSpanGamut($matches[2])."</$element>";
return "\n" . $this->hashBlock($block) . "\n\n";
}

Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "3.7.x"
},
"autoload": {
"psr-0": { "Michelf": "" }
},
Expand Down
Loading