Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dijs/infobox-parser
Parse Wikipedia Infoboxes
https://github.com/dijs/infobox-parser
parser wikipedia
Last synced: about 11 hours ago
JSON representation
Parse Wikipedia Infoboxes
- Host: GitHub
- URL: https://github.com/dijs/infobox-parser
- Owner: dijs
- Created: 2017-04-12T12:27:14.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-10-10T16:50:28.000Z (4 months ago)
- Last Synced: 2025-02-01T02:14:38.711Z (8 days ago)
- Topics: parser, wikipedia
- Language: JavaScript
- Size: 551 KB
- Stars: 40
- Watchers: 7
- Forks: 18
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
[![NPM Version](https://img.shields.io/npm/v/infobox-parser.svg)](https://www.npmjs.com/package/infobox-parser)
[![Build Status](https://travis-ci.org/dijs/infobox-parser.svg)](https://travis-ci.org/dijs/infobox-parser)## 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
```js
var parseInfo = require("infobox-parser")parseInfo(`
{{Infobox Batman
|name = Bruce Wayne
|hero = y
}}`);
// Outputs {
general: {
hero: true,
name: 'Bruce Wayne'
}
}
```### Parsing Options
```js
/**
* 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 ... chunks of source data
* @param {boolean} [options.removeReferences=true] - Remove ... 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.