Awk.Info

"Cause a little auk awk
goes a long way."

About awk.info
 »  table of contents
 »  featured topics
 »  page tags


About Awk
 »  advocacy
 »  learning
 »  history
 »  Wikipedia entry
 »  mascot
Implementations
 »  Awk (rarely used)
 »  Nawk (the-one-true, old)
 »  Gawk (widely used)
 »  Mawk
 »  Xgawk (gawk + xml + ...)
 »  Spawk (SQL + awk)
 »  Jawk (Awk in Java JVM)
 »  QTawk (extensions to gawk)
 »  Runawk (a runtime tool)
 »  platform support
Coding
 »  one-liners
 »  ten-liners
 »  tips
 »  the Awk 100
Community
 »  read our blog
 »  read/write the awk wiki
 »  discussion news group

Libraries
 »  Gawk
 »  Xgawk
 »  the Lawker library
Online doc
 »  reference card
 »  cheat sheet
 »  manual pages
 »  FAQ

Reading
 »  articles
 »  books:

WHAT'S NEW?

Mar 01: Michael Sanders demos an X-windows GUI for AWK.

Mar 01: Awk100#24: A. Lahm and E. de Rinaldis' patent search, in AWK

Feb 28: Tim Menzies asks this community to write an AWK cookbook.

Feb 28: Arnold Robbins announces a new debugger for GAWK.

Feb 28: Awk100#23: Premysl Janouch offers a IRC bot, In AWK

Feb 28: Updated: the AWK FAQ

Feb 28: Tim Menzies offers a tiny content management system, in Awk.

Jan 31: Comment system added to awk.info. For example, see discussion bottom of ?keys2awk

Jan 31: Martin Cohen shows that Gawk can handle massively long strings (300 million characters).

Jan 31: The AWK FAQ is being updated. For comments/ corrections/ extensions, please mail tim@menzies.us

Jan 31: Martin Cohen finds Awk on the Android platform.

Jan 31: Aleksey Cheusov released a new version of runawk.

Jan 31: Hirofumi Saito contributes a candidate Awk mascot.

Jan 31: Michael Sanders shows how to quickly build an AWK GUI for windows.

Jan 31: Hyung-Hwan Chung offers QSE, an embeddable Awk Interpreter.

[More ...]

Bookmark and Share

categories: Contribute,Jan,2009,Timm

Pretty Print AWK Code

The code that renders the awk.info web site can "pretty print" awk code. For example:

To enable that pretty print, add some html syntax inside your code and apply the following conventions.

Preview Engine

Note that if you want to see your "looking pretty", then you could could see how it looks using our preview tool:

http://awk.info/?awk:urlWithoutHTTPprefix

For exmaple, the file http://menzies.us/tmp/xx.awk can be previewed using http://awk.info/?awk:menzies.us/tmp/xx.awk

Contributing Pretty Code

Once you've got it "looking pretty", please consider contributing that code to awk.info, so our code library can grow. To do so, either email mail@awk.info with the URL of your pretty code or zip up the files and email them across.

HTML-based Commenting Conventions

The first paragraph of the file will be ignored. Use this first para for copyright notices or comments about down-in-the weeds trivia. Note: the first para ends with one blank line.

The next paragraph should start with

#.H1 <join>Title</join>

The code could should be topped and tailed as follows:

#<pre>
code
#</pre>

All other comment lines should start with a single "#" at front-of-line. These comment characters will be stripped away by the awk.info renderer.

Awk.info's renderer adopts the following html shorthand. If a line starts with

#.WORD other words 

this this is replaced with

<WORD> other words</WORD>

If no other words follow #.WORD then the line becomes just <WORD>

Awk.info's renderer supports a few HTML extensions:

  • #.IN path includes a file found in the LAWKER repositoriy at some path inside the trunk.
  • #.CODE path includes the contents of path, wrapped in <pre> tags, and prefixed by the path.
  • #.BODY path is the same as #.CODE but it skips the first paragraph (this is useful when the first paragraph includes tedious details you want to hite from the user).
  • Note that, for #.IN, #.CODE, #.BODY, the path must appear after a single space.

That's it. Now you can pretty print your code on the web just be adding a little html in the comments.

blog comments powered by Disqus