Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

We wish to use these pages for publishing various documents, announcements, FAQ etc related to beyondrelational.com

Administrators

Browse by Tag · View All
Announcements 8
new features 6
feedback 3
new feature 3
announcement 2
feature requests 2
TOP N 2
search 2
how to 1
setting up blogs 1

beyondrelational.com

Tips and Tricks for formatting code blocks - sample code listing

Apr 9 2012 12:00AM by webmaster   

Publishing sample code

Publishing sample code is always a challenge on web pages. When displaying a piece of sample code it is important to ensure the following.

  1. Syntax coloring - depending upon the programming languages, keywords should be colored
  2. Provide an easy way to copy the code and re-use it.

To provide these basic functionalities, we are using a Java Script based syntax highlighter library available here. However, to ensure that the code displays correctly, it has to be posted in a certain format. The rest of this post explains this.

Text Editors

Currently there are two types of text editors that you will see on various locations at beyondrelational.com

  1. WMD Java Script based editor - This is used primarily for the comments. It allows you to do basic formatting of the text when posting comments.
  2. HTML Editor - This is a WYSIWYG HTML editor that provides more HTML formatting options. This is used in the blogs section and used to create blog posts.

Formatting code listing when posting comments

To display code listing when posting a comment, then do the following:

  1. Past the sample code into the comment window
  2. Select the whole sample code
  3. Click on the code sample button on the toolbar window.

code sample button

After you post the comment, it will be displayed as follows:

code sample example

If you take mouse over the code listing, it will provide options to print, view or copy the code sample.

Formatting code sample in the HTML Editor

When using the HTML editor to publish code samples, this has to be done in a slightly different way. This is how the HTML editor looks like.

HTML editor at beyondrelational.com

The editor will display the design tab by default. To ensure the correct formatting, sample code should inserted from the HTML tab of the editor.

HTML tab of the editor

Insert the sample code into the HTML view tab within a pair of <pre> blocks as shown in the below illustration.

formatting sample code with pre blocks

The opening <pre> block (<pre class="brush: sql") can specify a brush which controls the syntax coloring. Currently the following brushes are supported.

  1. Cpp
  2. CSharp
  3. Css
  4. Delphi
  5. Groovy
  6. Java
  7. JScript
  8. Php
  9. Python
  10. Ruby
  11. Sql
  12. Vb
  13. Xml

If you do not find the desired brush listed above, use a generic brush plain as <pre class="brush: plain">. This formatting also works when posting to your blog using Windows Live Writer. Just like the HTML editor, the <pre> blocks should be inserted from the HTML view tab of Windows Live Writer.

Please share your comments, questions and feedback

Tags: how to


webmaster
242 · 1% · 184
9



Submit

5  Comments  

  • Good to see that posts. That is one of these things, that sometimes is missing. Especially for beginners.

    Although I have had chance to post few times some portion of code, still sometimes I have problems with correct formatting the code.

    commented on Apr 9 2012 1:48PM
    Adam Tokarski
    58 · 3% · 1021
  • I have a whole book on SQL PROGRAMMING STYLE in which I discussed the research on code readability. Sorry, but colored code does not work. The brain has to switch between language centers and visual centers and it pauses.

    There is a test for mild brain damage where the subject is shown flashcards with the names of colors in various colored inks ("GREEN" in red ink, etc) and asked to say the word or the color rapidly. If the pause rate changes then there is damage in the communication between hemispheres.

    Obviously, I cannot post a whole book here, but we spent a lot of tax payer money on this topic starting in the 1970's. That basic work has been confirmed in recent years with eye movement tools, MRI scans, etc.

    commented on Jul 8 2012 12:36PM
    jcelko
    444 · 0% · 87
  • jcelko it's very interesting, what you're writing - can you explain what means The brain has to switch between language centers and visual centers and it pauses?
    Did You draw these conclusions only after measuring time of response with naming colours? Interesting.
    Can you say us what exactly is that book, you're involved in? Are there any materials in net, you could send me in?

    commented on Jul 9 2012 7:03AM
    Adam Tokarski
    58 · 3% · 1021
  • Thank you very much for this post.

    **It is
    quite clear
    to me now**
    
    commented on Sep 21 2012 10:51AM
    OldStd
    262 · 1% · 165
  • Adam:

    SQL PROGRAMMING STYLE http://www.amazon.com/Celkos-Programming-Kaufmann-Management-Systems/dp/0120887975/ref=sr12?s=books&ie=UTF8&qid=1348253190&sr=1-2&keywords=Celko+SQL+programming+style

    The color test has been around for a long time. It is a quick test for brain damage from concussion. DISCOVER magazine had an article on this a few years ago; I do not have the reference.

    Sight and colcor processing is not done in the same aprt of the brain as reading and understanding. The frontal lobe has to switch between them; you can see the switch in MRIs. When I listen to music, only one part of my brain is active; when a musician hears music, both side of his brain are active.

    commented on Sep 21 2012 1:52PM
    jcelko
    444 · 0% · 87

Your Comment


Sign Up or Login to post a comment.

"Tips and Tricks for formatting code blocks - sample code listing" rated 5 out of 5 by 9 readers
Tips and Tricks for formatting code blocks - sample code listing , 5.0 out of 5 based on 9 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]