TASVideos Pandoc

Artifact [9eae8a5f7b]
Login

Artifact [9eae8a5f7b]

Artifact 9eae8a5f7b8a28098b748cc7f86a31b7655c1082abecc24400b7cc90f2c0dffd:


Pandoc [custom writer](https://pandoc.org/custom-writers.html)
for [TASVideos forum markup](https://tasvideos.org/ForumMarkup),
which is based on BBCode.
With this, you can convert from [many document formats](https://pandoc.org/MANUAL.html#option--from)
to the format used for forum posts and direct messages on TASVideos.

## Usage

Download the file [tasvideos_forum.lua](/raw/tasvideos_forum.lua?ci=trunk&at=tasvideos_forum.lua).

Run pandoc, passing it the option `-t tasvideos_forum.lua`
(using the name of the custom writer file as if it were a format name).

For example, to convert a Markdown file to TASVideos forum markup:

    pandoc -f markdown -t tasvideos_forum.lua README.md

The tasvideos_forum.lua filename may be given as a path,
or the file may be stored under the Pandoc user data directory.
See <https://pandoc.org/MANUAL.html#custom-readers-and-writers>.

## Accessing special features with classes and attributes

Some features of TASVideos forum markup can be accessed by
[setting classes and attributes](https://pandoc.org/MANUAL.html#divs-and-spans)
on parts of the input.
This is easiest to do with HTML input, or Markdown with the
[`fenced_divs`](https://pandoc.org/MANUAL.html#extension-fenced_divs) and
[`bracketed_spans`](https://pandoc.org/MANUAL.html#extension-bracketed_spans) extensions.

For example, this HTML:

    <div class="mark">
    highlighted <span class="spoiler">and spoilered</span>
    </div>

or this Markdown:

    ::: {.mark}
    highlighted [and spoilered]{.spoiler}
    :::

Renders to the following forum markup:

    [highlight]highlighted [spoiler]and spoilered[/spoiler][/highlight]

These are the understood classes
and what BBCode elements they correspond to:

|Class    |Alternative HTML|BBCode       |
|---------|----------------|-------------|
|`mark`   |`<mark>`        |`[highlight]`|
|`spoiler`|                |`[spoiler]`  |

The download filename for code blocks may be provided by a `filename` attribute, like so:

    ``` {filename=test.lua}
    print("hello")
    ```

You can use "note" and "warning" alerts.
The below Markdown input (with the [`alerts`](https://pandoc.org/MANUAL.html#extension-alerts) extension turned on):

    > [!NOTE]
    > A note

    > [!WARNING]
    > A warning

renders to:

    [note]A note[/note]

    [warning]A warning[/warning]

## Raw output

To output TASVideos-specific markup such as `[movie]` and `[post]`,
use Pandoc [raw attributes](https://pandoc.org/MANUAL.html#generic-raw-attribute)
with a format name of `tasvideos_forum`:

    This is `[frames]100[/frames]`{=tasvideos_forum} faster than `[movie]1234[/movie]`{=tasvideos_forum}.

    ``` {=tasvideos_forum}
    [center]
    More details are in [post=1234]this post[/post].
    [/center]
    ```

## Extensions

To enable an [extension](https://pandoc.org/MANUAL.html#extensions),
provide it after the custom writer filename with a `+` sign.
To disable, use a `-` sign.

    pandoc -f markdown -t tasvideos_forum.lua+embed_resources README.md

Supported extensions:

|Extension        |Effect|
|-----------------|------|
|`embed_resources`|Embed image data for the `[img]` tag as a [data URI](https://en.wikipedia.org/wiki/Data_URI_scheme), rather than a link. (Like the [`--embed-resources`](https://pandoc.org/MANUAL.html#option--embed-resources%5b) option of pandoc.) Default disabled.|

## To clone this repository

    fossil clone https://chiselapp.com/user/Sand/repository/tasvideos-pandoc

See the [Fossil quick start](https://fossil-scm.org/home/doc/trunk/www/quickstart.wiki).

## External links

* [TASVideos thread](https://tasvideos.org/Forum/Topics/27015)
* [Pandoc discussion](https://github.com/jgm/pandoc/discussions/11434)