ILIAS  trunk Revision v11.0_alpha-1846-g895b5f47236
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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

League CommonMark CommonMarkConverter $converter
 

Detailed Description

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

Definition at line 28 of file MarkdownFormattingToHTML.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 32 of file MarkdownFormattingToHTML.php.

33  {
34  $config = [
35  'allow_unsafe_links' => false,
36  'max_nesting_level' => 42 // https://commonmark.thephpleague.com/1.5/security/#nesting-level
37  ];
38 
39  if ($escape === true) {
40  $config['html_input'] = 'escape';
41  }
42 
43  $this->converter = new \League\CommonMark\CommonMarkConverter($config);
44  }

Member Function Documentation

◆ toHTML()

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

Returns the converted Markdown with HTML tags.

Definition at line 49 of file MarkdownFormattingToHTML.php.

49  : Transformation
50  {
51  return new \ILIAS\Refinery\Custom\Transformation(
52  fn($value) => $this->converter->convert($value)->getContent()
53  );
54  }

Field Documentation

◆ $converter

League CommonMark CommonMarkConverter ILIAS\Refinery\String\MarkdownFormattingToHTML::$converter
private

Definition at line 30 of file MarkdownFormattingToHTML.php.


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