improved readme maybe

master
Ondřej Hruška 10 years ago
parent b2b45dc5a0
commit 51b97ac5dd
  1. 62
      README.md

@ -5,40 +5,46 @@ Abbr is a JavaScript library / function for finding, highlighting and annotating
It needs no extra markup, all is done automatically. Just tell it what words you want to explain, and it'll do it. It needs no extra markup, all is done automatically. Just tell it what words you want to explain, and it'll do it.
Abbr takes the following arguments: Abbr takes the following (default) arguments:
var opts = { ```js
// selector in which to search for abbreviations {
where: 'body', // selector in which to search for abbreviations
// abbreviation list - word: explanation where: 'body',
words: {}, // abbreviation list - word: explanation
// Tag used to mark the matches words: {},
tag: 'abbr', // Tag used to mark the matches
// Attribute holding the "description" to be added to the tag tag: 'abbr',
attr: 'title', // Attribute holding the "description" to be added to the tag
// Case insensitive attr: 'title',
ci: true, // Case insensitive
// tags that shall not be traversed (in addition to opts.tag) ci: true,
excluded: ['script', 'style', 'code', 'head', 'textarea', 'embed'], // tags that shall not be traversed (in addition to opts.tag)
// Extra excluded (doesn't overwrite the original list) excluded: ['script', 'style', 'code', 'head', 'textarea', 'embed'],
exclude: [] // Extra excluded (doesn't overwrite the original list)
}; exclude: []
}
```
All config options are optional (though, obviously, you don't want to leave `words` empty). All config options are optional (though, obviously, you don't want to leave `words` empty).
To run it, simply call: To run it, simply call:
abbr({ ```js
// Your options here abbr({
}); // Your options here
});
```
For example: For example:
abbr({ ```js
where: 'article', abbr({
words: { where: 'article',
'NSA': 'National Spying Agency', words: {
'Putin': 'Bear rider' 'NSA': 'National Spying Agency',
} 'Putin': 'Bear rider'
}); }
});
```

Loading…
Cancel
Save