mirror of
https://github.com/Chouchen/tumblr2shaarli.git
synced 2018-06-06 17:22:06 +02:00
Reorganise le code et ajoute la doc
This commit is contained in:
42
src/vendor/league/html-to-markdown/src/Converter/TextConverter.php
vendored
Normal file
42
src/vendor/league/html-to-markdown/src/Converter/TextConverter.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace League\HTMLToMarkdown\Converter;
|
||||
|
||||
use League\HTMLToMarkdown\ElementInterface;
|
||||
|
||||
class TextConverter implements ConverterInterface
|
||||
{
|
||||
/**
|
||||
* @param ElementInterface $element
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function convert(ElementInterface $element)
|
||||
{
|
||||
$value = $element->getValue();
|
||||
|
||||
$markdown = preg_replace('~\s+~u', ' ', $value);
|
||||
|
||||
//escape the following characters: '*', '_' and '\'
|
||||
$markdown = preg_replace('~([*_\\\\])~u', '\\\\$1', $markdown);
|
||||
|
||||
$markdown = preg_replace('~^#~u', '\\\\#', $markdown);
|
||||
|
||||
if ($markdown === ' ') {
|
||||
$next = $element->getNext();
|
||||
if (!$next || $next->isBlock()) {
|
||||
$markdown = '';
|
||||
}
|
||||
}
|
||||
|
||||
return $markdown;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getSupportedTags()
|
||||
{
|
||||
return array('#text');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user