]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge pull request #1205 from ArthurHoaro/feature/opengraph
authorArthurHoaro <arthur@hoa.ro>
Sat, 6 Oct 2018 11:31:07 +0000 (13:31 +0200)
committerGitHub <noreply@github.com>
Sat, 6 Oct 2018 11:31:07 +0000 (13:31 +0200)
Add OpenGraph meta tags on permalink page

1  2 
plugins/markdown/markdown.php
tests/plugins/PluginMarkdownTest.php

index 21972814c046182f3e818a83787ff92111e96d19,d4fb1f76ab4613244de2b0dfe4885e804eb16aed..08e64dae087e1a9828bd23d8c0f54680c485e263
@@@ -28,6 -28,7 +28,7 @@@ function hook_markdown_render_linklist(
              $value = stripNoMarkdownTag($value);
              continue;
          }
+         $value['description_src'] = $value['description'];
          $value['description'] = process_markdown(
              $value['description'],
              $conf->get('security.markdown_escape', true),
@@@ -215,15 -216,6 +216,15 @@@ function reverse_text2clickable($descri
              $descriptionLine
          );
  
 +        // Make hashtag links markdown ready, otherwise the links will be ignored with escape set to true
 +        if (!$codeBlockOn && !$codeLineOn) {
 +            $descriptionLine = preg_replace(
 +                '#<a href="([^ ]*)"'. $hashtagTitle .'>([^<]+)</a>#m',
 +                '[$2]($1)',
 +                $descriptionLine
 +            );
 +        }
 +
          $descriptionOut .= $descriptionLine;
          if ($lineCount++ < count($descriptionLines) - 1) {
              $descriptionOut .= PHP_EOL;
index 319a94ba835ccfaeadfc917e487d35cb7a584165,31c1f8b7ff057d9e5c8dba9b77a654fb98ad76f3..44364b05b5f4a14036e432a51fdc539668ac39dd
@@@ -47,6 -47,8 +47,8 @@@ class PluginMarkdownTest extends PHPUni
          $data = hook_markdown_render_linklist($data, $this->conf);
          $this->assertNotFalse(strpos($data['links'][0]['description'], '<h1>'));
          $this->assertNotFalse(strpos($data['links'][0]['description'], '<p>'));
+         $this->assertEquals($markdown, $data['links'][0]['description_src']);
      }
  
      /**
          $this->assertEquals($text, $reversedText);
      }
  
 +    /**
 +     * Test reverse_text2clickable().
 +     */
 +    public function testReverseText2clickableHashtags()
 +    {
 +        $text = file_get_contents('tests/plugins/resources/hashtags.raw');
 +        $md = file_get_contents('tests/plugins/resources/hashtags.md');
 +        $clickableText = hashtag_autolink($text);
 +        $reversedText = reverse_text2clickable($clickableText);
 +        $this->assertEquals($md, $reversedText);
 +    }
 +
      /**
       * Test reverse_nl2br().
       */
              $this->conf->get('security.markdown_escape', true),
              $this->conf->get('security.allowed_protocols')
          );
 -        $this->assertEquals($html, $data);
 +        $this->assertEquals($html, $data . PHP_EOL);
      }
  
      /**