You are not logged in.
If you find it tedious to use the full formatting range of BBCode when posting longer posts here on the forum then this is for you. This script contains a Pandoc writer that can be used in your own scripts to convert any format recognized by Pandoc to BBCode. The script itself will compile to an executable that converts Markdown on stdin to BBCode on stdout for simplified forum posting.
This entire post was written in Markdown. You can get it here.
The writer is simple and could be optimized. It only supports FluxBB's (sub?)set of BBCode, so some formatting features are not supported (e.g. subscripts and superscripts).
Emphasized, strongly emphasized, struckout text and inline code (which I have arbitrarily made red for now).
Code blocks:
$ echo foo
Bullet lists:
foo
bar
baz
Numbered lists:
foo
bar
baz
Alphabetic lists:
foo
bar
baz
Quotes:
And also, Allan insulted me
Images:
It also supports headers and links as seen above.
The script's main function will read Markdown from stdin and print BBcode to stdout.
Script source: markdown2bbcode.hs.
You could also use xacget:
$ xacget markdown2bbcode.hs
ghc
haskell-pandoc
upx (optional: for reducing the binary size)
ghc -O2 --make -o markdown2bbcode pandocWriteBbcode.hs
By default GHC will create a relatively large, independent executable. To create a smaller dynamically linked exectuable, use
ghc -dynamic -O2 --make -o markdown2bbcode pandocWriteBbcode.hs
To reduce the size further, use upx:
upx --best markdown2bbcode
Open an editor, write your post in Markdown, save it to input.md, then run
markdown2bbcode < input.md > output.txt
Open output.txt, copy the contents and paste it into the forum text area. Preview it and then submit if everything looks good.
I will package this if people show interest. I need to figure out how to properly package Haskell modules before I do as this should install Text.Pandoc.Writers.BBCode along with the script markdown2bbcode. I'll try to get to that soon as I have a larger Haskell project that I hope to release in the coming weeks.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
What an awesome idea. I write most of my stuff in markdown, and was thinking about a solution for converting markdown to BBCode so I googled it and of course wound up at the Community Contributions part of our forum
Unfortunately I can't get it to compile, GHC just returns
<no location info>: can't find file: pandocWriteBbcode.hs
I have ghc 7.6.3-1 and haskell-pandoc 1.11.1-8
Offline
Sorry, at some point I changed the name of the file without updating the build commands on the page. It should match the name of the source file, e.g.
ghc -O2 --make -o markdown2bbcode markdown2bbcode.hs
[1 of 1] Compiling Main ( markdown2bbcode.hs, markdown2bbcode.o )
Linking markdown2bbcode .
Note that the current version requires haskell-pandoc 1.12. If you can't upgrade, there are 2 lines in the file that can be commented out for pandoc <1.12 support. They are marked in the file with comments. Just prepend "--" to those two lines.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Oh, I should have figured that out myself! Thanks for the heads up about haskell-pandoc 1.12. I switched to using the [haskell-core] repo instead. Great script, it does exactly what is says, and using markdown instead of bbcode for long forum post is much quicker/easier.
Offline