This extension allows Hoedown.
% phpize
% ./configure
% make
% make test
% make install
hoedown.ini:
extension=hoedown.so
$hoedown = new Hoedown;
echo $hoedown->parse('markdown text');
Name | Default | Changeable |
---|---|---|
hoedown.disable_default_options | 0 | PHP_INI_ALL |
-
hoedown.disable_default_options
It does not set the valid options for default of Hoedown class if you have to On.
- Hoedown::TABLES
- Hoedown::FENCED_CODE
- Hoedown::AUTOLINK
- Hoedown::STRIKETHROUGH
- Hoedown::NO_INTRA_EMPHASIS
Hoedown {
public __construct(array $options = [])
public mixed getOption(int $option)
public bool setOption(int $option, mixed $value)
public void setOptions(array $options = [])
public string parse(string $string, mixed &$state = NULL)
public string parseString(string $string, mixed &$state = NULL)
public string parseFile(string $filename, mixed &$state = NULL)
static public string ofString(string $string, array $options = [], mixed &$state = NULL)
static public string ofFile(string $filename, array $options = [], mixed &$state = NULL)
}
Name | Type | Default | Description |
---|---|---|---|
Hoedown::RENDERER_HTML | bool | TRUE | Render HTML |
Hoedown::RENDERER_TOC | bool | FALSE | Render the Table of Contents in HTML |
Hoedown::SKIP_HTML | bool | FALSE | Strip all HTML tags |
Hoedown::SKIP_STYLE | bool | FALSE | Stripg <style> tags |
Hoedown::SKIP_IMAGES | bool | FALSE | Don't render images |
Hoedown::SKIP_LINKS | bool | FALSE | Don't render links |
Hoedown::SAFELINK | bool | FALSE | Only allow links to safe protocols |
Hoedown::TOC | bool | FALSE | Produce links to the Table of Contents |
Hoedown::HARD_WRAP | bool | FALSE | Render each linebreak as <br> |
Hoedown::USE_XHTML | bool | FALSE | Render XHTML |
Hoedown::ESCAPE | bool | FALSE | Escaple all HTML |
Hoedown::TASK_LIST | bool | FALSE | Render task lists |
Hoedown::LINE_CONTINUE | bool | FALSE | Render line continue |
Hoedown::TABLES | bool | TRUE | Parse PHP-Markdown style tables |
Hoedown::FENCED_CODE | bool | TRUE | Parse fenced code blocks |
Hoedown::FOOTNOTES | bool | FALSE | Parse footnotes |
Hoedown::AUTOLINK | bool | TRUE | Automatically turn URLs into links |
Hoedown::STRIKETHROUGH | bool | TRUE | Parse ~~strikethrough~~ spans |
Hoedown::UNDERLINE | bool | FALSE | Parse _underline_ instead of emphasis |
Hoedown::HIGHLIGHT | bool | FALSE | Parse ==hightlight== spans |
Hoedown::QUOTE | bool | FALSE | Render "quotes" as <q> |
Hoedown::SUPERSCRIPT | bool | FALSE | Parse super^script |
Hoedown::NO_INTRA_EMPHASIS | bool | TRUE | Disable emphasis_between_words |
Hoedown::SPACE_HEADERS | bool | FALSE | Requqire a space after '#' in headers |
Hoedown::DISABLE_INDENTED_CODE | bool | FALSE | Don't parse indented code blocks |
Hoedown::SPECIA\L_ATTRIBUTE | bool | FALSE | Parse special attributes |
Hoedown::TOC_BEGIN | int | 0 | Begin level for headers included in the TOC. |
Hoedown::TOC_END | int | 6 | End level for headers included in the TOC. |
Hoedown::TOC_ESCAPE | bool | TRUE | Escape int the TOC |
Hoedown::TOC_HEADER | string | "" | Render header in the TOC |
Hoedown::TOC_FOOTER | string | "" | Render footer in the TOC |
Hoedown::CLASS_LIST | string | "" | Render class attribute in the list |
Hoedown::CLASS_ORDER_LIST | string | "" | Render class attribute in the ordered list |
Hoedown::CLASS_TASK_LIST | string | "" | Render class attribute in the task list |
- Hoedown::__construct - Create a Hoedown instance
- Hoedown::getOption - Retrieve a Hoedown option value
- Hoedown::setOption - Set Hoedown option
- Hoedown::setOptions - Set Hoedown options
- Hoedown::parse - retrieve html by parse string as markdown
- Hoedown::parseString - retrieve html by parse string as markdown
- Hoedown::parseFile - retrieve html by parse file as markdown
- Hoedown::ofString - retrieve html by parse string as markdown
- Hoedown::ofFile - retrieve html by parse file as markdown
public __construct(array $options = [])
Create a Hoedown instance.
Parameters:
-
options
An associative array of options where the key is the option to set and the value is the new value for the option.
Return Values:
Returns a new Hoedown object
public mixed getOption(int $option)
Retrieve a Hoedown option value.
Parameters:
-
option
One of the Hoedown::* constants.
Return Values:
Returns the value of the requested option, or FALSE on error.
public bool setOption(int $option, mixed $value)
Set Hoedown option.
Parameters:
-
option
One of the Hoedown::* constants.
-
value
Set option value.
Return Values:
Returns TRUE on success or FALSE on failure.
public void setOptions(array $options = [])
Set Hoedown options.
Parameters:
-
options
An associative array of options where the key is the option to set and the value is the new value for the option.
public string parse(string $string, mixed &$state = NULL)
retrieve html by parse text as markdown.
Parameters:
-
string
Markdown text string.
-
state
Returns the value of extend parse.
Return Values:
Returns the retrieve html, or FALSE on error.
public string parseString(string $string, mixed &$state = NULL)
retrieve html by parse string as markdown.
alias: Hoedown::parse
public string parseFile(string $filename, mixed &$state = NULL)
retrieve html by parse file as markdown.
Parameters:
-
filename
Markdown file name.
-
state
Returns the value of extend parse.
Return Values:
Returns the retrieve html, or FALSE on error.
static public string ofString(string $string, array $options = [], mixed &$state = NULL)
retrieve html by parse string as markdown (static method).
Parameters:
-
string
Markdown text string.
-
options
An associative array of options where the key is the option to set and the value is the new value for the option.
-
state
Returns the value of extend parse.
Return Values:
Returns the retrieve html, or FALSE on error.
static public string ofFile(string $filename, array $options = [], mixed &$state = NULL)
retrieve html by parse file as markdown (static method).
Parameters:
-
filename
Markdown file name.
-
options
An associative array of options where the key is the option to set and the value is the new value for the option.
-
state
Returns the value of extend parse.
Return Values:
Returns the retrieve html, or FALSE on error.
- Setting a Hoedown option
$hoedown = new Hoedown;
$hoedown->setOption(Hoedown::USE_XHTML, true);
$hoedown->setOption(Hoedown::HARD_WRAP, true);
// or $hoedown->setOptions([Hoedown::USE_XHTML => true, Hoedown::HARD_WRAP => true]);
// or new Hoedown([Hoedown::USE_XHTML => true, Hoedown::HARD_WRAP => true]);
echo $hoedown->parse("markdown\ntext");
The above example will output:
<p>markdown<br/>
text</p>
- Retrieve the Table of Contents
$hoedown = new Hoedown;
$hoedown->setOption(Hoedown::TOC, true);
echo $hoedown->parse("# header\n##a\n##b", $state);
echo "-- Table of Contents --\n";
echo $state['toc'];
The above example will output:
<h1 id="toc_header">header</h1>
<h2 id="toc_a">a</h2>
<h2 id="toc_b">b</h2>
-- Table of Contents --
<ul>
<li>
<a href="#toc_header">header</a>
<ul>
<li>
<a href="#toc_a">a</a>
</li>
<li>
<a href="#toc_b">b</a>
</li>
</ul>
</li>
</ul>
Only retrieve the Table of Contents.
$hoedown = new Hoedown;
$hoedown->setOption(Hoedown::TOC, true);
$hoedown->setOption(Hoedown::RENDERER_TOC, true);
echo $hoedown->parse("# header\n##a\n##b");
The above example will output:
<ul>
<li>
<a href="#toc_header">header</a>
<ul>
<li>
<a href="#toc_a">a</a>
</li>
<li>
<a href="#toc_b">b</a>
</li>
</ul>
</li>
</ul>