|
4 | 4 | * License: MIT |
5 | 5 | */ |
6 | 6 |
|
7 | | -/* |
8 | | -
|
9 | | - TODO: tests: |
10 | | - |
11 | | - <marked>##TEXT 1</marked> |
12 | | - <div marked>##TEXT 2</div> |
13 | | - <div ng-init="scope_element = '##TEST 4'"><div marked="scope_element"></div></div> |
14 | | - <div marked="'##TEXT 3'"></div> |
15 | | - <div marked opts="{gfm: true}"></div> |
16 | | - <div marked ng-include="'filename.md'"></div> |
17 | | - |
18 | | -*/ |
| 7 | +/* jshint undef: true, unused: true */ |
| 8 | +/* global angular:true */ |
| 9 | +/* global marked:true */ |
19 | 10 |
|
20 | 11 | (function () { |
| 12 | + 'use strict'; |
21 | 13 |
|
22 | 14 | var app = angular.module('hc.marked', []); |
23 | 15 |
|
24 | 16 | app.constant('marked', marked); |
25 | 17 |
|
26 | | - //TODO: filter |
| 18 | + // Maybe this is better? |
| 19 | + //app.service('marked', ['$window', function($window) { |
| 20 | + // return $window.marked; |
| 21 | + //}]); |
| 22 | + |
| 23 | + // TODO: filter tests */ |
| 24 | + //app.filter('marked', ['marked', function(marked) { |
| 25 | + // return marked; |
| 26 | + //}]); |
27 | 27 |
|
28 | | - app.directive("marked", ['$http', 'marked', function ($http, marked) { |
| 28 | + app.directive('marked', ['marked', function (marked) { |
29 | 29 | return { |
30 | 30 | restrict: 'AE', |
31 | 31 | replace: true, |
|
34 | 34 | marked: '=' |
35 | 35 | }, |
36 | 36 | link: function (scope, element, attrs) { |
37 | | - var value = scope.marked || element.text()|| ''; |
| 37 | + var value = scope.marked || element.text() || ''; |
38 | 38 | element.html(marked(value, scope.opts || null)); |
39 | 39 |
|
40 | 40 | if (attrs.marked) |
41 | 41 | scope.$watch('marked', function(value) { |
42 | | - element.html(marked(scope.marked || '', scope.opts || null)); |
| 42 | + element.html(marked(value || '', scope.opts || null)); |
43 | 43 | }); |
44 | 44 |
|
45 | 45 | } |
|
0 commit comments