Skip to content
Browse files

Removed support for adding default classes. If a class is added to al…

…l elements, the effect can be handled by just adding proper CSS to the stylesheets.
  • Loading branch information...
1 parent ec07067 commit 290ddbdd61849e34905b49c0bbfb7978d469075d @egil committed
Showing with 2 additions and 48 deletions.
  1. +0 −18 README.markdown
  2. +2 −30 markdown_extended.php
View
18 README.markdown
@@ -122,22 +122,4 @@ require_once('markdown_extended.php');
// Convert markdown formatted text in $markdown to HTML
$html = MarkdownExtended($markdown);
-```
-
-There are some new settings that can be applied to the parser.
-
-### Defining default CSS classes for all tags of a specific type
-It is now possible to append default CSS classes to all tags of a specific type, unless they are nested inside a `<code>` tag. Existing CSS classes will not be overwritten.
-
-It is done through the second argument to the `MarkdownExtended` function:
-
-```PHP
-$html = MarkdownExtended($markdown, array('tag' => 'css classes', 'anotherTag' => 'css classes'));
-```
-
-In the following example we add support for [Googles Javascript code prettifier](http://code.google.com/p/google-code-prettify/) by adding the *prettyprint* class to all `<pre>` tags.
-
-```PHP
-// Always add a 'prettyprint' to <pre> elements
-$html = MarkdownExtended($markdown, array('pre' => 'prettyprint'));
```
View
32 markdown_extended.php
@@ -1,6 +1,6 @@
<?php
require_once('markdown.php');
-define( 'MARKDOWNEXTRAEXTENDED_VERSION', "0.2" ); # 7/11/2011
+define( 'MARKDOWNEXTRAEXTENDED_VERSION', "0.3" );
function MarkdownExtended($text, $default_claases = array()){
$parser = new MarkdownExtraExtended_Parser($default_claases);
@@ -23,38 +23,10 @@ function MarkdownExtraExtended_Parser($default_classes = array()) {
}
function transform($text) {
- $text = parent::transform($text);
-
- // add default classes
- $text = $this->doAddDefaultClasses($text);
-
+ $text = parent::transform($text);
return $text;
}
- function doAddDefaultClasses($text) {
- // Dont wast time if there is no default classes defined
- if(!empty($default_classes)){
- $doc = new DOMDocument();
- $doc->loadHTML($text);
- $xpath = new DOMXpath($doc);
-
- // Iterate over all default classes tag-class sets
- // and update each tag with the classes.
- foreach ($default_classes as $tag => $classes){
- $query = '//' . $tag . '[not(ancestor::code)]';
- foreach($xpath->query($query) as $element){
- $classAttr = trim($element->getAttribute('class'));
- $classAttr .= empty($classAttr) ? $classes : " $classes";
- $element->setAttribute("class", $classAttr);
- }
- }
-
- // save the updated html
- $text = $doc->saveHTML();
- }
- return $text;
- }
-
function doHardBreaks($text) {
# Do hard breaks:
# EXTENDED: changed to allow breaks without two spaces and just one new line

0 comments on commit 290ddbd

Please sign in to comment.
Something went wrong with that request. Please try again.