Skip to content

HtmlTools

From Epubli\Common\Tools - see https://github.com/epubli/common

  • Full name: \SebLucas\EPubMeta\Tools\HtmlTools

Methods

convertEntitiesNamedToNumeric

public static convertEntitiesNamedToNumeric(string $html): string
  • This method is static.

Parameters:

Parameter Type Description
$html string

isBlockLevelElement

public static isBlockLevelElement(string $name): bool
  • This method is static.

Parameters:

Parameter Type Description
$name string

truncate

performs a tag-aware truncation of (html-) strings, preserving tag integrity

public static truncate(string[]|string $html, int|string $length = "20%"): bool|string
  • This method is static.

Parameters:

Parameter Type Description
$html string[]|string
$length int|string

stripHtmlTags

strips all occurring html tags from $html (which can either be a string or an array of strings), preserving all content enclosed by all tags in $keep and dumping the content residing in all tags listed in $drop

public static stripHtmlTags(string[]|string $html, string[] $keep = ['title', 'br', 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'span', 'div', 'i', 'strong', 'b', 'table', 'td', 'th', 'tr'], string[] $drop = ['head', 'style']): string[]|string
  • This method is static.

Parameters:

Parameter Type Description
$html string[]|string
$keep string[]
$drop string[]


Automatically generated on 2025-03-18