Struggling with the interpreter for reading in bladewiki files, but getting there slowly.
Currently I load a line from the file then process that line character by character to find the markup.
+ = <h1> Header Level 1
++ = <h2> Header Level 2
- = <li> list item
[ = Start of link to another file
] = end of link to another file
There is more but that's enough for now.
Here is my interpreter so far.
Code:
Sub GetFile(file)
file = ProgDir & file
If FileExist (file) = true Then
FileOpen (c1,file,cRead ,, cASCII)
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
line = FileRead (c1)
Do Until line = EOF
If line <> EOF Then ' START PROCESSING LINE
For i = 0 To StrLength(line)-1
If i = 0 AND bullet = True Then ' CHECK TO SEE IF WE SHOULD END BULLET LIST
HtmStr = HtmStr & "</ul>"
bullet = False
End If
If i = 0 AND SubString(line, i, 2) = "++" Then ' START HEADER LEVEL 2
If header2 = False Then
header2 = True
HtmStr = HtmStr & "<h2><a name=" & Chr(43) & currentpage & Chr(34) & ">"
End If
Else If i = 0 AND SubString(line, 0, 1) = "+" Then ' START HEADER LEVER 1
If header1 = False Then
header1 = True
HtmStr = HtmStr & "<h1><a name=" & Chr(43) & currentpage & Chr(34) & ">"
End If
Else If i = 0 AND SubString(line, 0, 1) = "-" Then
If bullet = False Then ' START BULLET LIST
bullet = True
HtmStr = HtmStr & "<ul><li>"
Else ' CONTINUE BULLET
HtmStr = HtmStr & "<li>"
End If
Else
If i = 0 Then
HtmStr = HtmStr & "<p>" ' START PARAGRAPH
paragraph = True
End If
HtmStr = HtmStr & SubString(line, i, 1)
End If
Next ' FINNISHED LINE NOW TIDYUP BEFORE NEXT LINE
End If
If header1 = True Then ' CLOSE HEADER 1
header1 = False
HtmStr = HtmStr & "</a></h1>" & crlf
End If
If header2 = True Then ' CLOSE HEADER 2
header2 = False
HtmStr = HtmStr & "</a></h2>" & crlf
End If
If paragraph = True Then ' CLOSE PARAGRAPH
paragraph = False
HtmStr = HtmStr & "</p>"
End If
HtmStr = HtmStr & crlf ' ADD LINE FEED TO MAKE SOURCE CLEAN
line = FileRead (c1)
Loop
FileClose (c1)
Return HtmStr
End If
End Sub