Allow special commands to be inserted anywhere in the line, except the '@{index}' one.
[GB.MARKDOWN] * NEW: Allow special commands to be inserted anywhere in the line, except the '@{index}' one.
This commit is contained in:
parent
65ccb4094c
commit
1afcd229f8
1 changed files with 46 additions and 62 deletions
|
@ -60,7 +60,7 @@ Private Sub ConvertMarkup(aLine As String[], Optional bDoNotSetLine As Boolean)
|
||||||
Dim hMarkupList As MarkupList
|
Dim hMarkupList As MarkupList
|
||||||
Dim bJustList As Boolean
|
Dim bJustList As Boolean
|
||||||
Dim sLink As String
|
Dim sLink As String
|
||||||
Dim iPos, iPos2 As Integer
|
Dim iPos As Integer
|
||||||
Dim aList As New MarkupList[]
|
Dim aList As New MarkupList[]
|
||||||
Dim sTable As String
|
Dim sTable As String
|
||||||
Dim iIndexPos As Integer = -1
|
Dim iIndexPos As Integer = -1
|
||||||
|
@ -73,7 +73,6 @@ Private Sub ConvertMarkup(aLine As String[], Optional bDoNotSetLine As Boolean)
|
||||||
Dim sList As String
|
Dim sList As String
|
||||||
Dim bSaveComment As Boolean
|
Dim bSaveComment As Boolean
|
||||||
Dim aTemp As String[]
|
Dim aTemp As String[]
|
||||||
Dim sCommand As String
|
|
||||||
|
|
||||||
aResult = New String[]
|
aResult = New String[]
|
||||||
|
|
||||||
|
@ -155,27 +154,14 @@ Private Sub ConvertMarkup(aLine As String[], Optional bDoNotSetLine As Boolean)
|
||||||
sLine = Mid$(sLine, iPos + 4)
|
sLine = Mid$(sLine, iPos + 4)
|
||||||
Endif
|
Endif
|
||||||
|
|
||||||
' Special command
|
' Special command alone on its line
|
||||||
|
|
||||||
|
If Left(sLine, 2) = "@{" And If Right(sLine) = "}" Then
|
||||||
If sLine = "@{index}" Then
|
If sLine = "@{index}" Then
|
||||||
iIndexPos = aResult.Count
|
iIndexPos = aResult.Count
|
||||||
aResult.Add(sLine)
|
aResult.Add(sLine)
|
||||||
Continue
|
Else
|
||||||
Endif
|
aCommand = $hMarkdown.Command(Mid$(sLine, 3, -1))
|
||||||
|
|
||||||
iPos = 0
|
|
||||||
Do
|
|
||||||
iPos = InStr(sLine, "@{", iPos + 1)
|
|
||||||
If iPos = 0 Then Break
|
|
||||||
iPos2 = InStr(sLine, "}", iPos + 2)
|
|
||||||
If iPos2 = 0 Then Break
|
|
||||||
sCommand = Mid$(sLine, iPos + 2, iPos2 - iPos - 2)
|
|
||||||
If Not sCommand Then Break
|
|
||||||
|
|
||||||
aCommand = $hMarkdown.Command(sCommand)
|
|
||||||
|
|
||||||
If iPos = 1 And If iPos2 = Len(sLine) Then
|
|
||||||
|
|
||||||
If aCommand And If aCommand.Count Then
|
If aCommand And If aCommand.Count Then
|
||||||
If $hMarkdown.Reinterpret Then
|
If $hMarkdown.Reinterpret Then
|
||||||
aLine.Insert(aCommand, iLine + 1)
|
aLine.Insert(aCommand, iLine + 1)
|
||||||
|
@ -184,42 +170,10 @@ Private Sub ConvertMarkup(aLine As String[], Optional bDoNotSetLine As Boolean)
|
||||||
Endif
|
Endif
|
||||||
$hMarkdown.Reinterpret = True
|
$hMarkdown.Reinterpret = True
|
||||||
Endif
|
Endif
|
||||||
|
|
||||||
Break
|
|
||||||
|
|
||||||
Else
|
|
||||||
|
|
||||||
If aCommand And If aCommand.Count Then
|
|
||||||
sLine = Left(sLine, iPos - 1) & aCommand[0] & Mid(sLine, iPos2 + 1)
|
|
||||||
iPos += Len(aCommand[0])
|
|
||||||
Endif
|
Endif
|
||||||
|
Continue
|
||||||
$hMarkdown.Reinterpret = True
|
|
||||||
|
|
||||||
Endif
|
Endif
|
||||||
|
|
||||||
Loop
|
|
||||||
|
|
||||||
If iPos Then Continue
|
|
||||||
|
|
||||||
' If Left(sLine, 2) = "@{" And If Right(sLine) = "}" Then
|
|
||||||
' If sLine = "@{index}" Then
|
|
||||||
' iIndexPos = aResult.Count
|
|
||||||
' aResult.Add(sLine)
|
|
||||||
' Else
|
|
||||||
' aCommand = $hMarkdown.Command(Mid$(sLine, 3, -1))
|
|
||||||
' If aCommand And If aCommand.Count Then
|
|
||||||
' If $hMarkdown.Reinterpret Then
|
|
||||||
' aLine.Insert(aCommand, iLine + 1)
|
|
||||||
' Else
|
|
||||||
' aResult.Insert(aCommand)
|
|
||||||
' Endif
|
|
||||||
' $hMarkdown.Reinterpret = True
|
|
||||||
' Endif
|
|
||||||
' Endif
|
|
||||||
' Continue
|
|
||||||
' Endif
|
|
||||||
|
|
||||||
' Blockquote
|
' Blockquote
|
||||||
|
|
||||||
I = 0
|
I = 0
|
||||||
|
@ -671,6 +625,8 @@ Private Sub ConvertLine(sLine As String) As String
|
||||||
Dim bUnderline As Boolean
|
Dim bUnderline As Boolean
|
||||||
Dim bLimitBefore, bLimitAfter As Boolean
|
Dim bLimitBefore, bLimitAfter As Boolean
|
||||||
Dim iLen As Integer
|
Dim iLen As Integer
|
||||||
|
Dim sCommand As String
|
||||||
|
Dim aCommand As String[]
|
||||||
|
|
||||||
iLen = String.Len(sLine)
|
iLen = String.Len(sLine)
|
||||||
|
|
||||||
|
@ -700,13 +656,11 @@ MAIN_LOOP:
|
||||||
|
|
||||||
If sCar = "<" Then Goto ENTER_MARKUP
|
If sCar = "<" Then Goto ENTER_MARKUP
|
||||||
|
|
||||||
'If $aMarkup.Count = 0 Then
|
|
||||||
|
|
||||||
If sCar = "&" Then Goto ENTER_AMPERSAND
|
If sCar = "&" Then Goto ENTER_AMPERSAND
|
||||||
|
|
||||||
If sCar = "[" And If String.Mid$(sLine, I + 1, 1) <> " " Then Goto ENTER_LINK
|
If sCar = "[" And If String.Mid$(sLine, I + 1, 1) <> " " Then Goto ENTER_LINK
|
||||||
|
|
||||||
'Endif
|
If sCar = "@" And If String.Mid$(sLine, I + 1, 1) = "{" Then Goto ENTER_COMMAND
|
||||||
|
|
||||||
If I = 1 Or If IsWordLimit(String.Mid$(sLine, I - 1, 1)) Then
|
If I = 1 Or If IsWordLimit(String.Mid$(sLine, I - 1, 1)) Then
|
||||||
bLimitBefore = True
|
bLimitBefore = True
|
||||||
|
@ -1027,6 +981,7 @@ ENTER_LINK:
|
||||||
|
|
||||||
sLink = $hLink.Link
|
sLink = $hLink.Link
|
||||||
sText = $hLink.Text
|
sText = $hLink.Text
|
||||||
|
If sText Then sText = ConvertLine(sText)
|
||||||
sTitle = $hLink.Title
|
sTitle = $hLink.Title
|
||||||
|
|
||||||
If Not sText Then sText = sLink
|
If Not sText Then sText = sLink
|
||||||
|
@ -1047,6 +1002,35 @@ ENTER_LINK:
|
||||||
|
|
||||||
Goto MAIN_LOOP
|
Goto MAIN_LOOP
|
||||||
|
|
||||||
|
ENTER_COMMAND:
|
||||||
|
|
||||||
|
GoSub NEXT_CAR
|
||||||
|
|
||||||
|
sCommand = ""
|
||||||
|
Do
|
||||||
|
GoSub NEXT_CAR
|
||||||
|
If Not sCar Then
|
||||||
|
sResult &= "<div class=\"error\">Missing closing '}'</div>"
|
||||||
|
Return sResult
|
||||||
|
Endif
|
||||||
|
If sCar = "}" Then Break
|
||||||
|
sCommand &= sCar
|
||||||
|
Loop
|
||||||
|
|
||||||
|
If sCommand Then
|
||||||
|
|
||||||
|
aCommand = $hMarkdown.Command(sCommand)
|
||||||
|
|
||||||
|
If aCommand And If aCommand.Count Then
|
||||||
|
sResult &= ConvertLine(aCommand[0])
|
||||||
|
Endif
|
||||||
|
|
||||||
|
$hMarkdown.Reinterpret = True
|
||||||
|
|
||||||
|
Endif
|
||||||
|
|
||||||
|
Goto MAIN_LOOP
|
||||||
|
|
||||||
Catch
|
Catch
|
||||||
|
|
||||||
Return "<div><div class=\"error\"><b>" & Html$(Error.Text) & ":</b><br>" & Html$(sLine) & "</div></div>"
|
Return "<div><div class=\"error\"><b>" & Html$(Error.Text) & ":</b><br>" & Html$(sLine) & "</div></div>"
|
||||||
|
|
Loading…
Reference in a new issue