subttribute
A sub-attribute system for constrained markup environments.
Use JavaScript to extract HTML element attributes from the content of other attributes. Primary use case at this time is to add other attributes to a and img tags on Markdown files in GitHub Pages.
This is a JavaScript way to solve the problem of adding class names to links in Markdown, and other similar problems when you want to, or have to, write Markdown but need to put in some more information for styling purposes.
Examples
HTML
See the HTML example or run it live:
The attributes are defined within the title or alt attributes on any element. They are seperated by the ~ character. The section preceding the first ~ is the actual content you want to end up in that attribute. The other are a series of : seperated attribute:value pairs. These will be attached to the same element.
Would (after JavaScript execution) end up looking like:
Although you can set the attributes yourself in HTML the place where subttribute really shines is in:
Markdown
Assuming the subttribute JavaScript included elsewhere in the template:
![some alt tag](http://lorempixel.com/g/200/100/ "title text ~ id: image-one ~ class: border border-purple ~ title: Some new title tag")![alt text ~ id: image-two ~ class: border border-red](http://lorempixel.com/g/200/100/ "Some title tag")
Will eventually set the attributes on the images:
See the example for Jekyll/Markdown (GitHub Pages-style) usage.