Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
Python, Lua, Tcl, C and C++ training - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Java, Ruby, MySQL and Linux / Tomcat systems
 
Using Pygments to colour our training examples

A browser receives text in a stream - as black and white, if you like. But the human eye prefers colour, so that's how modern, syntax aware editors display it for you, highlighting particular aspects of the text such as html tags in a different colour. Look what I mean:



For a number of years, we've published all the examples on our training courses, and extra blogged examples and examples written during courses too, indexed module by module - navigate here. Initially, they were monochrome, but over time I've added in syntax parsers to add some rudimentary colour. For PHP it was easy, using the highlight_string function, for other languages a little more tricky and I'll admit to not event trying with HTML ... until today!

My previous few blogs have been about HTML - a modern revision of the basics for staff and delegates who need to brush up before they look after our sites, or start generating code via Django, Rails, PHP or something else. And the examples weren't as easy to read as I would have wished.

If you want to do a job and you find yourself thinking "Surely someone has done this before" then:
a) They probably have
b) They have probably released it open source!


And so I found a lovely little Python package called Pygments and a command line utility to run it called pygmentize. You can find it too at http://pygments.org/. Easy to install - short and straightforward instructions and some local testing - the examples in the image above show such a test.

There's a huge number of languages and formats supported - Python, PHP, Ruby, Tcl, Perl, C, C++ and even Lua to support all of our current langauges. There's Java too. And lots of other interesting markups too including - for my initial purposes - HTML.

I've installed Pygments on our live server, and I have it highlighting all our HTML example files. I can now, proudly, publicise examples like our HTML one-of-each form sample, and our Cascading style sheet training examples. I'm leaving it at that for a few days - making sure it settles well, making sure I've not upset any other apple cart; we didn't use TDD (Test Driven Development) for the site, so we're somewhat lacking in wider ranging validators.
(written 2013-03-10, updated 2013-03-30)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
G914 - Well House Consultants - Other Software
  [4426] FileMaker Day to Unix Time conversion - (2015-02-15)
  [4303] Libre Office - unable to get past REOPEN WINDOWS? question - (2014-09-22)
  [3991] Email from Christopher Columbus to announce finding America? - (2013-01-29)
  [3896] An email marathon - (2012-10-15)
  [3648] iPad and iPhone programming - our seminar weekend with Xcode - (2012-03-11)
  [3599] Seeing how Melksham has changed over the years, via an iPad - (2012-01-30)
  [3584] QR codes - graphics images that provide quick phone links - (2012-01-18)
  [3213] Should I use Open Source or Commercial software? - (2011-03-26)
  [2906] Switching from Adobe Photoshop to Gimp - testing it on animals - (2010-08-06)
  [2600] Go Programming Language and Courses? - (2010-01-26)
  [2470] Windows 7 and Open Source Programming - (2009-10-22)
  [2191] RT @brento - a valuable source for the twitter newbie - (2009-05-20)
  [2106] Learning to Twitter / what is Twitter? - (2009-03-28)
  [75] It's just not cricket - (2004-10-06)


Back to
Cascading Style Sheets and formatting your web page
Previous and next
or
Horse's mouth home
Forward to
Seed Swap at Well House Manor
Some other Articles
Bright Spring Morning
Report on the last year - Melksham Chamber of Commerce and Industry for Melksham Without Parish Council
Report on the last year - Melksham Railway Developement Group for Melksham Without Parish Council
Seed Swap at Well House Manor
Using Pygments to colour our training examples
Cascading Style Sheets and formatting your web page
HTML tags uses in these blog articles
Special characters in HTML
The VERY basics of a web page ... and web site
Official Star ratings for hotels - still worth having?
4754 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2017: 404 The Spa • Melksham, Wiltshire • United Kingdom • SN12 6QL
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/4038_Usi ... mples.html • PAGE BUILT: Sat May 27 16:49:10 2017 • BUILD SYSTEM: WomanWithCat