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: 1731
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: 1731
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
vtol
Valued Contributor
Valued Contributor


Joined: 05 Feb 2004
Posts: 622
Location: Indiana

PostPosted: Tue Apr 16, 2019 5:05 pm    Post subject: hello hello Reply with quote

howdys
Sure do miss all this.
Anyways, nice POST, but I guess I'm a big dummy on
how it works.
I'm guessing it needs a MAIN DIALOG to get it working?
I compiled it as it is, but it got below error:
Invalid function at line 15

I'm sure its just me, but couldn't resist posting.

cheers

Oh yeah, ignore the VDS5 on my profile pic, its outdated.
I'm using VDS6 on Windows 10 /7 /XP /98 /95 /2k and DOS 1 Stupid
Forgot Commedore 64 Embarassed
Back to top
View user's profile Send private message Visit poster's website AIM Address
DaveR
Valued Contributor
Valued Contributor


Joined: 03 Sep 2005
Posts: 413
Location: Australia

PostPosted: Sun Apr 21, 2019 5:21 am    Post subject: Re: hello hello Reply with quote

vtol wrote:
I compiled it as it is, but it got below error:
Invalid function at line 15

As the code is just 2 user defined functions, you need to define those 2 functions at the top of your script:
Code:
#define function,markdown,rep


vtol wrote:
Oh yeah, ignore the VDS5 on my profile pic, its outdated.
I'm using VDS6 on Windows 10 /7 /XP /98 /95 /2k and DOS 1 Stupid
Forgot Commedore 64 Embarassed

I'd like to see VDS6 running on a Commodore 64. I'd be happy just to see a working Commodore 64 in the flesh again.

Now I've forgotten why I came here today... Must have been to search for an answer to something.

_________________
cheers

Dave
Back to top
View user's profile Send private message 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