├── README ├── applescript.js ├── code_highlighter.js ├── css.js ├── html.js ├── index.html ├── javascript.js ├── python.js ├── ruby.js ├── stylesetguide.html └── test.html /README: -------------------------------------------------------------------------------- 1 | CodeHighlighter 0.4 by Dan Webb 2 | ------------------------------- 3 | 4 | CodeHighlighter is a lightweight, unobstrusive and fully configurable script for displaying code examples highlighted in a way similar to the way many text editors highlight code. It weighs in at just under 4K, allows users to configure their own style sets so that you can highlight any language you like and is deployable simply by attaching it to a page with the script tag and adding class names as hooks. It should also play nicely with any other scripts on your page as it has a tiny footprint on the global namespace. 5 | 6 | Many thanks to Dean Edwards who's star-light behaviour inspired this. 7 | Deploying the script 8 | 9 | 1. Add a 7 | 8 | 9 | 10 | 11 | 102 | 103 | 104 |
105 |CodeHighlighter is a lightweight, unobstrusive and fully configurable script for displaying code examples highlighted in a way similar to the way many text editors highlight code. It weighs in at just under 4K, allows users to configure their own style sets so that you can highlight any language you like and is deployable simply by attaching it to a page with the script tag and adding class names as hooks. It should also play nicely with any other scripts on your page as it has a tiny footprint on the global namespace.
107 |Many thanks to Dean Edwards who's star-light behaviour inspired this.
108 |Known to work on:
116 |Known to degrade well on:
123 |Any other feedback for any other browser would be greatly apprieciated. Please email Dan Webb at dan[at]danwebb[dot]net. Have a look through the small examples below.
128 |Have a look at this guide to creating style sets.
130 |Cheers,
Dan
Hopefully, you should be able to put some code inline like this: document.write("bong")
and hopefully it should work.
/*
135 | This script detects external links in a page
136 | and attaches a behaviour to them so they open
137 | in a external window.
138 | */
139 |
140 | function initialiseLinks() {
141 | if (document.getElementsByTagName) {
142 | var links = document.getElementsByTagName("A");
143 | for (var i = 0; i < links.length; i++) {
144 | if (links[i].href.indexOf("http:")==0) {
145 | // if the links URL starts with http: then we assume it's an external link
146 | links[i].onclick = function() {
147 | window.open(this.href);
148 | return false; // stop normal link behaviour
149 | }
150 | }
151 | }
152 | }
153 | }
154 |
155 | window.onload = initialiseLinks();
156 | .javascript .comment {
158 | color : green; /* ffbgffg */
159 | }
160 |
161 | .javascript .string {
162 | color : maroon;
163 | }
164 |
165 | .javascript .keywords {
166 | font-weight : bold;
167 | }
168 |
169 | .javascript .global {
170 | color : blue;
171 | font-weight: bolder;
172 | }
173 |
174 | .javascript .brackets {
175 | color : Gray;
176 | }
177 |
178 | .javascript .thing {
179 | font-size : 10px;
180 | background : url(ghgfhfg gh f.rtjhf);
181 | }
182 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
184 | <html xmlns="http://www.w3.org/1999/xhtml">
185 | <head>
186 | <title>CodeHighlighter example</title>
187 | <!-- This is all you need to do to get CodeHighlighter working -->
188 | <script type="text/javascript" src="CodeHighlighter.js"> </script>
189 | <script type="text/javascript" src="html.js"> </script>
190 | </head>
191 | <body>
192 | <p>Put your pre tags here!</p>
193 | </body>
194 | </html>
195 |
196 | def login
198 | if !@params[:key].nil? && @attendee = Attendee.find_by_hashkey(@params[:key])
199 | # coming in with valid key
200 | if !@attendee.password_set?
201 | # no password yet, let them in
202 | @session[:attendee] = @attendee
203 | redirect_to :action => 'preferences', :id => @attendee.event.uri
204 | else
205 | @event = @attendee.event
206 | end
207 | else
208 | # if no key we need to know the event
209 | @event = get_event_by_id_or_uri
210 | end
211 |
212 | if @request.post?
213 | # posted login details
214 | if @attendee = Attendee.authenticate(@event, @params[:email], @params[:password])
215 | @session[:attendee] = @attendee
216 | redirect_to :action => 'preferences', :id => @event.uri
217 | else
218 | flash['notice'] = 'Login unsuccessful.'
219 | end
220 | end
221 |
222 | if @attendee.nil?
223 | @email = ''
224 | else
225 | @email = @attendee.email
226 | end
227 | end
228 |
229 |