You can help CodeWalrus stay online by donating here. | New CodeWalrus | Old (dark mode) | Old (light) | Discord server

BBCode to Wiki Markup - Name [Ruby]

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

0
b/PC, Mac & Vintage Computers publicado por u/Unicorn July 19, 2016, 05:38:29 PM
I've found that we need a program to convert BBCode (The formatting that the forum uses) to Wiki Markup (The formatting that most of the community wikis use). It will make it easy to bring tutorials written on the forum into the wiki.

I will be using Ruby to write it, with Shoesfor a gui. It will not support images, tables, lists, fonts, and colors right away, if ever. It will definitely support code, bold, italics, underlines, and urls.

The one problem I have is figuring out how to distribute it. Using Ocra, the gem that lets you package your script into a .exe file doesn't quite work, and I'm unsure how I would be able to host it online.

Here's an example that uses all of the converted functions:

BBCtoWiki Example

Wassup! This is an example![/b]
Strike this text, it makes no sense!
And don't forget an image!

Lets indent this code, as well!
    codecodecode codecodecode codecodecode
    codecodecode codecodecode
    codecodecode
    codecodecode
    codecodecode codecodecode codecodecode

    ---------------------------------------------------------------------
    That was the post, here's the BBC:

    [size=24]BBCtoWiki Example[/size]

    [i]Wassup! [b]This is an example![/i][/b]
    [s]Strike this text, it makes no sense![/s]
    [size=12]And don't forget an image![/size]
    [img]https://codewalr.us/Themes/CodeWalrus/images/english/smflogo.png[/img]
    Lets indent this code, as well!
    [list][code]codecodecode codecodecode codecodecode
    codecodecode codecodecode
    codecodecode
    codecodecode
    codecodecode codecodecode codecodecode

    [/list][/code]
    -------------------------------------------------------------------
    And here is the Wiki Markup:

    == BBCtoWiki Example ======

    ''Wassup! ''''This is an example!'''''
    <strike>Strike this text, it makes no sense!</strike>
    ==== And don't forget an image! ======
    https://codewalr.us/Themes/CodeWalrus/images/english/smflogo.png
    Lets indent this code, as well!
    <blockquote><pre>codecodecode codecodecode codecodecode
    codecodecode codecodecode
    codecodecode
    codecodecode
    codecodecode codecodecode codecodecode
    </pre>
    </blockquote>

    ----------------------------------------------
    Go here to see an example of the Wiki Markup: https://www.cemetech.net/learn/Bbcodeconvertexample
    Last Edit: July 22, 2016, 10:22:28 PM by Unicorn
    Inicia sesión o crea una cuenta para dejar un comentario
    u/Dream of Omnimaga July 20, 2016, 03:49:11 AM
    That would definitively be useful. I always wondered if such tool was available before, because I once wanted to convert a post to a TI-Story page and it was a major hassle.

    I can't help, but hopefully someone can. Just make sure before copying tutorials to ask the author's permission before uploading it elsewhere, though.
    u/Unicorn July 21, 2016, 02:39:25 AM
    Yup, that it exactly why, to lessen the hassle. Anyways, anyone have an idea for a name?
    u/Dream of Omnimaga July 21, 2016, 03:53:00 AM
    BBCode2wiki?

    Envoyé de mon Nexus 5 en utilisant Tapatalk

    u/Unicorn July 22, 2016, 04:08:09 AM
    Oh yes, anyone have an idea for a name?

    So I've made alot of progress. I have something of a gui, and teh program supports converting Bold text, strikethroughs, italics, images, lists (they get turned into those lines "----"), and code.

    Here's the code:


    require 'shoes'
    Shoes.app(title: "BBCode to Wiki Markup", width: 1000, height: 750, resizable: true) do
      background white
      @BBC = edit_box top: 60, left: 35, width: 940, height: 250
      @Convert = button "Convert", top: 340, left: 450
      @Convert.click do
        bbcode = @BBC.text
            bbcode.gsub! "[b]", "''''"
            bbcode.gsub! "[/b]", "'''"
            bbcode.gsub! "[i]", "''"
            bbcode.gsub! "[/i]", "''"
            bbcode.gsub! "[scode]", "<code>"
            bbcode.gsub! "[s/code]", "</code>"
            bbcode.gsub! "[s]", "<strike>"
            bbcode.gsub! "[/s]", "</strike>"
            bbcode.gsub! "[img]", ""
            bbcode.gsub! "[/img]", ""
            bbcode.gsub! "[list]", "----"
            bbcode.gsub! "[/list]", ""
        edit_box "#{bbcode}", top:400, left: 35, width: 940, height: 250
      end
      @quitB = button "Quit", top: 700, left: 455
      @quitB.click {exit}
      end


    EDIT: I fixed it! I had to use gsub! instead of sub!.

    A video, converting Bold text:

    It can convert the entirety of this post: https://www.cemetech.net/forum/viewtopic.php?t=12725&highlight=
    Example: https://www.cemetech.net/learn/Bbcodeconvertexample

    I'm going to work on headers, and maybe change up the list tag a little.

    Download Below
    Last Edit: July 22, 2016, 08:04:58 PM by Unicorn
    u/Unicorn July 22, 2016, 10:02:45 PM
    So I've added text sizes and tweaked the code conversion, so check out the examples.

    See the OP for an example! https://codewalr.us/index.php?topic=1467.msg41898#msg41898

    Any more ideas for other tags? I could include smilies...

    Download Below
    Last Edit: July 22, 2016, 10:24:53 PM by Unicorn
    u/Dream of Omnimaga July 22, 2016, 10:59:34 PM
    By the way, does this support Wikidot syntax too? It would be a nice addition for cross-posting BASIC tricks or posts into TI-BD wiki or to post TI community doc in TI-Story, which are both hosted on Wikidot.

    Other than that, Does this need dependencies other than Shoes? Because when I run this, once Shoes is downloaded, it takes about 1 minute to load and it takes over 15% CPU (I have a quad-core) during that time.

    EDIT: It doesn't seem to convert much so far. Does it only support PhpBB syntax? I tried converting this post, btw https://codewalr.us/index.php?topic=28.0
    Last Edit: July 22, 2016, 11:02:26 PM by DJ Omnimaga
    u/Unicorn July 23, 2016, 12:13:02 AM
    So yeah, urls, aren't implemented yet, and colors don't work. I also need to implement underlining.

    It shouldn't take to long, I'm not sure, on linux its fast...
    u/Dream of Omnimaga July 23, 2016, 12:21:37 AM
    I use Windows 7 64-bits. Maybe that's why?
    u/Unicorn July 23, 2016, 02:50:02 AM
    Quote from: DJ Omnimaga on July 23, 2016, 12:21:37 AM
    I use Windows 7 64-bits. Maybe that's why?

    Does it open the window right away, but then freeze? It does that for me when on Windows 10. I guess I'll have to package it a different way.
    u/Unicorn July 23, 2016, 07:21:36 PM
    OK, heres another thing to try, @DJ Omnimaga

    Use the same .exe, but shoes is already included in the application, you won't have to download it. You also might want to uninstall shoes before running it. And I made urls work :P

    http://www.mediafire.com/download/616o23g0c9hphsn/BBCtoWIKI.zip
    Last Edit: July 23, 2016, 07:29:35 PM by Unicorn
    u/aetios July 23, 2016, 07:27:55 PM
    How about BBC2WM for a name. BBCode to Wiki Markup.
    u/Dream of Omnimaga July 24, 2016, 12:46:13 AM
    Quote from: Unicorn on July 23, 2016, 02:50:02 AM
    Quote from: DJ Omnimaga on July 23, 2016, 12:21:37 AM
    I use Windows 7 64-bits. Maybe that's why?

    Does it open the window right away, but then freeze? It does that for me when on Windows 10. I guess I'll have to package it a different way.
    YEs it opens a window right away. It just remains blank like if it had frozen for about a minute. I'll try your other download link now.

    EDIT: The new version seems to open much faster now.
    Last Edit: July 24, 2016, 12:49:44 AM by DJ Omnimaga
    u/Unicorn July 24, 2016, 05:42:26 PM
    Good, I'm glad that's fixed. Now, is there anything else I should do?
    u/Dream of Omnimaga July 25, 2016, 07:38:29 AM
    Maybe there could be options to choose the formating style, such as, for example, if the user wants underline-bold text to be converted to big text and bold text to medium text or if he prefers that they are converted to something else?
    Start a Discussion

    b/PC, Mac & Vintage Computers

    Computer programming discussion and project showcase

    132
    Topics
    Explore Board
    Website statistics


    MyCalcs | Ticalc.org | Cemetech | Omnimaga | TI-Basic Developer | MaxCoderz | TI-Story | Casiocalc.org | Casiopeia | The Museum of HP Calculators | HPCalc.org | CnCalc.org | Music 2000 Community | TI Education | Casio Education | HP Calcs | NumWorks | SwissMicros | Sharp Calculators
    Powered by EzPortal