All Projects → twigphp → Markdown Extension

twigphp / Markdown Extension

Licence: mit
[DEPRECATED] Markdown support for Twig

Projects that are alternatives of or similar to Markdown Extension

time-ago-bundle
Provides a simple twig filter for expressing time difference in words.
Stars: ✭ 13 (-87.62%)
Mutual labels:  twig, twig-extension
Fmbbcodebundle
🔠 BBCode bundle for Symfony projects
Stars: ✭ 56 (-46.67%)
Mutual labels:  twig, twig-extension
Pico
Pico is a stupidly simple, blazing fast, flat file CMS.
Stars: ✭ 3,494 (+3227.62%)
Mutual labels:  twig, markdown
cache-extra
Template fragment cache support for Twig
Stars: ✭ 24 (-77.14%)
Mutual labels:  twig, twig-extension
Html Compress Twig
Twig extension for compressing HTML and inline CSS/JS using WyriHaximus/HtmlCompress
Stars: ✭ 72 (-31.43%)
Mutual labels:  twig, twig-extension
joomla-twig
Twig 2.0 & Twig extensions integration for Joomla! https://phproberto.github.io/joomla-twig/
Stars: ✭ 25 (-76.19%)
Mutual labels:  twig, twig-extension
Html Extra
HTML extension for Twig
Stars: ✭ 24 (-77.14%)
Mutual labels:  twig, twig-extension
DrupalTwigFood
Useful functions, filters for twig @ Drupal 8
Stars: ✭ 1 (-99.05%)
Mutual labels:  twig, twig-extension
Twig Cache Extension
Stars: ✭ 67 (-36.19%)
Mutual labels:  twig, twig-extension
Awesome Twig
A curated list of amazingly awesome Twig extensions, snippets and tutorials
Stars: ✭ 63 (-40%)
Mutual labels:  twig, twig-extension
twig-translation
A Twig Translation Extension
Stars: ✭ 15 (-85.71%)
Mutual labels:  twig, twig-extension
Cssinliner Extra
CSS Inliner support for Twig
Stars: ✭ 93 (-11.43%)
Mutual labels:  twig, twig-extension
PhpStorm-Live-Templates-Craft-CMS
PhpStorm Live Templates for Craft CMS
Stars: ✭ 34 (-67.62%)
Mutual labels:  twig, twig-extension
oc-twigextensions-plugin
Twig extensions plugin for OctoberCMS
Stars: ✭ 17 (-83.81%)
Mutual labels:  twig, twig-extension
markdown-extra
Markdown extension for Twig
Stars: ✭ 83 (-20.95%)
Mutual labels:  twig, twig-extension
Twig Extra Bundle
The Twig bundle for official extra extensions
Stars: ✭ 389 (+270.48%)
Mutual labels:  twig, twig-extension
breadcrumb-bundle
Symfony bundle for easy breadcrumbs management
Stars: ✭ 26 (-75.24%)
Mutual labels:  twig, twig-extension
cssinliner-extension
[DEPRECATED] CSS inliner support for Twig
Stars: ✭ 30 (-71.43%)
Mutual labels:  twig, twig-extension
Inky Extension
[DEPRECATED] Inky email template engine support for Twig
Stars: ✭ 57 (-45.71%)
Mutual labels:  twig, twig-extension
String Extra
Unicode/String support for Twig
Stars: ✭ 92 (-12.38%)
Mutual labels:  twig, twig-extension

Twig Markdown Extension

WARNINIG: This package is deprecate; migrate to twig/markdown-extra instead.

This package provides a Markdown to HTML filter (markdown) and an HTML to Markdown filter (html_to_markdown) for Twig and a Symfony bundle.

If you are not using Symfony, register the extension on Twig's Environment manually:

use Twig\Markdown\MarkdownExtension;
use Twig\Environment;

$twig = new Environment(...);
$twig->addExtension(new MarkdownExtension());

You must also register the extension runtime (skip this step if you are using Symfony or a framework with a Twig integration):

use Twig\Markdown\DefaultMarkdown;
use Twig\Markdown\MarkdownRuntime;
use Twig\RuntimeLoader\RuntimeLoaderInterface;

$twig->addRuntimeLoader(new class implements RuntimeLoaderInterface {
    public function load($class) {
        if (MarkdownRuntime::class === $class) {
            return new MarkdownRuntime(new DefaultMarkdown());
        }
    }
});

Use the markdown and html_to_markdown filters from a Twig template:

{% filter markdown %}
Title
======

Hello!
{% endfilter %}

{% filter html_to_markdown %}
    <html>
        <h1>Hello!</h1>
    </html>
{% endfilter %}

Note that you can indent the Markdown content as leading whitespaces will be removed consistently before conversion:

{% filter markdown %}
    Title
    ======

    Hello!
{% endfilter %}

You can also add some options by passing them as an argument to the filter:

{% filter html_to_markdown({hard_break: false}) %}
    <html>
        <h1>Hello!</h1>
    </html>
{% endfilter %}

You can also use the filters on an included file:

{{ include('some_template.html.twig')|html_to_markdown }}

{{ include('some_template.markdown.twig')|markdown }}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].