Dll: ConvertBBCodeToHTML

Plugins y todo lo relacionado para Autoplay Media Studio.
Hola amigos de AMSSpecialist.info, quiero presentaros la primera DLL que he creado es una dll muy simple y limitada pero bueno es lo que diríamos practicas con Visual Studio. Como el nombre bien describe esta dll es para convertir BBCode en HTML, y bueno no están todos los comando pero bueno la cuestión era crear mi primera dll y que funcionara bien.


C#:
using System;
using System.Collections.Generic;
using System.Text;
using RGiesecke.DllExport;
using System.Text.RegularExpressions;

namespace ConvertBBCodeToHTML
{
internal static class UnmanagedExports
{
[DllExport("ConvertBBCodeToHTML", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
static string ConvertBBCodeToHTML(string str)
{
Regex exp;
// format the bold tags:
// becomes: <strong></strong>
exp = new Regex(@"\[b\](.+?)\[/b\]");
str = exp.Replace(str, "<strong>$1</strong>");

// format the italic tags:
// becomes: <em></em>
exp = new Regex(@"\[i\](.+?)\[/i\]");
str = exp.Replace(str, "<em>$1</em>");

// format the underline tags:
// becomes: <u></u>
exp = new Regex(@"\[u\](.+?)\[/u\]");
str = exp.Replace(str, "<u>$1</u>");

// format the strike tags: [s][/s]
// becomes: <strike></strike>
exp = new Regex(@"\[s\](.+?)\[/s\]");
str = exp.Replace(str, "<strike>$1</strike>");

// format the url tags: my site
// becomes: <a href="www.website.com">my site</a>
exp = new Regex(@"\[url\=([^\]]+)\]([^\]]+)\[/url\]");
str = exp.Replace(str, "<a href=\"$1\">$2</a>");

// format the img tags: Imagen
// becomes: <img src="www.website.com/img/image.jpeg" />
exp = new Regex(@"\[img\]([^\]]+)\[/img\]");
str = exp.Replace(str, "<img src=\"$1\" />");

// format img tags with alt: Imagen
// becomes: <img src="www.website.com/img/image.jpeg" alt="this is the alt text" />
exp = new Regex(@"\[img\=([^\]]+)\]([^\]]+)\[/img\]");
str = exp.Replace(str, "<img src=\"$1\" alt=\"$2\" />");

//format the colour tags:
// becomes: <font color="red"></font>
// supports UK English and US English spelling of colour/color
exp = new Regex(@"\[color\=([^\]]+)\]([^\]]+)\[/color\]");
str = exp.Replace(str, "<font color=\"$1\">$2</font>");
exp = new Regex(@"\[colour\=([^\]]+)\]([^\]]+)\[/colour\]");
str = exp.Replace(str, "<font color=\"$1\">$2</font>");

// format the size tags:
// becomes: <font size="+3"></font>
exp = new Regex(@"\[size\=([^\]]+)\]([^\]]+)\[/size\]");
str = exp.Replace(str, "<font size=\"+$1\">$2</font>");

// lastly, replace any new line characters with <br />
str = str.Replace("\r\n", "<br />\r\n");

return str;
}
}
}


Lua:

Código: Seleccionar todo

str = [[
[b]negrita[/b]
[i]cursiva[/i]
[u]subrayado[/u]
[s]tachado[/s]
]]
result = DLL.CallFunction("AutoPlay\\Docs\\ConvertBBCodeToHTML.dll", "ConvertBBCodeToHTML", "\"" .. str .. "\"", DLL_RETURN_TYPE_STRING, DLL_CALL_STDCALL);
Dialog.Message("", result);
He puesto el "str" en code por que en lua me da algunos errores....

Decarga:
HIDE: ON
Hidebb Message Hidden Description
amigo esto esta de puta madre, me sera de ayuda para algunos programas que tengo en mente, por esas casualidades no tendrás el html de LUA.
el html de lua??
si para poder implementarlo como bbcode normal a si como el de youtube, pero sin usar el geshi
si quiere bájate un mod de geshi y búscalo por que no esta muy a mano, ahora mismo... ;)
dale ok amigo lo buscare entonces, se te agradece.
thanks
gracias!
thanx ceone
gracias
gracias :yes: :yes: :yes:
gracias
bravo
xd

Gracias

Thans Bro
thnksssss
Gracias
Gracias