Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

Save Automatically?

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

              
                <div class="container" id="container">
	<div class="row">
		<div class="col-12">
			<h1 class="text-center">GitHub Markdown Viewer</h1>
		</div>

		<div class="col-12 mb-5">
				<div class="text-center">
					<p>
						Use the toggle to switch between 
						black text and white background or 
						white text on black background for the text 						input area and the text output area.
					</p>
				</div>
				
				<div class="d-flex justify-content-center">
					<div class="toggle-btn active">
					<input type="checkbox" checked class="cb-value" />
					<span class="round-btn"></span>
				</div>
			</div>
		</div>
	</div>

	<div id="markDown" class="markDown">
	</div>
</div>
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css?family=Montserrat")

.container
	margin-top: 25px

body
	font-family: Montserrat, sans-serif

textarea
	resize: none
	width: 100%
	height: 400px
	padding: 10px

.outputText
	border-top: 1px solid #000
	padding-top: 25px
	width: 100%
	height: 400px
	padding: 10px

.drk-color
	background-color: #000
	color: #fff

.toggle-btn
	width: 80px
	height: 40px
	margin: 10px
	border-radius: 50px
	display: inline-block
	position: relative
	cursor: pointer
	background-color: #000
	-webkit-transition: background-color .40s ease-in-out
	-moz-transition: background-color .40s ease-in-out
	-o-transition: background-color .40s ease-in-out
	transition: background-color .40s ease-in-out
	cursor:pointer
	&.active
		background-color: #fff
		border: 1px solid #000
		.round-btn
			left: 45px
			background-color: #000

.round-btn
	width: 30px
	height: 30px
	background-color: #fff
	border-radius: 50%
	display: inline-block
	position: absolute
	left: 5px
	top: 50%
	margin-top: -15px
	-webkit-transition: all .30s ease-in-out
	-moz-transition: all .30s ease-in-out
	-o-transition: all .30s ease-in-out
	transition: all .30s ease-in-out


.cb-value
	position: absolute
	left: 0
	right: 0
	width: 100%
	height: 100%
	opacity: 0
	z-index: 9
	cursor:pointer
	
              
            
!

JS

              
                var MarkdownContainer = React.createClass({
	transMarkdown:function(someText){
		return{
			__html: marked(someText)
		};
	},
	getInitialState:function(){
		var someText ="This is __MARKDOWN__!"+
		"\n\nUse GitHub Flavored Markdown\n=======\n\n";
		
		return{
			text: someText,
			markedText: this.transMarkdown(someText)
		};
	},
	changedText:function(){
		var changed = event.target.value
    this.setState({
      text: changed,
      markedText: this.transMarkdown(changed)
    });
	},
	render: function(){
		return(
			<div className="row">
				<div className="col-lg-6 col-sm-12">
					<h1 className="text-center">Input Text here:</h1>
					
					<textarea id="editor" className="textBox" autofocus={true} value={this.state.text} onChange= {this.changedText}></textarea>
				</div>
			
				<div className="col-lg-6 col-sm-12">
					<h1 className="text-center">Output Text here:</h1>
          <div id="preview" className="outputText" dangerouslySetInnerHTML={this.state.markedText} />
				</div>
			</div>
		);
	}
});

React.render(
  <MarkdownContainer />,
  document.getElementById("markDown")
);

$('.cb-value').click(function() {
  var mainParent = $(this).parent('.toggle-btn');
  if($(mainParent).find('input.cb-value').is(':checked')) {
    $(mainParent).addClass('active');
		$(".textBox").removeClass("drk-color");
		$(".outputText").removeClass("drk-color");
		$("span").addClass("round-btn-drk");
  } else {
    $(mainParent).removeClass('active');
		$(".textBox").addClass("drk-color");
		$(".outputText").addClass("drk-color");
  }
});
              
            
!
999px

Console