forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Markdown

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1730
Location: Space and Time

PostPosted: Fri Feb 01, 2019 1:41 pm    Post subject: Markdown Reply with quote

Does anyone have code to convert markdown to html? I am going to try to write my own, but wanted to ask first.
_________________
Chris
Http://vdsfreak.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1730
Location: Space and Time

PostPosted: Fri Feb 01, 2019 3:02 pm    Post subject: Reply with quote

Made one. This is for use with the extText element.

%t = @markdown(<String>)

Code:

:markdown
  if @not(%1)
    exit
  end
  %%md = @new(list)
  %%out = @new(list)
  list assign,%%md,%1
  %x = 0
  repeat
    %i = @trim(@item(%%md,%x))
    %i = @rep(%i,**,<B>,</B>)
    %i = @rep(%i,__,<U>,</U>)
    %i = @rep(%i,//,<I>,</I>)
    if @equal(@substr(%i,1,2),##)
      list add,%%out,<H2>@strdel(%i,1,2)</H2>
    elsif @equal(@substr(%i,1,1),#)
      list add,%%out,<H1>@strdel(%i,1,1)</H1>
    else
      list add,%%out,%i
    end
    %x = @succ(%x)
  until @equal(%x,@count(%%md))
  %%exit = @text(%%out)
  list close,%%md
  list close,%%out
  exit %%exit

:rep
  #replace matching frist and second characters
  #%t = @rep(<string>,<matching characters>,<First>,<second>)
  #ex: %t = @rep(**Bold Text**,**,<B>,</B>)
  if @not(%1)
    exit
  end
  if @not(%2)
    exit
  end
  if @not(%3)
    exit
  end
  if @not(%4)
    exit
  end
  %a = %1
  %d =
  repeat
    %b = %a
    if @greater(@pos(%2,%a,EXACT),0)
      %%p1 = @pos(%2,%a,EXACT)
      %a = @strdel(%a,%%p1,@succ(%%p1))
      %a = @strins(%a,%%p1,%3)
      if @greater(@pos(%2,%a,EXACT),0)
        %%p1 = @pos(%2,%a,EXACT)
        %a = @strdel(%a,%%p1,@succ(%%p1))
        %a = @strins(%a,%%p1,%4)
      else
        %a = %b
        %d = T
      end
    else
      %d = T
    end
  until @equal(@pos(**,%a,EXACT),0)%d
  exit %a

_________________
Chris
Http://vdsfreak.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum




Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group