Socket
Socket
Sign inDemoInstall

infobox-parser

Package Overview
Dependencies
1
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    infobox-parser

Parse Wikipedia Infobox Source


Version published
Maintainers
1
Install size
97.1 kB
Created

Readme

Source

NPM Version Build Status

Buy Me A Coffee

Infobox Parser

This was originally written as a companion module for wikijs. But it can work great on it's own as well. The main function of this module is parsing wikipedia article's infobox data. The infobox source is in wikitext format and difficult to parse. This module analyzes it and outputs JSON for you.

Usage

var parseInfo = require("infobox-parser")

parseInfo(`
{{Infobox Batman
|name      = Bruce Wayne
|hero      = y
}}`);
// Outputs {
	general: {
		hero: true,
		name: 'Bruce Wayne'
	}
}

Parsing Options

/**
 * Parse Wiki Infobox Text
 * @param {string} source - Infobox source text
 * @param {Object} options - Parsing options
 * @param {boolean} [options.simplifyDataValues=true] - Only use primary data values
 * @param {boolean} [options.removeSmall=false] - Remove <small>...</small> chunks of source data
 * @param {boolean} [options.removeReferences=true] - Remove <ref>...</ref> chunks of source data
 * @returns {Object} Structured information from source text
 */
const info = parseInfo(source, options);

Support

It supports many of wikipedia features, but not all yet. If there is a feature you need it to support, but it does not. Please create an issue and I will add the functionality.

FAQs

Last updated on 05 Jan 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc