npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wikity

v1.3.0

Published

Compile wikitext to HTML: wikitext as a templating language.

Downloads

10

Readme

Latest version Last updated npm downloads

Wikity

Wikity is a tool that allows you to use Wikitext (used by Wikipedia, Fandom, etc) as a templating language to create HTML pages, useful in build tools such as Eleventy.

Install

Wikity is available on npm.

| Local install | Global install | | -------------------- | ----------------------- | | npm install wikity | npm install -g wikity |

API

Node

  • wikity.compile(folder?: string, options?: object): void

    • Compile all Wikitext (.wiki) files from an input folder (defaults to the current directory, .) into HTML.
  • wikity.eleventyPlugin(folder?: string, options?: object): void

    • An implementation of compile() for use with Eleventy's addPlugin API. Identical to compile() except that option eleventy is true by default.
  • wikity.parse(input: string, options?: object): string

    • Parse raw wikitext input into HTML. Only option available is templatesFolder.
  • Options:

    • outputFolder?: string
      • Where outputted HTML files shall be placed (default: wikity-out).
    • templatesFolder?: string
      • What folder to place templates in (default: 'templates').
    • imagesFolder?: string
      • What folder to place images in (default: 'images'). Make sure to pass through this folder to your build output if applicable.
  • eleventy?: boolean

    • Whether front matter will be added to the outputted HTML for Eleventy to read (default: false).
    • defaultStyles?: boolean
      • Whether to use default wiki styling (default: true).
    • customStyles?: string
      • Custom CSS to style the wiki pages (default: '').
const wikity = require('wikity');

// compile all .wiki files inside this directory
wikity.compile();

// parse wikitext from an input string
let html = wikity.parse(`'''bold''' [[link|text]]`); // <b>bold</b> <a href="link"...>text</a>

Use Wikity along with Eleventy to compile your wiki files during the build process:

// .eleventy.js (eleventy's configuration file)
const wikity = require('wikity');
module.exports = function (eleventyConfig) {
    const wikiFolder = '.'; // current directory
    const wikityOptions = {templatesFolder: 'templates', imagesFolder: 'images'}; // set as needed
    const wikityPlugin = () => wikity.eleventyPlugin(wikiFolder, wikityOptions);
    eleventyConfig.addPlugin(wikityPlugin);
    eleventyConfig.addPassthroughCopy({[imagesFolder]: 'wiki/' + imagesFolder}); // Eleventy does not pass through images by default
}

Command-line

$ wikity help
Display a help message
$ wikity compile [<folder>] [-o <folder>] [-t <folder>] [-e] [-d]
Compile Wikity with various options
$ wikity parse <input>
Parse raw input into HTML
$ wikity version
Display the latest version of Wikity

Usage

Use Wikitext (file extension .wiki) to create your pages.

Any wiki templates (called using {{template name}}) must be inside the templates/ folder by default. Any files must be inside the images/ folder by default.

Wiki markup

| Markup | Preview | | -------------------------------- | ----------------------------------------- | | '''bold''' | bold | | ''italic'' | italic | | '''''bold italic''''' | bold italic | | ``code`` | code | | ```code block``` | code block | | =heading= | heading | | ==subheading== | subheading | | *bulleted | bulleted | | **sub-bulleted | sub-bulleted | | #numbered | numbered | | ##sub-numbered | sub-numbered | | ;term | term | | :definition |  definition | | <ref>Text</ref> | [1] | | <references/> | 1. Text | | [[internal link]] | internal link | | [[link\|display text]] | display text | | [external-link] | [1] | | [external-link display text] | display text | | [[File:Example.png\|Caption.]] | Caption | | {{tp name}} | (contents of templates/tp_name.wiki) | | {{tp name\|arg=val}} | (ditto but {{{arg}}} is set to 'val') | | {{{arg}}} | (value given by template) | | {{{arg\|default val}}} | (ditto but 'default val' if unset) | | {\| style="margin:1em" | table opening | | ! Cell heading | Cell heading | | \|- class="new-row" | new table row | | \| Cell content | Cell content | | \|} | table closing | | {{#if:non-empty-string\|text}} | text | | {{#ifeq:1\|2\|true\|false}} | false | | {{#vardefine:varname\|text}} | (saved to memory) | | {{#var:varname}} | text (from memory) | | {{#var:varname\|default val}} | (ditto but 'default val' if unset) | | {{#switch:a\|a=1\|b=2\|c=3}} | 1 | | {{#time:dd/mm/yy\|2021-03-28}} | 28/03/21 | | {{#lc:TEXT}} | text | | {{#ucfirst:text}} | Text | | {{#len:12345}} | 5 | | {{#sub:string\|2\|4}} | ring | | {{#pos:text\|x}} | 2 | | {{#padleft:text\|5\|_}} | text | | {{#padright:msg\|5\|_}} | msg_ | | {{#replace:Message\|e\|3}} | M3ssag3 | | {{#explode:A-B-C-D\|-\|2}} | C | | {{#urlencode:t e x t}} | t%20e%20x%20t | | {{#urldecode:a%20b%27c}} | a b'c | | <noinclude>No</noinclude> | (blank outside a template) | | <onlyinclude>Yes</onlyinclude> | Yes | | <includeonly>Yes</includeonly> | Yes (blank inside a template) | | <nowiki>[[no link]]</nowiki> | [[no link]] |