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

@bscotch/steam-bbcode

v0.3.0

Published

Generate Steam-compatible BBCode from Markdown.

Downloads

33

Readme

Steam BBCode Generator

Steam has been around for a while, and many parts of its content management system still use legacy BBCode formats. This tool helps generate Steam-compatible BBCode from Markdown.

Note: currently only supports pure Markdown (embedded HTML is left as-is).

Features

  • Supports most of Steam's BBCode format
  • Leaves YouTube and Steam links as-is, allowing Steam to convert them into widgets.

Missing Features

  • Only the BBCode markup documented by Steam is supported
  • Only supports pure Markdown input, with the exception of <img> tags. HTML is left as-is.
  • Does not support tags that have no equivalent in Markdown
    • [spoiler]
    • [noparse]
    • [u]
  • Does not support tag options that don't have standard support in Markdown
    • [quote=author] ([quote] is supported, but there isn't a way to provide an author)

Usage

For a typical use case:

import { md2bbcode } from '@bscotch/steam-bbcode';

const converted = md2bbcode('# Hello, world!');
const bbcode = converted.bbcode;

This package uses marked for rendering. If you want to use your own version of the marked dependency, or want to further modify rendering with your own marked extensions, you can import the BBCode marked extension from this package to use directly:

import { markedBbcodeExtension } from '@bscotch/steam-bbcode/lib';
import { Marked } from 'marked';

const marked = new Marked(
  markedBbcodeExtension /* ... optional other extensions */,
);
function toBbcode(md: string): string {
  // (Marked replaces single-quotes with &#39;, which Steam doesn't know what to do with.)
  return (marked.parse(source) as string).replaceAll('&#39;', "'");
}
const converted = toBbcode('# Hello, world!');

Example

The following Markdown input:

# H1 Heading

## H2 Heading

### H3 Heading

Steam only supports h1-h3, the rest should just be bold.

#### H4 Heading

##### H5 Heading

###### H6 Heading

Some **Bold text**

Some _Italic text_

A [Link](https://example.com 'With a title')

Some ~~Strikethrough text~~

- Unordered list item 1
- Unordered list item 2

1. **Ordered** list item 1
1. Ordered list item 2

> Blockquote

Some `Inline Code!`!

\`\`\`
Block Code!
\`\`\`

![Image](https://example.com/image.jpg)

[![Image](https://example.com/image.jpg)](https://example.com)

---

Plain steam (store.steampowered.com, steamcommunity.com) and youtube links on their own lines should be left as-is since they'll create widgets

https://store.steampowered.com/app/1401730/Crashlands_2/

https://www.youtube.com/watch?v=yR_Opccn1n4

<!-- Image HTML should get converted even though HTML isn't fully supported by this tool -->
<img src="https://example.com/image.jpg" alt="Image" />

Yields the following BBCode output:

[h1]H1 Heading[/h1]

[h2]H2 Heading[/h2]

[h3]H3 Heading[/h3]

Steam only supports h1-h3, the rest should just be bold.

[b]H4 Heading[/b]

[b]H5 Heading[/b]

[b]H6 Heading[/b]

Some [b]Bold text[/b]

Some [i]Italic text[/i]

A [url=https://example.com]Link[/url]

Some [strike]Strikethrough text[/strike]

[list]
  [*] Unordered list item 1
  [*] Unordered list item 2
[/list]

[olist]
  [*] [b]Ordered[/b] list item 1
  [*] Ordered list item 2
[/olist]

[quote]Blockquote[/quote]

Some [code]Inline Code![/code]!

[code]
Block Code!
[/code]

[img alt="Image"]https://example.com/image.jpg[/img]

[url=https://example.com][img alt="Image"]https://example.com/image.jpg[/img][/url]

[hr][/hr]

Plain steam (store.steampowered.com, steamcommunity.com) and youtube links on their own lines should be left as-is since they'll create widgets

https://store.steampowered.com/app/1401730/Crashlands_2/

https://www.youtube.com/watch?v=yR_Opccn1n4

[img alt="Image"]https://example.com/image.jpg[/img]