Render Microformats2 JSON to semantic HTML
npm install mf2domRender Microformats2 JSON to semantic HTML.
``bash`
npm install mf2dom
`javascript
import { render, renderItems, renderItemElement } from 'mf2dom';
// Render a full mf2 document
const html = render(mf2Document);
// Render multiple items to a DocumentFragment
const fragment = renderItems(items, { topHeading: 2 });
document.querySelector('main').appendChild(fragment);
// Render a single item to an HTMLElement
const element = renderItemElement(item, { topHeading: 2 });
`
`html`
`javascript
import { render } from 'mf2dom';
import { JSDOM } from 'jsdom';
// Set up global document for Node.js
const dom = new JSDOM('
const html = render(mf2Document);
`
Render an mf2 document to HTML.
- doc: Microformats2 document with items arrayoptions.asElement
- : Return HTMLElement instead of string (default: false)options.topHeading
- : Starting heading level for names (1-6)
Render multiple mf2 items to a DocumentFragment.
- items: Array of mf2 itemsoptions.relUrls
- : rel-urls from parsed documentoptions.topHeading
- : Starting heading level
Render a single mf2 item to an HTMLElement.
- item: Single mf2 itemoptions.relUrls
- : rel-urls from parsed documentoptions.topHeading
- : Starting heading level
- Renders h-entry, h-card, h-feed, h-event, and other microformat types
- Semantic HTML output (article, address, time, etc.)
- Proper heading hierarchy with topHeading` option
- Handles embedded items (author h-cards, location, etc.)
- Ruby annotations for names with IPA pronunciation
- Linked names when URL matches
- Media handling (photo, video, audio)
- Date/time formatting
AGPL-3.0-or-later