diff options
author | Lloyd Hilaiel <lloyd@hilaiel.com> | 2009-02-25 13:33:44 -0700 |
---|---|---|
committer | Lloyd Hilaiel <lloyd@hilaiel.com> | 2009-02-25 13:33:44 -0700 |
commit | 965d3d257d6a90ffa257d160c1302eb61e2bf141 (patch) | |
tree | 5ba719c3f9a977ec582230889ad252ce245a422f | |
parent | 978688c2847535d3e98a7ddd73c6757b8c30edba (diff) | |
download | yajl-965d3d257d6a90ffa257d160c1302eb61e2bf141.tar.gz |
a simple project page for yajl
-rw-r--r-- | dp.SyntaxHighlighter/SyntaxHighlighter.css | 185 | ||||
-rw-r--r-- | dp.SyntaxHighlighter/shBrushCpp.js | 11 | ||||
-rw-r--r-- | dp.SyntaxHighlighter/shCore.js | 161 | ||||
-rw-r--r-- | index.html | 407 |
4 files changed, 715 insertions, 49 deletions
diff --git a/dp.SyntaxHighlighter/SyntaxHighlighter.css b/dp.SyntaxHighlighter/SyntaxHighlighter.css new file mode 100644 index 0000000..85a8261 --- /dev/null +++ b/dp.SyntaxHighlighter/SyntaxHighlighter.css @@ -0,0 +1,185 @@ +.dp-highlighter
+{
+ font-family: "Consolas", "Courier New", Courier, mono, serif;
+ font-size: 12px;
+ background-color: #E7E5DC;
+ width: 99%;
+ overflow: auto;
+ margin: 18px 0 18px 0 !important;
+ padding-top: 1px; /* adds a little border on top when controls are hidden */
+}
+
+/* clear styles */
+.dp-highlighter ol,
+.dp-highlighter ol li,
+.dp-highlighter ol li span
+{
+ margin: 0;
+ padding: 0;
+ border: none;
+}
+
+.dp-highlighter a,
+.dp-highlighter a:hover
+{
+ background: none;
+ border: none;
+ padding: 0;
+ margin: 0;
+}
+
+.dp-highlighter .bar
+{
+ padding-left: 45px;
+}
+
+.dp-highlighter.collapsed .bar,
+.dp-highlighter.nogutter .bar
+{
+ padding-left: 0px;
+}
+
+.dp-highlighter ol
+{
+ list-style: decimal; /* for ie */
+ background-color: #fff;
+ margin: 0px 0px 1px 45px !important; /* 1px bottom margin seems to fix occasional Firefox scrolling */
+ padding: 0px;
+ color: #5C5C5C;
+}
+
+.dp-highlighter.nogutter ol,
+.dp-highlighter.nogutter ol li
+{
+ list-style: none !important;
+ margin-left: 0px !important;
+}
+
+.dp-highlighter ol li,
+.dp-highlighter .columns div
+{
+ list-style: decimal-leading-zero; /* better look for others, override cascade from OL */
+ list-style-position: outside !important;
+ border-left: 3px solid #6CE26C;
+ background-color: #F8F8F8;
+ color: #5C5C5C;
+ padding: 0 3px 0 10px !important;
+ margin: 0 !important;
+ line-height: 14px;
+}
+
+.dp-highlighter.nogutter ol li,
+.dp-highlighter.nogutter .columns div
+{
+ border: 0;
+}
+
+.dp-highlighter .columns
+{
+ background-color: #F8F8F8;
+ color: gray;
+ overflow: hidden;
+ width: 100%;
+}
+
+.dp-highlighter .columns div
+{
+ padding-bottom: 5px;
+}
+
+.dp-highlighter ol li.alt
+{
+ background-color: #FFF;
+ color: inherit;
+}
+
+.dp-highlighter ol li span
+{
+ color: black;
+ background-color: inherit;
+}
+
+/* Adjust some properties when collapsed */
+
+.dp-highlighter.collapsed ol
+{
+ margin: 0px;
+}
+
+.dp-highlighter.collapsed ol li
+{
+ display: none;
+}
+
+/* Additional modifications when in print-view */
+
+.dp-highlighter.printing
+{
+ border: none;
+}
+
+.dp-highlighter.printing .tools
+{
+ display: none !important;
+}
+
+.dp-highlighter.printing li
+{
+ display: list-item !important;
+}
+
+/* Styles for the tools */
+
+.dp-highlighter .tools
+{
+ padding: 3px 8px 3px 10px;
+ font: 9px Verdana, Geneva, Arial, Helvetica, sans-serif;
+ color: silver;
+ background-color: #f8f8f8;
+ padding-bottom: 10px;
+ border-left: 3px solid #6CE26C;
+}
+
+.dp-highlighter.nogutter .tools
+{
+ border-left: 0;
+}
+
+.dp-highlighter.collapsed .tools
+{
+ border-bottom: 0;
+}
+
+.dp-highlighter .tools a
+{
+ font-size: 9px;
+ color: #a0a0a0;
+ background-color: inherit;
+ text-decoration: none;
+ margin-right: 10px;
+}
+
+.dp-highlighter .tools a:hover
+{
+ color: red;
+ background-color: inherit;
+ text-decoration: underline;
+}
+
+/* About dialog styles */
+
+.dp-about { background-color: #fff; color: #333; margin: 0px; padding: 0px; }
+.dp-about table { width: 100%; height: 100%; font-size: 11px; font-family: Tahoma, Verdana, Arial, sans-serif !important; }
+.dp-about td { padding: 10px; vertical-align: top; }
+.dp-about .copy { border-bottom: 1px solid #ACA899; height: 95%; }
+.dp-about .title { color: red; background-color: inherit; font-weight: bold; }
+.dp-about .para { margin: 0 0 4px 0; }
+.dp-about .footer { background-color: #ECEADB; color: #333; border-top: 1px solid #fff; text-align: right; }
+.dp-about .close { font-size: 11px; font-family: Tahoma, Verdana, Arial, sans-serif !important; background-color: #ECEADB; color: #333; width: 60px; height: 22px; }
+
+/* Language specific styles */
+
+.dp-highlighter .comment, .dp-highlighter .comments { color: #008200; background-color: inherit; }
+.dp-highlighter .string { color: blue; background-color: inherit; }
+.dp-highlighter .keyword { color: #069; font-weight: bold; background-color: inherit; }
+.dp-highlighter .preprocessor { color: gray; background-color: inherit; }
diff --git a/dp.SyntaxHighlighter/shBrushCpp.js b/dp.SyntaxHighlighter/shBrushCpp.js new file mode 100644 index 0000000..2ba1b7a --- /dev/null +++ b/dp.SyntaxHighlighter/shBrushCpp.js @@ -0,0 +1,11 @@ +/*
+ * JsMin
+ * Javascript Compressor
+ * http://www.crockford.com/
+ * http://www.smallsharptools.com/
+*/
+
+dp.sh.Brushes.Cpp=function()
+{var datatypes='ATOM BOOL BOOLEAN BYTE CHAR COLORREF DWORD DWORDLONG DWORD_PTR '+'DWORD32 DWORD64 FLOAT HACCEL HALF_PTR HANDLE HBITMAP HBRUSH '+'HCOLORSPACE HCONV HCONVLIST HCURSOR HDC HDDEDATA HDESK HDROP HDWP '+'HENHMETAFILE HFILE HFONT HGDIOBJ HGLOBAL HHOOK HICON HINSTANCE HKEY '+'HKL HLOCAL HMENU HMETAFILE HMODULE HMONITOR HPALETTE HPEN HRESULT '+'HRGN HRSRC HSZ HWINSTA HWND INT INT_PTR INT32 INT64 LANGID LCID LCTYPE '+'LGRPID LONG LONGLONG LONG_PTR LONG32 LONG64 LPARAM LPBOOL LPBYTE LPCOLORREF '+'LPCSTR LPCTSTR LPCVOID LPCWSTR LPDWORD LPHANDLE LPINT LPLONG LPSTR LPTSTR '+'LPVOID LPWORD LPWSTR LRESULT PBOOL PBOOLEAN PBYTE PCHAR PCSTR PCTSTR PCWSTR '+'PDWORDLONG PDWORD_PTR PDWORD32 PDWORD64 PFLOAT PHALF_PTR PHANDLE PHKEY PINT '+'PINT_PTR PINT32 PINT64 PLCID PLONG PLONGLONG PLONG_PTR PLONG32 PLONG64 POINTER_32 '+'POINTER_64 PSHORT PSIZE_T PSSIZE_T PSTR PTBYTE PTCHAR PTSTR PUCHAR PUHALF_PTR '+'PUINT PUINT_PTR PUINT32 PUINT64 PULONG PULONGLONG PULONG_PTR PULONG32 PULONG64 '+'PUSHORT PVOID PWCHAR PWORD PWSTR SC_HANDLE SC_LOCK SERVICE_STATUS_HANDLE SHORT '+'SIZE_T SSIZE_T TBYTE TCHAR UCHAR UHALF_PTR UINT UINT_PTR UINT32 UINT64 ULONG '+'ULONGLONG ULONG_PTR ULONG32 ULONG64 USHORT USN VOID WCHAR WORD WPARAM WPARAM WPARAM '+'char bool short int __int32 __int64 __int8 __int16 long float double __wchar_t '+'clock_t _complex _dev_t _diskfree_t div_t ldiv_t _exception _EXCEPTION_POINTERS '+'FILE _finddata_t _finddatai64_t _wfinddata_t _wfinddatai64_t __finddata64_t '+'__wfinddata64_t _FPIEEE_RECORD fpos_t _HEAPINFO _HFILE lconv intptr_t '+'jmp_buf mbstate_t _off_t _onexit_t _PNH ptrdiff_t _purecall_handler '+'sig_atomic_t size_t _stat __stat64 _stati64 terminate_function '+'time_t __time64_t _timeb __timeb64 tm uintptr_t _utimbuf '+'va_list wchar_t wctrans_t wctype_t wint_t signed';var keywords='break case catch class const __finally __exception __try '+'const_cast continue private public protected __declspec '+'default delete deprecated dllexport dllimport do dynamic_cast '+'else enum explicit extern if for friend goto inline '+'mutable naked namespace new noinline noreturn nothrow '+'register reinterpret_cast return selectany '+'sizeof static static_cast struct switch template this '+'thread throw true false try typedef typeid typename union '+'using uuid virtual void volatile whcar_t while';this.regexList=[{regex:dp.sh.RegexLib.SingleLineCComments,css:'comment'},{regex:dp.sh.RegexLib.MultiLineCComments,css:'comment'},{regex:dp.sh.RegexLib.DoubleQuotedString,css:'string'},{regex:dp.sh.RegexLib.SingleQuotedString,css:'string'},{regex:new RegExp('^ *#.*','gm'),css:'preprocessor'},{regex:new RegExp(this.GetKeywords(datatypes),'gm'),css:'datatypes'},{regex:new RegExp(this.GetKeywords(keywords),'gm'),css:'keyword'}];this.CssClass='dp-cpp';this.Style='.dp-cpp .datatypes { color: #2E8B57; font-weight: bold; }';}
+dp.sh.Brushes.Cpp.prototype=new dp.sh.Highlighter();dp.sh.Brushes.Cpp.Aliases=['cpp','c','c++'];
+
diff --git a/dp.SyntaxHighlighter/shCore.js b/dp.SyntaxHighlighter/shCore.js new file mode 100644 index 0000000..1418632 --- /dev/null +++ b/dp.SyntaxHighlighter/shCore.js @@ -0,0 +1,161 @@ +/*
+ * JsMin
+ * Javascript Compressor
+ * http://www.crockford.com/
+ * http://www.smallsharptools.com/
+*/
+
+var dp={sh:{Toolbar:{},Utils:{},RegexLib:{},Brushes:{},Strings:{AboutDialog:'<html><head><title>About...</title></head><body class="dp-about"><table cellspacing="0"><tr><td class="copy"><p class="title">dp.SyntaxHighlighter</div><div class="para">Version: {V}</p><p><a href="http://www.dreamprojections.com/syntaxhighlighter/?ref=about" target="_blank">http://www.dreamprojections.com/syntaxhighlighter</a></p>©2004-2007 Alex Gorbatchev.</td></tr><tr><td class="footer"><input type="button" class="close" value="OK" onClick="window.close()"/></td></tr></table></body></html>'},ClipboardSwf:null,Version:'1.5.1'}};dp.SyntaxHighlighter=dp.sh;dp.sh.Toolbar.Commands={ExpandSource:{label:'+ expand source',check:function(highlighter){return highlighter.collapse;},func:function(sender,highlighter)
+{sender.parentNode.removeChild(sender);highlighter.div.className=highlighter.div.className.replace('collapsed','');}},ViewSource:{label:'view plain',func:function(sender,highlighter)
+{var code=dp.sh.Utils.FixForBlogger(highlighter.originalCode).replace(/</g,'<');var wnd=window.open('','_blank','width=750, height=400, location=0, resizable=1, menubar=0, scrollbars=0');wnd.document.write('<textarea style="width:99%;height:99%">'+code+'</textarea>');wnd.document.close();}},CopyToClipboard:{label:'copy to clipboard',check:function(){return window.clipboardData!=null||dp.sh.ClipboardSwf!=null;},func:function(sender,highlighter)
+{var code=dp.sh.Utils.FixForBlogger(highlighter.originalCode).replace(/</g,'<').replace(/>/g,'>').replace(/&/g,'&');if(window.clipboardData)
+{window.clipboardData.setData('text',code);}
+else if(dp.sh.ClipboardSwf!=null)
+{var flashcopier=highlighter.flashCopier;if(flashcopier==null)
+{flashcopier=document.createElement('div');highlighter.flashCopier=flashcopier;highlighter.div.appendChild(flashcopier);}
+flashcopier.innerHTML='<embed src="'+dp.sh.ClipboardSwf+'" FlashVars="clipboard='+encodeURIComponent(code)+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';}
+alert('The code is in your clipboard now');}},PrintSource:{label:'print',func:function(sender,highlighter)
+{var iframe=document.createElement('IFRAME');var doc=null;iframe.style.cssText='position:absolute;width:0px;height:0px;left:-500px;top:-500px;';document.body.appendChild(iframe);doc=iframe.contentWindow.document;dp.sh.Utils.CopyStyles(doc,window.document);doc.write('<div class="'+highlighter.div.className.replace('collapsed','')+' printing">'+highlighter.div.innerHTML+'</div>');doc.close();iframe.contentWindow.focus();iframe.contentWindow.print();alert('Printing...');document.body.removeChild(iframe);}},About:{label:'?',func:function(highlighter)
+{var wnd=window.open('','_blank','dialog,width=300,height=150,scrollbars=0');var doc=wnd.document;dp.sh.Utils.CopyStyles(doc,window.document);doc.write(dp.sh.Strings.AboutDialog.replace('{V}',dp.sh.Version));doc.close();wnd.focus();}}};dp.sh.Toolbar.Create=function(highlighter)
+{var div=document.createElement('DIV');div.className='tools';for(var name in dp.sh.Toolbar.Commands)
+{var cmd=dp.sh.Toolbar.Commands[name];if(cmd.check!=null&&!cmd.check(highlighter))
+continue;div.innerHTML+='<a href="#" onclick="dp.sh.Toolbar.Command(\''+name+'\',this);return false;">'+cmd.label+'</a>';}
+return div;}
+dp.sh.Toolbar.Command=function(name,sender)
+{var n=sender;while(n!=null&&n.className.indexOf('dp-highlighter')==-1)
+n=n.parentNode;if(n!=null)
+dp.sh.Toolbar.Commands[name].func(sender,n.highlighter);}
+dp.sh.Utils.CopyStyles=function(destDoc,sourceDoc)
+{var links=sourceDoc.getElementsByTagName('link');for(var i=0;i<links.length;i++)
+if(links[i].rel.toLowerCase()=='stylesheet')
+destDoc.write('<link type="text/css" rel="stylesheet" href="'+links[i].href+'"></link>');}
+dp.sh.Utils.FixForBlogger=function(str)
+{return(dp.sh.isBloggerMode==true)?str.replace(/<br\s*\/?>|<br\s*\/?>/gi,'\n'):str;}
+dp.sh.RegexLib={MultiLineCComments:new RegExp('/\\*[\\s\\S]*?\\*/','gm'),SingleLineCComments:new RegExp('//.*$','gm'),SingleLinePerlComments:new RegExp('#.*$','gm'),DoubleQuotedString:new RegExp('"(?:\\.|(\\\\\\")|[^\\""\\n])*"','g'),SingleQuotedString:new RegExp("'(?:\\.|(\\\\\\')|[^\\''\\n])*'",'g')};dp.sh.Match=function(value,index,css)
+{this.value=value;this.index=index;this.length=value.length;this.css=css;}
+dp.sh.Highlighter=function()
+{this.noGutter=false;this.addControls=true;this.collapse=false;this.tabsToSpaces=true;this.wrapColumn=80;this.showColumns=true;}
+dp.sh.Highlighter.SortCallback=function(m1,m2)
+{if(m1.index<m2.index)
+return-1;else if(m1.index>m2.index)
+return 1;else
+{if(m1.length<m2.length)
+return-1;else if(m1.length>m2.length)
+return 1;}
+return 0;}
+dp.sh.Highlighter.prototype.CreateElement=function(name)
+{var result=document.createElement(name);result.highlighter=this;return result;}
+dp.sh.Highlighter.prototype.GetMatches=function(regex,css)
+{var index=0;var match=null;while((match=regex.exec(this.code))!=null)
+this.matches[this.matches.length]=new dp.sh.Match(match[0],match.index,css);}
+dp.sh.Highlighter.prototype.AddBit=function(str,css)
+{if(str==null||str.length==0)
+return;var span=this.CreateElement('SPAN');str=str.replace(/ /g,' ');str=str.replace(/</g,'<');str=str.replace(/\n/gm,' <br>');if(css!=null)
+{if((/br/gi).test(str))
+{var lines=str.split(' <br>');for(var i=0;i<lines.length;i++)
+{span=this.CreateElement('SPAN');span.className=css;span.innerHTML=lines[i];this.div.appendChild(span);if(i+1<lines.length)
+this.div.appendChild(this.CreateElement('BR'));}}
+else
+{span.className=css;span.innerHTML=str;this.div.appendChild(span);}}
+else
+{span.innerHTML=str;this.div.appendChild(span);}}
+dp.sh.Highlighter.prototype.IsInside=function(match)
+{if(match==null||match.length==0)
+return false;for(var i=0;i<this.matches.length;i++)
+{var c=this.matches[i];if(c==null)
+continue;if((match.index>c.index)&&(match.index<c.index+c.length))
+return true;}
+return false;}
+dp.sh.Highlighter.prototype.ProcessRegexList=function()
+{for(var i=0;i<this.regexList.length;i++)
+this.GetMatches(this.regexList[i].regex,this.regexList[i].css);}
+dp.sh.Highlighter.prototype.ProcessSmartTabs=function(code)
+{var lines=code.split('\n');var result='';var tabSize=4;var tab='\t';function InsertSpaces(line,pos,count)
+{var left=line.substr(0,pos);var right=line.substr(pos+1,line.length);var spaces='';for(var i=0;i<count;i++)
+spaces+=' ';return left+spaces+right;}
+function ProcessLine(line,tabSize)
+{if(line.indexOf(tab)==-1)
+return line;var pos=0;while((pos=line.indexOf(tab))!=-1)
+{var spaces=tabSize-pos%tabSize;line=InsertSpaces(line,pos,spaces);}
+return line;}
+for(var i=0;i<lines.length;i++)
+result+=ProcessLine(lines[i],tabSize)+'\n';return result;}
+dp.sh.Highlighter.prototype.SwitchToList=function()
+{var html=this.div.innerHTML.replace(/<(br)\/?>/gi,'\n');var lines=html.split('\n');if(this.addControls==true)
+this.bar.appendChild(dp.sh.Toolbar.Create(this));if(this.showColumns)
+{var div=this.CreateElement('div');var columns=this.CreateElement('div');var showEvery=10;var i=1;while(i<=150)
+{if(i%showEvery==0)
+{div.innerHTML+=i;i+=(i+'').length;}
+else
+{div.innerHTML+='·';i++;}}
+columns.className='columns';columns.appendChild(div);this.bar.appendChild(columns);}
+for(var i=0,lineIndex=this.firstLine;i<lines.length-1;i++,lineIndex++)
+{var li=this.CreateElement('LI');var span=this.CreateElement('SPAN');li.className=(i%2==0)?'alt':'';span.innerHTML=lines[i]+' ';li.appendChild(span);this.ol.appendChild(li);}
+this.div.innerHTML='';}
+dp.sh.Highlighter.prototype.Highlight=function(code)
+{function Trim(str)
+{return str.replace(/^\s*(.*?)[\s\n]*$/g,'$1');}
+function Chop(str)
+{return str.replace(/\n*$/,'').replace(/^\n*/,'');}
+function Unindent(str)
+{var lines=dp.sh.Utils.FixForBlogger(str).split('\n');var indents=new Array();var regex=new RegExp('^\\s*','g');var min=1000;for(var i=0;i<lines.length&&min>0;i++)
+{if(Trim(lines[i]).length==0)
+continue;var matches=regex.exec(lines[i]);if(matches!=null&&matches.length>0)
+min=Math.min(matches[0].length,min);}
+if(min>0)
+for(var i=0;i<lines.length;i++)
+lines[i]=lines[i].substr(min);return lines.join('\n');}
+function Copy(string,pos1,pos2)
+{return string.substr(pos1,pos2-pos1);}
+var pos=0;if(code==null)
+code='';this.originalCode=code;this.code=Chop(Unindent(code));this.div=this.CreateElement('DIV');this.bar=this.CreateElement('DIV');this.ol=this.CreateElement('OL');this.matches=new Array();this.div.className='dp-highlighter';this.div.highlighter=this;this.bar.className='bar';this.ol.start=this.firstLine;if(this.CssClass!=null)
+this.ol.className=this.CssClass;if(this.collapse)
+this.div.className+=' collapsed';if(this.noGutter)
+this.div.className+=' nogutter';if(this.tabsToSpaces==true)
+this.code=this.ProcessSmartTabs(this.code);this.ProcessRegexList();if(this.matches.length==0)
+{this.AddBit(this.code,null);this.SwitchToList();this.div.appendChild(this.bar);this.div.appendChild(this.ol);return;}
+this.matches=this.matches.sort(dp.sh.Highlighter.SortCallback);for(var i=0;i<this.matches.length;i++)
+if(this.IsInside(this.matches[i]))
+this.matches[i]=null;for(var i=0;i<this.matches.length;i++)
+{var match=this.matches[i];if(match==null||match.length==0)
+continue;this.AddBit(Copy(this.code,pos,match.index),null);this.AddBit(match.value,match.css);pos=match.index+match.length;}
+this.AddBit(this.code.substr(pos),null);this.SwitchToList();this.div.appendChild(this.bar);this.div.appendChild(this.ol);}
+dp.sh.Highlighter.prototype.GetKeywords=function(str)
+{return'\\b'+str.replace(/ /g,'\\b|\\b')+'\\b';}
+dp.sh.BloggerMode=function()
+{dp.sh.isBloggerMode=true;}
+dp.sh.HighlightAll=function(name,showGutter,showControls,collapseAll,firstLine,showColumns)
+{function FindValue()
+{var a=arguments;for(var i=0;i<a.length;i++)
+{if(a[i]==null)
+continue;if(typeof(a[i])=='string'&&a[i]!='')
+return a[i]+'';if(typeof(a[i])=='object'&&a[i].value!='')
+return a[i].value+'';}
+return null;}
+function IsOptionSet(value,list)
+{for(var i=0;i<list.length;i++)
+if(list[i]==value)
+return true;return false;}
+function GetOptionValue(name,list,defaultValue)
+{var regex=new RegExp('^'+name+'\\[(\\w+)\\]$','gi');var matches=null;for(var i=0;i<list.length;i++)
+if((matches=regex.exec(list[i]))!=null)
+return matches[1];return defaultValue;}
+function FindTagsByName(list,name,tagName)
+{var tags=document.getElementsByTagName(tagName);for(var i=0;i<tags.length;i++)
+if(tags[i].getAttribute('name')==name)
+list.push(tags[i]);}
+var elements=[];var highlighter=null;var registered={};var propertyName='innerHTML';FindTagsByName(elements,name,'pre');FindTagsByName(elements,name,'textarea');if(elements.length==0)
+return;for(var brush in dp.sh.Brushes)
+{var aliases=dp.sh.Brushes[brush].Aliases;if(aliases==null)
+continue;for(var i=0;i<aliases.length;i++)
+registered[aliases[i]]=brush;}
+for(var i=0;i<elements.length;i++)
+{var element=elements[i];var options=FindValue(element.attributes['class'],element.className,element.attributes['language'],element.language);var language='';if(options==null)
+continue;options=options.split(':');language=options[0].toLowerCase();if(registered[language]==null)
+continue;highlighter=new dp.sh.Brushes[registered[language]]();element.style.display='none';highlighter.noGutter=(showGutter==null)?IsOptionSet('nogutter',options):!showGutter;highlighter.addControls=(showControls==null)?!IsOptionSet('nocontrols',options):showControls;highlighter.collapse=(collapseAll==null)?IsOptionSet('collapse',options):collapseAll;highlighter.showColumns=(showColumns==null)?IsOptionSet('showcolumns',options):showColumns;var headNode=document.getElementsByTagName('head')[0];if(highlighter.Style&&headNode)
+{var styleNode=document.createElement('style');styleNode.setAttribute('type','text/css');if(styleNode.styleSheet)
+{styleNode.styleSheet.cssText=highlighter.Style;}
+else
+{var textNode=document.createTextNode(highlighter.Style);styleNode.appendChild(textNode);}
+headNode.appendChild(styleNode);}
+highlighter.firstLine=(firstLine==null)?parseInt(GetOptionValue('firstline',options,1)):firstLine;highlighter.Highlight(element[propertyName]);highlighter.source=element;element.parentNode.insertBefore(highlighter.div,element);}}
@@ -5,76 +5,385 @@ <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> - <title>lloyd/yajl @ GitHub</title> - - <style type="text/css"> - body { - margin-top: 1.0em; - background-color: #b7281a; - font-family: "helvetica"; - color: #ffffff; - } - #container { - margin: 0 auto; - width: 700px; - } - h1 { font-size: 3.8em; color: #48d7e5; margin-bottom: 3px; } - h1 .small { font-size: 0.4em; } - h1 a { text-decoration: none } - h2 { font-size: 1.5em; color: #48d7e5; } - h3 { text-align: center; color: #48d7e5; } - a { color: #48d7e5; } - .description { font-size: 1.2em; margin-bottom: 30px; margin-top: 30px; font-style: italic;} - .download { float: right; } - pre { background: #000; color: #fff; padding: 15px;} - hr { border: 0; width: 80%; border-bottom: 1px solid #aaa} - .footer { text-align:center; padding-top:30px; font-style: italic; } - </style> - + <title>yajl</title> + + <style type="text/css"> + body { + background-color: #D5D6D7; + padding:20px; + text-align: center; + align: center; + } + .header { + border-bottom: 1px solid #959596; + padding: 5px; + color: #ffffff; + background-color: rgb(115, 160, 197); + } + .header a { + text-decoration: none; + color: #ffffff; + } + .pageTitle { + font-size: 3em; + font-weight: normal; + } + .small { font-size: 1em; } + + #outerContainer { + border:1px solid #959596; + font-family: "helvetica"; + color: #000000; + margin: 0 auto; + background-color: #ffffff; + } + #container { + margin-left: auto; + margin-right: auto; + text-align: left; + width: 700px; + color: #333333; + } + h1 { font-size: 3.8em; color: #736f30; margin-bottom: 3px; } + h1 .small { font-size: 0.4em; } + h1 a { text-decoration: none } + h2 { font-size: 1.5em; text-align: center;} + h3 { font-size: 1.2em; color: #111144} + .description { + font-size: 1.2em; + margin-bottom: 30px; + margin-top: 30px; + font-style: italic; + } + .download { float: right; } + pre { background: #000; color: #fff; padding: 15px;} + hr { border: 0; width: 80%; border-bottom: 1px solid #aaa} + .footer { text-align:center; padding-top:30px; font-style: italic; } + .styleCredit { font-size: 75%; } + </style> + </head> <body> <a href="http://github.com/lloyd/yajl"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub" /></a> + <div id="outerContainer"> + <div class="header"> + <span class="pageTitle"> + <a href="http://github.com/lloyd/yajl">yajl</a> + </span><br> + <span class="small"> + by <a href="http://github.com/lloyd">lloyd</a> + </span> + </div> <div id="container"> - - <div class="download"> - <a href="http://github.com/lloyd/yajl/zipball/master"> - <img border="0" width="90" src="http://github.com/images/modules/download/zip.png"></a> - <a href="http://github.com/lloyd/yajl/tarball/master"> - <img border="0" width="90" src="http://github.com/images/modules/download/tar.png"></a> - </div> - - <h1><a href="http://github.com/lloyd/yajl">yajl</a> - <span class="small">by <a href="http://github.com/lloyd">lloyd</a></small></h1> - <div class="description"> - Yet Another JSON Library - A Portable JSON parsing and serialization library in ANSI C </div> - <h2>Authors</h2> -<p>Lloyd Hilaiel (lloyd@hilaiel.com)
<br/>
<br/> </p> -<h2>Contact</h2> -<p>Lloyd Hilaiel (lloyd@hilaiel.com)
<br/> </p> + <h2>Overview</h2> + Yet Another JSON Library. YAJL is a small event-driven + (SAX-style) JSON parser written in ANSI C, and a small + validating JSON generator. YAJL is released under the BSD + license. <h2>Download</h2> <p> - You can download this project in either - <a href="http://github.com/lloyd/yajl/zipball/master">zip</a> or - <a href="http://github.com/lloyd/yajl/tarball/master">tar</a> formats. + <ul> + <li><a href="http://github.com/lloyd/yajl/zipball/0.4.0">yajl-0.4.0.zip</a> + <li><a href="http://github.com/lloyd/yajl/tarball/0.4.0">yajl-0.4.0.tar.gz</a> + <li><a href="http://github.com/lloyd/yajl/zipball/master">yajl-trunk.zip</a> + <li><a href="http://github.com/lloyd/yajl/tarball/master">yajl-trunk.tar.gz</a> + </ul> </p> <p>You can also clone the project with <a href="http://git-scm.com">Git</a> by running: <pre>$ git clone git://github.com/lloyd/yajl</pre> </p> - + + <h2>Features</h2> + + + <h3> Simple Interface </h3> + + Largely because YAJL is event driven, the interface is very concise + object oriented C. The interface is not cluttered with data + representation, that bit is left up to higher level code. Indeed + it should be possible to port most existing JSON libraries onto YAJL + if so desired. + + <h3> portable </h3> + + It's all ANSI C. It's been successfully compiled + on debian linux, OSX 10.4 i386 & ppc, OSX 10.5 i386, winXP, + FreeBSD 4.10, FreeBSD 6.1 amd64, FreeBSD 7 i386, and windows vista. + More platforms and binaries as time permits. + + <h3> Stream parsing </h3> + + YAJL remembers all state required to support restarting parsing. + This allows parsing to occur incrementally as data is read off a + disk or network. + + <h3> Fast </h3> + + A second motivation for writing YAJL, was that many available free + JSON parsers fall over on large or complex inputs. YAJL is careful + to minimize memory copying and input re-scanning when possible. The + result is a parser that should be fast enough for most applications + or tunable for any application. On my mac pro (2.66 ghz) it takes 1s + to verify a 60meg json file. Minimizing that same file with + json_reformat takes 4s. + + <h3> Low resource consumption </h3> + + Largely because YAJL deals with streams, it's possible to parse JSON in + low memory environments. Oftentimes with other parsers an application + must hold both the input text and the memory representation of the + tree in memory at one time. With YAJL you can incrementally read the + input stream and hold only the in memory representation. Or for + filtering or validation tasks, it's not required to hold the entire + input text in memory. + + <h3> sample programs </h3> + + included in the source are a couple sample programs to demonstrate and + test yajl:<br> + <b>json_reformat</b>: a minimizer and beautifier in one.<br/ + <b>json_verify</b>: a JSON verifier. + + <h3> comments in JSON </h3> + + If you're dead set on using JSON throughout your system, you'll + probably end up using it for your configuration files too. A little + crazy, perhaps. But so am I. At parser allocation time you may + specify a configuration parameter to allow comments inside the JSON + input text. This is supported in versions 0.2.0 and above. + + + <h2>Example Programmatic Usage In C</h2> + + <textarea name="code" class="c"> +#include <yajl/yajl_parse.h> +#include <yajl/yajl_gen.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +static int reformat_null(void * ctx) +{ + yajl_gen g = (yajl_gen) ctx; + yajl_gen_null(g); + return 1; +} + +static int reformat_boolean(void * ctx, int boolean) +{ + yajl_gen g = (yajl_gen) ctx; + yajl_gen_bool(g, boolean); + return 1; +} + +static int reformat_number(void * ctx, const char * s, unsigned int l) +{ + yajl_gen g = (yajl_gen) ctx; + yajl_gen_number(g, s, l); + return 1; +} + +static int reformat_string(void * ctx, const unsigned char * stringVal, + unsigned int stringLen) +{ + yajl_gen g = (yajl_gen) ctx; + yajl_gen_string(g, stringVal, stringLen); + return 1; +} + +static int reformat_map_key(void * ctx, const unsigned char * stringVal, + unsigned int stringLen) +{ + yajl_gen g = (yajl_gen) ctx; + yajl_gen_string(g, stringVal, stringLen); + return 1; +} + +static int reformat_start_map(void * ctx) +{ + yajl_gen g = (yajl_gen) ctx; + yajl_gen_map_open(g); + return 1; +} + + +static int reformat_end_map(void * ctx) +{ + yajl_gen g = (yajl_gen) ctx; + yajl_gen_map_close(g); + return 1; +} + +static int reformat_start_array(void * ctx) +{ + yajl_gen g = (yajl_gen) ctx; + yajl_gen_array_open(g); + return 1; +} + +static int reformat_end_array(void * ctx) +{ + yajl_gen g = (yajl_gen) ctx; + yajl_gen_array_close(g); + return 1; +} + +static yajl_callbacks callbacks = { + reformat_null, + reformat_boolean, + NULL, + NULL, + reformat_number, + reformat_string, + reformat_start_map, + reformat_map_key, + reformat_end_map, + reformat_start_array, + reformat_end_array +}; + +static void +usage(const char * progname) +{ + fprintf(stderr, "usage: %s <filename>\n" + " -m minimize json rather than beautify (default)\n" + " -u allow invalid UTF8 inside strings during parsing\n", + progname); + exit(1); + +} + +int +main(int argc, char ** argv) +{ + yajl_handle hand; + static unsigned char fileData[65536]; + /* generator config */ + yajl_gen_config conf = { 1, " " }; + yajl_gen g; + yajl_status stat; + size_t rd; + /* allow comments */ + yajl_parser_config cfg = { 1, 1 }; + + /* check arguments. We expect exactly one! */ + if (argc == 2) { + if (!strcmp("-m", argv[1])) { + conf.beautify = 0; + + } else if (!strcmp("-u", argv[1])) { + cfg.checkUTF8 = 0; + } else { + usage(argv[0]); + } + } else if (argc != 1) { + usage(argv[0]); + } + + g = yajl_gen_alloc(&conf); + + /* ok. open file. let's read and parse */ + hand = yajl_alloc(&callbacks, &cfg, (void *) g); + + for (;;) { + rd = fread((void *) fileData, 1, sizeof(fileData) - 1, stdin); + + if (rd == 0) { + if (feof(stdin)) { + break; + } else { + fprintf(stderr, "error on file read.\n"); + break; + } + } else { + fileData[rd] = 0; + + /* read file data, pass to parser */ + stat = yajl_parse(hand, fileData, rd); + if (stat != yajl_status_ok && + stat != yajl_status_insufficient_data) + { + unsigned char * str = yajl_get_error(hand, 1, fileData, rd); + fprintf(stderr, (const char *) str); + yajl_free_error(str); + } else { + const unsigned char * buf; + unsigned int len; + yajl_gen_get_buf(g, &buf, &len); + fwrite(buf, 1, len, stdout); + yajl_gen_clear(g); + } + } + } + + yajl_gen_free(g); + yajl_free(hand); + + return 0; +} + </textarea> + + <h2>License</h2> + + <pre> + Copyright 2007, Lloyd Hilaiel. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + 3. Neither the name of Lloyd Hilaiel nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING + IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +</pre> + + <h2>Author</h2> + <p>Lloyd Hilaiel (lloyd@hilaiel.com)</p> + <div class="footer"> get the source code on GitHub : <a href="http://github.com/lloyd/yajl">lloyd/yajl</a> </div> - </div> - - + <div class="styleCredit footer"> + (page style "borrowed" from + <a href="http://kylecordes.com">Kyle Cordes</a>) + </div> + + </div></div> </body> + +<link type="text/css" rel="stylesheet" href="dp.SyntaxHighlighter/SyntaxHighlighter.css"></link> +<script language="javascript" src="dp.SyntaxHighlighter/shCore.js"></script> +<script language="javascript" src="dp.SyntaxHighlighter/shBrushCpp.js"></script> +<script language="javascript"> +dp.SyntaxHighlighter.HighlightAll('code'); +</script> </html> |