diff --git a/README.md b/README.md index 4d858ae0..568384af 100644 --- a/README.md +++ b/README.md @@ -241,7 +241,7 @@ var defaultOptions = showdown.getDefaultOptions();

foo

``` - * **parseImgDimensions**: (boolean) [default false] Enable support for setting image dimensions from within markdown syntax. + * **parseImgDimensions**: (boolean) [default true] Enable support for setting image dimensions from within markdown syntax. Examples: ``` ![foo](foo.jpg =100x80) simple, assumes units are in px diff --git a/docs/available-options.md b/docs/available-options.md index 9cbc3c05..71ced37c 100644 --- a/docs/available-options.md +++ b/docs/available-options.md @@ -475,7 +475,7 @@ Open links in new windows. Set image dimensions from within Markdown syntax. * type: `boolean` -* default value: `false` +* default value: `true` * introduced in: `1.1.0` === "example" diff --git a/src/options.js b/src/options.js index 19deb667..addd830c 100644 --- a/src/options.js +++ b/src/options.js @@ -42,7 +42,7 @@ function getDefaultOpts (simple) { type: 'integer' }, parseImgDimensions: { - defaultValue: false, + defaultValue: true, describe: 'Turn on/off image dimension parsing', type: 'boolean' }, diff --git a/src/subParsers/makehtml/images.js b/src/subParsers/makehtml/images.js index e7fbbc1d..8b28537d 100644 --- a/src/subParsers/makehtml/images.js +++ b/src/subParsers/makehtml/images.js @@ -75,7 +75,7 @@ showdown.subParser('makehtml.images', function (text, options, globals) { result += ' title="' + title + '"'; } - if (width && height) { + if (options.parseImgDimensions && width && height) { width = (width === '*') ? 'auto' : width; height = (height === '*') ? 'auto' : height; diff --git a/test/functional/makehtml/cases/features/#143.not.support-image-dimensions.html b/test/functional/makehtml/cases/features/#143.not.support-image-dimensions.html new file mode 100644 index 00000000..0bc6a8a3 --- /dev/null +++ b/test/functional/makehtml/cases/features/#143.not.support-image-dimensions.html @@ -0,0 +1,2 @@ +

my image

+

my image2

diff --git a/test/functional/makehtml/cases/features/#143.not.support-image-dimensions.md b/test/functional/makehtml/cases/features/#143.not.support-image-dimensions.md new file mode 100644 index 00000000..ecbd02f5 --- /dev/null +++ b/test/functional/makehtml/cases/features/#143.not.support-image-dimensions.md @@ -0,0 +1,5 @@ +![my image](./pic/pic1_50.png =100pxx20px) + +![my image2][1] + +[1]: ./pic/pic1_50.png =100pxx20px diff --git a/test/functional/makehtml/testsuite.features.js b/test/functional/makehtml/testsuite.features.js index 2ef6c38e..62d89bc0 100644 --- a/test/functional/makehtml/testsuite.features.js +++ b/test/functional/makehtml/testsuite.features.js @@ -32,6 +32,8 @@ describe('makeHtml() features testsuite', function () { var converter; if (testsuite[i].name === '#143.support-image-dimensions') { converter = new showdown.Converter({parseImgDimensions: true}); + } else if (testsuite[i].name === '#143.not.support-image-dimensions') { + converter = new showdown.Converter({parseImgDimensions: false}); } else if (testsuite[i].name === '#69.header-level-start') { converter = new showdown.Converter({headerLevelStart: 3}); } else if (testsuite[i].name === '#164.1.simple-autolink' || testsuite[i].name === '#204.certain-links-with-at-and-dot-break-url') {