MCPcopy Index your code
hub / github.com/andrejewski/himalaya

github.com/andrejewski/himalaya @v1.1.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v1.1.1 ↗ · + Follow
33 symbols 115 edges 13 files 0 documented · 0%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Himalaya

Parse HTML into JSON

npm Build Status Coverage Status

Try online 🚀 | Read the specification 📖

Usage

Node

npm install himalaya
import fs from 'fs'
import { parse } from 'himalaya'
const html = fs.readFileSync('/webpage.html', { encoding: 'utf8' })
const json = parse(html)
console.log('👉', json)

Browser

Download himalaya.js and put it in a <script> tag. Himalaya will be accessible from window.himalaya.

const html = '

Hello world

'
const json = window.himalaya.parse(html)
console.log('👉', json)

Himalaya bundles well with Browersify and Webpack.

Example Input/Output






Himalaya parsed me...






;[
  {
    type: 'element',
    tagName: 'div',
    attributes: [
      {
        key: 'class',
        value: 'post post-featured',
      },
    ],
    children: [
      {
        type: 'element',
        tagName: 'p',
        attributes: [],
        children: [
          {
            type: 'text',
            content: 'Himalaya parsed me...',
          },
        ],
      },
      {
        type: 'comment',
        content: ' ...and I liked it. ',
      },
    ],
  },
]

Note: In this example, text nodes consisting of whitespace are not shown for readability.

Features

Synchronous

Himalaya transforms HTML into JSON, that's it. Himalaya is synchronous and does not require any complicated callbacks.

Handles Weirdness

Himalaya handles a lot of HTML's fringe cases, like:

  • Closes unclosed tags `

...

- Ignores extra closing tags...- Properly handles void tags likeand- Properly handles self-closing tags like- Handles<!doctype>and<-- comments -->- Does not parse the contents of

Core symbols most depended-on inside this repo

ps
called by 118
test/parser.js
ps
called by 74
test/lexer.js
parse
called by 23
src/index.js
lexer
called by 19
src/lexer.js
parser
called by 16
src/parser.js
arrayIncludes
called by 13
src/compat.js
stringify
called by 13
src/index.js
copyPosition
called by 9
src/lexer.js

Shape

Function 33

Languages

TypeScript100%

Modules by API surface

src/lexer.js14 symbols
src/compat.js5 symbols
src/parser.js4 symbols
src/format.js4 symbols
src/stringify.js2 symbols
src/index.js2 symbols
test/parser.js1 symbols
test/lexer.js1 symbols

For agents

$ claude mcp add himalaya \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page