Empty Block

Method mtof


Info
  public function mtof (
    string $source, 
    bool $skeptic = true, 
    bool $dtd = false, 
    bool $normalize = false,
    int $lang = 1
  ): string; 

Converts Markup Language data (HTML or XML, string or file) to Funcdown code.

This method is purely recreational and one should not rely on its safety or its precision as with other methods in production environment.

Arguments
  • @source - Provided value must be valid markup string or file path to markup code.
  • @skeptic - Boolean TRUE will force conversion of all dangerous characters in attribute values to their decimal entities. FALSE will not modify attribute values.
  • @dtd - Boolean TRUE will prepend document type definition tag, based on $lang.
  • @normalize - Boolean TRUE will try to make html or xml white-space-free as much as possible.
  • @lang - Accepts 1 or 0. For HTML to Funcdown, choose 1. For XML to Funcdown choose 0.
Return Value

Returns valid, safe and escaped Funcdown string.

Additional Info

In most cases, delivered funcdown string will be ok, but keep in mind that only direct string nodes are written in inline fashion.

For instance, if You provide something like this <b>Bold text</b>, You will get this: b[~{Bold text}], instead of expected: b{Bold text}, which will be a disaster if converted string with its <span> elements for example, has strong white-space importance. Funcdown is treating [] as block elements (with the exception of pre and textarea tags) and will render those with new lines and with calculated tabs.

To some extent, squeezing the content might help. Also, $normalize parameter set to true can be of good usage, but .. again .. - unless - there's standalone nested textnode within parent tag, outside other child tags with their textnodes within the same parent tag. In such scenario, parsing Funcdown string which is created by conversion will produce Funcdown Syntax error. This is very likely to happen with HTML but unlikely (not excluded) with XML markup.

It is also worth mentioning that if markup You want to convert starts with <html><body> that is, just html and no attributes, both html and body will be wiped out (not the inner tags and content), but changing to <html lang="en"> for instance will prevent that removal.

Empty Block
Empty Block
Empty Block
Empty Block