Página 1 de 1

Dll: ConvertBBCodeToHTML

Publicado: 23 Abr 2011 21:40
por Ceone
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

Re: Dll: ConvertBBCodeToHTML

Publicado: 23 Abr 2011 22:28
por Agotaras123
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.

Re: Dll: ConvertBBCodeToHTML

Publicado: 23 Abr 2011 22:31
por Ceone
el html de lua??

Re: Dll: ConvertBBCodeToHTML

Publicado: 23 Abr 2011 22:33
por Agotaras123
si para poder implementarlo como bbcode normal a si como el de youtube, pero sin usar el geshi

Re: Dll: ConvertBBCodeToHTML

Publicado: 23 Abr 2011 22:39
por Ceone
si quiere bájate un mod de geshi y búscalo por que no esta muy a mano, ahora mismo... ;)

Re: Dll: ConvertBBCodeToHTML

Publicado: 23 Abr 2011 22:42
por Agotaras123
dale ok amigo lo buscare entonces, se te agradece.

Re: Dll: ConvertBBCodeToHTML

Publicado: 27 Abr 2011 15:28
por dangngocnguyenit
thanks

Re: Dll: ConvertBBCodeToHTML

Publicado: 02 May 2011 12:35
por er_mejor
gracias!

Re: Dll: ConvertBBCodeToHTML

Publicado: 04 May 2011 00:59
por ahmed elsayed
thanx ceone

Re: Dll: ConvertBBCodeToHTML

Publicado: 04 May 2011 08:57
por xxsolracxx
gracias

Re: Dll: ConvertBBCodeToHTML

Publicado: 07 May 2011 23:29
por abood1987
gracias :yes: :yes: :yes:

Re: Dll: ConvertBBCodeToHTML

Publicado: 17 Oct 2011 17:42
por julian000
gracias

Re: Dll: ConvertBBCodeToHTML

Publicado: 10 Nov 2011 01:34
por bumbo
bravo

Re: Dll: ConvertBBCodeToHTML

Publicado: 29 Mar 2012 06:33
por omisterioo
xd

Publicado: 30 Ago 2013 22:01
por chakal03
Gracias

Publicado: 13 Mar 2014 08:09
por tmraslan
Thans Bro

Re: Dll: ConvertBBCodeToHTML

Publicado: 10 Sep 2017 20:33
por jhonitimer
thnksssss

Re: Dll: ConvertBBCodeToHTML

Publicado: 22 Dic 2017 16:44
por dripro
Gracias

Re: Dll: ConvertBBCodeToHTML

Publicado: 21 Sep 2019 09:20
por Cristian Veliz M.
Gracias