Overview
Comment:Fix user_prefix argument in markdown passed to skriv
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | stable
Files: files | file ages | folders
SHA3-256: 01df610025f625548a41982e614df74a165f27a1d620f1bd6709e27bdf0e6ee0
User & Date: bohwaz on 2021-09-16 17:49:52
Other Links: manifest | tags
Context
2021-09-16
17:53
Fix call in homepage check-in: 47fe686522 user: bohwaz tags: trunk, stable
17:49
Fix user_prefix argument in markdown passed to skriv check-in: 01df610025 user: bohwaz tags: trunk, stable
17:41
Fix image tag in file preview, as reported by @Eric. Also fix URL prefix for links in specific contexts in admin. check-in: 9e33c7cafd user: bohwaz tags: trunk, stable
Changes

Modified src/include/lib/Garradin/Web/Render/Markdown.php from [b756d5ef2a] to [1e59334a43].

9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use Garradin\Files\Files;
use Garradin\UserTemplate\CommonModifiers;

use const Garradin\{ADMIN_URL, WWW_URL};

class Markdown extends AbstractRender
{
	public function render(?string $content = null, array $options = []): string
	{
		$parsedown = new Parsedown($this->file);
		$parsedown->setBreaksEnabled(true);
		$parsedown->setUrlsLinked(true);
		$parsedown->setSafeMode(true);

		$str = $content ?? $this->file->fetch();

		$str = $parsedown->text($str);







|

|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use Garradin\Files\Files;
use Garradin\UserTemplate\CommonModifiers;

use const Garradin\{ADMIN_URL, WWW_URL};

class Markdown extends AbstractRender
{
	public function render(?string $content = null): string
	{
		$parsedown = new Parsedown($this->file, $this->user_prefix);
		$parsedown->setBreaksEnabled(true);
		$parsedown->setUrlsLinked(true);
		$parsedown->setSafeMode(true);

		$str = $content ?? $this->file->fetch();

		$str = $parsedown->text($str);

Modified src/include/lib/Garradin/Web/Render/Parsedown.php from [3feb34d63b] to [8582efeb8b].

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 * @see https://github.com/erusev/parsedown/wiki/Tutorial:-Create-Extensions
 */
class Parsedown extends Parent_Parsedown
{
	protected $skriv;
	protected $toc = [];

	function __construct(?File $file)
	{
		$this->BlockTypes['<'][] = 'SkrivExtension';
		$this->BlockTypes['['][]= 'TOC';

		# identify footnote definitions before reference definitions
		array_unshift($this->BlockTypes['['], 'Footnote');

		# identify footnote markers before before links
		array_unshift($this->InlineTypes['['], 'FootnoteMarker');

		$this->skriv = new Skriv($file);
	}

	protected function blockSkrivExtension(array $line): ?array
	{
		$line = $line['text'];

		if (strpos($line, '<<') === 0 && preg_match('/^<<<?([a-z_]+)((?:(?!>>>?).)*?)(>>>?$|$)/i', trim($line), $match)) {







|










|







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 * @see https://github.com/erusev/parsedown/wiki/Tutorial:-Create-Extensions
 */
class Parsedown extends Parent_Parsedown
{
	protected $skriv;
	protected $toc = [];

	function __construct(?File $file, ?string $user_prefix)
	{
		$this->BlockTypes['<'][] = 'SkrivExtension';
		$this->BlockTypes['['][]= 'TOC';

		# identify footnote definitions before reference definitions
		array_unshift($this->BlockTypes['['], 'Footnote');

		# identify footnote markers before before links
		array_unshift($this->InlineTypes['['], 'FootnoteMarker');

		$this->skriv = new Skriv($file, $user_prefix);
	}

	protected function blockSkrivExtension(array $line): ?array
	{
		$line = $line['text'];

		if (strpos($line, '<<') === 0 && preg_match('/^<<<?([a-z_]+)((?:(?!>>>?).)*?)(>>>?$|$)/i', trim($line), $match)) {