From c209cc3ffcd2e7a7305423bccb8588c034ae041e Mon Sep 17 00:00:00 2001 From: steve mao Date: Mon, 22 Sep 2014 13:31:27 +1000 Subject: [PATCH 1/2] fix(packages): ignore node_modules, set bower path --- .bowerrc | 3 +++ .gitignore | 1 + 2 files changed, 4 insertions(+) create mode 100644 .bowerrc 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 From a166d532c71f50c36b20ba7b543d87a6cbfa1963 Mon Sep 17 00:00:00 2001 From: steve mao Date: Mon, 22 Sep 2014 13:37:45 +1000 Subject: [PATCH 2/2] fix(makeHtml): trim space before parse it to html --- markdown.js | 3 ++- markdown.spec.js | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) 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* '); + $compile(elt)($rootScope); + expect(elt.html()).toBe('

hi

'); + }); + it('should work as an attribute', function () { var elt = angular.element('
*hi*
'); $compile(elt)($rootScope);