From 6547ed0c04466ca0d1994c642e002f12ef0b0ace Mon Sep 17 00:00:00 2001 From: Yaman Qalieh Date: Tue, 10 May 2022 03:37:53 -0400 Subject: [docs] Add documentation for html.php functions (#2714) --- docs/06_Helper_functions/index.md | 102 +++++++++++++++++++++++++++++++++++++- 1 file changed, 101 insertions(+), 1 deletion(-) (limited to 'docs/06_Helper_functions/index.md') diff --git a/docs/06_Helper_functions/index.md b/docs/06_Helper_functions/index.md index da06d251..708155a8 100644 --- a/docs/06_Helper_functions/index.md +++ b/docs/06_Helper_functions/index.md @@ -89,4 +89,104 @@ $html = defaultLinkTo($html, $this->getURI()); // Using bridge URL // Output // -``` \ No newline at end of file +``` + +# backgroundToImg +Replaces tags with styles of `backgroud-image` by `` tags. + +```php +backgroundToImg(mixed $htmlContent) : object +``` + +Returns a DOM object (even if provided a string). + +# extractFromDelimiters +Extract the first part of a string matching the specified start and end delimiters. +```php +function extractFromDelimiters(string $string, string $start, string $end) : mixed +``` + +Returns the extracted string if delimiters were found and false otherwise. + +**Example** + +```php +$string = '
Post author: John Doe
'; +$start = 'author: '; +$end = '<'; +$extracted = extractFromDelimiters($string, $start, $end); + +// Output +// 'John Doe' +``` + +# stripWithDelimiters +Remove one or more part(s) of a string using a start and end delmiters. +It is the inverse of `extractFromDelimiters`. + +```php +function stripWithDelimiters(string $string, string $start, string $end) : string +``` + +Returns the cleaned string, even if no delimiters were found. + +**Example** + +```php +$string = 'foobar'; +$start = ''; +$cleaned = stripWithDelimiters($string, $start, $end); + +// Output +// 'foobar' +``` + +# stripRecursiveHTMLSection +Remove HTML sections containing one or more sections using the same HTML tag. + +```php +function stripRecursiveHTMLSection(string $string, string $tag_name, string $tag_start) : string +``` + +**Example** + +```php +$string = 'foo
ads
ads
bar'; +$tag_name = 'div'; +$tag_start = '
'; +$cleaned = stripRecursiveHTMLSection($string, $tag_name, $tag_start); + +// Output +// 'foobar' +``` + +# markdownToHtml +Converts markdown input to HTML using [Parsedown](https://parsedown.org/). + +```php +function markdownToHtml(string $string) : string +``` + +**Example** +```php +$input = <<RELEASE-2.8

+//
    +//
  • Share QR code of a token
  • +//
  • Dark mode improvemnet
  • +//
  • Fix some layout issues
  • +//
  • Add shortcut to launch the app with screenshot mode on
  • +//
  • Translation improvements
  • +//
+``` -- cgit v1.2.3