joscha/html-context


Gives (textual) context for a given DOM node

License: MIT

Language: JavaScript


HTML Context

Build status npm npm David node coveralls

This package allows you to generate some HTML context for a given DOM node. E.g. Some markup looking like this:

<html>
  <div id="x">
    <h1>Hello world</h1>
  </div>
</html>

with

  const div = window.document.getElementById('x');
  htmlContext(div, {
    maxLength: 19,
  });

would result in

<div id="x">…</div>

The context can either be document or an HTMLElement.

Install

npm install html-context --save

or in the browser (UMD):

<script src="html-context/dist/index.js"></script>

Options

options.maxLength: the maximum length of the returned context. The package will try and fit the outermost tag in if it can. Defaults to no maximum length.

options.beautify: Beautifies the returned context snippet. Defaults to false.

options.placeholder: The placeholder to use for capped markup. Defaults to .

Project Statistics

Sourcerank 5
Repository Size 59.6 KB
Stars 0
Forks 0
Watchers 0
Open issues 39
Dependencies 19
Contributors 2
Tags 6
Created
Last updated
Last pushed

Top Contributors See all

Joscha Feth Greenkeeper

Packages Referencing this Repo

html-context
Gives (textual) context for a given DOM node
Latest release 1.0.6 - Updated

Recent Tags See all

v1.0.6 December 15, 2015
v1.0.5 December 01, 2015
v1.0.4 November 30, 2015
v1.0.3 November 30, 2015
v1.0.2 November 30, 2015
v1.0.1 November 30, 2015

Something wrong with this page? Make a suggestion

Last synced: 2016-10-26 09:30:27 UTC

Login to resync this repository