picocms / Pico

Pico is a stupidly simple, blazing fast, flat file CMS.
http://picocms.org/
MIT License
3.83k stars 614 forks source link

Sintax color in Pico #115

Closed erufenix closed 9 years ago

erufenix commented 10 years ago

In Pico can use syntax highlighting github style using ```language or type Pygments with :::language Or how I can highlight code in my post? Sorry my bad english

En pico se puede usar el resalto de sintaxis al estilo github haciendo uso de ```lenguaje o tipo Pygments con :::leguaje ¿O como puedo resaltar código en mis post?

Frodox commented 10 years ago

@erufenix , There is no imbedded syntax-highlighting in the PicoCMS ... But.. it can be done quite easily.

First of all, you should mark your program code as code in .md files. You could use backtricks "", or tab (4 spaces) before code (check [official markdown guide](http://daringfireball.net/projects/markdown/syntax) and [php-markdown](http://michelf.ca/projects/php-markdown/concepts/)). This will prodice output like Your code.. here.and

Your code#2.. here.
` respectively.

Now, you can use any dynamic code highlight JavaScript library. For example, Syntax Highlighter, highlight.js and so on.

bricebou commented 10 years ago

Hi,

I've just worked on a plugin to add automatically SyntaxHighlighter to pages. You can find it here: https://github.com/bricebou/pico_SyntaxHighlighter

I'm not a developper, that's my first plugin, so I'm not sure the code is the most effective but it works great ; you can check it here for example: http://momh.fr/tutos/GCweb/GCweb_champs_perso

Don't hesitate to review the code and to tell me how to improve it !

EDIT : I've rewriten the entire plugin, trying to be more "organized" and "clean" ; don't hesitate to comment on the code, on the two versions, and to give me some advide :)

Thanks :)

theshka commented 9 years ago

Plugin is featured in Wiki.