Giter Club home page Giter Club logo

ci-markdown's Introduction

CI Markdown

CI Markdown is a modified rendition of Michel Fortin's PHP Markdown and PHP Markdown Extra for CodeIgniter.

Install

Requirements

Download

Download and extract the zip release to your CoddeIgniter application/libraries/ directory.

The extracted path should resemble:

  • application/libraries/Markdown.php

Usage

Configuration

Custom PHP Markdown settings are defined in the config/markdown.php config file.

Initializing the Markdown Class

Like most other classes in CodeIgniter, initialize it from your controller using the $this->load->library() method:

$this->load->library('markdown');

To programmatically configure the Markdown instance, overriding any matched settings defined in the config file:

$config = array(
    'tab_width' => 2,
    'no_markup' => true,
    'empty_element_suffix' => '/>'
);

$this->load->library('markdown', $config);

Markdown to HTML

  • $this->markdown->transform()

Accepts a single string parameter of Markdown text and returns the transformed HTML.

$this->load->library('markdown');

$markdownText = "# Heading "."\n"."## Sub-heading";
echo $this->markdown->transform($markdownText);
// <h1>Heading</h1>
// <h2>Sub-heading</h2>

Markdown file to HTML

  • $this->markdown->transform_file()

Accepts a single string parameter for a Markdown file path and returns the transformed HTML.

$this->load->library('markdown');

echo $this->markdown->transform_file('/path/to/markdown/file.md');
// <h1>Heading</h1>
// <h2>Sub-heading</h2>

Issues

For all issues including feature requests, please open a new issue.

Changes

See the Changelog page.

Credits

ci-markdown's People

Contributors

barbzyhool avatar jonlabelle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ci-markdown's Issues

How to get class in blockquote?

Hello!

I have the following code:

{: .note}
>
>Allowing unrestricted access to MySQL on a public IP not advised, but you may change the address it listens on by modifying the `bind-address` parameter in `/etc/my.cnf`. If you decide to bind MySQL to your public IP, you should implement firewall rules that only allow connections from specific IP addresses.

And the library translate it to:

<p>{: .note}
></p>

<blockquote>
  <p>Allowing unrestricted access to MySQL on a public IP not advised, but you may change the address it listens on by modifying the <code>bind-address</code> parameter in <code>/etc/my.cnf</code>. If you decide to bind MySQL to your public IP, you should implement firewall rules that only allow connections from specific IP addresses.</p>
</blockquote>

Any solution to return a <blockquote class="note">...?

Thank you! ๐Ÿ˜ƒ

How to replace specific <span> like actually with <abbr>?

I'd like to explain some words, but they are not abbreviations, so it's wrong to explain these words with <abbr title="">

I just would like to reproduce the system of abbrs but with some changes and only to certain <span>, any idea how to proceed?

I read the code a bit but it looked very confusing, with meaningless names etc

Break line doesn't work

Hi.
I'm using this library in my Project, but if i want to make new line i press ENTER and finally text is in the same line.

Issue with markdown transform of nested lists

Hi,

From some articles I have read, it appears that the markdown standard has issues with code blocks and nested lists: the two are getting mixed up, so nested lists are styled the way code blocks would be styled.

The advice of the people on the forum is to use two spaces instead, but that makes it render as a paragraph.

To test it out:

$this->markdown->transform('  1.1. Hello');
$this->markdown->transform('    1.1. Hello');

You will see that the first one renders in a paragraph tag and the second one as a code block.

I guess it can be disputed as to where the issue lies (with the renderer or with markdown itself) but I figured that, since this issue is almost 10 years old, the markdown syntax won't be fixed (if it is at fault).

Is there something you can do about it?

Cross Site Scripting Vulnerabilty

The parser allows you to create links with a source such as javascript:alert('xss'), this could lead to cross site scripting vulnerabilities when a content security policy is not in use. Thoughts?

Error when calling parse in view file

I keep running into this error

A PHP Error was encountered

Severity: Notice

Message: Undefined property: CI_Loader::$markdown

Filename: views/view_article.php

Line Number: 68

I am saving the Markdown data in a database and pulling that from the database and displaying in my code like this:

$string = $a->body;
$this->load->library('markdown');
echo $this->markdown->parse($string);

As soon as I remove "echo $this->markdown->parse($string);", I get no errors.

Any suggestions would help.

Awesome

Just wanted to say this is awesome, and very easy to install and use.

Thank you!

Btw I didn't know all the possibilities of markdown-extra until i read carefully the original site. Might be interesting to put a more elaborate example.

# Heading

## Subheading with ID {#my_header}

### Subsubheading with class {.my_class}

<div style="color: purple" markdown=1>
    <http://google.com>
</div>

_italic_ **bold**

More on: https://michelf.ca/projects/php-markdown/dingus/

Markdown Extra

Is there a way to use Markdown Extra with this library?

Abbreviations improvement

Predefined abbreviations are very useful but they don't work in specific cases:

  • if the abbreviation is singular, then the plural form won't be detected as an abbr. There could be a way to define this per abbreviation eventually? atm forced to duplicate each abbr
  • If the abbreviation has one uppercase character, then it won't be detected, but sometimes acronyms have weird casing, or putting an abbr on a simple word which is the first word in a sentence means it won't be detected

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.