Resource Marx - a Markup-to-Minecraft translator

Discussion in 'Spigot Plugin Development' started by SCPKeter, Jan 14, 2019.

  1. Hey everyone!

    I was inspired by Discord and this forum's markup features, and, knowing that Minecraft also has its own 'formatting' syntax, I've made this lib: [GitHub Repo].
    Also, here's my resource with this lib - Markle.

    Besides, it's not just a markup translator, it is also capable of optimizing Minecraft formatting.
    For example:
    • Removes multiple formatting characters
    • Removes trailing formatting characters
    • Removes instantly terminated formatting

    How does it work?
    It's a regular expression based translator.
    There are various markup language translators built-in, which contain their specific patterns, still, translators' pattern sets are easily expanded.

    Why I have posted this?
    First, I want this lib to be just a little more popular (of course, if it's a good way to spread stuff across the world).
    Second, I need your help.
    Though it perfectly optimizes and translates markup, it is not capable of ignoring escaped patterns like
    Code (Text):
    \**bold** // Has to remain **bold** but it is not affected
    Any suggestions/problem solutions?
    I would appreciate any feedback~
     
    • Winner Winner x 1
  2. Maby first check if there is anything like '\**bold**' in the text, then replace those for something else, then apply the normal filter and then replace the '\**bold**' back to normal.
     
  3. Yes, I was trying - some commits still have traces of my pathetic attempts.
    It fails, because escaped bold (**bold**) is treated as an unescaped italic (*italic*)
     
  4. Thanks, will try this.
     
  5. Well if you try it in discord itself (at least last time I checked), \**bold** does become *bold*. What you're looking for is \*\*bold**
     
  6. It does not. It becomes plain **bold**
     
    • Like Like x 1
  7. Ohhhh interesting. It is likely possible to get around this using negative looks behinds still though.
     
    #8 GreatThane, Jan 14, 2019
    Last edited: Jan 14, 2019
  8. You could replace "\**" with "\*\*" beforehand.
     
  9. When it comes to escaping in strings, it's a very tricky thing to do with raw regex.

    I suggest you stick with your current regex. When it comes to checking them however, I would recommend that you check if a '\' exists. So pass off any raw regex data to whatever method you have, and for each occurrence get the index of the first whatever character (whether that be '*' or '_'). What you do next is check to the left of that, and check if there's a \. If it's at the start of the string... well you have to check for that too. Once you've done that, if there's a slash, simply move on to processing the next occurrence as bold!

    Regex is designed primarily to match certain descriptors, not against certain descriptors (though it has and still continues to be used in that way, which is okay - just pointing it out). For trivial things like a backslash, it's better to do that in code yourself.
     
  10. Alright, seems like a good plan.
    Still, what to do with backslashes themselves?
    They must be escapable, too.

    UPD:
    Have you actually checked out source codes?
     
  11. I made a similar plugin which accepts escaped patterns here: https://www.spigotmc.org/resources/md_.57529/

    The source code can be found here: https://github.com/Aeternum-Studios/MarkdownForMinecraft/blob/master/m/d/MD_.java

    It's much simpler than yours, and uses some workarounds, but I used negative look behinds to escape patterns. As for how they should be escaped, if you want to do something such as **bold**, you would need to use \*\*bold\*\*. It makes the most sense since it lets you be as specific as you want.
     
  12. I owe you a huge thanks, my friend <3
     
  13. Should I keep working on Marx using Kotlin, or switch to Java?
    I'm sort of disturbed about that large Kotlin's stdlib.
     
  14. I do not recommend downloading translator plugin as there is alot of grammar error(and this will get your serv rep down). Please use a profesional translator(real person) or have a single language server :p
     
    • Funny Funny x 5
  15. You have misunderstood the purpose of this plugin.
    It does not translate real human languages like English or Russian, instead, it translates Markups (HTML/BBCode/Markdown) into a Minecraft formatting.

    UPD:
    Also, it's not even a plugin, it's a lib lol

    UPD2:
    Indeed funny
     
    • Agree Agree x 1
  16. Then what is the use lollll HTML into mc, why integrating some web in mc
     
    • Funny Funny x 2
    • Optimistic Optimistic x 1
  17. *Applying your exact logic*
    Then what is the use of Spigot, there is a pretty good working official Mojang server core

    (if you reached here and still did not understand)
    Because I'd like to make formatting in chat easier, like in Discord

    UPD:
    Not just HTML, simple markups like Markdown or BBCode
     
  18. No but HTML is designing, not executing... your comparaison makes no sence...
     
  19. 2008Choco

    Junior Mod

    You're still misunderstanding. The OP's resource converts Markup-formatted text to Minecraft's colour format. For example

    "**this is bold** and _this is italic_"
    would then become, in Minecraft,
    "this is bold and this is italic"

    As it stands currently, you cannot use colour codes in-game without a plugin such as Essentials to replace &<code> with colours, the OP seeks to add an alternative chat format, Markdown, an existing formatting "language".
     
    • Agree Agree x 2
    • Like Like x 1

Share This Page