Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <pre class="syntax-csharp">
public static class Something : From
{
	void Ohyeah(int num) { }
}

public override bool ShouldUseSharedBuildEnvironment(TargetInfo Target)
{
	return true;
}

while(true)
{
	if ( leftPressed )
		rotateShipLeft(); // Comment

	if ( rightPressed )
		rotateShipRight(); // And another comment. Yes. Alright

	/*
		Big comment
		Quisque sagittis auctor volutpat.
		Mauris nec elementum ligula, non vestibulum nibh.
		Phasellus dapibus vulputate ligula eu egestas.
		Proin rutrum urna felis, pellentesque tempus metus pretium vel.
	*/

	drawShip(); /** lol */

	/*
		Something
	*/
}
</pre>

<pre class="syntax-html">
<a href="#" title="Html soemthiggbg" id="prev-post">Name
	<span>10.10.2013</span>
	<!-- comment -->
</a>
<!-- efefew
f
ew
wfwefwefwefewew
-->
</pre>

<pre class="syntax-csharp">
randomvalue = Random.Range(1,5);
GameObject newbox = (GameObject)Instantiate(Woodbox, transform.position, Quaternion.identity);
newbox.AddComponent<Rigidbody>();
//long comment.. Morbi neque justo, tincidunt at euismod vitae, rutrum in enim. Aliquam ante dui, suscipit ut diam lacinia, varius elementum felis. Phasellus sit amet mattis diam. Mauris vel lectus malesuada, feugiat massa quis, vehicula purus.
StartCoroutine(NewWoodBoxTime(randomvalue));
Destroy(newbox.gameObject,6f);
</pre>

<pre class="syntax-csharp">
// It's just an example!!! Brought from UE4 code (all rights to Epic Games)
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.

using UnrealBuildTool;
using System.Collections.Generic;

public class UE4ClientTarget : TargetRules
{

	public UE4ClientTarget(TargetInfo Target)
	{
		Type = TargetType.Client;
		bOutputToEngineBinaries = true;
	}

	//
	// TargetRules interface.
	//
	public override void SetupBinaries(
		TargetInfo Target,
		ref List<UEBuildBinaryConfiguration> OutBuildBinaryConfigurations,
		ref List<string> OutExtraModuleNames
		)
	{
		base.SetupBinaries(Target, ref OutBuildBinaryConfigurations, ref OutExtraModuleNames);
		OutExtraModuleNames.Add("UE4Game");
	}

	public override void SetupGlobalEnvironment(
		TargetInfo Target,
		ref LinkEnvironmentConfiguration OutLinkEnvironmentConfiguration,
		ref CPPEnvironmentConfiguration OutCPPEnvironmentConfiguration
		)
	{
	}

	public override bool ShouldUseSharedBuildEnvironment(TargetInfo Target)
	{
		return true;
	}

	public override void GetModulesToPrecompile(TargetInfo Target, List<string> ModuleNames)
	{
		// Add all the precompiled modules for this target
		ModuleNames.Add("Launch");
		ModuleNames.Add("InputDevice");
		ModuleNames.Add("GameMenuBuilder");
		ModuleNames.Add("GameplayAbilities");
		ModuleNames.Add("XmlParser");
		ModuleNames.Add("UE4Game");
		ModuleNames.Add("AITestSuite");
		ModuleNames.Add("RuntimeAssetCache");
		ModuleNames.Add("UnrealCodeAnalyzerTests");
		if (Target.Platform == UnrealTargetPlatform.Win32 || Target.Platform == UnrealTargetPlatform.Win64)
		{
			ModuleNames.Add("OnlineSubsystemNull");
			ModuleNames.Add("OnlineSubsystemAmazon");
			if (UEBuildConfiguration.bCompileSteamOSS == true)
			{
				ModuleNames.Add("OnlineSubsystemSteam");
			}
			ModuleNames.Add("OnlineSubsystemFacebook");
		}
		else if (Target.Platform == UnrealTargetPlatform.Mac || Target.Platform == UnrealTargetPlatform.Linux)
		{
			ModuleNames.Add("OnlineSubsystemNull");
			if (UEBuildConfiguration.bCompileSteamOSS == true)
			{
				ModuleNames.Add("OnlineSubsystemSteam");
			}
		}
		else if (Target.Platform == UnrealTargetPlatform.IOS)
		{
			ModuleNames.Add("OnlineSubsystemFacebook");
			ModuleNames.Add("OnlineSubsystemIOS");
			ModuleNames.Add("IOSAdvertising");
			ModuleNames.Add("MetalRHI");
		}
		else if (Target.Platform == UnrealTargetPlatform.Android)
		{
			// @todo android: Add Android online subsystem
			ModuleNames.Add("AndroidAdvertising");
		}
		else if (Target.Platform == UnrealTargetPlatform.HTML5)
		{
			ModuleNames.Add("OnlineSubsystemNull");
		}
	}

	public override List<UnrealTargetPlatform> GUBP_GetPlatforms_MonolithicOnly(UnrealTargetPlatform HostPlatform)
	{
		List<UnrealTargetPlatform> Platforms = null;

		switch(HostPlatform)
		{
			case UnrealTargetPlatform.Mac:
				Platforms = new List<UnrealTargetPlatform> { HostPlatform, UnrealTargetPlatform.IOS };
				break;

			case UnrealTargetPlatform.Linux:
				Platforms = new List<UnrealTargetPlatform> { HostPlatform };
				break;

			case UnrealTargetPlatform.Win64:
				Platforms = new List<UnrealTargetPlatform> { HostPlatform, UnrealTargetPlatform.Win32, UnrealTargetPlatform.Linux /*, UnrealTargetPlatform.IOS, UnrealTargetPlatform.XboxOne, UnrealTargetPlatform.PS4 */};
				break;

			default:
				Platforms = new List<UnrealTargetPlatform>();
				break;
		}

		return Platforms;
	}

	public override List<UnrealTargetConfiguration> GUBP_GetConfigs_MonolithicOnly(UnrealTargetPlatform HostPlatform, UnrealTargetPlatform Platform)
	{
		return new List<UnrealTargetConfiguration> { UnrealTargetConfiguration.Development };
	}
}
</pre>
              
            
!

CSS

              
                /* CODE BLOCK */
.code
{
	display: block;
	max-height: 500px;
	width: 100%;
	margin: 20px 0;
	font-family: monospace;
	font-size: 13px;
	line-height: 23px;
	position: relative;
	overflow: auto
}

.code .numbers, .code .source { float: left }

.code .numbers
{
	padding: 10px;
	text-align: right
}

.code .source { padding: 10px 0 }
.code .source .line:nth-child(2n) { }
.code .source .line { padding: 0 10px }
.code .source .comment { font-style: italic }

.code .copy
{
	position: absolute;
	right: 10px;
	top: 5px;
	font-size: 12px;
	text-decoration: underline;
	cursor: pointer
}

/* STYLES for CODE*/
.code-style-light
{
	color: #444;
	background: #f5f5f5;
}
.code-style-light .numbers
{
	color: #999;
	background: #fff;
}
.code-style-light .source .line:nth-child(2n) {background: #f2f2f2}
.code-style-light .source .comment {color: #3FAB46}

/* CSharp */
.code-style-light .source .c-pppvaovcsn {color: #E05366}
.code-style-light .source .c-iescbrnu {color: #6593E0}

.code-style-dark
{
	color: #E6E6E6;
	background: #333;
}
.code-style-dark .numbers
{
	color: #999;
	background: #fff;
}
.code-style-dark .source .line:nth-child(2n) {background: #363636}
.code-style-dark .source .comment {color: #588A5B}

/* CSharp */
.code-style-dark .source .sharp-keywords {color: #DF5D6E}
.code-style-dark .source .sharp-default-types {color: #718DBD}
              
            
!

JS

              
                $(document).ready(function() {
	$('pre').makeCode({style: 'code-style-dark', addons: [{ name: 'js', parser: javascriptCode }]});
});

var javascriptCode = function(text) {
	return text;
};

// All shit

var csharpCode = function(text) {
	var comment = false;
	var lines = text.split('\n');
	text = '';

	for(var i = 0; i < lines.length; i++) {
		var line = lines[i];

		line = line.replace(/(public|private|protected|static|virtual|abstract|override|class|struct|new)\b/ig, '<span class="sharp-keywords">$1</span>')
					.replace(/\b(if|else|switch|case|break|return|namespace|using|while|bool|int|float|double|true|false|void)\b/ig, '<span class="sharp-default-types">$1</span>')
					.replace(/(\/\/(.*)$)/g, '<span class="comment">$1</span>');

		if (!comment) // Multiline comments shit
		{
			var result1 = line.match(/\/\*([\s\S]*?)\*\//ig);

			if(result1 != null)
			{
				for(var r = 0; r < result1.length; r++)
				{
					line = line.replace(result1[r], '<span class="comment">$&</span>');
				}
			}
			else
			{
				var result = line.match(/\/\*([\s\S]*?)[\s\S]*/i);

				if(result != null)
				{
					line = line.replace(result[0], '<span class="comment">$&</span>');

					comment = true;
				}
			}
		}
		else
		{
			var result = line.match(/[\s\S]*\*\/|\*\//);

			if(result != null)
			{
				line = line.replace(result[0], '<span class="comment">$&</span>');

				comment = false;
			}
			else
			{
				line = '<span class="comment">' + line + '</span>';
			}
		}

		text += line;
		if (i != lines.length - 1)
			text += '\n';
	}

	return text;
};

var htmlCode = function(text) {
	return text;
};

(function($) {

	$.fn.makeCode = function(options) {

		var settings = $.extend({
			style: 'code-style-light',
			selectLabel: 'Select',
			addons: []
		}, options);

		var defaultAddons = [
			{ name: 'csharp', parser: csharpCode },
			{ name: 'html', parser: htmlCode }
		];

		options.addons = options.addons.concat(defaultAddons);
		defaultAddons = null;

		//replace html tags
		function replaceTag(tag) {
			var tagsToReplace = { '&': '&amp;', '<': '&lt;', '>': '&gt;' };
			return tagsToReplace[tag] || tag;
		}
		function safe_tags_replace(str) {
			return str.replace(/[&<>]/g, replaceTag);
		}

		function getAddon(name)	{
			var result = null;
			options.addons.forEach(function(item, i, arr) {
				if(item.name == name)
					result = item;
			});
			return result;
		}

		$(this).each(function() {
			$this = $(this);
			var syntax = $this.prop('class').replace('syntax-', '');
			var text = $this.html();

			text = safe_tags_replace(text);

			var addon = getAddon(syntax);

			if(addon != null)
				text = addon.parser(text);

			var splitter = text.split(/\n/);

			text = '';

			for(var s = 0; s < splitter.length-1; s++) {
				if(splitter[s].length > 0) {
					text += '<div class="line">' + splitter[s].replace(/^ +/gm, '\t').replace(/\t/g, '&nbsp;&nbsp;&nbsp;&nbsp;') + '</div>';
				} else {
					text += '<div class="line"><br></div>';
				}
			}

			$this.before('<div class="code ' + settings.style + '"><div class="copy">' + settings.selectLabel + '</div><div class="numbers"></div><div class="source">' + text + '</div><div class="clear"></div></div>');

			for(var i = 1; i < splitter.length; i++) {
				var height = $this.prev().find('.source .line').eq(i-1).height();
				$this.prev().find('.numbers').append('<div style="height: ' + height + 'px">' + i + '</div>');
			}

			$this.prev().find('.source').width($this.prev().width() - ($this.prev().find('.numbers').width() + 37));
			$this.remove();
		});

		// fixed link
		$('.code').scroll(function() {
			var top = $(this).scrollTop();
			$(this).find('.copy').css('top', top + 5);
		});

		// select a code
		$('.code .copy').on('click', function(e) {
			selectText(this.parentNode.getElementsByClassName('source')[0]);
		});

		// select a line of code
		$('.code .numbers div').on('click', function(e) {
			var line = $(this).parent().parent().find('.source .line').eq($(this).index());
			selectText(line.get(0));
		});

		$(window).resize(function() {
			// --- ?
		});

		function selectText(node)
		{
			var e = node, s, r;

			if(window.getSelection) {
				s = window.getSelection();
				r = document.createRange();
				r.selectNodeContents(e);
				s.removeAllRanges();
				s.addRange(r);
			} else if(document.selection) {
				r = document.body.createTextRange();
				r.moveToElementText(e);
				r.select();
			}
		}
	};

}(jQuery));

              
            
!
999px

Console