Coder Social home page Coder Social logo

gearoidc / php-markdown-extra-extended Goto Github PK

View Code? Open in Web Editor NEW

This project forked from egil/php-markdown-extra-extended

0.0 2.0 0.0 137 KB

An fork of the PHP Markdown (Extra) project, extended with extra syntax, especially focused on adding support for more HTML attributes to outputted HTML, and for outputting HTML5.

php-markdown-extra-extended's Introduction

PHP Markdown Extra Extended

An fork of the PHP Markdown (Extra) project (PME), extended with extra syntax, especially focused on adding support for more HTML attributes to outputted HTML, and for outputting HTML5.

Changes to syntax from PHP Markdown (Extra)

Unless explicitly specified, existing Markdown markup works exactly as it did before. The orginal syntax is documentated here:

Line break generates a <br />

In PME, when you want to insert a <br /> break tag using Markdown, you end a line with two or more spaces, then type return. This turned out to be more annoying than helpful in my projects, so now you just have to type return. This is also how Markdown works with GFM.

Two returns does not insert a <br />, but instead creates a new paragraph as usual.

Support for cite attribute on blockquotes

It is now possible to add the optional cite attribute to the blockquote element.

The new, optional, syntax is:

> (cite url) Cited content follows ...

Example:

> (http://www.whatwg.org/) Content inside a blockquote must be quoted 
> from another source, whose address, if it has one, 
> may be cited in the `cite` attribute.

Will result in the following HTML:

<blockquote cite="http://www.whatwg.org/">
<p>Content inside a blockquote must be quoted 
from another source, whose address, if it has one, 
may be cited in the `cite` attribute.</p>
</blockquote>

Breaking changes from PME

The existing rules for and formatting options for blockquotes still apply. There is one small breaking changes with this addition. If your quote starts with "(" you have two have at least two spaces between the initial ">" and the "(". E.g.:

>  (Ut brisket flank salami.) Cow cupidatat ex t-bone sirloin id. 
> Sunt flank pastrami spare ribs sint id, nulla nisi.

Will result in the following HTML:

<blockquote>
  <p>(Ut brisket flank salami.) Cow cupidatat ex t-bone sirloin id.<br>
  Sunt flank pastrami spare ribs sint id, nulla nisi.</p>
</blockquote>

Fenced code block with language support and alternating fence markers (```)

It is now possible to specify the language type of a code block, and use an alternatinge fence markers (```), enabling the same syntax as that of GFM.

This addition follows the suggested way to specify language by W3C.

Example:

~~~html
<p>Ut brisket flank salami.  Cow cupidatat ex t-bone sirloin id.</p>
~~~

Using alternative fence markers:

```html
<p>Ut brisket flank salami.  Cow cupidatat ex t-bone sirloin id.</p>
```

Both will output the following HTML:

<pre><code class="language-html">
<p>Ut brisket flank salami.  Cow cupidatat ex t-bone sirloin id.</p>
</code></pre>

Support for figure and figcaption tags

There is now experimental support for the the HTML5 tags figure and figcaption.

A figure is a block level element and is created by wrapping some other content in three or more equal (=) signs.

A optional figure caption can be added to either the top of the figure or the bottom at the figure, right after the equal signs, wrapped in [ and ] signs.

Examples

This example shows a figure without a caption:

===
![](img/reference.png)
===

This example shows a figure with a caption added before the content:

=== [A **happy face** is good for web developers]
![](img/reference.png)
===

This example shows a figure with a caption added after the content:

===
![](img/reference.png)
=== [A **happy face** is good for web developers]

Usage

You need both the markdown.php and the markdown_extended.php files, but only needs to include markdown_extended.php.

require_once('markdown_extended.php');

// Convert markdown formatted text in $markdown to HTML
$html = MarkdownExtended($markdown);

php-markdown-extra-extended's People

Contributors

egil avatar sumpygump avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.