ebookr-acronym
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -28,2 +28,5 @@ var util = require('util'); | ||
}); | ||
ebookr.addParser('acp', function (text) { | ||
return [text]; | ||
}); | ||
ebookr.addParser('acrodef', function (acronym, short, text) { | ||
@@ -40,4 +43,12 @@ acronymHandler.addAcronym(acronym, short, text); | ||
}); | ||
ebookr.addRenderer('acp', function (ac) { | ||
var acronym = acronymHandler.getAcronym(ac); | ||
var text = acronym.used | ||
? util.format('<abbr title="%ss">%ss</abbr>', acronym.full, ac) | ||
: util.format('%ss (%ss)', acronym.full, ac); | ||
acronym.used = true; | ||
return text; | ||
}); | ||
return acronymHandler; | ||
}; |
{ | ||
"name": "ebookr-acronym", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "An extension to ebookr based on the popular LaTeX-package acronym", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -23,2 +23,20 @@ var expect = require('chai').expect; | ||
}); | ||
describe('Using <acp>', function () { | ||
beforeEach(function () { | ||
ebookr = require('ebookr').new(); | ||
acronym = require('../index')(ebookr); | ||
ebookr.parse('<acrodef acronym="TLA">Three Letter Acronym</acrodef>'); | ||
}); | ||
it('should render', function () { | ||
expect(ebookr.parse('<acp>TLA</acp>').render()).to.equal('Three Letter Acronyms (TLAs)'); | ||
}); | ||
it('should render differently when already used', function () { | ||
expect(ebookr.parse('<acp>TLA</acp>\ | ||
<acp>TLA</acp>').render()).to.equal('Three Letter Acronyms (TLAs)\ | ||
<abbr title="Three Letter Acronyms">TLAs</abbr>'); | ||
}); | ||
}); | ||
}); |
6644
118