All scripts in one repository
This commit is contained in:
parent
a0a86492ee
commit
9f9304d6aa
61 changed files with 6668 additions and 681 deletions
42
blogger2rangitaki/vendor/league/html-to-markdown/src/Converter/LinkConverter.php
vendored
Normal file
42
blogger2rangitaki/vendor/league/html-to-markdown/src/Converter/LinkConverter.php
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace League\HTMLToMarkdown\Converter;
|
||||
|
||||
use League\HTMLToMarkdown\ElementInterface;
|
||||
|
||||
class LinkConverter implements ConverterInterface
|
||||
{
|
||||
/**
|
||||
* @param ElementInterface $element
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function convert(ElementInterface $element)
|
||||
{
|
||||
$href = $element->getAttribute('href');
|
||||
$title = $element->getAttribute('title');
|
||||
$text = $element->getValue();
|
||||
|
||||
if ($title !== '') {
|
||||
$markdown = '[' . $text . '](' . $href . ' "' . $title . '")';
|
||||
} elseif ($href === $text) {
|
||||
$markdown = '<' . $href . '>';
|
||||
} else {
|
||||
$markdown = '[' . $text . '](' . $href . ')';
|
||||
}
|
||||
|
||||
if (!$href) {
|
||||
$markdown = html_entity_decode($element->getChildrenAsString());
|
||||
}
|
||||
|
||||
return $markdown;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getSupportedTags()
|
||||
{
|
||||
return array('a');
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue