2017 © Pedro Peláez
 

library markdown-extender

Extend Markdown extra with ease

image

patrickrose/markdown-extender

Extend Markdown extra with ease

  • Thursday, September 1, 2016
  • by PatrickRose
  • Repository
  • 1 Watchers
  • 1 Stars
  • 21 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 5 % Grown

The README.md

Markdown Extender

Do you use Markdown to write blog posts and websites? Do you really hate the fact that embedding things like YouTube videos is a bit of a pain and you want it to be a bit more...Markdown-y? Meet Markdown Extender., (*1)

This extends the michelf/php-markdown package to provide new functionality and also allow you to extend., (*2)

Installation

Add the following to your composer.json., (*3)

"require": {
    "patrickrose/markdown-extender": "~1"
}

Usage

Build up your markdown string and pass it to the compile function. Extensions are handled using the syntax [{extensionName:arg1,arg2,arg3}] in your markdown., (*4)

If you need a new function then you can add it using extend($extensionName, $extensionFunction), where $extensionName is the string to use inside the [{}] block and $extensionFunction is a closure that takes any number of arguments and returns a string., (*5)

Current Functions

  • Youtube Embedding: [{youtube:youtubeID}] => <iframe width="560" height="315" src="//www.youtube.com/embed/BgAdeuxkUyY" frameborder="0" allowfullscreen></iframe>
  • Vimeo Embedding: [{vimeo:vimeoID}] => <iframe src="//player.vimeo.com/video/95810934" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
  • Tweet Embedding: [{twitter:tweetID}] => <blockquote class="twitter-tweet"><p>Search API will now always return &quot;real&quot; Twitter user IDs. The with_twitter_user_id parameter is no longer necessary. An era has ended. ^TS</p>&mdash; Twitter API (@twitterapi) <a href="https://twitter.com/twitterapi/statuses/133640144317198338">November 7, 2011</a></blockquote>\n<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
  • Description Lists: [{description:item1|description1,item2|description2}] => <dl><dt>first</dt><dd>first text</dd><dt>second</dt><dd>second text</dd></dl>

Example


$markdown = new PatrickRose\MarkdownExtender\MarkdownExtender; $string = "I really like this youtube video! [{youtube:BgAdeuxkUyY}] And I added an extension: [{extended:one,two,3}]"; $markdown->extend("extended", function($one,$two,$three) { return "You passed in <em>$one</em>, <em>$two</em> and <em>$three</em>."; }); $markdown->compile($string) /* returns: "

I really like this youtube video!, (*6)

, (*7)

And I added an extension:, (*8)

You passed in one, two and 3., (*9)

" */

Laravel Users

Using Laravel? Then feel free to use the service provider and facade. First, add this to your providers array:, (*10)


"providers" => [ ... "PatrickRose\\MarkdownExtender\\MarkdownExtenderServiceProvider", ]

And add the facade to your aliases array, (*11)


"aliases" => [ ... "MarkdownExtender" => "PatrickRose\\MarkdownExtender\\Facades\\MarkdownExtender" ]

Then you can use MarkdownExtender::compile($markdown) and MarkdownExtender::extend($extension)., (*12)

The Versions

01/09 2016

dev-master

9999999-dev

Extend Markdown extra with ease

  Sources   Download

MIT

The Requires

 

The Development Requires

by Patrick Rose

markdown

01/09 2016

2.0.0

2.0.0.0

Extend Markdown extra with ease

  Sources   Download

MIT

The Requires

 

The Development Requires

by Patrick Rose

markdown

23/06 2014

1.3.0

1.3.0.0

Extend Markdown extra with ease

  Sources   Download

MIT

The Requires

 

The Development Requires

by Patrick Rose

markdown

31/05 2014

1.2.0

1.2.0.0

Extend Markdown extra with ease

  Sources   Download

MIT

The Requires

 

The Development Requires

by Patrick Rose

markdown

27/05 2014

1.1.0

1.1.0.0

Extend Markdown extra with ease

  Sources   Download

MIT

The Requires

 

The Development Requires

by Patrick Rose

markdown

26/05 2014

0.1.0

0.1.0.0

Extend Markdown extra with ease

  Sources   Download

MIT

The Requires

 

The Development Requires

by Patrick Rose

markdown

26/05 2014

1.0.0

1.0.0.0

Extend Markdown extra with ease

  Sources   Download

MIT

The Requires

 

The Development Requires

by Patrick Rose

markdown