diff --git a/.bowerrc b/.bowerrc new file mode 100644 index 0000000..69fad35 --- /dev/null +++ b/.bowerrc @@ -0,0 +1,3 @@ +{ + "directory": "bower_components" +} diff --git a/.gitignore b/.gitignore index fbe05fc..8e3b2e4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ bower_components/ +node_modules diff --git a/markdown.js b/markdown.js index 08f2248..7b68c89 100644 --- a/markdown.js +++ b/markdown.js @@ -28,7 +28,8 @@ angular.module('btford.markdown', ['ngSanitize']). element.html(html); }); } else { - var html = $sanitize(markdownConverter.makeHtml(element.text())); + var rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g; + var html = $sanitize(markdownConverter.makeHtml(element.text().replace(rtrim, ''))); element.html(html); } } diff --git a/markdown.spec.js b/markdown.spec.js index a6dc3a4..4e6c6bc 100644 --- a/markdown.spec.js +++ b/markdown.spec.js @@ -16,6 +16,12 @@ describe('btfMarkdown', function () { expect(elt.html()).toBe('
hi
'); }); + it('should trim spaces', function () { + var elt = angular.element('hi
'); + }); + it('should work as an attribute', function () { var elt = angular.element('