Skip to content
Peter Andrews edited this page Oct 24, 2017 · 10 revisions

The NPC listings created by the list command are a handy way to get displayable versions of every character into one place, like a campaign website. Here's how they work under the hood.

Gathering the Files

The characters in a listing are modified slightly before being passed to the formatter.

  1. Characters with the @skip directive are omitted from the output.
  2. The @type is replaced by the contents of the @faketype tag.
  3. Any characters that still have no @type tag are given the "Unknown" type. The character file is not changed.

After all the files have been gathered, they are sorted as requested, by either first or last name.

Output Formats

There are three supported formats right now: JSON, Markdown, and HTML. Each one is designed to create a different kind of listing. The Markdown and HTML formats use templates to create their output, so the content can be changed by supplying a different template in your settings. The descriptions here cover the default templates.

JSON Listings

JSON listings are the simplest. They simply contain the character data after it's been gathered. This format is designed to be used for passing this data to other programs for further manipulation.

Metadata in a JSON listing is simply an extra dict. It will always have a key named meta with a value of True so that it can easily be recognized.

Markdown Listings

Markdown listings are more involved and are designed to create readable web pages after being put through a markdown parser. NPC uses basic Markdown syntax, so the generated listing should work fine with whatever parser you use.

One caveat is that the formatter isn't smart enough to put spaces at the end of lines to indicate a newline. What that means for the output is that multiple consecutive lines will be look fine in text form, but wind up as one paragraph when the list is processed by Markdown. To avoid that, use a parser that supports GitHub-style line endings, i.e. a <br> for every newline.

Metadata

The metadata in a Markdown listing can be included as YAML Front Matter or MultiMarkdown metadata. YAML front matter appears like this:

---
title: NPC Listing
created: Mon, Aug 15 11:35 AM
---

And MultiMarkdown Metadata appears like this:

Title: NPC Listing
Created: 2016-02-14T16:12:49.359675

General Format

The details of each character are written to the listing based on their type (or fake type, if that was provided). Tags that are unique to a different type are not included in the output, even if they appear in the sheet.

Most characters use the following format.

Using this character sheet:

A devilishly evil man, forever battling a British spy.

@realname Dr. Evil
@name Douglas Powers, not widely known
@type Human
@group Evil League of Evil
@rank Pre-Founding Non-Member
@group SPECTRE
@rank Groupie

@appearance Bald, with a scar down his cheek and cocky eyebrow.

The listing would appear like this:

## Dr. Evil

*AKA Douglas Powers, not widely known*
Human, Evil League of Evil (Pre-Founding Non-Member)
Member of SPECTRE (Groupie)

*Appearance:* Bald, with a scar down his cheek and cocky eyebrow.

*Notes:* A devilishly evil man, forever battling a British spy.

Changeling Characters

If Dr. Evil were kidnapped by a mad Faerie and returned as a Changeling (bear with me), his sheet might instead look like this:

A devilishly evil man, forever battling a British spy. Now doubly evil!

@realname Dr. Evil
@name Douglas Powers, not widely known

@changeling Wizened Chatelaine
@court Summer
@motley AWM
@group Evil League of Evil
@rank Pre-Founding Non-Member
@group SPECTRE
@rank Groupie

@mask Bald, with a scar down his cheek and cocky eyebrow.
@mien His body is completely depilated, with permanent eyebrows of dried blood. The scar on his cheek is an angry purple, and his eyes burn icy blue with resentment for the world.

His listing would then appear as this:

## Dr. Evil

*AKA Douglas Powers, not widely known*
Changeling, AWM Motley, Summer Court
Wizened Chatelaine
Member of Evil League of Evil (Pre-Founding Non-Member), SPECTRE (Groupie)

*Mien:* His body is completely depilated, with permanent eyebrows of dried blood. The scar on his cheek is an angry purple, and his eyes burn icy blue with resentment for the world.
*Mask:* Bald, with a scar down his cheek and cocky eyebrow.

*Notes:* A devilishly evil man, forever battling a British spy. Now doubly evil!

HTML Listings

HTML listings are similar to what would happen after putting the Markdown listing through a markdown processor. They differ in a few key ways, however.

Metadata

Metadata is inserted using <meta> tags in HTML listings, one per metadata element. The title metadata is put in a <title> element instead, since that's what it's there for. In addition, a element is always present, regardless of whether metadata is requested. This is to help browsers render the page correctly. A sample metadata block might look like this:

<html>
<head>
    <title>NPC Listing</title>
    <meta name="created" content="Mon, Aug 15 11:35 AM" />
    <meta charset="ascii" />
</head>

General Format

Unlike Markdown listings, the character entries in an HTML listing are broken down into alphabetical sections. Otherwise, they're mostly the same. Any markdown in the description or the @appearance, @mien, @mask, or @dead tags is converted to HTML during output. Markdown in other tags is not processed.

Using the same example as before, a human entry would have this structure:

<h2>E</h2>
<h3>Dr. Evil</h3>

<div><em>AKA Douglas Powers, not widely known</em></div>
<div>Human, Evil League of Evil (Pre-Founding Non-Member)</div>
<div>SPECTRE (Groupie)</div>

<p><em>Appearance:</em> Bald, with a scar down his cheek and cocky eyebrow.</p>
<p><em>Notes:</em> A devilishly evil man, forever battling a British spy.</p>

And it would be rendered like this:

E

Dr. Evil

AKA Douglas Powers, not widely known
Human, Evil League of Evil (Pre-Founding Non-Member)
SPECTRE (Groupie)

Appearance: Bald, with a scar down his cheek and cocky eyebrow.

Notes: A devilishly evil man, forever battling a British spy.

Changeling Characters

Still with the same example, a changeling entry would would have this markup:

<h2>E</h2>
<h3>Dr. Evil</h3>

<div><em>AKA Douglas Powers, not widely known</em></div>
<div>Changeling, AWM Motley, Summer Court</div>
<div>Wizened Chatelaine</div>
<div>Evil League of Evil (Pre-Founding Non-Member), SPECTRE (Groupie)</div>

<p><em>Mien:</em> His body is completely depilated, with permanent eyebrows of dried blood. The scar on his cheek is an angry purple, and his eyes burn icy blue with resentment for the world.</p>
<p><em>Mask:</em> Bald, with a scar down his cheek and cocky eyebrow.</p>
<p><em>Notes:</em> A devilishly evil man, forever battling a British spy. Now doubly evil!</p>

And be rendered like this:

E

Dr. Evil

AKA Douglas Powers, not widely known
Changeling, AWM Motley, Summer Court
Wizened Chatelaine
Evil League of Evil (Pre-Founding Non-Member), SPECTRE (Groupie)

Mien: His body is completely depilated, with permanent eyebrows of dried blood. The scar on his cheek is an angry purple, and his eyes burn icy blue with resentment for the world.

Mask: Bald, with a scar down his cheek and cocky eyebrow.

Notes: A devilishly evil man, forever battling a British spy. Now doubly evil!

Markdown Handling

Any markdown-formatted text in the description, @appearance, @mien, @mask, and @dead tags is processed into html for the character's listing.

Sections and Footers

The markdown and html formats support section headings as well as footer content. The footer content is inserted once at the end of the output, but the sections work a little differently. They are controlled by a sectioner function which is passed to the formatter. By default, this function returns the first letter of the character's last name (the last word in their name tag). Whenever the value returned by the function changes, a section header is output containing the new value.