ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ILIAS\Refinery\String\MarkdownFormattingToHTML Class Reference

This class provides a transformation that converts Markdown formatting to HTML using the CommonMark Library. More...

+ Collaboration diagram for ILIAS\Refinery\String\MarkdownFormattingToHTML:

Public Member Functions

 __construct (bool $escape=true)
 
 toHTML ()
 Returns the converted Markdown with HTML tags. More...
 

Private Attributes

MarkdownConverter $converter
 

Detailed Description

This class provides a transformation that converts Markdown formatting to HTML using the CommonMark Library.

Definition at line 32 of file MarkdownFormattingToHTML.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Refinery\String\MarkdownFormattingToHTML::__construct ( bool  $escape = true)

Definition at line 36 of file MarkdownFormattingToHTML.php.

37 {
38 $config = [
39 'html_input' => 'escape',
40 'renderer' => [
41 'soft_break' => "<br/>"
42 ],
43 'allow_unsafe_links' => false,
44 'max_nesting_level' => 42 // https://commonmark.thephpleague.com/1.5/security/#nesting-level
45 ];
46
47 $environment = new Environment($config);
48 $environment->addExtension(new CommonMarkCoreExtension());
49 $this->converter = new MarkDownConverter($environment);
50 }

Member Function Documentation

◆ toHTML()

ILIAS\Refinery\String\MarkdownFormattingToHTML::toHTML ( )

Returns the converted Markdown with HTML tags.

Definition at line 55 of file MarkdownFormattingToHTML.php.

55 : Transformation
56 {
57 return new \ILIAS\Refinery\Custom\Transformation(
58 fn($value) => $this->converter->convert($value)->getContent()
59 );
60 }

Field Documentation

◆ $converter

MarkdownConverter ILIAS\Refinery\String\MarkdownFormattingToHTML::$converter
private

Definition at line 34 of file MarkdownFormattingToHTML.php.


The documentation for this class was generated from the following file: