BoundInCode/AutoFileName — pull request #55 by codecarson (2014-01-16 21:55:44+00:00)
Title: Add support for single quotes and fix edge cases that cause duplicate attributes and incorrect ordering.

I uncovered a couple of edge case bugs while working with the plugin. I would normally split all of this up, but the solution for one issue also solved the other and I inadvertently noticed and fixed a third issue along the way.

**Issue 1. Trying to insert a tag that already has a single dimension attribute causes duplicate attributes. Order preference may not be respected.**

_Settings:_ `"afn_template_languages": false, "afn_insert_width_first": true`
``
becomes:
``

If you set `"afn_template_languages": true`, it's a little worse:
`img src="images/gmlmd-nav-offers.jpg" width="83"`
becomes:
`img src="images/gmlmd-nav-offers.jpg" width="83" height="25" width="83"`

**Issue 2. Incorrectly replaces dimensions in sibling tags (`extract_scope` selects more than just the current tag).**

_Settings:_ `afn_template_languages: false`
``
becomes:
``

In the example, you can see dimensions in the first image were incorrectly changed when auto-completing the second image.

**Issue 3. Dimension attributes with single quotes are not replaced**
e.g. ``

**Changes:**
- Added `get_tag_scope` to specifically select ONLY the image tag in question, matching on what's autocompleted in the src attribute value because extract_scope bites off too much and captures sibling tags.
- Added `clear_dimensions` to wipe out any existing dimensions before inserting new ones. Seemed to be the easiest way to solve duplicate dimensions and ordering issues.
- Modified `insert_dimension` to only do an insert - replacing is unnecessary because we are clearing attributes in the tag first.