{"_id":"line-height","_rev":"11-2b225ba3696c6770e2b05934ecf73282","name":"line-height","description":"Calculate line-height of an HTML element (IE6 compatible)","dist-tags":{"latest":"0.3.1"},"versions":{"0.1.0":{"name":"line-height","description":"Calculate line-height of an HTML element (IE6 compatible)","version":"0.1.0","homepage":"https://github.com/twolfson/line-height","author":{"name":"Todd Wolfson","email":"todd@twolfson.com","url":"http://twolfson.com/"},"repository":{"type":"git","url":"git://github.com/twolfson/line-height.git"},"bugs":{"url":"https://github.com/twolfson/line-height/issues"},"licenses":[{"type":"MIT","url":"https://github.com/twolfson/line-height/blob/master/LICENSE-MIT"}],"main":"lib/line-height","engines":{"node":">= 0.6.0"},"scripts":{"build-test":"browserify --transform brfs test/line-height_test.js --outfile test/line-height_test.browserify.js","build":"browserify lib/line-height.js --standalone line-height --outfile dist/line-height.js","test":"testem ci"},"dependencies":{},"devDependencies":{"grunt":"~0.3.17","mocha":"~1.11.0","browserify":"~2.23.1","brfs":"0.0.6","computed-style":"~0.1.3","chai":"~1.7.2","domify":"~1.0.0","css-controls":"~0.1.0","testem":"~0.3.12","proclaim":"~1.5.0"},"keywords":["line-height","lineHeight","getComputedStyle","css"],"testling":{"files":["test/line-height_test.js"],"harness":"mocha","browsers":["ie/6..latest","chrome/20..latest","chrome/canary","firefox/10..latest","firefox/nightly","safari/latest","opera/11.0..latest","opera/next","iphone/6","ipad/6"]},"_id":"line-height@0.1.0","dist":{"shasum":"2a264c0dfe38aaeaea4269e201757bedbb9125b2","tarball":"https://registry.npmjs.org/line-height/-/line-height-0.1.0.tgz","integrity":"sha512-JzYMGLpUbzLy6WD/BILt+7Vvh4jX4wQrJfgYUaht5nlfg6wwWgBX7FrJGjS4Mwc2/nCuds07bxOESyzJhzydfg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDea55L1HUG8Uv7yaZ3bu0VrqFaAciZWK0fUG/UzJ7CiwIhAOZIw+ASlBANLQRgddokFJJSNa68d6+K4Z10X1DfVpbV"}]},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"twolfson","email":"todd@twolfson.com"},"maintainers":[{"name":"twolfson","email":"todd@twolfson.com"}]},"0.1.1":{"name":"line-height","description":"Calculate line-height of an HTML element (IE6 compatible)","version":"0.1.1","homepage":"https://github.com/twolfson/line-height","author":{"name":"Todd Wolfson","email":"todd@twolfson.com","url":"http://twolfson.com/"},"repository":{"type":"git","url":"git://github.com/twolfson/line-height.git"},"bugs":{"url":"https://github.com/twolfson/line-height/issues"},"licenses":[{"type":"MIT","url":"https://github.com/twolfson/line-height/blob/master/LICENSE-MIT"}],"main":"lib/line-height","engines":{"node":">= 0.6.0"},"scripts":{"build-test":"browserify --transform brfs test/line-height_test.js --outfile test/line-height_test.browserify.js","build":"browserify lib/line-height.js --standalone line-height --outfile dist/line-height.js","test":"testem ci"},"dependencies":{"computed-style":"~0.1.3"},"devDependencies":{"grunt":"~0.3.17","mocha":"~1.11.0","browserify":"~2.23.1","brfs":"0.0.6","chai":"~1.7.2","domify":"~1.0.0","css-controls":"~0.1.0","testem":"~0.3.12","proclaim":"~1.5.0"},"keywords":["line-height","lineHeight","getComputedStyle","css"],"testling":{"files":["test/line-height_test.js"],"harness":"mocha","browsers":["ie/6..latest","chrome/20..latest","chrome/canary","firefox/10..latest","firefox/nightly","safari/latest","opera/11.0..latest","opera/next","iphone/6","ipad/6"]},"_id":"line-height@0.1.1","dist":{"shasum":"e86705fbf0a6f50607aed65500d69db2d9db37e2","tarball":"https://registry.npmjs.org/line-height/-/line-height-0.1.1.tgz","integrity":"sha512-JDIlrJycHpYS1bY1sDwlqmOaouI2lzLXvwqitRrf+AJXpvkWUK4m0Hz6TK7F7xZSarWOMEPMN7LxsjUHU+UEpg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCdHI5xhSVwdp10bibEgY9/Ec3IT1GpwLBzx99ye3ysbAIhALOiXH/C60q9bSgcgtPLLDN333Pgl6gz00IrSuWJU9ST"}]},"_from":".","_npmVersion":"1.2.14","_npmUser":{"name":"twolfson","email":"todd@twolfson.com"},"maintainers":[{"name":"twolfson","email":"todd@twolfson.com"}]},"0.2.0":{"name":"line-height","description":"Calculate line-height of an HTML element (IE6 compatible)","version":"0.2.0","homepage":"https://github.com/twolfson/line-height","author":{"name":"Todd Wolfson","email":"todd@twolfson.com","url":"http://twolfson.com/"},"repository":{"type":"git","url":"git://github.com/twolfson/line-height.git"},"bugs":{"url":"https://github.com/twolfson/line-height/issues"},"licenses":[{"type":"MIT","url":"https://github.com/twolfson/line-height/blob/master/LICENSE-MIT"}],"main":"lib/line-height","engines":{"node":">= 4.0.0"},"scripts":{"build":"browserify lib/line-height.js --standalone line-height --outfile dist/line-height.js","test":"npm run build && npm run test-karma-single","_test-karma-comment":"`xvfb-maybe` checks for DISPLAY environment variable but we hate non-headless browsers so we always shut it off","test-karma-continuous":"DISPLAY=\"\" xvfb-maybe karma start --no-single-run","test-karma-single":"DISPLAY=\"\" xvfb-maybe karma start"},"dependencies":{"computed-style":"~0.1.3"},"devDependencies":{"brfs":"~1.4.3","browserify":"~13.1.1","css-controls":"~0.1.0","domify":"~1.0.0","foundry":"~4.3.3","foundry-release-component":"~2.0.0","foundry-release-git":"~2.0.2","foundry-release-npm":"~2.0.2","grunt":"~0.3.17","karma":"~1.4.1","karma-browserify":"~5.1.1","karma-chrome-launcher":"~2.0.0","karma-mocha":"~1.3.0","karma-phantomjs-launcher":"~1.0.2","mocha":"~1.11.0","proclaim":"~3.4.4","xvfb-maybe":"~0.1.3"},"keywords":["line-height","lineHeight","getComputedStyle","css"],"foundry":{"releaseCommands":[{"type":"customCommand","updateFiles":"npm run build"},"foundry-release-git","foundry-release-npm","foundry-release-component"]},"gitHead":"03152224138bcb0225c31da2ea5444024e77de4e","_id":"line-height@0.2.0","_shasum":"40de4a55b7b7ab7813b2a0d12e6ff0d143219df9","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.6.2","_npmUser":{"name":"twolfson","email":"todd@twolfson.com"},"dist":{"shasum":"40de4a55b7b7ab7813b2a0d12e6ff0d143219df9","tarball":"https://registry.npmjs.org/line-height/-/line-height-0.2.0.tgz","integrity":"sha512-JufGRg7do0FB2r8NKFG5fVsWpdkrZMcaGrekVmc+78s0zwYOSq5VG8Jra0DDDWq+uqWKA2kDshSZ0L19XB/r2A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD+9vcphIgk2sHxYgryNx+Brk88RGz6Vc5Yef0Bk+S2YQIgHUj4IGC04NeQAcQklEFSN+jz1zEjdfMJ7cYRbWb1sDc="}]},"maintainers":[{"name":"twolfson","email":"todd@twolfson.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/line-height-0.2.0.tgz_1486636844741_0.3933051445055753"}},"0.2.1":{"name":"line-height","description":"Calculate line-height of an HTML element (IE6 compatible)","version":"0.2.1","homepage":"https://github.com/twolfson/line-height","author":{"name":"Todd Wolfson","email":"todd@twolfson.com","url":"http://twolfson.com/"},"repository":{"type":"git","url":"git://github.com/twolfson/line-height.git"},"bugs":{"url":"https://github.com/twolfson/line-height/issues"},"license":"MIT","main":"lib/line-height","engines":{"node":">= 4.0.0"},"scripts":{"build":"browserify lib/line-height.js --standalone line-height --outfile dist/line-height.js","lint":"twolfson-style lint lib/ test/","test":"npm run build && npm run test-karma-single && npm run lint","_test-karma-comment":"`xvfb-maybe` checks for DISPLAY environment variable but we hate non-headless browsers so we always shut it off","test-karma-continuous":"DISPLAY=\"\" xvfb-maybe karma start --no-single-run","test-karma-single":"DISPLAY=\"\" xvfb-maybe karma start"},"dependencies":{"computed-style":"~0.1.3"},"devDependencies":{"brfs":"~1.4.3","browserify":"~13.1.1","css-controls":"~0.1.0","domify":"~1.0.0","foundry":"~4.3.3","foundry-release-component":"~2.0.0","foundry-release-git":"~2.0.2","foundry-release-npm":"~2.0.2","karma":"~1.4.1","karma-browserify":"~5.1.1","karma-chrome-launcher":"~2.0.0","karma-mocha":"~1.3.0","karma-phantomjs-launcher":"~1.0.2","mocha":"~3.2.0","proclaim":"~3.4.4","twolfson-style":"~1.6.1","xvfb-maybe":"~0.1.3"},"keywords":["line-height","lineHeight","getComputedStyle","css"],"foundry":{"releaseCommands":[{"type":"customCommand","updateFiles":"npm run build"},"foundry-release-git","foundry-release-npm","foundry-release-component"]},"gitHead":"6376dda139a92ccf85ad10aa7768886a5e1d25eb","_id":"line-height@0.2.1","_shasum":"67d6ffda008b5989627b9775cecce659b67b1aac","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.6.2","_npmUser":{"name":"twolfson","email":"todd@twolfson.com"},"dist":{"shasum":"67d6ffda008b5989627b9775cecce659b67b1aac","tarball":"https://registry.npmjs.org/line-height/-/line-height-0.2.1.tgz","integrity":"sha512-7Cgan/FFjq5MEpEzZtLy0P2kQc1bnVjVjASR+f9wZz7sspnaxD70Q+A1++iDaUcicinMQd7dSaPZTkn9JJOCtg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDtHd3rdEp3pRPkTi3KyjYQEsclMZveN0oueA6evOp6zAiB2GcuDLh5mBvbuUwY104cZ4zjg1gNp4TTbLCPldQ4SSw=="}]},"maintainers":[{"name":"twolfson","email":"todd@twolfson.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/line-height-0.2.1.tgz_1486638490185_0.5668678982183337"}},"0.3.0":{"name":"line-height","description":"Calculate line-height of an HTML element (IE6 compatible)","version":"0.3.0","homepage":"https://github.com/twolfson/line-height","author":{"name":"Todd Wolfson","email":"todd@twolfson.com","url":"http://twolfson.com/"},"repository":{"type":"git","url":"git://github.com/twolfson/line-height.git"},"bugs":{"url":"https://github.com/twolfson/line-height/issues"},"license":"MIT","main":"lib/line-height","engines":{"node":">= 4.0.0"},"scripts":{"build":"browserify lib/line-height.js --standalone line-height --outfile dist/line-height.js","lint":"twolfson-style lint lib/ test/","test":"npm run build && npm run test-karma-single && npm run lint","_test-karma-comment":"`xvfb-maybe` checks for DISPLAY environment variable but we hate non-headless browsers so we always shut it off","test-karma-continuous":"DISPLAY=\"\" xvfb-maybe karma start --no-single-run","test-karma-single":"DISPLAY=\"\" xvfb-maybe karma start"},"dependencies":{"computed-style":"~0.1.3"},"devDependencies":{"brfs":"~1.4.3","browserify":"~13.1.1","css-controls":"~0.1.0","domify":"~1.0.0","foundry":"~4.3.3","foundry-release-component":"~2.0.0","foundry-release-git":"~2.0.2","foundry-release-npm":"~2.0.2","karma":"~1.4.1","karma-browserify":"~5.1.1","karma-chrome-launcher":"~2.0.0","karma-mocha":"~1.3.0","karma-phantomjs-launcher":"~1.0.2","mocha":"~3.2.0","proclaim":"~3.4.4","twolfson-style":"~1.6.1","xvfb-maybe":"~0.1.3"},"keywords":["line-height","lineHeight","getComputedStyle","css"],"foundry":{"releaseCommands":[{"type":"customCommand","updateFiles":"npm run build"},"foundry-release-git","foundry-release-npm","foundry-release-component"]},"gitHead":"526942bbade65b792172b8034bd55725647dcba2","_id":"line-height@0.3.0","_shasum":"89aac740c7392aa8d0cd0583e319dfa682df1eae","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.6.2","_npmUser":{"name":"twolfson","email":"todd@twolfson.com"},"dist":{"shasum":"89aac740c7392aa8d0cd0583e319dfa682df1eae","tarball":"https://registry.npmjs.org/line-height/-/line-height-0.3.0.tgz","integrity":"sha512-74aREkriHRcXE7vUKkj/Cvo6pNHCXTP3zUvEj1CXRk4xuMWXb5zc/jgBi0/5i4fcKZrCKhljVswB11g/ud2FPQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBW1NxOC2i9xdCg9bAzZjIWOgDBjiKyIYeuPadiI7Xs6AiBk/wWR723kcuoreIEjChFctxijkUdzM5sq2Q37iVYZXA=="}]},"maintainers":[{"name":"twolfson","email":"todd@twolfson.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/line-height-0.3.0.tgz_1486639126077_0.8375520810950547"}},"0.3.1":{"name":"line-height","description":"Calculate line-height of an HTML element (IE6 compatible)","version":"0.3.1","homepage":"https://github.com/twolfson/line-height","author":{"name":"Todd Wolfson","email":"todd@twolfson.com","url":"http://twolfson.com/"},"repository":{"type":"git","url":"git://github.com/twolfson/line-height.git"},"bugs":{"url":"https://github.com/twolfson/line-height/issues"},"license":"MIT","main":"lib/line-height","engines":{"node":">= 4.0.0"},"scripts":{"build":"browserify lib/line-height.js --standalone line-height --outfile dist/line-height.js","lint":"twolfson-style lint lib/ test/","test":"npm run build && npm run test-karma-single && npm run lint","_test-karma-comment":"`xvfb-maybe` checks for DISPLAY environment variable but we hate non-headless browsers so we always shut it off","test-karma-continuous":"DISPLAY=\"\" xvfb-maybe karma start --no-single-run","test-karma-single":"DISPLAY=\"\" xvfb-maybe karma start"},"dependencies":{"computed-style":"~0.1.3"},"devDependencies":{"brfs":"~1.4.3","browserify":"~13.1.1","css-controls":"~0.1.0","domify":"~1.0.0","foundry":"~4.3.3","foundry-release-component":"~2.0.0","foundry-release-git":"~2.0.2","foundry-release-npm":"~2.0.2","jscs":"~3.0.7","jshint":"~2.9.4","karma":"~1.4.1","karma-browserify":"~5.1.1","karma-chrome-launcher":"~2.0.0","karma-mocha":"~1.3.0","karma-phantomjs-launcher":"~1.0.2","mocha":"~3.2.0","proclaim":"~3.4.4","twolfson-style":"~1.6.1","xvfb-maybe":"~0.1.3"},"keywords":["line-height","lineHeight","getComputedStyle","css"],"foundry":{"releaseCommands":[{"type":"customCommand","updateFiles":"npm run build"},"foundry-release-git","foundry-release-npm","foundry-release-component"]},"gitHead":"fa494dc99e01c0753b757eb90b53ced1c95df04f","_id":"line-height@0.3.1","_shasum":"4b1205edde182872a5efa3c8f620b3187a9c54c9","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.6.2","_npmUser":{"name":"twolfson","email":"todd@twolfson.com"},"dist":{"shasum":"4b1205edde182872a5efa3c8f620b3187a9c54c9","tarball":"https://registry.npmjs.org/line-height/-/line-height-0.3.1.tgz","integrity":"sha512-YExecgqPwnp5gplD2+Y8e8A5+jKpr25+DzMbFdI1/1UAr0FJrTFv4VkHLf8/6B590i1wUPJWMKKldkd/bdQ//w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCk1hubqb7FlQdLgmc+5EK+puW/5mUkmbgXietbYDOCegIhAP94GIBddUNeCQkK68Q+CGdviXVJg8Q5QM2BVbjNAzLk"}]},"maintainers":[{"name":"twolfson","email":"todd@twolfson.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/line-height-0.3.1.tgz_1486639577644_0.8625765938777477"}}},"readme":"# line-height [![Build status](https://travis-ci.org/twolfson/line-height.svg?branch=master)](https://travis-ci.org/twolfson/line-height)\n\nCalculate line-height of an HTML element (IE6 compatible)\n\nThis was created for provide a well-tested module for calculating [line-height][] in pixels for [trunkata][], a line-based truncation library for HTML.\n\n[line-height]: https://developer.mozilla.org/en-US/docs/Web/CSS/line-height\n[trunkata]: https://github.com/twolfson/trunkata\n\n## Getting Started\n`line-height` is available via the following:\n\n- [npm][npm], `npm install line-height`\n- [bower][bower], `bower install line-height`\n- [component][component], `component install line-height`\n- [Download via HTTP][download]\n\n[npm]: http://npmjs.org/\n[bower]: http://bower.io/\n[component]: http://component.io/\n[download]: https://raw.github.com/twolfson/line-height/master/dist/line-height.js\n\nFor `npm` and `component`, you can load it in as follows:\n\n```js\nvar lineHeight = require('line-height');\n```\n\nFor `bower` and `http`, you can use vanilla JS\n```html\n<script src=\"components/line-height.js\"></script>\nwindow.lineHeight; // `line-height` is defined on `window` in camelCase\n```\n\nor you can use [AMD][amd]\n\n[amd]: http://wiki.commonjs.org/wiki/Modules/AsynchronousDefinition\n\n```js\nrequire(['line-height'], funtion (lineHeight) { /* code */ });\n```\n\nor [CommonJS][commonjs] syntax (see `npm`/`component` section).\n\n[commonjs]: http://wiki.commonjs.org/wiki/Modules/1.0\n\nOnce you have the module loaded, you can get the `line-height` of any node in the DOM.\n\n```js\n// Calculate the `line-height` of the body\nlineHeight(document.body); // 19\n\n// Calculate the `line-height` of an h2\nvar h2 = document.createElement('h2');\ndocument.body.appendChild(h2);\nlineHeight(h2); // 29\n\n// Calculate how many lines tall an element is\nvar div = document.createElement('div');\ndiv.innerHTML = '<p>1</p><p>2</p>';\n(lineHeight(div) / div.offsetHeight); // 2, how trunkata performs its calculations\n```\n\n## Donations\nSupport this project and [others by twolfson][projects] via [donations][support-me]\n\n[projects]: http://twolfson.com/projects\n[support-me]: http://twolfson.com/support-me\n\n## Documentation\n`line-height` provides a single function.\n\n```js\nlineHeight(node);\n/**\n * Calculate the `line-height` of a given node\n * @param {HTMLElement} node Element to calculate line height of. Must be in the DOM.\n * @returns {Number} `line-height` of the element in pixels\n */\n```\n\n## Solved problems\n### `line-height: normal`\nIn a large amount of browsers, the [computed style][computed-style] for an element's `line-height` is `normal` by default.\n\nIf it is specified by any other means (e.g. ancestor has a `line-height` or the element has a `line-height` specified), it is either a [CSS length][css-length].\n\nTo solve this problem, we create a vanilla element of the same `nodeName` (e.g. `h2` if it is an `h2`), apply the original element's `font-size`, and return the element `offsetHeight`. This is the `height` of `1 line` of the element (i.e. `line-height`).\n\n[computed-style]: https://developer.mozilla.org/en-US/docs/Web/API/window.getComputedStyle\n[css-length]: https://developer.mozilla.org/en-US/docs/Web/CSS/length\n\n### Converting `pt`, `pc`, `in`, `cm`, `mm` to `px`\nIn most browsers, when the `line-height` is specified in `pt`, `pc`, `in`, `cm` or `mm`, the `computedStyle` value is in the same unit.\n\nTo solve this problem, we use the [standard ratios of conversion to pixels][css-length] to make a conversion to pixels.\n\n- 3pt to 4px\n- 1pc to 16px\n- 1in to 96px\n- 2.54cm to 96px\n- 25.4mm to 96px\n\n### `numeric` font-size in IE6\nIn IE6, `numeric` `font-size`s (e.g. `font-size: 2.3`) are returned without a unit.\n\nTo solve this problem, we treat this number as an `em` since it is relative as well. To do that, we set the element's style to `\"numeric value\" + \"em\"`, compute and save the `font-size`, remove the temporary style. This conversion gives us the unit in `pt` which we know how to deal with from before.\n\n## Development\n### Testing\nTests can be run once via:\n\n```bash\nnpm test\n# Or with Karma directly via\n# npm run test-karma-single\n```\n\nTests can also be run continuously via:\n\n```bash\nnpm run test-karma-single\n```\n\n## Contributing\nIn lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint via `npm run lint` and test via `npm test`.\n\n## License\nCopyright (c) 2013 Todd Wolfson\n\nLicensed under the MIT license.\n","maintainers":[{"name":"twolfson","email":"todd@twolfson.com"}],"time":{"modified":"2022-06-19T12:28:18.097Z","created":"2013-07-22T01:32:32.319Z","0.1.0":"2013-07-22T01:32:33.833Z","0.1.1":"2013-07-22T02:10:31.345Z","0.2.0":"2017-02-09T10:40:46.430Z","0.2.1":"2017-02-09T11:08:10.427Z","0.3.0":"2017-02-09T11:18:47.756Z","0.3.1":"2017-02-09T11:26:17.881Z"},"author":{"name":"Todd Wolfson","email":"todd@twolfson.com","url":"http://twolfson.com/"},"repository":{"type":"git","url":"git://github.com/twolfson/line-height.git"},"homepage":"https://github.com/twolfson/line-height","keywords":["line-height","lineHeight","getComputedStyle","css"],"bugs":{"url":"https://github.com/twolfson/line-height/issues"},"readmeFilename":"README.md","license":"MIT"}