Skip to content

fix: properly handle a false value for the parseImgDimensions option#985

Open
paviad wants to merge 2 commits into
showdownjs:masterfrom
paviad:parse-image-dimensions-fix
Open

fix: properly handle a false value for the parseImgDimensions option#985
paviad wants to merge 2 commits into
showdownjs:masterfrom
paviad:parse-image-dimensions-fix

Conversation

@paviad

@paviad paviad commented Jul 11, 2023

Copy link
Copy Markdown

Contains two fixes:

  1. Change the default value of the parseImgDimensions option to true (also in documentation)
  2. Properly reject image dimensions when the option is set to false

Closes #984

@joshiayush joshiayush left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just add options.parseImgDimensions down in the if clause:

    if (options.parseImgDimensions && width && height) {
      width  = (width === '*') ? 'auto' : width;
      height = (height === '*') ? 'auto' : height;
      result += ' width="' + width + '"';
      result += ' height="' + height + '"';
    }

Look, the desired behaviour should be this.

Comment thread src/subParsers/makehtml/images.js Outdated
@qlty-cloud-legacy

Copy link
Copy Markdown

Code Climate has analyzed commit 456a6f7 and detected 0 issues on this pull request.

View more on Code Climate.

@paviad

paviad commented Jul 18, 2023

Copy link
Copy Markdown
Author

Resolved all issues, new behavior will not reject dimensions, but will simply ignore them.

@joshiayush joshiayush left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR fixes #984 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Option parseImgDimensions is actually true by default despite doc, and also, when false still behaves as if true

2 participants