marky.js

Usage

Using marky.js is easy!

To style some code, just wrap it in a `.codeSection` block.

For example, the following code ...

function myFunction() { var x = 5, y = 10; return x+y; } myFunction();

... renders as ...

function myFunction() { var x = 5, y = 10; return x+y; } myFunction();

However, you can use any tag to contain your code. For example, use a `textarea` block if you want to prevent the browser from "cleaning" your code.

JavaScript Tests

Single line of code:

var x = 5;

Multiple lines of code:

if (x>=1) { x=2; if (y==3) { y=4; } }

Variations on Operations and Syntax:

var x = { "key":"value", "key1": { "key2" : [1, 2, 3, "hello"] }, "key_3": /someRegExp/ };

Inline and Multiline Comments:

var x=5; // This is a comment (5+4); var y=6; /* And So is this */ var z = "Jimmy's friend said, \"Hey!\""; //Jimmy's! "COMMENTS!" // ... And more!
if ([]) console.log("TRUE!"); if (+[]) console.log("TRUE!");

Console Snippet

>>> 2+2; 4

Uber jQuery Snippet (as textarea)

Python Tests

Basic Function Declaration:

def myFunction(): print "Hello world!"

Comprehensions:

newList = [elem for elem in oldList] newDict = {elem:val for elem,val in oldDict.items()} newSet = {elem for elem in oldSet}

Basic Control Flow

from myModule import myFunction for item in iterator: if item and True: myFunction(item)

Comments

y = 2+2 """ This is a comment """ x = 5%5 # This is a comment. return x+y

Ruby Tests

Comments Galore

=begin This is a comment! =end x = (2+2) defined? x #>Should be defined! __END__ And so is this! 2+2 "asdf" and this # yup!
x = "Hello world!" y.someMethod? y.add(x) puts y
for i in 1...10 print "#", i end puts "Tada!" #End of Program!

HTML Tests

Basic HTML with comment:

hello
Not a comment!

Some link!

Deeply nested tags, a custom tag, and strange capitalization as div (should be "cleaned" by browser):

Hello world!

Same test as above but with textarea (should be "raw"):

CSS Style applied to HTML plus a Doctype

Bash Tests

Basic commands

cd ./static/
mv ../old.txt new.md
#!/bin/bash if [ "foo" = "foo" ]; then echo "Hello world!" else echo "Goodbye world!" fi

Command with Options:

find . -type f "*.py" -exec grep -nr "some string"

Nginx Tests

Documentation's "Example Config"

user www www; ## Default: nobody worker_processes 5; ## Default: 1 error_log logs/error.log; pid logs/nginx.pid; worker_rlimit_nofile 8192; events { worker_connections 4096; ## Default: 1024 } http { include conf/mime.types; include /etc/nginx/proxy.conf; include /etc/nginx/fastcgi.conf; index index.html index.htm index.php; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] $status ' '"$request" $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log logs/access.log main; sendfile on; tcp_nopush on; server_names_hash_bucket_size 128; # this seems to be required for some vhosts server { # php/fastcgi listen 80; server_name domain1.com www.domain1.com; access_log logs/domain1.access.log main; root html; location ~ \.php$ { fastcgi_pass 127.0.0.1:1025; } } server { # simple reverse-proxy listen 80; server_name domain2.com www.domain2.com; access_log logs/domain2.access.log main; # serve static files location ~ ^/(images|javascript|js|css|flash|media|static)/ { root /var/www/virtual/big.server.com/htdocs; expires 30d; } # pass requests for dynamic content to rails/turbogears/zope, et al location / { proxy_pass http://127.0.0.1:8080; } } upstream big_server_com { server 127.0.0.3:8000 weight=5; server 127.0.0.3:8001 weight=5; server 192.168.0.1:8000; server 192.168.0.1:8001; } server { # simple load balancing listen 80; server_name big.server.com; access_log logs/big.server.access.log main; location / { proxy_pass http://big_server_com; } } }
server { server_name MyDjangoApp MyDjangoApp.co.vu; root /var/www/MyAppFiles; access_log /var/www/MyAppFiles/access.log; error_log /var/www/MyAppFiles/error.log; location /static/ { alias /var/www/MyAppFiles/static/; if ($query_string) { expires max; } } location / { include /etc/nginx/ uwsgi_pass 127.0.0.1:49517; } }

UWSGI Tests

[uwsgi] plugins = python chdir=/var/www/MyAppFiles/ module=MyDjangoApp.wsgi:application env DJANGO_SETTINGS_MODULE=MyDjangoApp.settings master = True socket=127.0.0.1:49157 processes=5 harakiri=60 max-requests=5000 vacuum = True daemonize=/var/www/MyAppFiles/uwsgi.log

Misc. Tests

Language-ambiguous code:

x = 5; x += 2;

Completely invalid code:

!@#I%$5i934i5034oklersf;

Empty code: