C# syntax highlighter for blogging on BlogSpot
Asked Answered
Y

6

7

I'm looking for a syntax highlighter cum code formatter for my blog on BlogSpot. I've tried several today, but the all want to include <style> tags, or reference a stylesheet. I'm looking for one that is ideal for segments of code, and includes styling inline. Any suggestions?

Yate answered 27/11, 2008 at 15:42 Comment(2)
Finding the answer to this quesion helped me resolve my own problemTetrad
Blattant self promotion of a deleted blog :)Skaw
L
3

You can always copy the extra few bytes of styling for, say, a Pygments highlighter (which really is quite excellent) into the <head> of your blog. You don't even need to install any software; just copy the HTML from the online service.

Liturgical answered 27/11, 2008 at 16:33 Comment(2)
You can't touch the <head> directly using Blogger or BlogSpot. If those styling bytes are the same all of the time for Pygments and don't conflict with styles that Blogger might use, it is necessary to adjust the <head> section in the Blogger template for all posts. How well does RSS work?Obstruent
The styles would be the same for all pages; they shouldn't conflict with Blogspot's highlighting. There would not be highlighting in feeds, but that's kind of just like the norm for special blog formatting -- you only get the structure.Liturgical
R
7

The project referenced above has moved:
http://alexgorbatchev.com/wiki/SyntaxHighlighter

Instructions for using it on Blogger:
mlawire.blogspot.com/2009/07/blogger-syntax-highlighting.html

Radiophone answered 6/8, 2009 at 5:19 Comment(2)
This is nice. I'm using it myself nowTetrad
Careful with using SyntaxHighlighter 3.0.83 with Chrome, I'm exeriencing some line numbering issues, I think it is a bug.Lowther
L
3

You can always copy the extra few bytes of styling for, say, a Pygments highlighter (which really is quite excellent) into the <head> of your blog. You don't even need to install any software; just copy the HTML from the online service.

Liturgical answered 27/11, 2008 at 16:33 Comment(2)
You can't touch the <head> directly using Blogger or BlogSpot. If those styling bytes are the same all of the time for Pygments and don't conflict with styles that Blogger might use, it is necessary to adjust the <head> section in the Blogger template for all posts. How well does RSS work?Obstruent
The styles would be the same for all pages; they shouldn't conflict with Blogspot's highlighting. There would not be highlighting in feeds, but that's kind of just like the norm for special blog formatting -- you only get the structure.Liturgical
S
3

I've created a Free Online C# Syntax Highlighter that has exactly the ability you need - to inline the needed CSS styles. All you have to do is to select the "Inlined styles" check box, paste your C# code and click the Colorize button. You can find it on my blog.

Seismism answered 27/3, 2013 at 16:16 Comment(1)
Nice, thanks for this. Unbelievably frustrating trying to manually align and format elements through Blogspot's web interface!Marcusmarcy
K
2

Try this one: http://code.google.com/p/syntaxhighlighter/

Koehler answered 27/11, 2008 at 16:23 Comment(1)
I wrote a step-by-step howto to help configure it in blogger on my blog: yacoding.blogspot.com/2008/05/…Levigate
I
1

I use SyntaxHighlighter Javascript Library. It's really easy to add and use.

here's more information on it that might help others out:

http://www.craftyfella.com/2010/01/syntax-highlighting-with-blogger-engine.html

Illuminator answered 1/2, 2010 at 10:4 Comment(0)
B
0

I had this exact problem.

I wrote an image formatter for Pygments (included in the core distribution).

Please don't hate me for such an abomination, but yes, it renders the highlighted code as a png or jpg or whatever you want. So it has no external dependencies etc.

pygmentize -f png -o mysource.png mysource.cs 

I try to make sure that I always link a plain text version of the source for people copy-pasting.

Bruyn answered 27/11, 2008 at 15:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.