Download the PHP package atk14/drink-markdown without Composer

On this page you can find all versions of the php package atk14/drink-markdown. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package drink-markdown

DrinkMarkdown

Extended PHP Markdown parser tuned for usage in ATK14 projects. It's built on Michel Fortin's PHP Markdown Extra.

Originally it was developed for the project "Doctor Ink" (shortly "Drink").

Beware! It is in alpha state. It has some interconnections to the ATK14 Framework thus it can't be easily used in other projects.

Features

DrinkMarkdown extends PHP Markdown Extra to:

Basic Usage

$dm = new DrinkMarkdown([
  "table_class" => "table", // the CSS class for tables, default is "table table-bordered table-hover"
  "html_purification_enabled" => true, // default is true
  "temp_dir" => "/path/to/temp", // default is constant TEMP or sys_get_temp_dir()
  "iobjects_processing_enabled" => true, // insertable objects processing, default is true
  "urlize_text" => true, // reconstruct missing links to urls or emails? default is true
  "shortcodes_enabled" => true, // whether to enable or disable processing of shortcodes, default is true
  "shortcode_autowiring_enabled" => true, // Smarty shortcodes are being registered automatically
]);

$html = $dm->transform($markdown);

Usage in a ATK14 template

DrinkMarkdown package comes with two helpers usables in ATK14 templates.

If you have a trusted content:

{$text|markdown nofilter} {* or *}
{!$text|markdown}

If you have an insecure content, e.g. a comment from a user:

{$comment|safe_markdown nofilter} {* or *}
{!$comment|safe_markdown}

Shortcodes

DrinkMarkdown can be extended with extensions: so called shortcodes.

There are three types of shortcodes:

Rendering of shortcodes is either provided callback functions or by Smarty (template engine used in ATK14 framework) plugins. Block shortcodes corresponds to Smarty block plugins, function shortcodes corresponds to Smarty function plugins. The difference between block and inline block shortcodes is that block shortcodes affect whole paragraphs, but inline block shortcodes can operate inside paragraphs or sentences.

Built-in shortcodes

DrinkMarkdown contains block shortcodes for organizing text into columns.

[row]

[col]
### Column 1
This is text of the first column.
[/col]

[col]
### Column 2
This is text of the second column.
[/col]

[col]
### Column 3
This is text of the third column.
[/col]

[/row]

See a living example at http://markdown.plovarna.cz/czech/multiple-columns/

Shortcode div renders

element with given attributes. Unlike direct usage of the HTML element div, markdown syntax is being interpreted inside the shortcode.

[div class="teaser" id="id_teaser"]

## Hello World!

Welcome to this very nice place.

[/div]

Inline block shortcode span renders element with given attributes. Again, markdown syntax is being interpreted inside the shortcode.

## Hello [span class="world"]World[/span]!

Welcome to this very nice place.

Custom shortcodes

$dm = new DrinkMarkdown();

1. Callbacks

$dm->registerBlockShortcode("alert", function($columns,$params){
  $params += [
    "type" => "primary"
  ];
  return "<div class=\"alert alert-$params[type]\" role=\"alert\">$content</div>";
});

$dm->registerInlineBlockShortcode("upper", function($content,$params){ return strtoupper($content); });

$dm->registerFunctionShortcode("name", function($params){
  $params += [
    "gender" => "male"
  ];
  return $params["gender"]=="female" ? "Samantha Doe" : "John Doe";
});

2. Smarty plugins

$dm->registerBlockShortcode("alert");
$dm->registerInlineBlockShortcode("upper");
$dm->registerFunctionShortcode("name");

If no callback is specified during a shortcode registration, an appropriate Smarty plugin is required. Note the naming conventions of plugins.

<?php
// file: app/helpers/block.drink_shortcode__alert.php
function smarty_block_drink_shortcode__alert($params,$content,$template,&$repeat){
  if($repeat){ return; }

  $params += array(
    "type" => "primary"
  );

  return "<div class=\"alert alert-$params[type]\" role=\"alert\">$content</div>";
}

<?php
// file: app/helpers/block.drink_shortcode__upper.php
function smarty_block_drink_shortcode__upper($params,$content,$template,&$repeat){
  if($repeat){ return; }

  return strtoupper($content);
}

<?php
// file: app/helpers/function.drink_shortcode__name.php
function smarty_function_drink_shortcode__name($params,$template){
  $params += array(
    "gender" => "male"
  );

  return $params["gender"]=="female" ? "Samantha Doe" : "John Doe";
}

Now, everything is set and ready. The following markdown text...

## This is welcome screen!

[alert type="info"]
Welcome [upper][name gender="female"][/upper]
[/alert]

... will be rendered as:

<h2>This is welcome screen!</h2>

<div class="alert alert-info">
<p>Welcome SAMANTHA DOE!</p>
</div>

Shortcode autowiring

By default, all Smarty plugins found are registered as either function shortcodes or block shortcodes.

For example, if file app/helpers/function.drink_shortcode__current_year.php exists, the shortcode [current_year] can be used without previous registration.

If shortcode autowiring is not desired behaviour, it can be disabled by "shortcode_autowiring_enabled" option in the constructor.

Installation

Just use the Composer:

cd path/to/your/atk14/project/
composer require atk14/drink-markdown

Optionaly you can link (or copy & edit) helpers to your project.

ln -s ../../vendor/atk14/drink-markdown/src/app/helpers/block.markdown.php app/helpers/
ln -s ../../vendor/atk14/drink-markdown/src/app/helpers/block.safe_markdown.php app/helpers/
ln -s ../../vendor/atk14/drink-markdown/src/app/helpers/modifier.markdown.php app/helpers/
ln -s ../../vendor/atk14/drink-markdown/src/app/helpers/modifier.safe_markdown.php app/helpers/
ln -s ../../vendor/atk14/drink-markdown/src/app/helpers/block.drink_shortcode__row.php app/helpers/
ln -s ../../vendor/atk14/drink-markdown/src/app/helpers/block.drink_shortcode__col.php app/helpers/
mkdir -p app/views/shared/helpers/drink_shortcodes
ln -s ../../../../../vendor/atk14/drink-markdown/src/app/views/shared/helpers/drink_shortcodes/_row.tpl app/views/shared/helpers/drink_shortcodes/
ln -s ../../../../../vendor/atk14/drink-markdown/src/app/views/shared/helpers/drink_shortcodes/_col.tpl app/views/shared/helpers/drink_shortcodes/

License

DrinkMarkdown is free software distributed under the terms of the MIT license


All versions of drink-markdown with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
geshi/geshi Version 1.0.8.*|1.0.9.*
michelf/php-markdown Version 1.7.*|1.8.*|1.9.*
ezyang/htmlpurifier Version >=4.8|<=4.13
yarri/link-finder Version 2.*
atk14/files Version 1.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package atk14/drink-markdown contains the following files

Loading the files please wait ....