Today I decided to give cebe’s markdown a try and I couldn’t get it to fully work. I used github markdown and when I try to display some code specific syntax all I get is <pre> formatting. Do I have to explicitely register additional assets in order to get code syntax displayed properly? I tried this
```javascript
var s = "JavaScript syntax highlighting";
alert(s);
taken directly from github cheatsheet but all i get is grey background with text (no code specific highlighting). I wonder if I am missing anything. I read through the documentation and couldn't find any info about it except for how to parse it on Yii side.
Thanks
There are some differences between traditional markdown and github-flavoured one.
Thanks for the quick reply ORey. Still there something wrong somewhere.
I tried:
```ruby
require 'redcarpet'
markdown = Redcarpet.new("Hello World!")
puts markdown.to_html
and
function test() {
console.log("notice the blank line before this function?");
}
both copied from the link you provided and both give me the same result. No ruby specific highlighting. It is either I am missing something or the markdown extension is not fully working or missing instructions.
I also checked in the console and I can see the following code:
<pre><code class="language-ruby">require 'redcarpet'
markdown = Redcarpet.new("Hello World!")
puts markdown.to_html
</code></pre>
so the language specific class has been applied. It seems like only the assets are missing.
I see.
First of all, seems like github syntax is actually supported:
A super fast, highly extensible markdown parser for PHP
=======================================================
[](https://packagist.org/packages/cebe/markdown)
[](https://packagist.org/packages/cebe/markdown)
[](http://travis-ci.org/cebe/markdown)
[](https://scrutinizer-ci.com/g/cebe/markdown/)
[](https://scrutinizer-ci.com/g/cebe/markdown/)
What is this? <a name="what"></a>
-------------
A set of [PHP][] classes, each representing a [Markdown][] flavor, and a command line tool
for converting markdown files to HTML files.
The implementation focus is to be **fast** (see [benchmark][]) and **extensible**.
Parsing Markdown to HTML is as simple as calling a single method (see [Usage](#usage)) providing a solid implementation
that gives most expected results even in non-trivial edge cases.
Extending the Markdown language with new elements is as simple as adding a new method to the class that converts the
This file has been truncated. show original
// use github
$parser = new \cebe\markdown\GithubMarkdown();
$parser->parse($markdown);
and here’s the example of extending for fenced code blocks:
A super fast, highly extensible markdown parser for PHP
=======================================================
[](https://packagist.org/packages/cebe/markdown)
[](https://packagist.org/packages/cebe/markdown)
[](http://travis-ci.org/cebe/markdown)
[](https://scrutinizer-ci.com/g/cebe/markdown/)
[](https://scrutinizer-ci.com/g/cebe/markdown/)
What is this? <a name="what"></a>
-------------
A set of [PHP][] classes, each representing a [Markdown][] flavor, and a command line tool
for converting markdown files to HTML files.
The implementation focus is to be **fast** (see [benchmark][]) and **extensible**.
Parsing Markdown to HTML is as simple as calling a single method (see [Usage](#usage)) providing a solid implementation
that gives most expected results even in non-trivial edge cases.
Extending the Markdown language with new elements is as simple as adding a new method to the class that converts the
This file has been truncated. show original
Sorry, I havent used it by myself yet, but seems like it’s highly customizable.
I think Carsten Brandt can shed some light on it.
You need to add a syntax highlighting JS plugin separately (cebe’s parser does not include the syntax highlighter). This is discussed in this issue.
samdark
(Alexander Makarov)
April 23, 2014, 9:09pm
7
Highlighting is to be implemented. Currently the best option is to use something like https://github.com/isagalaev/highlight.js
Thanks guys.
@samdark , why is this the best option? maturity? stability? ease of use? Thanks
samdark
(Alexander Makarov)
April 27, 2014, 7:45pm
9
Because it doesn’t require to modify markdown parser + library itself is of very good quality. We’re considering using its PHP port by default.