npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

dejats

v1.7.0

Published

Extracts JATS to HTML

Downloads

43

Readme

dejats

This library converts from JATS files to HTML in the dumbest way possible. That is to say that it does almost nothing beyond producing a lot of divs, spans, and a few other such elements,ps. It does a pretty strict minimum in terms of interpreting JATS as HTML.

While this may seem counterintuitive, the value in this approach is that the programming model with which one transforms to better, richer HTML is then simply by manipulating the HTML DOM. If a feature of the transformation is not supported, you don't need to learn a new API: you just need to write some JS to modify an HTML DOM. You can use whichever way of doing that you like, be it the raw DOM, jQuery, or whatever else you might enjoy. By applying several small additional modules that enhance the pretty brutal (to say the least) HTML that comes out of this module, you can get really rich and useful HTML in a very flexible and modular manner.

One thing that this module does do for you is that it tries to expose all the information that a JATS file contains. This means that the HTML that comes out directly of it is pretty much unusable as is. You will need to carry out at least some post-processing. But you have all the information you need to do that, and (one hopes, soon) a small ecosystem of libraries to handle various subsets of the cleanup.

Installation

npm install dejats

API

The dejats API is exceeding simple. Only one function is exported (the default export). It takes a string of JATS and a callback. The callback receives an error if there was one, and an HTML DOM Document. It looks like this:

dejats(someStringOfJATS, (err, doc) => {
  // do whatever you want with the HTML doc here
});

The HTML

The HTML being produced is largely a collection of span and div representing the content. When there is a class, it contains the name of the original element that generated it. JATS attributes are all mapped. Those that map sufficiently directly to HTML are as they are in HTML, all of the others are prefixed with data- (and have - instead of : if they were namespaced).

When it is straightforward, links are generated (in which case the matching data-xlink-href is removed) but that is not always the case. A little amount of specificity is built into graphics, media, and friends handling in order to produce img, video, audio, or iframe but it remains superficial.

Note that even when for instance img are generated, they may not point to an actual resource depending on who produced the JATS to start with. To give an example, it is relatively typical for OAPMC markup to lead to <img src="pone.0012255.g004"> but to provide no pone.0012255.g004 in the tarball: instead there are pone.0012255.g004.gif and pone.0012255.g004.jpg. Resolving media based on such lovely details is the responsibility of the calling application.