From 63990682938d053b0602eae46d902e0872d72d97 Mon Sep 17 00:00:00 2001
From: Roland Heyder
Date: Sun, 12 Feb 2023 14:37:51 +0100
Subject: [PATCH 1/7] Change line end detection
- use color bit 7 instead of the CR char to mark the end of a help line
---
source/ide/ide_methods.bas | 13 ++++++-------
source/ide/wiki/wiki_methods.bas | 29 ++++++++++++++---------------
2 files changed, 20 insertions(+), 22 deletions(-)
diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas
index f3ce9c523..837a66c04 100644
--- a/source/ide/ide_methods.bas
+++ b/source/ide/ide_methods.bas
@@ -2376,7 +2376,7 @@ FUNCTION ide2 (ignore)
x = l
x3 = 1
c = ASC(Help_Txt$, x)
- DO UNTIL c = 13
+ DO UNTIL ASC(Help_Txt$, x + 1) > 127
IF Help_Select = 2 THEN
IF y >= Help_SelY1 AND y <= Help_SelY2 THEN
IF x3 >= Help_SelX1 AND x3 <= Help_SelX2 THEN
@@ -2464,7 +2464,7 @@ FUNCTION ide2 (ignore)
x = l
a$ = ""
c = ASC(Help_Txt$, x)
- DO UNTIL c = 13
+ DO UNTIL ASC(Help_Txt$, x + 1) > 127
lnk = CVI(MID$(Help_Txt$, x + 2, 2))
IF lnk THEN a$ = a$ + CHR$(c) ELSE a$ = a$ + CHR$(0) 'only add text with links
x = x + 4: c = ASC(Help_Txt$, x)
@@ -2485,7 +2485,7 @@ FUNCTION ide2 (ignore)
c = ASC(Help_Txt$, x)
oldlnk = 0
lnkx1 = 0: lnkx2 = 0
- DO UNTIL c = 13
+ DO UNTIL ASC(Help_Txt$, x + 1) > 127
lnk = CVI(MID$(Help_Txt$, x + 2, 2))
IF lnkx1 = 0 AND lnk <> 0 AND oldlnk = 0 AND px = x2 THEN lnkx1 = x2
IF lnkx1 <> 0 AND lnk = 0 AND lnkx2 = 0 THEN lnkx2 = x2 - 1
@@ -2597,7 +2597,7 @@ FUNCTION ide2 (ignore)
x = l
x2 = 1
c = ASC(Help_Txt$, x)
- DO UNTIL c = 13
+ DO UNTIL ASC(Help_Txt$, x + 1) > 127
IF x2 = Help_cx THEN
lnk = CVI(MID$(Help_Txt$, x + 2, 2))
@@ -17723,7 +17723,7 @@ SUB Help_ShowText
sx = Help_wx1
c = ASC(Help_Txt$, x): col = ASC(Help_Txt$, x + 1)
LOCATE sy, sx
- DO UNTIL c = 13
+ DO UNTIL col > 127
COLOR col AND 15, col \ 16
IF IdeSystem = 3 AND Help_Select = 2 THEN
IF y >= Help_SelY1 AND y <= Help_SelY2 THEN
@@ -17744,8 +17744,7 @@ SUB Help_ShowText
Help_LineLen(y - Help_sy) = x3 - 1
FOR x4 = 1 TO Help_wx2 - POS(0) + 1
- IF col = 0 THEN col = 7
- COLOR col AND 15, col \ 16
+ COLOR 7, (col - 128) \ 16
IF IdeSystem = 3 AND Help_Select = 2 THEN
IF y >= Help_SelY1 AND y <= Help_SelY2 THEN
IF x3 >= Help_SelX1 AND x3 <= Help_SelX2 THEN
diff --git a/source/ide/wiki/wiki_methods.bas b/source/ide/wiki/wiki_methods.bas
index d35548341..03a12cbe4 100644
--- a/source/ide/wiki/wiki_methods.bas
+++ b/source/ide/wiki/wiki_methods.bas
@@ -104,7 +104,6 @@ END FUNCTION
SUB Help_AddTxt (t$, col, link) 'Add help text, handle word wrap
IF t$ = "" THEN EXIT SUB
- IF t$ = CHR$(13) THEN Help_NewLine: EXIT SUB
IF Help_ChkBlank <> 0 THEN Help_CheckBlankLine: Help_ChkBlank = 0
FOR i = 1 TO LEN(t$)
@@ -155,7 +154,7 @@ SUB Help_NewLine 'Start a new help line, apply indention (if any)
IF Help_Pos > help_w THEN help_w = Help_Pos
Help_Txt_Len = Help_Txt_Len + 1: ASC(Help_Txt$, Help_Txt_Len) = 13
- Help_Txt_Len = Help_Txt_Len + 1: ASC(Help_Txt$, Help_Txt_Len) = Help_BG_Col * 16
+ Help_Txt_Len = Help_Txt_Len + 1: ASC(Help_Txt$, Help_Txt_Len) = 128 + (Help_BG_Col * 16)
Help_Txt_Len = Help_Txt_Len + 1: ASC(Help_Txt$, Help_Txt_Len) = 0
Help_Txt_Len = Help_Txt_Len + 1: ASC(Help_Txt$, Help_Txt_Len) = 0
@@ -189,20 +188,20 @@ END SUB
SUB Help_CheckFinishLine 'Make sure the current help line is finished
IF Help_Txt_Len >= 4 THEN
- IF ASC(Help_Txt$, Help_Txt_Len - 3) <> 13 THEN Help_NewLine
+ IF ASC(Help_Txt$, Help_Txt_Len - 2) < 128 THEN Help_NewLine
END IF
END SUB
SUB Help_CheckBlankLine 'Make sure the last help line is a blank line (implies finish current)
IF Help_Txt_Len >= 8 THEN
- IF ASC(Help_Txt$, Help_Txt_Len - 3) <> 13 THEN Help_NewLine
- IF ASC(Help_Txt$, Help_Txt_Len - 7) <> 13 THEN Help_NewLine
+ IF ASC(Help_Txt$, Help_Txt_Len - 2) < 128 THEN Help_NewLine
+ IF ASC(Help_Txt$, Help_Txt_Len - 6) < 128 THEN Help_NewLine
END IF
END SUB
SUB Help_CheckRemoveBlankLine 'If the last help line is blank, then remove it
IF Help_Txt_Len >= 8 THEN
- IF ASC(Help_Txt$, Help_Txt_Len - 3) = 13 THEN
+ IF ASC(Help_Txt$, Help_Txt_Len - 2) > 127 THEN
Help_Txt_Len = Help_Txt_Len - 4
help_h = help_h - 1
Help_Line$ = LEFT$(Help_Line$, LEN(Help_Line$) - 4)
@@ -212,7 +211,7 @@ SUB Help_CheckRemoveBlankLine 'If the last help line is blank, then remove it
Help_Txt_Len = i + 3: EXIT FOR
END IF
NEXT
- IF ASC(Help_Txt$, Help_Txt_Len - 3) <> 13 THEN Help_NewLine
+ IF ASC(Help_Txt$, Help_Txt_Len - 2) < 128 THEN Help_NewLine
END IF
END SUB
@@ -737,11 +736,11 @@ SUB WikiParse (a$) 'Wiki page interpret
FOR ii = Help_Txt_Len - 3 TO 1 STEP -4
IF ASC(Help_Txt$, ii) = 32 AND iii < 0 THEN
Help_Pos = Help_Pos - 1
- ELSEIF ASC(Help_Txt$, ii) = 13 AND iii < 0 THEN
+ ELSEIF ASC(Help_Txt$, ii + 1) > 127 AND iii < 0 THEN
help_h = help_h - 1: Help_Line$ = LEFT$(Help_Line$, LEN(Help_Line$) - 4)
ELSEIF ASC(Help_Txt$, ii) = 196 AND iii < 0 THEN
iii = -iii
- ELSEIF ASC(Help_Txt$, ii) = 13 AND iii > 0 THEN
+ ELSEIF ASC(Help_Txt$, ii + 1) > 127 AND iii > 0 THEN
Help_Txt_Len = ii + 3: EXIT FOR
END IF
NEXT
@@ -921,13 +920,13 @@ SUB WikiParse (a$) 'Wiki page interpret
IF Help_LockParse > -2 THEN 'everywhere except in fixed blocks
IF Help_Txt_Len >= 8 THEN 'allow max. one blank line (ie. collapse multi blanks to just one)
- IF ASC(Help_Txt$, Help_Txt_Len - 3) = 13 AND ASC(Help_Txt$, Help_Txt_Len - 7) = 13 THEN
+ IF ASC(Help_Txt$, Help_Txt_Len - 2) > 127 AND ASC(Help_Txt$, Help_Txt_Len - 6) > 127 THEN
IF Help_Center > 0 THEN Help_CIndent$ = MID$(Help_CIndent$, 2) 'drop respective center indent
GOTO skipMultiBlanks
END IF
END IF
END IF
- Help_AddTxt CHR$(13), col, 0
+ Help_NewLine
skipMultiBlanks:
IF Help_LockParse <> 0 THEN 'in all blocks reset styles at EOL
@@ -991,8 +990,8 @@ SUB WikiParse (a$) 'Wiki page interpret
FOR i = 17 TO LEN(Help_Line$) STEP 4: MID$(Help_Line$, i, 4) = MKL$(CVL(MID$(Help_Line$, i, 4)) + dtl): NEXT
END IF
END IF
- 'Trim Help_Txt$
- Help_Txt$ = LEFT$(Help_Txt$, Help_Txt_Len) + CHR$(13) 'chr13 stops reads past end of content
+ 'Finish and Trim Help_Txt$
+ Help_CheckFinishLine: Help_Txt$ = LEFT$(Help_Txt$, Help_Txt_Len)
IF Help_PageLoaded$ = "Keyword Reference - Alphabetical" THEN
@@ -1007,11 +1006,11 @@ SUB WikiParse (a$) 'Wiki page interpret
c = ASC(Help_Txt$, x)
oldlnk = 0
lnkx1 = 0: lnkx2 = 0
- DO UNTIL c = 13
+ DO UNTIL ASC(Help_Txt$, x + 1) > 127
ASC(a$, x2) = c
lnk = CVI(MID$(Help_Txt$, x + 2, 2))
IF oldlnk = 0 AND lnk <> 0 THEN lnkx1 = x2
- IF (lnk = 0 OR ASC(Help_Txt$, x + 4) = 13) AND lnkx1 <> 0 THEN
+ IF (lnk = 0 OR ASC(Help_Txt$, x + 5) > 127) AND lnkx1 <> 0 THEN
lnkx2 = x2: IF lnk = 0 THEN lnkx2 = lnkx2 - 1
IF lnkx1 <> 3 THEN GOTO ignorelink
From 174a95b05219099673320cca811370abd2482875 Mon Sep 17 00:00:00 2001
From: Roland Heyder
Date: Sun, 12 Feb 2023 15:01:21 +0100
Subject: [PATCH 2/7] Change flow logic (Entity/UTF-8 related)
- targets especially links, templates and centered text
- every char must properly run through the Entity/UTF-8 substitution stage
---
source/ide/wiki/wiki_global.bas | 2 +-
source/ide/wiki/wiki_methods.bas | 174 ++++++++++++++++++++++---------
2 files changed, 124 insertions(+), 52 deletions(-)
diff --git a/source/ide/wiki/wiki_global.bas b/source/ide/wiki/wiki_global.bas
index 432adb1c8..c09e60ff9 100644
--- a/source/ide/wiki/wiki_global.bas
+++ b/source/ide/wiki/wiki_global.bas
@@ -27,7 +27,7 @@ DIM SHARED Help_Col_Link: Help_Col_Link = 9
DIM SHARED Help_Col_Bold: Help_Col_Bold = 15
DIM SHARED Help_Col_Italic: Help_Col_Italic = 3
DIM SHARED Help_Col_Section: Help_Col_Section = 8
-DIM SHARED Help_Bold, Help_Italic, Help_Heading
+DIM SHARED Help_Bold, Help_Italic, Help_LinkTxt, Help_Heading
DIM SHARED Help_Underline, Help_ChkBlank
DIM SHARED Help_LockWrap, Help_LockParse
DIM SHARED Help_DList, Help_LIndent$
diff --git a/source/ide/wiki/wiki_methods.bas b/source/ide/wiki/wiki_methods.bas
index 03a12cbe4..fe40cd574 100644
--- a/source/ide/wiki/wiki_methods.bas
+++ b/source/ide/wiki/wiki_methods.bas
@@ -219,7 +219,11 @@ FUNCTION Help_Col 'Helps to calculate the default color
col = Help_Col_Normal
IF Help_Italic THEN col = Help_Col_Italic
IF Help_Bold THEN col = Help_Col_Bold 'Bold overrides Italic
- IF Help_Heading THEN col = Help_Col_Section 'Heading overrides all
+ IF Help_Heading THEN col = Help_Col_Section 'Heading overrides text styles
+ IF Help_LinkTxt THEN 'Link overrides all
+ 'for better contrast use alternative color in (code)blocks
+ IF Help_LockParse = 0 THEN col = Help_Col_Link: ELSE col = Help_Col_Italic
+ END IF
Help_Col = col
END FUNCTION
@@ -238,12 +242,12 @@ SUB WikiParse (a$) 'Wiki page interpret
'hard: 2 = inside code blocks, 1 = inside output blocks
'soft: -1 = inside text blocks, -2 = inside pre or fixed blocks
'=> all parser locks also imply a wrapping lock (except text (-1))
- '=> hard: locks almost every parsing except HTML-entity/UTF-8 substitution and line breaks
+ '=> hard: locks almost every parsing except UTF-8 substitution and line breaks
'=> soft: allows all elements not disrupting the current block, hence only
' paragraph creating things are locked (eg. headings, lists, rulers etc.),
' but text styles, links and template processing is still possible
Help_LockParse = 0
- Help_Bold = 0: Help_Italic = 0: Help_Heading = 0
+ Help_Bold = 0: Help_Italic = 0: Help_LinkTxt = 0: Help_Heading = 0
Help_Underline = 0
Help_BG_Col = 0
Help_Center = 0: Help_CIndent$ = ""
@@ -475,38 +479,36 @@ SUB WikiParse (a$) 'Wiki page interpret
IF Help_LockParse <= 0 THEN
'External links
IF c$(5) = "[http" AND elink = 0 THEN
- elink = 1
- elink$ = ""
+ elink = 1: elink$ = "": elcol$ = ""
+ Help_LinkTxt = 1: col = Help_Col
GOTO charDone
END IF
IF elink = 1 THEN
IF c$ = "]" THEN
- elink = 0
+ elink = 0: Help_LinkTxt = 0: col = Help_Col
etext$ = elink$
i2 = INSTR(elink$, " ")
IF i2 > 0 THEN
etext$ = MID$(elink$, i2 + 1) 'text part
+ elcol$ = MID$(elcol$, i2 + 1) 'text color part
elink$ = LEFT$(elink$, i2 - 1) 'link part
END IF
Help_LinkN = Help_LinkN + 1
Help_Link$ = Help_Link$ + "EXTL:" + elink$ + Help_Link_Sep$
- IF Help_LockParse = 0 THEN
- Help_AddTxt etext$, Help_Col_Link, Help_LinkN
- ELSE
- Help_AddTxt etext$, Help_Col_Italic, Help_LinkN
- END IF
+ FOR j = 1 TO LEN(etext$)
+ Help_AddTxt CHR$(ASC(etext$, j)), ASC(elcol$, j), Help_LinkN
+ NEXT
GOTO charDone
END IF
- elink$ = elink$ + c$
- GOTO charDone
+ GOTO chkEntUtf
END IF
'Internal links
IF c$(2) = "[[" AND link = 0 THEN
i = i + 1
- link = 1
- link$ = ""
+ link = 1: link$ = "": lcol$ = ""
+ Help_LinkTxt = 1: col = Help_Col
GOTO charDone
END IF
END IF
@@ -515,16 +517,21 @@ SUB WikiParse (a$) 'Wiki page interpret
IF link = 1 THEN
IF c$(2) = "]]" OR c$(2) = "}}" THEN
i = i + 1
- link = 0
+ link = 0: Help_LinkTxt = 0: col = Help_Col
text$ = link$
i2 = INSTR(link$, "|") 'pipe link?
IF i2 > 0 THEN
text$ = MID$(link$, i2 + 1) 'text part
+ lcol$ = MID$(lcol$, i2 + 1) 'text color part
link$ = LEFT$(link$, i2 - 1) 'link part
END IF
i2 = INSTR(link$, "#") 'local link?
IF i2 > 0 THEN
- IF text$ = link$ THEN text$ = MID$(link$, i2 + 1) 'use anchor if no alternate text yet
+ IF text$ = link$ THEN 'no alternate text for local link?
+ text$ = MID$(link$, i2 + 1) 'use anchor part
+ lcol$ = MID$(lcol$, i2 + 1) 'and respective color part
+ END IF
+
IF LEFT$(link$, 1) = "#" THEN link$ = Help_PageLoaded$ + link$ 'add current page if missing
END IF
IF LEFT$(link$, 9) = "Category:" THEN 'ignore category links
@@ -539,15 +546,12 @@ SUB WikiParse (a$) 'Wiki page interpret
Help_Link$ = Help_Link$ + "PAGE:" + link$ + Help_Link_Sep$
END IF
- IF Help_LockParse = 0 THEN
- Help_AddTxt text$, Help_Col_Link, Help_LinkN
- ELSE
- Help_AddTxt text$, Help_Col_Italic, Help_LinkN
- END IF
+ FOR j = 1 TO LEN(text$)
+ Help_AddTxt CHR$(ASC(text$, j)), ASC(lcol$, j), Help_LinkN
+ NEXT
GOTO charDone
END IF
- link$ = link$ + c$
- GOTO charDone
+ GOTO chkEntUtf
END IF
'Wiki tables ({|...|}) are not handled in Code/Output blocks (hard lock),
@@ -579,8 +583,8 @@ SUB WikiParse (a$) 'Wiki page interpret
'the wiki pages, but look for special conditions inside (Help_LockParse checks)
IF c$(5) = "{{Cb|" OR c$(5) = "{{Cl|" THEN 'just nice wrapped links
i = i + 4
- link = 1
- link$ = ""
+ link = 1: link$ = "": lcol$ = ""
+ Help_LinkTxt = 1: col = Help_Col
GOTO charDone
END IF
IF c$(2) = "{{" THEN 'any other templates
@@ -757,8 +761,8 @@ SUB WikiParse (a$) 'Wiki page interpret
GOTO charDone
END IF
- IF cb = 1 THEN cb$ = cb$ + c$ 'reading macro name
- IF cb = 2 THEN Help_AddTxt CHR$(c), col, 0 'copy macro'd text
+ IF cb = 1 THEN cb$ = cb$ + c$ 'reading template name
+ IF cb = 2 GOTO chkEntUtf 'copy text with proper Entity/UTF-8 substitution
GOTO charDone
END IF
@@ -864,49 +868,56 @@ SUB WikiParse (a$) 'Wiki page interpret
END IF
END IF
- 'HTML entity handling (no restrictions)
- IF c$ = "&" THEN 'possible entity
- FOR ii = 0 TO wpEntReplCnt
- ent$ = RTRIM$(wpEntRepl(ii).enti)
- IF c$(LEN(ent$)) = ent$ THEN
- Help_AddTxt RTRIM$(wpEntRepl(ii).repl), col, 0
- i = i + LEN(ent$) - 1: GOTO charDone
+ 'Entities are not handled in Code/Output blocks (hard lock), as all text could
+ 'be part of the code example itself (just imagine a HTML parser/writer demo)
+ chkEntUtf:
+ ocol = col 'save original current color for later reset
+ IF Help_LockParse <= 0 THEN
+ IF c$ = "&" THEN 'possible entity
+ FOR ii = 0 TO wpEntReplCnt
+ ent$ = RTRIM$(wpEntRepl(ii).enti)
+ IF c$(LEN(ent$)) = ent$ THEN
+ c$ = RTRIM$(wpEntRepl(ii).repl)
+ i = i + LEN(ent$) - 1: GOTO charAccum
+ END IF
+ NEXT
+ IF Help_LockParse = 0 THEN 'take as is in other blocks (skip unknown check)
+ ii = INSTR(c$(8), ";"): iii = INSTR(c$(8), " ") 'unknown entity?
+ IF ii > 2 AND (iii = 0 OR iii > ii) THEN
+ c$ = c$(ii): col = 8: ue = -1
+ i = i + ii - 1: GOTO charAccum
+ END IF
END IF
- NEXT
- ii = INSTR(c$(8), ";"): iii = INSTR(c$(8), " ") 'unknown entity?
- IF ii > 0 AND (iii = 0 OR iii > ii) THEN
- Help_AddTxt c$(ii), 8, 0: ue = -1
- i = i + ii - 1: GOTO charDone
END IF
END IF
- 'Unicode handling (no restrictions)
+ 'UTF-8 handling (no restrictions)
IF ((c AND &HE0~%%) = 192) AND ((ASC(c$(2), 2) AND &HC0~%%) = 128) THEN '2-byte UTF-8
i = i + 1
FOR ii = 0 TO wpUtfReplCnt
IF wpUtfRepl(ii).utf8 = c$(2) + MKI$(&H2020) THEN
- Help_AddTxt RTRIM$(wpUtfRepl(ii).repl), col, 0: GOTO charDone
+ c$ = RTRIM$(wpUtfRepl(ii).repl): GOTO charAccum
END IF
NEXT
- Help_AddTxt CHR$(168), 8, 0: uu = -1: GOTO charDone
+ c$ = CHR$(168): col = 8: uu = -1: GOTO charAccum
END IF
IF ((c AND &HF0~%%) = 224) AND ((ASC(c$(2), 2) AND &HC0~%%) = 128) AND ((ASC(c$(3), 3) AND &HC0~%%) = 128) THEN '3-byte UTF-8
i = i + 2
FOR ii = 0 TO wpUtfReplCnt
IF wpUtfRepl(ii).utf8 = c$(3) + CHR$(0) THEN
- Help_AddTxt RTRIM$(wpUtfRepl(ii).repl), col, 0: GOTO charDone
+ c$ = RTRIM$(wpUtfRepl(ii).repl): GOTO charAccum
END IF
NEXT
- Help_AddTxt CHR$(168), 8, 0: uu = -1: GOTO charDone
+ c$ = CHR$(168): col = 8: uu = -1: GOTO charAccum
END IF
IF ((c AND &HF8~%%) = 240) AND ((ASC(c$(2), 2) AND &HC0~%%) = 128) AND ((ASC(c$(3), 3) AND &HC0~%%) = 128) AND ((ASC(c$(4), 4) AND &HC0~%%) = 128) THEN '4-byte UTF-8
i = i + 3
FOR ii = 0 TO wpUtfReplCnt
IF wpUtfRepl(ii).utf8 = c$(4) THEN
- Help_AddTxt RTRIM$(wpUtfRepl(ii).repl), col, 0: GOTO charDone
+ c$ = RTRIM$(wpUtfRepl(ii).repl): GOTO charAccum
END IF
NEXT
- Help_AddTxt CHR$(168), 8, 0: uu = -1: GOTO charDone
+ c$ = CHR$(168): col = 8: uu = -1: GOTO charAccum
END IF
'Line break handling (no restrictions)
@@ -946,8 +957,18 @@ SUB WikiParse (a$) 'Wiki page interpret
nl = 1
GOTO charDoneKnl 'keep just set nl state
END IF
- Help_AddTxt CHR$(c), col, hl
+ charAccum: 'accumulate char(s) in the correct channel
+ IF elink = 1 THEN
+ elink$ = elink$ + c$
+ FOR j = 1 TO LEN(c$): elcol$ = elcol$ + CHR$(col): NEXT
+ ELSEIF link = 1 THEN
+ link$ = link$ + c$
+ FOR j = 1 TO LEN(c$): lcol$ = lcol$ + CHR$(col): NEXT
+ ELSE
+ Help_AddTxt c$, col, hl
+ END IF
+ col = ocol 'reset signal color (Entity/UTF-8 check) to original current color
charDone:
nl = 0
charDoneKnl: 'done, but keep nl state
@@ -955,7 +976,7 @@ SUB WikiParse (a$) 'Wiki page interpret
LOOP
'END_PARSE_LOOP
- 'Write and rearrange Entity & Unicode error messages (if any)
+ 'Write and rearrange missing Entity & UTF-8 warnings (if any)
IF ue OR uu THEN
Help_LinkN = Help_LinkN + 1
Help_Link$ = Help_Link$ + "EXTL:https://qb64phoenix.com/forum/forumdisplay.php?fid=25" + Help_Link_Sep$
@@ -1244,8 +1265,59 @@ FUNCTION wikiBuildCIndent$ (a$) 'Pre-calc center indentions
IF MID$(org$, i, 2) = "''" THEN i = i + 2
b$ = b$ + MID$(org$, i, 1)
NEXT
- b$ = StrReplace$(b$, "
", CHR$(10)) 'convert HTML line breaks
- b$ = StrReplace$(b$, "
", CHR$(10)) 'convert XHTML line breaks
+ org$ = b$: b$ = "" 'substitute Entities
+ FOR i = 1 TO LEN(org$)
+ IF MID$(org$, i, 1) = "&" THEN 'possible entity
+ FOR ii = 0 TO wpEntReplCnt
+ ent$ = RTRIM$(wpEntRepl(ii).enti)
+ IF MID$(org$, i, LEN(ent$)) = ent$ THEN
+ b$ = b$ + RTRIM$(wpEntRepl(ii).repl)
+ i = i + LEN(ent$): GOTO charDoneEnt
+ END IF
+ NEXT
+ END IF
+ b$ = b$ + MID$(org$, i, 1)
+ charDoneEnt:
+ NEXT
+ org$ = b$: b$ = "" 'substitute UTF-8
+ FOR i = 1 TO LEN(org$)
+ IF i + 1 <= LEN(org$) THEN
+ IF ((ASC(org$, i) AND &HE0~%%) = 192) AND ((ASC(org$, i + 1) AND &HC0~%%) = 128) THEN '2-byte UTF-8
+ utf$ = MID$(org$, i, 2) + MKI$(&H2020): i = i + 2
+ FOR ii = 0 TO wpUtfReplCnt
+ IF wpUtfRepl(ii).utf8 = utf$ THEN
+ b$ = b$ + RTRIM$(wpUtfRepl(ii).repl): GOTO charDoneUtf
+ END IF
+ NEXT
+ b$ = b$ + CHR$(168): GOTO charDoneUtf
+ END IF
+ END IF
+ IF i + 2 <= LEN(org$) THEN
+ IF ((ASC(org$, i) AND &HF0~%%) = 224) AND ((ASC(org$, i + 1) AND &HC0~%%) = 128) AND ((ASC(org$, i + 2) AND &HC0~%%) = 128) THEN '3-byte UTF-8
+ utf$ = MID$(org$, i, 3) + CHR$(0): i = i + 3
+ FOR ii = 0 TO wpUtfReplCnt
+ IF wpUtfRepl(ii).utf8 = utf$ THEN
+ b$ = b$ + RTRIM$(wpUtfRepl(ii).repl): GOTO charDoneUtf
+ END IF
+ NEXT
+ b$ = b$ + CHR$(168): GOTO charDoneUtf
+ END IF
+ END IF
+ IF i + 3 <= LEN(org$) THEN
+ IF ((ASC(org$, i) AND &HF8~%%) = 240) AND ((ASC(org$, i + 1) AND &HC0~%%) = 128) AND ((ASC(org$, i + 2) AND &HC0~%%) = 128) AND ((ASC(org$, i + 3) AND &HC0~%%) = 128) THEN '4-byte UTF-8
+ utf$ = MID$(org$, i, 4): i = i + 4
+ FOR ii = 0 TO wpUtfReplCnt
+ IF wpUtfRepl(ii).utf8 = utf$ THEN
+ b$ = b$ + RTRIM$(wpUtfRepl(ii).repl): GOTO charDoneUtf
+ END IF
+ NEXT
+ b$ = b$ + CHR$(168): GOTO charDoneUtf
+ END IF
+ END IF
+ b$ = b$ + MID$(org$, i, 1)
+ charDoneUtf:
+ NEXT
+
b$ = _TRIM$(b$) + CHR$(10) 'safety fallback
i = 1: st = 1: br = 0: res$ = ""
From dfa65b8fdd9a1012f321c925baac886c0b25ff7b Mon Sep 17 00:00:00 2001
From: Roland Heyder
Date: Sun, 12 Feb 2023 19:13:05 +0100
Subject: [PATCH 3/7] Add more Entities/UTF-8 chars
- adds some 20+ more chars to the list
- re-grouping and some comment changes
---
source/ide/wiki/wiki_global.bas | 84 +++++++++++++++++++++------------
1 file changed, 55 insertions(+), 29 deletions(-)
diff --git a/source/ide/wiki/wiki_global.bas b/source/ide/wiki/wiki_global.bas
index c09e60ff9..d1d3b85a0 100644
--- a/source/ide/wiki/wiki_global.bas
+++ b/source/ide/wiki/wiki_global.bas
@@ -52,7 +52,7 @@ DIM SHARED Help_Search_Str AS STRING
DIM SHARED Help_PageLoaded AS STRING
DIM SHARED Help_Recaching, Help_IgnoreCache
-'HTML entity replacements
+'Entity replacements
'(for non HTML chars only, ie. no & < > " which are handled in SUB Wiki$ directly)
TYPE wikiEntityReplace
enti AS STRING * 8 '= entity as supported (ie. name where available, else as decimal number)
@@ -62,42 +62,46 @@ DIM SHARED wpEntRepl(0 TO 10) AS wikiEntityReplace
DIM SHARED wpEntReplCnt: wpEntReplCnt = -1 'wpEntRepl index counter (pre-increment, hence
'you don't need "wpEntReplCnt - 1" when used in loops, just do "0 TO wpEntReplCnt"
wpEntReplCnt = wpEntReplCnt + 1: wpEntRepl(wpEntReplCnt).enti = "'": wpEntRepl(wpEntReplCnt).repl = "'" 'apostrophe
-wpEntReplCnt = wpEntReplCnt + 1: wpEntRepl(wpEntReplCnt).enti = "[": wpEntRepl(wpEntReplCnt).repl = "[" 'open square bracket
-wpEntReplCnt = wpEntReplCnt + 1: wpEntRepl(wpEntReplCnt).enti = "]": wpEntRepl(wpEntReplCnt).repl = "]" 'close square bracket
-wpEntReplCnt = wpEntReplCnt + 1: wpEntRepl(wpEntReplCnt).enti = "{": wpEntRepl(wpEntReplCnt).repl = "{" 'open curly bracket
-wpEntReplCnt = wpEntReplCnt + 1: wpEntRepl(wpEntReplCnt).enti = "}": wpEntRepl(wpEntReplCnt).repl = "}" 'close curly bracket
+wpEntReplCnt = wpEntReplCnt + 1: wpEntRepl(wpEntReplCnt).enti = "[": wpEntRepl(wpEntReplCnt).repl = "[" 'square bracket (open)
+wpEntReplCnt = wpEntReplCnt + 1: wpEntRepl(wpEntReplCnt).enti = "]": wpEntRepl(wpEntReplCnt).repl = "]" 'square bracket (close)
+wpEntReplCnt = wpEntReplCnt + 1: wpEntRepl(wpEntReplCnt).enti = "{": wpEntRepl(wpEntReplCnt).repl = "{" 'curly bracket (open)
+wpEntReplCnt = wpEntReplCnt + 1: wpEntRepl(wpEntReplCnt).enti = "}": wpEntRepl(wpEntReplCnt).repl = "}" 'curly bracket (close)
wpEntReplCnt = wpEntReplCnt + 1: wpEntRepl(wpEntReplCnt).enti = "π": wpEntRepl(wpEntReplCnt).repl = CHR$(227) 'pi
wpEntReplCnt = wpEntReplCnt + 1: wpEntRepl(wpEntReplCnt).enti = "θ": wpEntRepl(wpEntReplCnt).repl = CHR$(233) 'theta
wpEntReplCnt = wpEntReplCnt + 1: wpEntRepl(wpEntReplCnt).enti = " ": wpEntRepl(wpEntReplCnt).repl = CHR$(255) 'non-breaking space
-'Unicode replacements
+'UTF-8 replacements
TYPE wikiUtf8Replace
utf8 AS STRING * 4 '= MKI$(reversed hex 2-byte UTF-8 sequence) or MKL$(reversed hex 3/4-byte UTF-8 sequence)
repl AS STRING * 8 '= replacement string (1-8 chars)
END TYPE
-DIM SHARED wpUtfRepl(0 TO 40) AS wikiUtf8Replace
+DIM SHARED wpUtfRepl(0 TO 65) AS wikiUtf8Replace
DIM SHARED wpUtfReplCnt: wpUtfReplCnt = -1 'wpUtfRepl index counter (pre-increment, hence
'you don't need "wpUtfReplCnt - 1" when used in loops, just do "0 TO wpUtfReplCnt"
'Note: All UTF-8 values must be reversed in MKI$/MKL$, as it flips them to little endian.
' In the wiki text they are noted in big endian, hence we need to pre-flip them.
'2-byte sequences
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HB6C2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(20) 'pilcrow
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HA7C2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(21) 'section
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HA9C2): wpUtfRepl(wpUtfReplCnt).repl = "(c)" 'copyright
-wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HA9C3): wpUtfRepl(wpUtfReplCnt).repl = CHR$(130) 'accent (é)
-wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HA2C3): wpUtfRepl(wpUtfReplCnt).repl = CHR$(131) 'accent (â)
-wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HA0C3): wpUtfRepl(wpUtfReplCnt).repl = CHR$(133) 'accent (à)
-wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HA5C3): wpUtfRepl(wpUtfReplCnt).repl = CHR$(134) 'accent (å)
-wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HA7C3): wpUtfRepl(wpUtfReplCnt).repl = CHR$(135) 'accent (ç)
-wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HAAC3): wpUtfRepl(wpUtfReplCnt).repl = CHR$(136) 'accent (ê)
-wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HABC3): wpUtfRepl(wpUtfReplCnt).repl = CHR$(137) 'accent (ë)
-wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HA8C3): wpUtfRepl(wpUtfReplCnt).repl = CHR$(138) 'accent (è)
-wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HAFC3): wpUtfRepl(wpUtfReplCnt).repl = CHR$(139) 'accent (ï)
-wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HAEC3): wpUtfRepl(wpUtfReplCnt).repl = CHR$(140) 'accent (î)
-wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HA2C2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(155) 'cents (ø)
-wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HBDC2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(171) 'fraction (½)
-wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HBCC2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(172) 'fraction (¼)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HA9C3): wpUtfRepl(wpUtfReplCnt).repl = CHR$(130) 'accent (‚)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HA2C3): wpUtfRepl(wpUtfReplCnt).repl = CHR$(131) 'accent (ƒ)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HA0C3): wpUtfRepl(wpUtfReplCnt).repl = CHR$(133) 'accent (…)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HA5C3): wpUtfRepl(wpUtfReplCnt).repl = CHR$(134) 'accent (†)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HA7C3): wpUtfRepl(wpUtfReplCnt).repl = CHR$(135) 'accent (‡)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HAAC3): wpUtfRepl(wpUtfReplCnt).repl = CHR$(136) 'accent (ˆ)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HABC3): wpUtfRepl(wpUtfReplCnt).repl = CHR$(137) 'accent (‰)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HA8C3): wpUtfRepl(wpUtfReplCnt).repl = CHR$(138) 'accent (Š)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HAFC3): wpUtfRepl(wpUtfReplCnt).repl = CHR$(139) 'accent (‹)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HAEC3): wpUtfRepl(wpUtfReplCnt).repl = CHR$(140) 'accent (Œ)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HA2C2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(155) 'cents
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HBDC2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(171) 'fraction («)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HBCC2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(172) 'fraction (¬)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&H80CF): wpUtfRepl(wpUtfReplCnt).repl = CHR$(227) 'pi
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKI$(&HA0C2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(255) 'non-breaking space
'3-byte sequences
-wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HA680E2): wpUtfRepl(wpUtfReplCnt).repl = "..." 'ellipsis
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HA680E2): wpUtfRepl(wpUtfReplCnt).repl = "..." 'ellipsis (hori.)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HAE8BE2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(240) 'ellipsis (vert.) (ð)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H8C94E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(218) 'single line draw (top/left corner)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H9094E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(191) 'single line draw (top/right corner)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H9494E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(192) 'single line draw (bottom/left corner)
@@ -109,14 +113,36 @@ wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HAC94E2):
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HA494E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(180) 'single line draw (vert. line + left connection)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H9C94E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(195) 'single line draw (vert. line + right connection)
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HBC94E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(197) 'single line draw (hori./vert. line cross)
-wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HB296E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(30) 'triangle up
-wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HBC96E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(31) 'triangle down
-wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H8497E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(17) 'triangle left
-wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HBA96E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(16) 'triangle right
-wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H9186E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(24) 'arrow up
-wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H9386E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(25) 'arrow down
-wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H9086E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(27) 'arrow left
-wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H9286E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(26) 'arrow right
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HB296E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(30) 'triangle (up)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HBC96E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(31) 'triangle (down)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H8497E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(17) 'triangle (left)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HBA96E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(16) 'triangle (right)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H9186E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(24) 'arrow (up)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H9386E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(25) 'arrow (down)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H9586E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(18) 'arrow (up down)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HA886E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(23) 'arrow (up down with base)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H9086E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(27) 'arrow (left)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H9286E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(26) 'arrow (right)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H9486E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(29) 'arrow (left right)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HBA98E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(1) 'face (drawing)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HBB98E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(2) 'face (solid)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HA599E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(3) 'card suit (heart)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HA699E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(4) 'card suit (diamond)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HA399E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(5) 'card suit (club)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HA099E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(6) 'card suit (spade)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H8299E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(11) 'gender sign (male)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H8099E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(12) 'gender sign (female)
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HAA99E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(13) 'eighth note
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HAB99E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(14) 'beamed eighth notes
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HA280E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(7) 'bullet
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H9897E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(8) 'inverse bullet
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H8B97E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(9) 'circle
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H9997E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(10) 'inverse circle
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HBC98E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(15) 'sun with rays
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HBC80E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(19) 'double exclamation
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&HAC96E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(22) 'rectangle
+wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H9F88E2): wpUtfRepl(wpUtfReplCnt).repl = CHR$(28) 'right angle
'4-byte sequences
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H80989FF0): wpUtfRepl(wpUtfReplCnt).repl = ":)" 'smily
wpUtfReplCnt = wpUtfReplCnt + 1: wpUtfRepl(wpUtfReplCnt).utf8 = MKL$(&H88989FF0): wpUtfRepl(wpUtfReplCnt).repl = ";)" 'wink
+
From 08b000b71ce532aa53bdc838d2a21ad924b10c35 Mon Sep 17 00:00:00 2001
From: Roland Heyder
Date: Sun, 12 Feb 2023 19:20:50 +0100
Subject: [PATCH 4/7] Skip more useless line feeds
- ignore line feeds after HTML comments and
and
tags
---
source/ide/wiki/wiki_methods.bas | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/source/ide/wiki/wiki_methods.bas b/source/ide/wiki/wiki_methods.bas
index fe40cd574..43336c1c1 100644
--- a/source/ide/wiki/wiki_methods.bas
+++ b/source/ide/wiki/wiki_methods.bas
@@ -449,7 +449,8 @@ SUB WikiParse (a$) 'Wiki page interpret
IF c$(LEN(s$)) = s$ THEN
i = i + LEN(s$) - 1
FOR ii = i TO LEN(a$) - 1
- IF MID$(a$, ii, 3) = "-->" THEN i = ii + 2: EXIT FOR
+ IF MID$(a$, ii, 4) = "-->" + CHR$(10) THEN i = ii + 3: GOTO charDoneKnl
+ IF MID$(a$, ii, 3) = "-->" THEN i = ii + 2: GOTO charDone
NEXT
GOTO charDone
END IF
@@ -922,8 +923,8 @@ SUB WikiParse (a$) 'Wiki page interpret
'Line break handling (no restrictions)
IF c = 10 OR c$(4) = "
" OR c$(6) = "
" THEN
- IF c$(4) = "
" THEN i = i + 3
- IF c$(6) = "
" THEN i = i + 5
+ IF c$(4) = "
" THEN i = i + 3: IF ASC(c$(5), 5) = 10 THEN i = i + 1
+ IF c$(6) = "
" THEN i = i + 5: IF ASC(c$(7), 7) = 10 THEN i = i + 1
IF c = 10 THEN 'on real new line only
IF dl > 1 THEN dl = dl - 1 'update def list state
IF Help_LockParse = 0 THEN Help_LIndent$ = "" 'end indention outside blocks
@@ -1317,7 +1318,10 @@ FUNCTION wikiBuildCIndent$ (a$) 'Pre-calc center indentions
b$ = b$ + MID$(org$, i, 1)
charDoneUtf:
NEXT
-
+ b$ = StrReplace$(b$, "
" + CHR$(10), CHR$(10)) 'convert HTML line breaks
+ b$ = StrReplace$(b$, "
", CHR$(10))
+ b$ = StrReplace$(b$, "
" + CHR$(10), CHR$(10)) 'convert XHTML line breaks
+ b$ = StrReplace$(b$, "
", CHR$(10))
b$ = _TRIM$(b$) + CHR$(10) 'safety fallback
i = 1: st = 1: br = 0: res$ = ""
From dacff9e1b84d4fdeef7724553b5a2d1321aa89fe Mon Sep 17 00:00:00 2001
From: Roland Heyder
Date: Sun, 12 Feb 2023 19:32:47 +0100
Subject: [PATCH 5/7] Improve local linking for #toc/#top links
- designate the help page header as target for #toc/#top links (Return to Top, Return to Table of Contents in the Wiki)
- include bottom {{PageNavigation}} links
- implement headings (==== in the Wiki), used as letter anchors in the alphabetic index
---
source/ide/wiki/wiki_methods.bas | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/source/ide/wiki/wiki_methods.bas b/source/ide/wiki/wiki_methods.bas
index 43336c1c1..f30184eab 100644
--- a/source/ide/wiki/wiki_methods.bas
+++ b/source/ide/wiki/wiki_methods.bas
@@ -301,7 +301,8 @@ SUB WikiParse (a$) 'Wiki page interpret
Help_AddTxt SPACE$(i) + CHR$(4), 14, 0
IF LEFT$(d$, 4) = "Page" THEN i = 8: ELSE i = 7
Help_LockWrap = 1: Help_AddTxt " " + d$, i, 0: Help_NewLine: Help_LockWrap = 0
- Help_AddTxt "ÄÄÁ" + STRING$(ii + 2, "Ä") + "Á" + STRING$(Help_ww - ii - 6, "Ä"), 14, 0: Help_NewLine
+ Help_AddTxt "ÄÄÁ", 14, 1 '#toc/#top local link anchor
+ Help_AddTxt STRING$(ii + 2, "Ä") + "Á" + STRING$(Help_ww - ii - 6, "Ä"), 14, 0: Help_NewLine
'Init prefetch array
prefetch = 20
@@ -334,6 +335,8 @@ SUB WikiParse (a$) 'Wiki page interpret
s$ = "__NOEDITSECTION__": IF c$(LEN(s$)) = s$ THEN i = i + LEN(s$) - 1: GOTO charDone
s$ = "__NOTOC__" + CHR$(10): IF c$(LEN(s$)) = s$ THEN i = i + LEN(s$) - 1: GOTO charDoneKnl
s$ = "__NOTOC__": IF c$(LEN(s$)) = s$ THEN i = i + LEN(s$) - 1: GOTO charDone
+ s$ = "__TOC__" + CHR$(10): IF c$(LEN(s$)) = s$ THEN i = i + LEN(s$) - 1: GOTO charDoneKnl
+ s$ = "__TOC__": IF c$(LEN(s$)) = s$ THEN i = i + LEN(s$) - 1: GOTO charDone
s$ = "": IF c$(LEN(s$)) = s$ THEN i = i + LEN(s$) - 1: GOTO charDone
s$ = "": IF c$(LEN(s$)) = s$ THEN i = i + LEN(s$) - 1: GOTO charDone
s$ = " 0 THEN i = i + ii: col = Help_Col: Help_Underline = 0: GOTO charDone
ii = 0
IF c$(4) = " ===" AND Help_Heading = 3 THEN ii = 3: Help_Heading = 0: hl = 0: ah = 2
IF c$(3) = "===" AND Help_Heading = 3 THEN ii = 2: Help_Heading = 0: hl = 0: ah = 2
From b1c9733420e2ce6d6435bac419d3c1e8a9c9f7ba Mon Sep 17 00:00:00 2001
From: Roland Heyder
Date: Sun, 12 Feb 2023 19:41:25 +0100
Subject: [PATCH 6/7] Removes old code
- unused (commented) code
- no longer needed HTML tag handling (eliminated from Wiki pages)
- #toc/#top link filters removed (those links are supported now)
---
source/ide/ide_methods.bas | 25 ---------------------
source/ide/wiki/wiki_methods.bas | 38 ++++----------------------------
2 files changed, 4 insertions(+), 59 deletions(-)
diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas
index 837a66c04..a0bf6ba35 100644
--- a/source/ide/ide_methods.bas
+++ b/source/ide/ide_methods.bas
@@ -17703,19 +17703,9 @@ SUB Help_ShowText
REDIM Help_LineLen(Help_wh)
- COLOR 7, 0
-
- 'CLS
- 'FOR y = Help_wy1 - 1 TO Help_wy2 + 1
- ' FOR x = Help_wx1 - 1 TO Help_wx2 + 1
- ' LOCATE y, x: PRINT chr$(219);
- ' NEXT
- 'NEXT
-
sy = Help_wy1
FOR y = Help_sy TO Help_sy + Help_wh - 1
IF y <= help_h THEN
- 'PRINT CVL(MID$(Help_Line$, (y - 1) * 4 + 1, 4)), LEN(Help_Txt$)
l = CVL(MID$(Help_Line$, (y - 1) * 4 + 1, 4))
x = l
x3 = 1
@@ -17779,21 +17769,6 @@ SUB Help_ShowText
sy = sy + 1
NEXT
- 'LOCATE Help_cy - Help_sy + Help_wy1, Help_cx - Help_sx + Help_wx1
- 'COLOR 15, 4
- 'PRINT CHR$(SCREEN(CSRLIN, POS(0)));
-
- 'c = 0
- 'DO
- ' old_kcontrol = KCONTROL
- ' GetInput
- ' IF KB > 0 THEN c = 1
- ' IF mCLICK THEN c = 1
- ' IF mWHEEL THEN c = 1
- ' IF KCONTROL AND old_kcontrol = 0 THEN c = 0
- ' IF mB THEN c = 1
- 'LOOP UNTIL c
-
END SUB
diff --git a/source/ide/wiki/wiki_methods.bas b/source/ide/wiki/wiki_methods.bas
index f30184eab..6167b9f20 100644
--- a/source/ide/wiki/wiki_methods.bas
+++ b/source/ide/wiki/wiki_methods.bas
@@ -377,20 +377,13 @@ SUB WikiParse (a$) 'Wiki page interpret
'Direct HTML code is not handled in Code/Output blocks (hard lock), as all text
'could be part of the code example itself (just imagine a HTML parser/writer demo)
IF Help_LockParse <= 0 THEN
- s$ = "": IF c$(LEN(s$)) = s$ THEN Help_AddTxt "^", col, 0: i = i + LEN(s$) - 1: GOTO charDone
- s$ = "": IF c$(LEN(s$)) = s$ THEN i = i + LEN(s$) - 1: GOTO charDone
-
s$ = "" 'centered section
IF c$(LEN(s$)) = s$ THEN
i = i + LEN(s$) - 1
wla$ = wikiLookAhead$(a$, i + 1, "")
- IF INSTR(wla$, "#toc") > 0 OR INSTR(wla$, "#top") > 0 OR INSTR(wla$, "to Top") > 0 THEN
- i = i + LEN(wla$) + 9 'ignore TOC/TOP links
- ELSE
- Help_Center = 1: Help_CIndent$ = wikiBuildCIndent$(wla$)
- Help_AddTxt SPACE$(ASC(Help_CIndent$, 1)), col, 0 'center content
- Help_CIndent$ = MID$(Help_CIndent$, 2)
- END IF
+ Help_Center = 1: Help_CIndent$ = wikiBuildCIndent$(wla$)
+ Help_AddTxt SPACE$(ASC(Help_CIndent$, 1)), col, 0 'center content
+ Help_CIndent$ = MID$(Help_CIndent$, 2)
GOTO charDone
END IF
s$ = ""
@@ -406,9 +399,7 @@ SUB WikiParse (a$) 'Wiki page interpret
FOR ii = i TO LEN(a$) - 1
IF MID$(a$, ii, 1) = ">" THEN
wla$ = wikiLookAhead$(a$, ii + 1, "
")
- IF INSTR(wla$, "#toc") > 0 OR INSTR(wla$, "#top") > 0 OR INSTR(wla$, "to Top") > 0 THEN
- i = ii + LEN(wla$) + 4 'ignore TOC/TOP links
- ELSEIF INSTR(MID$(a$, i, ii - i), "center") > 0 THEN
+ IF INSTR(MID$(a$, i, ii - i), "center") > 0 THEN
Help_Center = 1: Help_CIndent$ = wikiBuildCIndent$(wla$)
Help_AddTxt SPACE$(ASC(Help_CIndent$, 1)), col, 0 'center (if in style)
Help_CIndent$ = MID$(Help_CIndent$, 2)
@@ -426,28 +417,7 @@ SUB WikiParse (a$) 'Wiki page interpret
Help_NewLine
GOTO charDone
END IF
- s$ = "" THEN i = ii: EXIT FOR
- NEXT
- GOTO charDone
- END IF
- s$ = ""
- IF c$(LEN(s$)) = s$ THEN
- i = i + LEN(s$) - 1
- GOTO charDone
- END IF
- s$ = "" THEN i = ii + 5: EXIT FOR
- NEXT
- GOTO charDone
- END IF
s$ = "