1
0
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:
2016-10-10 23:25:21 +02:00
parent 18f9d44410
commit 869c57b7f3
45 changed files with 85 additions and 1 deletions

View 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');
}
}