From 6364bd1376953c4e4fed8328d6ac56ee41e505a2 Mon Sep 17 00:00:00 2001 From: gambas Date: Fri, 29 Jan 2021 15:47:35 +0100 Subject: [PATCH] Some fixes in line anchors generation. [GB.MARKDOWN] * BUG: Some fixes in line anchors generation. --- comp/src/gb.markdown/.src/Markup.module | 42 ++++++++++++++++++++----- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/comp/src/gb.markdown/.src/Markup.module b/comp/src/gb.markdown/.src/Markup.module index 6f3dbedcf..cb12952c4 100644 --- a/comp/src/gb.markdown/.src/Markup.module +++ b/comp/src/gb.markdown/.src/Markup.module @@ -73,6 +73,9 @@ Private Sub ConvertMarkup(aLine As String[], Optional bNoLineAnchors As Boolean) Dim sList As String Dim bSaveComment As Boolean Dim aTemp As String[] + Dim cLine As Collection + Dim J As Integer + Dim iNextLine As Integer aResult = New String[] @@ -119,6 +122,8 @@ Private Sub ConvertMarkup(aLine As String[], Optional bNoLineAnchors As Boolean) aLine[iLine] = "" Next + + If $hMarkdown.LinkAnchors And If Not bNoLineAnchors Then cLine = New Collection iLine = -1 While iLine < aLine.Max @@ -126,7 +131,7 @@ Private Sub ConvertMarkup(aLine As String[], Optional bNoLineAnchors As Boolean) Inc iLine sLine = aLine[iLine] - If $hMarkdown.LinkAnchors And If Not bNoLineAnchors Then aResult.Add("") + If $hMarkdown.LinkAnchors And If Not bNoLineAnchors Then GoSub ADD_LINE $hMarkdown.Line = iLine $hMarkdown.Current = sLine @@ -551,7 +556,28 @@ Private Sub ConvertMarkup(aLine As String[], Optional bNoLineAnchors As Boolean) aResult[iIndexPos] = "
\n" & ConvertMarkup($aIndex, True) & "
\n" Endif - If $hMarkdown.LinkAnchors And If Not bNoLineAnchors Then aResult.Add("") + If $hMarkdown.LinkAnchors And If Not bNoLineAnchors Then + + iLine = 0 + For I = 0 To aResult.Max + If cLine.Exist(I) Then + aLine = New String[] + 'If iLine Then aLine.Add("") + iNextLine = cLine[I] + For J = iLine To iNextLine - 1 + aLine.Add("") ' & "") + Next + J = Len(aResult[I]) - Len(LTrim(aResult[I])) + aResult[I] = Left(aResult[I], J) & aLine.Join("") & "" & Mid$(aResult[I], J + 1) + iLine = iNextLine + 1 + Endif + Next + + 'aLine = New String[] + 'If iLine Then aLine.Add("") + aResult.Add("") ' & "") + + Endif $bComment = bSaveComment $aMarkup = aSaveMarkup @@ -571,7 +597,7 @@ CLOSE_CODE: CLOSE_BLOCKQUOTE: While iBlockQuote - aResult.Add("") + aResult[aResult.Max] &= "" Dec iBlockQuote Wend Return @@ -581,7 +607,8 @@ CLOSE_LIST: While iIndent < iCurrentIndent GoSub CLOSE_PARA GoSub CLOSE_CODE - aResult.Add(Space$(iCurrentIndent) & "") + 'aResult.Add(Space$(iCurrentIndent) & "") + aResult[aResult.Max] &= "" bJustList = False aResult.Add(Space$(aList[aList.Max].iIndent) & "") aList.Remove(aList.Max) @@ -605,10 +632,11 @@ CLOSE_PARA: Endif Return -'Catch - -' Error.Raise("Line " & CStr(iLine + 1) & ": " & Error.Text) +ADD_LINE: + cLine[aResult.Count] = iLine + Return + End