Giter Club home page Giter Club logo

markdown_to_bgg's Introduction

md_to_bgg.py is a Markdown to boardgamegeek.com (BGG) markup converter (this is the markup used in the BGG forums).

Markdown to BGG

md_to_bgg.py is useful for a few reasons:

  1. You can write BGG posts and have a live preview (through your Markdown editor).
  2. Markdown is easier to use than the BGG markup, which is quite verbose.
  3. The BGG markup requires some cumbersome editing (like when extracting the numeric identifier of a board game from its full URL), which is eschewed by md_to_bgg.py.
  4. Markdown is a much more common format.

Markdown syntax

Standard Markdown

md_to_bgg.py reads texts writen in the standard CommonMark version of Markdown.

Many common Markdown constructs are supported:

  • headers—but only levels 1 (#) and 2 (##)—,
  • BGG italics (_important_…),
  • BGG bold (**very important**…),
  • BGG monospace (`inline code`),
  • quotes (> …),
  • lists (numbered or not),
  • links ([search engine](https://google.com), with the exact same syntax used for links to BGG itself).

Lists are left untouched (as the BGG markup doesn't support them), except for numbered lists, which are automatically numbered in BGG markup:

1. First item
1. Second item

will thus automatically produce:

1. First item
2. Second item

Extended Markdown

md_to_bgg.py extends CommonMark Markdown so as to handle some specificities of the BGG markup.

Strikethrough

Strikethrough text uses a double tilde: ~~…~~ (this follows the GitHub Flavored Markdown syntax).

Automatic link names

BGG can automatically insert the names of board games, forum threads, etc., which is something not handled by standard Markdown links. md_to_bgg.py therefore extends Markdown by removing the link text part ([…]), for links to BGG contents:

This game is similar to (https://boardgamegeek.com/boardgame/224517/brass-birmingham).

will produce

This game is similar to Brass Birmingham.

Images

Images on BGG do not have any alternate text, so this part of the Markdown syntax is similarly removed:

External image: !(https://github.com/lebigot/markdown_to_BGG/blob/main/markdown.png)
BGG image (same Markdown syntax): !(https://boardgamegeek.com/image/2355823/clockwork-wars)

The size of a BGG image can be indicated in a way reminiscent of the BGG markup:

Large BGG image: !(https://boardgamegeek.com/image/2355823/clockwork-wars large)

(the size names are the same as in BGG markup).

Embedded YouTube videos

YouTube videos on BGG don't have any alternate text, so, similarly to images, their Markdown syntax has no link text part:

Nice intro to Eldritch Horror:
(https://www.youtube.com/watch?v=x-J2KzQb5lI)

Raw BGG markup

Most of the BGG markup syntax is left untouched by md_to_bgg.py: it is therefore also possible to directly insert many BGG markup constructs in the Markdown source (e.g. [q="lebigot"]…[/q] should work unless the beginning looks like a Markdown link—[q=…](…)…).

Limitations

Some of the Markdown syntax is not converted to BGG markup, and is instead left essentially as is. If you expect some of the Markdown syntax to produce some specific BGG markup which is not currently covered, don't hesitate to open an Issue on GitHub. In any case, raw BGG markup can often be used directly in the Markdown source in order to get the desired effect.

Usage

You can convert any Markdown file directly with

python md_to_bgg.py your_file.md

md_to_bgg.py will print the rendering in BoardGameGeek markup. Under Unix, you can of course save the result in a file and then paste its contents on BGG:

python md_to_bgg.py your_file.md > your_file.bgg

On a recent enough macOS, you may also copy the BGG markup directly to the clipboard, for easy pasting into the BGG forums:

python md_to_bgg.py your_file.md | pbcopy

Requirements

md_to_bgg.py requires Python 3.6+.

Installation

md_to_bgg.py depends on the marko Markdown parser, so you need to have it installed:

pip install marko

The md_to_bgg.py script itself can simply be directly downloaded (select the "Raw" version with the button on top).

markdown_to_bgg's People

Contributors

lebigot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.