| 1 | <?php |
||
| 9 | class HardBreakConverter implements ConverterInterface, ConfigurationAwareInterface |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var Configuration |
||
| 13 | */ |
||
| 14 | protected $config; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @param Configuration $config |
||
| 18 | */ |
||
| 19 | 90 | public function setConfig(Configuration $config) |
|
| 23 | |||
| 24 | /** |
||
| 25 | * @param ElementInterface $element |
||
| 26 | * |
||
| 27 | * @return string |
||
| 28 | */ |
||
| 29 | 9 | public function convert(ElementInterface $element) |
|
| 30 | { |
||
| 31 | 9 | $return = $this->config->getOption('hard_break') ? "\n" : " \n"; |
|
| 32 | |||
| 33 | 9 | $next = $element->getNext(); |
|
| 34 | 9 | if ($next) { |
|
| 35 | 9 | $next_value = $next->getValue(); |
|
| 36 | 9 | if ($next_value) { |
|
| 37 | 9 | if (in_array(substr($next_value, 0, 2), array('- ', '* ', '+ '))) { |
|
| 38 | $parent = $element->getParent(); |
||
| 39 | if ($parent && $parent->getTagName() == 'li') { |
||
| 40 | $return .= '\\'; |
||
| 41 | } |
||
| 42 | } |
||
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 46 | 9 | return $return; |
|
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @return string[] |
||
| 51 | */ |
||
| 52 | 90 | public function getSupportedTags() |
|
| 56 | } |
||
| 57 |