2017 © Pedro Peláez
 

library commonmark-twig-renderer

The Twig renderer for CommonMark PHP implementation

image

webuni/commonmark-twig-renderer

The Twig renderer for CommonMark PHP implementation

  • Thursday, July 14, 2016
  • by hason
  • Repository
  • 2 Watchers
  • 6 Stars
  • 191 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 3 Versions
  • 10 % Grown

The README.md

CommonMark Twig Renderer

Latest Stable Version Build Status Scrutinizer Code Quality SensioLabsInsight, (*1)

This extension allows you to use Twig templates to render CommonMark document., (*2)

Installation

This project can be installed via Composer:, (*3)

composer require webuni/commonmark-twig-renderer

Usage

    use League\CommonMark\CommonMarkConverter;
    use Webuni\CommonMark\TwigRenderer\CommonMarkTwig;

    $converter = new CommonMarkConverter();
    CommonMarkTwig::setTwigRenderer($converter);

    echo $converter->convertToHtml('# Hello World!');

Template customization

In Twig, each Commonmark Node is represented by a Twig block. To customize any part of how a node renders, you just need to override the appropriate block., (*4)

{% extends 'commonmark.html.twig' %}

{% block header -%}
    {% set content = block('_inline_children') -%}
    <h{{ node.level }}><a name="{{ content|striptags|lower }}"></a>{{ content|raw }}</h{{ node.level }}>
{%- endblock %}

The Versions

28/09 2015

0.1.0

0.1.0.0 https://github.com/webuni/commonmark-twig-renderer

The Twig renderer for CommonMark PHP implementation

  Sources   Download

MIT

The Requires

 

The Development Requires

by Martin Hasoň

twig markdown commonmark