Esempio n. 1
0
 /**
  * Be sure to have a full attributes set (add a title if needed)
  *
  * @param   array   $attributes     Passed by reference
  */
 protected function _validateLinkAttributes(array &$attributes, &$text)
 {
     if (isset($attributes['email'])) {
         list($address_link, $address_text) = Helper::encodeEmailAddress($attributes['email']);
         if (!isset($attributes['href']) || empty($attributes['href'])) {
             $attributes['href'] = $address_link;
         }
         if ($this->getConfig('mailto_title_mask') && empty($attributes['title'])) {
             $attributes['title'] = Helper::fillPlaceholders($this->getConfig('mailto_title_mask'), $address_text);
         }
         unset($attributes['email']);
         $text = $address_text;
     }
     if (empty($attributes['title']) && isset($attributes['href'])) {
         $first_char = substr($attributes['href'], 0, 1);
         if ($first_char === '#' && $this->getConfig('anchor_title_mask')) {
             $attributes['title'] = Helper::fillPlaceholders($this->getConfig('anchor_title_mask'), $attributes['href']);
         } elseif ($this->getConfig('link_title_mask')) {
             $attributes['title'] = Helper::fillPlaceholders($this->getConfig('link_title_mask'), !empty($attributes['href']) ? $attributes['href'] : '');
         }
     }
 }
 /**
  * Writes a content in a local path and returns written length
  *
  * @param string $path
  * @param \MarkdownExtended\API\ContentInterface $content
  *
  * @return int
  */
 protected function writeOutputFile($path, ContentInterface $content)
 {
     // construct output file name
     $name = $content->getMetadata('file_name');
     $path = Helper::fillPlaceholders($path, !empty($name) ? pathinfo($name, PATHINFO_FILENAME) : Helper::header2Label($content->getTitle()));
     // make a backup if `option[force]!==true`
     $backup = (bool) $this->getKernel()->getConfig('force') !== true;
     // write output
     Helper::writeFile($path, (string) $content, $backup);
     // return created path
     return $path;
 }