Re: Posting Source Code

123 views
Skip to first unread message

Eduardo Rivas

unread,
Feb 10, 2013, 10:52:39 PM2/10/13
to mezzani...@googlegroups.com
You can use mezzanine-pagedown (as Rich Text Editor) with Pygments (for code highlightning), both installable via pip.
https://bitbucket.org/akhayyat/mezzanine-pagedown

Josh Cartmell

unread,
Feb 11, 2013, 12:37:20 PM2/11/13
to mezzani...@googlegroups.com
What Eduardo suggested is a great idea, but if you want to stick with the vanilla editor you can also use the <code>[code goes here]</code> html tag and then style it using CSS.  This is definitely not as user friendly because it will involve editing the html directly.

On Sun, Feb 10, 2013 at 7:52 PM, Eduardo Rivas <jeriva...@gmail.com> wrote:
You can use mezzanine-pagedown (as Rich Text Editor) with Pygments (for code highlightning), both installable via pip.
https://bitbucket.org/akhayyat/mezzanine-pagedown

--
You received this message because you are subscribed to the Google Groups "Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-use...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Leonard

unread,
Feb 11, 2013, 7:54:33 PM2/11/13
to mezzani...@googlegroups.com
Thank you guys, I was actually thinking about a in-browser solution.
I found this little post, I still haven't tested it yet but it seems pretty neat and easy: http://joejulian.name/blog/using-alex-gorbatchevs-syntaxhighlighter-with-mezzanine/
what do you about it? 

Eduardo Rivas

unread,
Feb 11, 2013, 9:50:39 PM2/11/13
to mezzani...@googlegroups.com
Both solutions suggested above are in-browser. In either case you edit the Rich Text Content in Mezzanine's admin interface, right in your browser as you've been doing so far. Following the advice from the post you linked to will be actually using Josh's solution.

Personally, I'm not a fan of Javascript based syntax highlightning; it adds extra burden to the client for some content that is (basically) static. Just an opinion :)

Leonard

unread,
Feb 11, 2013, 10:58:04 PM2/11/13
to mezzani...@googlegroups.com
I've tested the Eduardo solution, it's very nice! You are right, maybe it's not useful/necessary to call every time javascript to process the code block and highlight it.
The only doubt I have is if it possible to customize pygments in order to have an output similar to the one that I can obtain with SyntaxHighlighter (http://alexgorbatchev.com/SyntaxHighlighter/). 
I mean: 
  1. The line numbers 
  2. The horizontal scrollbar in case of long code lines
  3. The possibility to optionally raising a popup with the plain text (without line number to have an easy copy-paste)
I don't think this is possible with pure Css, so I suppose some javascript is required. Should I write it from scratch or pygments have these kind of features (optionally generating the js for me) ?

Hope I was clear.
Thank you

Eduardo Rivas

unread,
Feb 11, 2013, 11:05:45 PM2/11/13
to mezzani...@googlegroups.com
1. Prefix your code block (in Markdown) with # and language code to get line numbers http://pythonhosted.org/Markdown/extensions/code_hilite.html
2. This is a CSS problem:
    pre, code {max-width: 100%; overflow-x: scroll}
3. Yes, some JS will be required for this. The code is highlightable as it is, though.
Reply all
Reply to author
Forward
0 new messages