@vibe-reader/core
v0.1.0
Published
Core utilities for parsing Hacker News discussions, converting HTML to Markdown, and more
Maintainers
Readme
@vibe-reader/core
Core utilities for parsing Hacker News discussions, converting HTML to Markdown, and more. Used by the Vibe Reader Chrome extension and CLI.
Install
npm install @vibe-reader/coreModules
hn-parser
Parse HN discussion pages and build comment trees.
import {
parseHNDiscussion,
buildCommentTree,
renderMarkdown,
condenseComments,
fetchHNDiscussion,
type HNComment,
type HNDiscussion,
} from '@vibe-reader/core';
// Fetch and parse a full HN discussion
const discussion = await fetchHNDiscussion('https://news.ycombinator.com/item?id=12345');
console.log(discussion.title, discussion.comments.length);
// Build a tree from flat comments
const tree = buildCommentTree(discussion.comments);
// Render as Markdown
const markdown = renderMarkdown(tree);
// Condense for AI consumption
const condensed = condenseComments(discussion.comments);hn-search
Search HN discussions via the Algolia API.
import {
searchHNDiscussions,
cleanUrl,
getHNItemUrl,
type HNSearchHit,
type HNSearchResult,
} from '@vibe-reader/core';
// Find HN discussions for a URL
const results = await searchHNDiscussions('https://example.com/article');
// Get the canonical HN item URL
const hnUrl = getHNItemUrl(12345); // "https://news.ycombinator.com/item?id=12345"
// Clean a URL for search matching
const cleaned = cleanUrl('https://www.example.com/page?ref=hn');html-to-markdown
Convert HTML content to Markdown.
import { htmlToMarkdown } from '@vibe-reader/core';
const markdown = htmlToMarkdown('<h1>Hello</h1><p>World</p>');template
Simple template rendering with {{variable}} placeholders.
import { renderTemplate } from '@vibe-reader/core';
const result = renderTemplate('Hello {{name}}!', { name: 'World' });preprocess-dom
Preprocess a DOM document before content extraction (removes noise elements like nav, ads, etc.).
import { preprocessDOM } from '@vibe-reader/core';
preprocessDOM(document);License
MIT
