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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="theme-color" content="#000000">
    <link href="https://fonts.googleapis.com/css?family=Ubuntu+Mono" rel="stylesheet">
   
    <link rel="manifest" href="%PUBLIC_URL%/manifest.json">
 
    <title>React App</title>
  </head>
  <body>
    <noscript>
      You need to enable JavaScript to run this app.
    </noscript>
    <script src ='https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js'></script>
    <div id="root"></div>
  
  </body>
</html>

              
            
!

CSS

              
                body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
    "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

code {
  font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
    monospace;
}

#root{
  display:flex;
  justify-content: center;
  background: #D6A69A;
  height: auto;
  min-height: 100vh;
}

#preview, #editor{
  background: #ECE2D0;
  margin-top: 0px;
  padding: 10px;
  border: solid #403D39 1px;

}

#preview-header, #editor-header{
  background: #CE696E;
  font-weight: bold;
  font-size: 20px;
  padding: 10px;
  margin-bottom: 0px;
  border: solid #403D39 1px;

}

#editor, #editor-header{
  width: 700px;
  box-shadow: 5px 5px 20px;
}

#editor-container{
  display: flex;
  flex-direction: column;
  align-items: center;
}

#preview-container{
  margin: 20px;
}

#editor{
  height: 400px;
}

#preview{
  min-height:400px;
}

#preview, #preview-header{
  width: 900px;
  box-shadow: 5px 5px 20px;

}

pre {
  font-family: 'Ubuntu Mono', monospace;
  background: #F2ECE1;
  border-left: solid;
  border-color: #BBB6DF;
}
code{
  font-family: 'Ubuntu Mono', monospace;
  background: #F2ECE1;
}

table{
  border-collapse: collapse;
}
table, th, td {
  border: 1px solid black;
}


              
            
!

JS

              
                //import React from 'react';
//import ReactDOM from 'react-dom';
//import './index.css';
//import { createStore } from 'redux';
//import { Provider } from 'react-redux';
//import { connect } from 'react-redux';
//import marked from 'marked';

/*app*/


class App extends React.Component{
    constructor(props){
        super(props);
        this.handleInput=this.handleInput.bind(this);
    }

    handleInput(event){
        this.props.onInput(event.target.value);
    }
    render(){
        return(
            <div id="markup-editor">
                <Editor inputValue={this.props.inputValue}
                        handleInput = {this.handleInput}/>
                <Previewer inputValue={this.props.inputValue}/>
            </div>
        );
    }
}

class Editor extends React.Component{
    render(){
        return (
            <div id="editor-container">
                <p id = "editor-header">Editor</p>
                <textarea
                    id="editor"
                    value={this.props.inputValue} 
                    onChange={this.props.handleInput} >
                </textarea>

            </div>
        );
    }
}

class Previewer extends React.Component{
    render(){
        var renderer = new marked.Renderer();
        renderer.link= function(href, title, text){
            return `
                <a title="${title}" href="${href}" target="_blank">${text}</a>
            `
        }
        marked.setOptions({
            renderer: renderer,
            gfm: true,
            tables: true,
            breaks: true,
            pedantic: false,
            sanitize: true,
            smartLists: true,
            smartypants: false
        });
        var markedInput = marked(this.props.inputValue, {sanitize: true});
        let obj = {
            __html: markedInput
        };
        return(
            <div id = "preview-container">
                <p id = "preview-header">Previewer</p>
                <div id ="preview" dangerouslySetInnerHTML={obj} ></div>
            </div>
        );
    }
}


/*State management */

const INPUT = 'INPUT';
const defaultState = {
    input: "# Welcome to my React Markdown Previewer!\n "
            .concat("## This is a\\r sub-heading...\n")
            .concat("### And here's some other cool stuff:\n")
            .concat("Heres some code, `<div></div>`, between 2 backticks.\n\n")
            .concat("```\n")
            .concat("//this is multi-line code:\n\n")
            .concat("function anotherExample(firstLine, lastLine) {\n")
            .concat("\tif (firstLine == '```' && lastLine == '```') {\n")
            .concat("\t\treturn multiLineCode;\n\t}\n}\n```\n\n")
            .concat("You can also make text **bold**... whoa!\n")
            .concat("Or _italic_.\n")
            .concat("Or... wait for it... **_both!_**\n")
            .concat("And feel free to go crazy ~~crossing stuff out~~.\n\n")
            .concat("There's also [links](https://www.freecodecamp.com), and\n")
            .concat("> Block Quotes!\n\n")
            .concat("And if you want to get really crazy, even tables:\n\n")
            .concat("Wild Header | Crazy Header | Another Header?\n")
            .concat("------------ | ------------- | ------------- \n")
            .concat("Your content can | be here, and it | can be here....\n")
            .concat("And here. | Okay. | I think we get it.\n\n")
            .concat("- And of course there are lists.\n")
            .concat("  - Some are bulleted.\n")
            .concat("     - With different indentation levels.\n")
            .concat("        - That look like this.\n\n\n")
            .concat("1. And there are numbererd lists too.\n")
            .concat("1. Use just 1s if you want! \n")
            .concat("1. But the list goes on...\n")
            .concat("- Even if you use dashes or asterisks.\n")
            .concat("* And last but not least, let's not forget embedded images:\n\n")
            .concat("![React Logo w/ Text](https://goo.gl/Umyytc)\n")
};

const changeInput = (userInput) =>{

     
    return {
        type: INPUT,
        userInput,
    };
}

const inputReducer = (state = defaultState, action) => {
    switch(action.type){
        case INPUT:
            return Object.assign(
                {},
                state,
                {input: action.userInput}
            );
        default:
            return state;     
    };
}

const mapStateToProps = (state)=>{
    return {
        inputValue: state.input
    };
}

const mapDispatchToProps = (dispatch) =>{
    return {
        onInput: userInput => dispatch(changeInput(userInput)) 
    };
}

const Component = ReactRedux.connect(mapStateToProps, mapDispatchToProps)(App)

const store = Redux.createStore(inputReducer);

/*conncetion*/
const rootElement = document.getElementById("root");
const Provider = ReactRedux.Provider;

ReactDOM.render(
    <Provider store={store}>
        <Component />
    </Provider>,
    rootElement);


              
            
!
999px

Console