Skip to content

Commit a5b53c2

Browse files
committed
Merge pull request #147 from bengotow/master
Make spaces between HTML attributes optional
2 parents e7717e6 + 72b8163 commit a5b53c2

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ The full API docs for Autolinker may be referenced at:
316316
Pull requests definitely welcome.
317317

318318
- Make sure to add tests to cover your new functionality/bugfix.
319-
- Run the `grunt` command to build/test (or alternatively, open the `tests/index.html` file to run the tests).
319+
- Run the `gulp` command to build/test (or alternatively, open the `tests/index.html` file to run the tests).
320320
- When committing, please omit checking in the files in the `dist/` folder after building/testing. These are only committed to the repository for users downloading Autolinker via Bower. I will build these files and assign them a version number when merging your PR.
321321
- Please use tabs for indents! Tabs are better for everybody (individuals can set their editors to different tab sizes based on their visual preferences).
322322

src/htmlParser/HtmlParser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Autolinker.htmlParser.HtmlParser = Autolinker.Util.extend( Object, {
6969

7070
// Zero or more attributes following the tag name
7171
'(?:',
72-
'\\s+', // one or more whitespace chars before an attribute
72+
'\\s*', // any number of whitespace chars before an attribute
7373
nameEqualsValueRegex, // attr="value" (with optional ="value" part)
7474
')*',
7575

tests/AutolinkerSpec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,12 @@ describe( "Autolinker", function() {
11351135
} );
11361136

11371137

1138+
it( "should NOT automatically link an image tag with incorrect HTML attribute spacing", function() {
1139+
var result = autolinker.link( '<img src="https://ssl.gstatic.com/welcome_calendar.png" alt="Calendar" style="display:block;"width="129"height="129"/>' );
1140+
expect( result ).toBe( '<img src="https://ssl.gstatic.com/welcome_calendar.png" alt="Calendar" style="display:block;"width="129"height="129"/>' );
1141+
} );
1142+
1143+
11381144
it( "should NOT automatically link an image tag with a URL inside it, inside an anchor tag", function() {
11391145
var result = autolinker.link( '<a href="http://google.com"><img src="http://google.com/someImage.jpg" /></a>' );
11401146
expect( result ).toBe( '<a href="http://google.com"><img src="http://google.com/someImage.jpg" /></a>' );

0 commit comments

Comments
 (0)