]> git.mxchange.org Git - friendica.git/commitdiff
New versions.
authorMichael Vogel <icarus@dabo.de>
Sun, 22 Feb 2015 19:26:56 +0000 (20:26 +0100)
committerMichael Vogel <icarus@dabo.de>
Sun, 22 Feb 2015 19:26:56 +0000 (20:26 +0100)
library/html-to-markdown/.gitignore [new file with mode: 0644]
library/html-to-markdown/.travis.yml [new file with mode: 0644]
library/html-to-markdown/HTML_To_Markdown.php
library/html-to-markdown/README.md
library/html-to-markdown/circle.yml [new file with mode: 0644]
library/html-to-markdown/composer.json [new file with mode: 0644]
library/parsedown/.travis.yml [new file with mode: 0644]
library/parsedown/composer.json [new file with mode: 0644]
library/parsedown/phpunit.xml.dist [new file with mode: 0644]

diff --git a/library/html-to-markdown/.gitignore b/library/html-to-markdown/.gitignore
new file mode 100644 (file)
index 0000000..aa429a9
--- /dev/null
@@ -0,0 +1,3 @@
+~*
+vendor
+composer.lock
\ No newline at end of file
diff --git a/library/html-to-markdown/.travis.yml b/library/html-to-markdown/.travis.yml
new file mode 100644 (file)
index 0000000..48b3e64
--- /dev/null
@@ -0,0 +1,6 @@
+language: php
+php:
+  - "5.5"
+  - "5.4"
+  - "5.3"
+script: phpunit --no-configuration HTML_To_MarkdownTest ./tests/HTML_To_MarkdownTest.php
\ No newline at end of file
index 1cc86505b6c411cf4fe25211422456dc84d177e6..109780eddfb33f42082c0b9b96eaed1ffcae109a 100644 (file)
@@ -4,7 +4,7 @@
  *
  * A helper class to convert HTML to Markdown.
  *
- * @version 2.1.2
+ * @version 2.2.1
  * @author Nick Cernis <nick@cern.is>
  * @link https://github.com/nickcernis/html2markdown/ Latest version on GitHub.
  * @link http://twitter.com/nickcernis Nick on twitter.
@@ -97,7 +97,7 @@ class HTML_To_Markdown
      *
      * Is the node a child of the given parent tag?
      *
-     * @param $parent_name string The name of the parent node to search for (e.g. 'code')
+     * @param $parent_name string|array The name of the parent node(s) to search for e.g. 'code' or array('pre', 'code')
      * @param $node
      * @return bool
      */
@@ -107,6 +107,9 @@ class HTML_To_Markdown
             if (is_null($p))
                 return false;
 
+            if ( is_array($parent_name) && in_array($p->nodeName, $parent_name) )
+                return true;
+            
             if ($p->nodeName == $parent_name)
                 return true;
         }
@@ -127,7 +130,7 @@ class HTML_To_Markdown
     private function convert_children($node)
     {
         // Don't convert HTML code inside <code> and <pre> blocks to Markdown - that should stay as HTML
-        if (self::is_child_of('pre', $node) || self::is_child_of('code', $node))
+        if (self::is_child_of(array('pre', 'code'), $node))
             return;
 
         // If the node has children, convert those to Markdown first
@@ -388,6 +391,9 @@ class HTML_To_Markdown
             $markdown = '[' . $text . '](' . $href . ')';
         }
 
+        if (! $href)
+            $markdown = html_entity_decode($node->C14N());
+
         // Append a space if the node after this one is also an anchor
         $next_node_name = $this->get_next_node_name($node);
 
@@ -437,7 +443,7 @@ class HTML_To_Markdown
 
         $markdown = '';
 
-        $code_content = html_entity_decode($this->document->saveHTML($node));
+        $code_content = html_entity_decode($node->C14N());
         $code_content = str_replace(array("<code>", "</code>"), "", $code_content);
         $code_content = str_replace(array("<pre>", "</pre>"), "", $code_content);
 
index 124c9868a968082a500c6b282535f21d5c8d5d50..de91c9d08d51065059b34420ed3c1b576b027d43 100644 (file)
@@ -5,7 +5,7 @@ A helper class that converts HTML to [Markdown](http://daringfireball.net/projec
 
 [![Build Status](https://travis-ci.org/nickcernis/html-to-markdown.png?branch=master)](https://travis-ci.org/nickcernis/html-to-markdown)
 
-**Version**: 2.2.0  
+**Version**: 2.2.1  
 **Requires**: PHP 5.3+  
 **Author**: [@nickcernis](http://twitter.com/nickcernis)  
 **License**: [MIT](http://www.opensource.org/licenses/mit-license.php)  
diff --git a/library/html-to-markdown/circle.yml b/library/html-to-markdown/circle.yml
new file mode 100644 (file)
index 0000000..9893a4b
--- /dev/null
@@ -0,0 +1,4 @@
+test:
+  override:
+    - phpunit --no-configuration HTML_To_MarkdownTest ./tests/HTML_To_MarkdownTest.php
+
diff --git a/library/html-to-markdown/composer.json b/library/html-to-markdown/composer.json
new file mode 100644 (file)
index 0000000..beb7faa
--- /dev/null
@@ -0,0 +1,25 @@
+{
+    "name": "nickcernis/html-to-markdown",
+    "type": "library",
+    "description": "An HTML-to-markdown conversion helper for PHP",
+    "keywords": ["markdown", "html"],
+    "homepage": "https://github.com/nickcernis/html-to-markdown",
+    "license": "MIT",
+    "authors": [
+        {
+            "name": "Nick Cernis",
+            "email": "nick@cern.is",
+            "homepage": "http://modernnerd.net"
+        }
+    ],
+    "autoload": {
+        "classmap": [ "HTML_To_Markdown.php" ]
+    },
+    "require": {
+        "php": ">=5.3"
+    },
+    "require-dev": {
+        "php": ">=5.3.3",
+        "phpunit/phpunit": "4.*"
+    }
+}
diff --git a/library/parsedown/.travis.yml b/library/parsedown/.travis.yml
new file mode 100644 (file)
index 0000000..7d782fe
--- /dev/null
@@ -0,0 +1,8 @@
+language: php
+
+php:
+  - 5.6
+  - 5.5
+  - 5.4
+  - 5.3
+  - hhvm
diff --git a/library/parsedown/composer.json b/library/parsedown/composer.json
new file mode 100644 (file)
index 0000000..1439b82
--- /dev/null
@@ -0,0 +1,18 @@
+{
+    "name": "erusev/parsedown",
+    "description": "Parser for Markdown.",
+    "keywords": ["markdown", "parser"],
+    "homepage": "http://parsedown.org",
+    "type": "library",
+    "license": "MIT",
+    "authors": [
+        {
+            "name": "Emanuil Rusev",
+            "email": "hello@erusev.com",
+            "homepage": "http://erusev.com"
+        }
+    ],
+    "autoload": {
+        "psr-0": {"Parsedown": ""}
+    }
+}
\ No newline at end of file
diff --git a/library/parsedown/phpunit.xml.dist b/library/parsedown/phpunit.xml.dist
new file mode 100644 (file)
index 0000000..b2d5e9d
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<phpunit bootstrap="test/bootstrap.php" colors="true">
+       <testsuites>
+               <testsuite>
+                       <file>test/ParsedownTest.php</file>
+               </testsuite>
+       </testsuites>
+</phpunit>
\ No newline at end of file