Pandoc2BBCode — PB Forums posts from any format!

Developed or developing a new product in PureBasic? Tell the world about it.
User avatar
Tristano
Enthusiast
Enthusiast
Posts: 190
Joined: Thu Nov 26, 2015 6:52 pm
Location: Italy
Contact:

Pandoc2BBCode — PB Forums posts from any format!

Post by Tristano »

Good new for all the forum’s posters: Pandoc2BBCode has arrived!

Pandoc2BBCode

Pandoc2BBCode is a pandoc writer for converting to PHPBBCode from over 20 input formats (including markdown, html, ODT and docx).

It’s a useful tool for writing elegantly formatted posts on PureBASIC forums using Markdown, or to convert existing documents on the fly.

The script (Lua) was adapted to target specifically the BBCode flavour used on PB Forums. It also introduces some fancy features, like different size and color for each heading level (H1-H6), where colors where chosen based on PB Forums default color scheme.

Pandoc2BBCode has been included in the «PureBASIC Archives» project, where only the files relevant to PB Forums usage are kept:
The original 2bbcode script was created by @lilydjwg, and I have made changes to adapt it to the BBCode flavour used on PB Forums:
Typography Examples

Here are some typography examples:

Heading 1

Heading 2

Heading 3

Heading 4

Heading 5

Heading 6
BlockQuotes: This is a blockquote element, either created in html with the <blockquote> tag, or in markdown with >.
Source code examples can be easily created with <pre> or <pre><code> tags in html, or using fenced code in markdown (``` or ~~~):

Code: Select all

NewMap Country.s()

Country("US") = "United States"
Country("FR") = "France"
Country("GE") = "Germany"

ForEach Country()
  Debug Country()
Next
Bullet lists:
  • I’m a bullete list
  • another item
    • a sublist

      I’m a loose paragraph within a list. Nesting elements — even block elements! — in a forum post has never been easier.
      And a list-nested blockquote to…
      And, of course, we can also nest source code:

      Code: Select all

      Debug("Geee ... pandoc2bbc is really cool!")
      
    • another item
    • and so on
Ordered lists:
  1. I’m an ordered list
  2. another item
    1. a sub list
    2. another item
All text is smartly cleaned up: straight double " and single ' quotes become “curly” and ‘nice’. Two hyphens -- become –en dashes–, and thre hyphens --- become —em dashes—.

Inline formatting is also styled: bold, italic, strikethrough, inline code.

Project Status

There are still some functions unsupported/unimplemented by the script. Some of these will eventually be implemented (sooner or later), others simply can’t be implemented in BBCode (eg: tables, or other unsupported tags).

Pandoc2BBCode issues warnings on STDERR when it is suppressing some text than can’t be converted, or error messages if it encounters a formatting element for which there is no corresponding function — if you do stumble in a warning of the latter type, please open an issue on GitHub an report it (paste the error message, if possible):
This would greatly help further developement of the script.

Enjoy!

Tristano
The PureBASIC Archives: FOSS Resources: