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

@a-morphous/recital-stage-html

v1.1.1

Published

Converts a Recital `.stage` file into an HTML page, suitable for then converting into pdf or other form. Uses `markdown` to process non-Recital markup, which generally follows the CommonMark spec.

Downloads

15

Readme

Stage Export to HTML

Converts a Recital .stage file into an HTML page, suitable for then converting into pdf or other form. Uses markdown to process non-Recital markup, which generally follows the CommonMark spec.

Usage

CLI

stage-html input-file.stage optional-file-2.stage -o outputfile.html

	Options:
		*TAG OPTIONS*
		--sceneTag tagName - Tag (without brackets) that wraps around scenes. Defaults to 'section'
		--blockTag tagName - Tag (without brackets) that wraps around fragments. Defaults to 'div'
		--separator '<hr />' - HTML that goes between scenes. Defaults to nothing.

		*CONVERSION OPTIONS*
		--useIncludes - if set, will accept the $include command to have HTML templates. Defaults to false.
		--pureMarkdown - if set, will not use any of the common extensions (e.g. wikilinks). Defaults to false.

If you have multiple input files, they'll be concatenated. Prefer using the $include command with the --useIncludes flag instead and just pointing to the first file; the parser supports $includes.

In JS

const stageToHtml = require('@a-morphous/recital-stage-html')

const defaultOpts = {
	sceneTag: 'section',
	blockTag: 'div',
	sceneSeparator: '',
}

return stageToHTML(fs.readFileSync('input-file.stage', 'utf-8'), defaultOpts)

How does it work?

By default, the parser wraps scenes with <section> and fragments with <div>. The only other metadata that is relevant is the default id and classes metadata tags, which are set as the id and class of the resulting HTML element, respectively. The parser enforces an id; if a scene or a fragment is defined without one, one will be automatically generated.

All inline markup is parsed with micromark in Markdown, essentially turning the original Recital document into a Markdown superscript.

You can also add a separator between every scene, which is defined in the --separator option. This separator is added as-is as an HTML string with no further processing.

If the --useIncludes flag is set, the logic tag $include will also operate, defined in the common extensions.:

The include command's usage is:

$include <file to include> <raw: boolean>

The file to include should be a relative path from the original parsed file, or an absolute path.

'raw' determines whether we process the included stage file for more includes, or just leave the text unprocessed.

Limitations

This parser ultimately converts to a string, and does not check the validity of the generated HTML. It also doesn't set proper head tags, with the assumption that additional processing be used to create a whole page.

In addition, there is no functionality to add script tags or any kind of Javascript from within the parser.

Recipes

To use this as a full-blown HTML generator, you can take advantage of the --useIncludes flag, and include things like CSS styles and JS scripts via external includes.

Something like:

head.html

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width,initial-scale=1" />
		<title>ROGUELIKE</title>
		<link rel="stylesheet" href="css/skeleton.css" />
	</head>
	<body></body>
</html>

content.stage

$include './head.html'

= Put content in here!
#

This is the first scene.

#

This is the second scene.

$include './footer.html'

footer.html

	</body>
</html>