Hi Tony,
I noticed that you are reading the wiki file one line at a time. There are some pros and cons to that, but my opinion is that you may want to read the whole file at once and then parse. The reason is that you don't have to write the wiki text with the closing tags all on one line.
I created two new procedures that you may want to look at
Read File
Code:
Sub ReadWikiFile(file)
file = ProgDir & file
If FileExist (file) = true Then
FileOpen (c1, file, cRead ,, cASCII)
wiki = FileReadToEnd(c1)
FileClose (c1)
Return ParseWiki(wiki)
Else
' wiki file doesn't exist - how did that happen?
End If
End Sub
Parser
Code:
Sub ParseWiki (wiki)
'HTML Header
HtmStr = "<html><head><meta http-equiv=" & Chr(34) & "Content-Type" & Chr(34) & " content=" & Chr(34) & "text/html; charset=utf-8" & Chr(34) & ">" & crlf
HtmStr = HtmStr & "<title>homepage</title>" & crlf
HtmStr = HtmStr & "<link rel=" & Chr(34) & "stylesheet" & Chr(34) & " href=" & Chr(34) & "file:///" & ProgDir & "wikistyle.css" & Chr(34) & " Type=" & Chr(34) & "text/css" & Chr(34) & ">" & crlf
HtmStr = HtmStr & "</head><body>" & crlf
For x=0 To StrLength(wiki)
schr=SubString(wiki,x,1)
' Msgbox(schr)
' --- CONVERT SIMPLE SINGLE CHARACTERS ---
If schr=" " Then
HtmStr=HtmStr & " "
End If
If schr=Chr(13) Then
HtmStr=Htmstr & "<br>"
End If
' --- CONVERT LINK ---
Select schr
Case "["
'If schr="[" Then
If SubString(wiki,x+1,1)="[" Then ' this is reference with differnt text ie [[wiki][welcome to my wiki!]]
End If
y=StrIndexOf(wiki, "]", x)
'Msgbox(x & " " & y)
HtmStr=Htmstr & "<a href='" & SubString(wiki,x+1,y-x-1) & "'>" & SubString(wiki,x+1,y-x-1) & "</a>"
' Msgbox(SubString(wiki,x+1,y-x-1))
'Msgbox(htmstr)
x=y
'End If
Case Else
HtmStr=HtmStr & schr
End Select
Next
'HTML FOOTER
HtmStr=HtmStr & "</body></html>"
Return Htmstr
End Sub
This was tested on your sample wiki text and it creates links out of the "[text]" markups. It still needs a lot of work but it's an example.