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

vue-hocr

v0.5.4

Published

Vue component for viewing hOCR files

Downloads

7

Readme

hocrjs

Working with hOCR in Javascript

Showcase

Demo

See this demo document: Demo

Video

video of hocrjs

Screenshots

background image, transparent text

text only, scaled font

Usage

Simple Usage

To add the interface to a plain hOCR file, add this line just before the closing </body> tag:

<script src="https://unpkg.com/hocrjs"/>

User script

Also bundled is a browser extension that lets you add the hocrjs interface to any hOCR document you browse on the web.

Tampermonkey:

Tampermonkey

Greasemonkey:

Greasemonkey

Command line interface

hocrjs comes with a command line tool hocrjs-inject that inserts the necessary <script> tag to a local hOCR document. To use it, first install hocrjs system-wide:

npm install -g hocrjs

Then run hocrjs-inject /path/to/ocr-doc.hocr. The resulting file will be /path/to/ocr-doc.hocrjs.html which you can open in a browser.

Development

To build hocrjs from source, you need Node.js and make.

Clone the repository and run make for a list of targets:

Targets

dist   webpack
clean  Remove built targets
test   Run unit tests
serve  Run a development server
watch  Continuously rebuild dist

Variables

VERSION        Version of the latest git tag ('0.4.0')
ASSET_SERVER   URL of the asset server, serving the built files and userscript ('https://unpkg.com/[email protected]/dist')
UPDATE_SERVER  URL of the userscript update server ('https://unpkg.com/hocrjs', will automatically redirect to latest version)
STATIC_SERVER  Command to run a static server ('@python2 -m SimpleHTTPServer 8888')
PORT           Server port. ('8888')

Layout

The hOCR elements are positioned with display: fixed. The trick is that they are within a container element that has transformation. This makes the fixed positions relative to the container element instead of the viewport.

Features and SASS

A feature is behavior that can be enabled or disabled and possibly configured, such as displaying the background image (BackgroundImage) or whether to disable <strong>/<em> display of text (DisableEmStrong).

If a feature is enabled, a class hocr-viewer-feature-<NAME-OF-FEATURE> will be added to the root container.

These classes are used in the SCSS stylesheet to implement the desired behavior using CSS, if possible.

Adding a feature

Add enableMyFeature property to the HocrViewer component.

In hocr-viewer.scss add rules for .hocr-viewer-feature-myFeature as necessary.

If the behavior requires modifying the hOCR (e.g. ScaleFont), create a class ./src/components/hocr-viewer/feature/MyFeature.js that gets passed the component to the constructor and implements an apply(dom) method to modify the HTML. Use the methods provided by hocr-dom to access hOCR specific features like properties.