` Attributes on `` Element
~~~ .php
$Parsedown->codeAttributesOnParent = true;
~~~
### Custom Quote Block Class
~~~ .php
$Parsedown->blockQuoteAttributes = ['class' => 'quote'];
~~~
~~~ .php
$Parsedown->blockQuoteAttributes = function($Text, $Attributes, &$Element) {
if (strpos($Text, '**Danger:** ') === 0) {
return ['class' => 'alert alert-danger'];
}
if (strpos($Text, '**Info:** ') === 0) {
return ['class' => 'alert alert-info'];
}
return [];
};
~~~
### Custom Table Attributes
~~~ .php
$Parsedown->tableAttributes = ['border' => 1];
~~~
### Custom Table Alignment Class
~~~ .php
$Parsedown->tableColumnAttributes = function($Text, $Attributes, &$Element, $Align) {
return [
'class' => $Align ? 'text-' . $Align : null,
'style' => null // Remove inline styles
];
};
~~~
### Custom Footnote ID Format
~~~ .php
$Parsedown->footnoteLinkAttributes = function($Number, $Attributes, &$Element, $Name) {
return ['href' => '#to:' . $Name];
};
$Parsedown->footnoteReferenceAttributes = function($Number, $Attributes, &$Element, $Name, $Index) {
return ['id' => 'from:' . $Name . '.' . $Index];
};
$Parsedown->footnoteBackLinkAttributes = function($Number, $Attributes, &$Element, $Name, $Index) {
return ['href' => '#from:' . $Name . '.' . $Index];
};
$Parsedown->footnoteBackReferenceAttributes = function($Number, $Attributes, &$Element, $Name, $Total) {
return ['id' => 'to:' . $Name];
};
~~~
### Custom Footnote Class
~~~ .php
$Parsedown->footnoteAttributes = ['class' => 'notes'];
~~~
### Custom Footnote Link Text
~~~ .php
$Parsedown->footnoteLinkHtml = '[%s]';
~~~
### Custom Footnote Back Link Text
~~~ .php
$Parsedown->footnoteBackLinkHtml = '';
~~~
### Advance Attribute Parser
- `{#foo}` → ``
- `{#foo#bar}` → ``
- `{.foo}` → ``
- `{.foo.bar}` → ``
- `{#foo.bar.baz}` → ``
- `{#foo .bar .baz}` → `` (white-space before `#` and `.` becomes optional in my extension)
- `{foo="bar"}` → ``
- `{foo="bar baz"}` → ``
- `{foo='bar'}` → ``
- `{foo='bar baz'}` → ``
- `{foo=bar}` → ``
- `{foo=}` → ``
- `{foo}` → ``
- `{foo=bar baz}` → ``
- `{#a#b.c.d e="f" g="h i" j='k' l='m n' o=p q= r s t="u#v.w.x y=z"}` → ``
### Code Block Class Without `language-` Prefix
Dot prefix in class name are now becomes optional, custom attributes syntax also acceptable:
- `php` → ``
- `php html` → ``
- `.php` → ``
- `.php.html` → ``
- `.php html` → ``
- `{.php #foo}` → ``
Property Aliases as Methods
---------------------------
Property aliases are available as methods just to follow the way **Parsedown** set its configuration data. It uses PHP `__call` method to generate the class methods automatically:
~~~ .php
// This is ...
$Parsedown->setBlockCodeHtml(function() { ... });
// ... equal to this
$Parsedown->blockCodeHtml = function() { ... };
~~~