The Hubzilla
 All Classes Namespaces Files Functions Variables Pages
markdown.php File Reference

Some functions for BB conversions for Diaspora protocol. More...

Functions

 markdown_to_bb ($s, $use_zrl=false, $options=[])
 Convert Markdown to bbcode. More...
 
 bb_to_markdown_share ($match)
 
 bb_to_markdown ($Text, $options=[])
 Convert bbcode to Markdown. More...
 
 html2markdown ($html)
 Convert a HTML text into Markdown. More...
 

Detailed Description

Some functions for BB conversions for Diaspora protocol.

Function Documentation

bb_to_markdown (   $Text,
  $options = [] 
)

Convert bbcode to Markdown.

Parameters
string$TextThe message as bbcode
array$optionsdefault empty
Returns
string The message converted to Markdown
Hooks:
bb_to_markdown_bb
  • string bbcode - The message as bbcode and what will get returned
  • array options
Hooks:
bb_to_markdown
  • string - The already converted message as bbcode and what will get returned
bb_to_markdown_share (   $match)
Parameters
array$match
Returns
string
html2markdown (   $html)

Convert a HTML text into Markdown.

This function uses the library league/html-to-markdown for this task.

If the HTML text can not get parsed it will return an empty string.

Parameters
string$htmlThe HTML code to convert
Returns
string Markdown representation of the given HTML text, empty on error

Referenced by bb_to_markdown().

markdown_to_bb (   $s,
  $use_zrl = false,
  $options = [] 
)

Convert Markdown to bbcode.

We don't want to support a bbcode specific markdown interpreter and the markdown library we have is pretty good, but provides HTML output. So we'll use that to convert to HTML, then convert the HTML back to bbcode, and then clean up a few Diaspora specific constructs.

Parameters
string$sThe message as Markdown
boolean$use_zrldefault false
array$optionsdefault empty
Returns
string The message converted to bbcode
Hooks:
markdown_to_bb_init
  • string text - The message as Markdown and what will get returned
  • boolean zrl
  • array options
Hooks:
markdown_to_bb
  • string - The already converted message as bbcode

Referenced by Zotlabs\Module\Item\post().