Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


[VB.Net] CodeSyntax - BBcode Syntax Highlighter v1.0 filter_list
Author
Message
[VB.Net] CodeSyntax - BBcode Syntax Highlighter v1.0 #1
CodeSyntax - BBcode Syntax Highlighter v1.0

[Image: cSGwF.png]

Info:

CodeSyntax is a BBcode highlighter for languages like VB.Net and C#.
Since we do not have codeblock for programming languages and [php] codeblock looks confusing to recreate, I made this for syntax highlighting.
You can probably fool the program in one way or the other if you look carefully, so don't get too over-excited and shout "BUGGY" on top of your lungs. Just post here and I'll try to fix them. Smile

Input:
Code:
If ArrLines(intL).Contains("//") AndAlso ArrLines(intL).Contains("""//""") = False Then
    ArrWords(intW) = "[color=#32CD32]" & ArrWords(intW) & "[/color]"
Else
    If My.Resources.csharpSyntax.Contains(ArrWords(intW)) Then
        ArrWords(intW) = "[color=#87CEEB]" & ArrWords(intW) & "[/color]"
        'Else
        '    ArrWords(intW) = ArrWords(intW)
    End If
End If

Output:

If ArrLines(intL).Contains("//") AndAlso ArrLines(intL).Contains("""//""") = False Then
ArrWords(intW) = "[color=# 32CD32]" & ArrWords(intW) & "[/ color]"
Else
If My.Resources.csharpSyntax.Contains(ArrWords(intW)) Then
ArrWords(intW) = "[color=# 87CEEB]" & ArrWords(intW) & "[/ color]"
'Else
' ArrWords(intW) = ArrWords(intW)
End If
End If

[link=http://hotfile.com/dl/119439886/9a59567/CodeSyntax.exe.html][Image: Download.png]
CodeSyntax - BBcode Syntax Highlighter v1.0 (69 Kb)
[/link]

Spoiler: Source
Code:
Private Sub btnMain_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnVBnet.Click, btnCsharp.Click

        Dim ArrLines As String() = richText.Lines
        Dim tempBuilder As New System.Text.StringBuilder
        For intL As Integer = 0 To ArrLines.Length - 1
            Dim ArrWords As String() = ArrLines(intL).Split(" ")
            If ArrWords.Length > 1 Then
                For intW As Integer = 0 To ArrWords.Length - 1
                    If ArrWords(intW).Length > 0 Then
                        If CType(sender, Button).Text = "C#" Then
                            If ArrLines(intL).Contains("//") AndAlso ArrLines(intL).Contains("""//""") = False Then
                                ArrWords(intW) = "[color=#32CD32]" & ArrWords(intW) & "[/color]"
                            Else
                                If My.Resources.csharpSyntax.Contains(ArrWords(intW)) Then
                                    ArrWords(intW) = "[color=#87CEEB]" & ArrWords(intW) & "[/color]"
                                End If
                            End If
                        Else
                            If ArrLines(intL).Contains("'") AndAlso ArrLines(intL).Contains("""'""") = False Then
                                ArrWords(intW) = "[color=#32CD32]" & ArrWords(intW) & "[/color]"
                            Else
                                If My.Resources.vbSyntax.Contains(ArrWords(intW)) Then
                                    ArrWords(intW) = "[color=#87CEEB]" & ArrWords(intW) & "[/color]"
                                End If
                            End If

                        End If

                    End If
                    tempBuilder.Append(ArrWords(intW) & " ")

                Next
            End If
            tempBuilder.Append(vbCrLf)
        Next
        richText.Text = tempBuilder.ToString
    End Sub



Note:
Tabs and spaces in code are not preserved since no current MyBB codeblock provides blank space preservation other than [code] ( it ignores every BBcode so it doesn't matter).
This is a huge problem and a big code output from CodeSyntax looks confusing without blank spaces. Unfortunately nothing can be done for it currently.
[Image: rytwG00.png]
Redcat Revolution!

Reply

RE: [VB.Net] CodeSyntax - BBcode Syntax Highlighter v1.0 #2
wow great program and very nice usage! since there is no [VB] tag Biggrin
Pierce the life fibers with your drill.

Reply







Users browsing this thread: 1 Guest(s)