Skip to content

Instantly share code, notes, and snippets.

@arm5077
Created February 23, 2015 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arm5077/839fe379ff8c0612b558 to your computer and use it in GitHub Desktop.
Save arm5077/839fe379ff8c0612b558 to your computer and use it in GitHub Desktop.
Converts a copy-and-pasted table of emails into readable text.
<!doctype html>
<html ng-app="formatApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js"></script>
<style type="text/css">
body {
font-family: Helvetica, sans-serif;
}
#export {
padding: 5px;
border: 1px solid #ccc;
font-size:11pt;
}
#input {
width:50%;
margin-bottom:30px;
}
.email {
padding:10px;
background-color: #ccc;
margin-bottom:50px;
}
</style>
</head>
<body ng-controller="formatController">
<div>Paste the input here:</div>
<textarea id="input" ng-model="input" ></textarea>
<div>And you'll see the output here!</div>
<div id="export" ng-bind-html="format(input)"></div>
</body>
</html>
<script type="text/javascript">
app = angular.module("formatApp", []);
app.controller("formatController", ["$scope", "$sce", function($scope, $sce){
$scope.input = "<p>Some html!</p>";
$scope.format = function(input){
input = input.replace(/\n/g, '</div><div class="email">');
return $sce.trustAsHtml("<div class='email'>" + input + "</div>");
}
}]);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment