
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
This library allows you to parse wikitext to extract values or manipulate the contents. It turns raw MediaWiki-style wikitext into a structured, machine-friendly representation you can explore, transform, lint, or post-process however you want.
This project is actively evolving. Although the API is expected to remain stable and focus mostly in finding edge-cases or supporting other wikitext elements, breaking changes may occur until 1.0.
The resulting AST is inspired in the HTMLElement structure. All elements (except TextNodes) can have children for their values; some structures, such as TemplateNodes, can have multiple groups of children: one for its name and other for its parameters.
All nodes implement their own toString method to turn the AST back
into wikitext. You can modify any of the nodes’ children and get the
resulting wikitext back.
At the current version, this library does not support some complex wikitext elements such as wikitables and HTML tags that are usually supported in wikitext.
This project does not try to be a resilient parser and will throw an error when it finds wikitext it can’t understand.
npm install wikitext
yarn add wikitext
import { parse } from 'wikitext';
function main() {
const source = `{{Item Infobox
| name = Item Name
| price = {{Price|200}}
}}
'''Item Name''' is an item in [[game]]. `;
const page = parse(source);
const price = page.findTemplate(/price/i)
if (!price) return;
price.set(1, '300');
console.log(`${page}`)
}
Calling the previous function will print in the console:
{{Item Infobox
| name = Item Name
| price = {{Price|300}}
}}
'''Item Name''' is an item in [[game]].
Parsing wikitext can be prone to errors due to ambiguous tokens. Due to
this, by default the parse function runs in “paranoid mode”, which
will stringify the AST to compare it back to the input text, and will
throw an error if it does not match. This step can be unnecessary for
most cases, and you can disable it by passing an options object to the
function:
parse(input, { paranoid: false })
This isn’t an exhaustive list of cases where the parser can fail, but some examples are:
{{ or [[.{{{1}}}, which should not show in regular
pages but makes this parser unsuitable to parse template code.FAQs
Parse wikitext into an Abstract Syntax Tree
We found that wikitext demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.