🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

parse-mediawiki-template

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-mediawiki-template

Parses all occurences of a Mediawiki Template from Mediawiki text

latest
Source
npmnpm
Version
0.2.2
Version published
Weekly downloads
30
Maintainers
1
Weekly downloads
 
Created
Source

parse-mediawiki-template

Parses all occurences of a Mediawiki Template from Mediawiki text

INSTALLATION

From npm.js:

npm install --save parse-mediawiki-template

From Github:

git clone https://github.com/plepe/parse-mediawiki-template
cd parse-mediawiki-template
npm install

With script tag in the browser:

<script src="https://cdn.jsdelivr.net/npm/parse-mediawiki-template@0.2.2/dist/parse-mediawiki-template.umd.js"></script>

USAGE

The function will parse wikitext (parameter 1) and find all occurences of the specified template (parameter 2). Mediawiki text is case insensitive.

The result is an array with an entry for each occurence. If the template has parameters, it will list them.

import parseMediawikiTemplate from 'parse-mediawiki-template';

const wikitext = 'Page content {{Template|param1|foo=paramFoo}} {{OtherTemplate}} {{Template|second|occurence}}';
const template = 'template';

const result = parseMediawikiTemplate(wikitext, template);

result is:

[
  {
    "1": "param1",
    "foo": "paramFoo"
  },
  {
    "1": "second",
    "2": "occurence"
  }
]

CONTRIBUTORS

  • Stephan Bösch-Plepelits (initial code)
  • Lenni009 (port to TypeScript)

FAQs

Package last updated on 11 May 2024

Did you know?

Socket

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