Created
January 9, 2014 07:03
-
-
Save dsci/8330467 to your computer and use it in GitHub Desktop.
Revisions
-
dsci created this gist
Jan 9, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ A Pen by Daniel Schmidt ----------------------- A [Pen](http://codepen.io/dsci/pen/Istpa) by [Daniel Schmidt](http://codepen.io/dsci) on [CodePen](http://codepen.io/). [License](http://codepen.io/dsci/pen/Istpa/license). This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ <div ng-app="markdownApp"> <nav class="navbar navbar-default"> <a class="navbar-brand" href="#">Markdown Editor</a> </nav> <div ng-controller="markdownController" class="pure-g"> <div class="pure-u-1-2" id="source-editor"> <p class="md-introduction"> Your Markdown here. </p> <textarea ng-model="editor.source"> </textarea> <p id="compile-btn"> <button ng-click="compile()">Show me the HTML</button> </p> <div id="raw-source" ng-show="rawSource"><pre>{{rawSource}}</pre></div> </div> <div class="pure-u-1-2"> <p>Your preview here.</p> <div id="preview"> <p ng-bind-html="editor.compiled"></p> </div> </div> </div> </div> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ var markdownCompilerModule = angular.module('mdown', []); markdownCompilerModule.factory('Compiler', function(){ return { compile: function(source){ return window.marked(source); } } }); var markdownApp = angular.module("markdownApp", ['ngSanitize', 'mdown']); var markdownController = function($scope, Compiler){ $scope.editor = { source: "", compiled: "" } $scope.compile = function(){ if($scope.editor.source.length != 0){ $scope.editor.compiled = Compiler.compile($scope.editor.source); $scope.rawSource = $scope.editor.compiled; }else{ alert("Whoops. It seems you haven't start typing yet!"); } } $scope.$watch('editor.source', function(source){ if(source){ $scope.editor.compiled = Compiler.compile(source); } }); } // Inject dependencies. Good for minification. markdownController.$inject = ['$scope', 'Compiler']; // Name the controllers for the app. markdownApp.controller("markdownController", markdownController); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ @import "compass"; @import url(http://fonts.googleapis.com/css?family=Source+Code+Pro:400,500); @import url(http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz); $mdBorder: 1px solid #cccccc; $leftMargin: 10px; $leftBoxWidth: 95%; button { @include button; } #source-editor{} #source-editor textarea{ height: 300px; width: $leftBoxWidth; font-family: 'Source Code Pro', sans-serif; background-color: #ddddddd; margin-left: $leftMargin; } #source-editor textarea, #preview{ border: $mdBorder; } #source-editor #raw-source{ padding-left: $leftMargin; width: $leftBoxWidth; } #preview{ font-family: 'Yanone Kaffeesatz', sans-serif; min-height: 300px; padding-left: $leftMargin; padding-right: $leftMargin; width:98%; } #compile-btn{ padding: $leftMargin; } .md-introduction{ margin-left: $leftMargin; }