2015-08-02 12:12:44 +00:00
FUNCTION Back2BackName$ ( a$ )
2018-07-17 03:01:23 +00:00
IF a$ = "Keyword Reference - Alphabetical" THEN Back2BackName$ = "Alphabetical" : EXIT FUNCTION
IF a$ = "Keyword Reference - By usage" THEN Back2BackName$ = "By Usage" : EXIT FUNCTION
IF a$ = "QB64 Help Menu" THEN Back2BackName$ = "Help" : EXIT FUNCTION
IF a$ = "QB64 FAQ" THEN Back2BackName$ = "FAQ" : EXIT FUNCTION
Back2BackName$ = a$
2015-08-02 12:12:44 +00:00
END FUNCTION
2022-05-15 00:45:45 +00:00
FUNCTION Wiki$ ( PageName$ ) 'Read cached wiki page (download, if not yet cached)
2018-07-17 03:01:23 +00:00
Help_PageLoaded$ = PageName$
2022-05-10 12:43:53 +00:00
'Escape all invalid and other critical chars in filenames
PageName2$ = ""
FOR i = 1 TO LEN ( PageName$ )
c = ASC ( PageName$ , i )
SELECT CASE c
CASE 32 ' '(space)
PageName2$ = PageName2$ + "_"
CASE 34 , 38 , 42 , 47 , 58 , 60 , 62 , 63 , 92 , 124 '("&*/:<>?\|)
PageName2$ = PageName2$ + "%" + HEX$ ( c )
CASE ELSE
PageName2$ = PageName2$ + CHR$ ( c )
END SELECT
NEXT
2022-05-19 23:41:05 +00:00
PageName3$ = wikiSafeName$ ( PageName2$ ) 'case independent name
2018-07-17 03:01:23 +00:00
'Is this page in the cache?
IF Help_IgnoreCache = 0 THEN
2022-05-19 23:41:05 +00:00
IF _FILEEXISTS ( Cache_Folder$ + "/" + PageName3$ + ".txt" ) THEN
2018-07-17 03:01:23 +00:00
fh = FREEFILE
2022-05-19 23:41:05 +00:00
OPEN Cache_Folder$ + "/" + PageName3$ + ".txt" FOR BINARY AS # fh
2018-07-17 03:01:23 +00:00
a$ = SPACE$ ( LOF ( fh ) )
GET # fh , , a$
CLOSE # fh
Wiki$ = a$
EXIT FUNCTION
END IF
2015-08-02 12:12:44 +00:00
END IF
2018-07-17 03:01:23 +00:00
2022-05-15 00:45:45 +00:00
'Check for curl
2022-01-20 22:38:34 +00:00
IF _SHELLHIDE ( "curl --version" ) < > 0 THEN
2022-05-30 01:15:36 +00:00
a$ = CHR$ ( 10 ) + "{{PageInternalError}}" + CHR$ ( 10 )
IF PageName$ = "Initialize" THEN
a$ = a$ + "To be able to initialize the help system, "
ELSEIF PageName$ = "Update All" THEN
a$ = a$ + "To be able to update the help pages from the online Wiki, "
ELSE
a$ = a$ + "The requested help page is not yet cached locally. To download the help page from the online Wiki, "
END IF
a$ = a$ + "a tool called ''curl'' is required, but it wasn't found on your system." + CHR$ ( 10 ) + CHR$ ( 10 )
a$ = a$ + "* To get ''curl'', visit the official [https://curl.se/download.html download page]." + CHR$ ( 10 )
a$ = a$ + "** Grab the latest ''binary'' archive available for your system." + CHR$ ( 10 )
a$ = a$ + "** Unpack and drop the ''curl'' executable into the QB64 folder." + CHR$ ( 10 )
a$ = a$ + "** If there's a file named ''curl-ca-bundle.crt'' or similar, drop it into the QB64 folder too." + CHR$ ( 10 )
Wiki$ = a$ : EXIT FUNCTION
2022-01-20 22:38:34 +00:00
END IF
2022-05-15 00:45:45 +00:00
'Download message (Status Bar)
2018-07-17 03:01:23 +00:00
IF Help_Recaching = 0 THEN
a$ = "Downloading '" + PageName$ + "' page..."
IF LEN ( a$ ) > 60 THEN a$ = LEFT$ ( a$ , 57 ) + STRING$ ( 3 , 250 )
IF LEN ( a$ ) < 60 THEN a$ = a$ + SPACE$ ( 60 - LEN ( a$ ) )
COLOR 0 , 3 : LOCATE idewy + idesubwindow , 2
PRINT a$ ;
PCOPY 3 , 0
END IF
2022-05-15 00:45:45 +00:00
'Url query and output arguments for curl
2022-01-20 22:38:34 +00:00
url$ = CHR$ ( 34 ) + wikiBaseAddress$ + "/index.php?title=" + PageName2$ + "&action=edit" + CHR$ ( 34 )
2022-05-19 23:41:05 +00:00
outputFile$ = Cache_Folder$ + "/" + PageName3$ + ".txt"
2022-05-15 00:45:45 +00:00
'Wikitext delimiters
2018-08-17 21:15:40 +00:00
s1$ = "name=" + CHR$ ( 34 ) + "wpTextbox1" + CHR$ ( 34 ) + ">"
2022-01-20 22:38:34 +00:00
s2$ = "</textarea>"
2022-05-20 21:44:55 +00:00
'Download page using curl
SHELL _HIDE "curl -o " + CHR$ ( 34 ) + outputFile$ + CHR$ ( 34 ) + " " + url$
2022-01-20 22:38:34 +00:00
fh = FREEFILE
OPEN outputFile$ FOR BINARY AS # fh 'get new content
a$ = SPACE$ ( LOF ( fh ) )
GET # fh , 1 , a$
CLOSE # fh
2022-05-15 00:45:45 +00:00
'Find wikitext in the downloaded page
2022-01-20 22:38:34 +00:00
s1 = INSTR ( a$ , s1$ )
2022-05-10 12:43:53 +00:00
IF s1 > 0 THEN a$ = MID$ ( a$ , s1 + LEN ( s1$ ) ) : s2 = INSTR ( a$ , s2$ ) : ELSE s2 = 0
IF s2 > 0 THEN a$ = LEFT$ ( a$ , s2 - 1 )
IF s1 > 0 AND s2 > 0 AND a$ < > "" THEN
2022-05-18 23:45:25 +00:00
'If wikitext was found, then substitute stuff & save it
'--- first HTML specific entities
2022-05-10 12:43:53 +00:00
WHILE INSTR ( a$ , "&" ) > 0 ' '& must be first and looped until all
a$ = StrReplace$ ( a$ , "&" , "&" ) 'multi-escapes are resolved (eg. &lt; &amp;lt; etc.)
WEND
a$ = StrReplace$ ( a$ , "<" , "<" )
a$ = StrReplace$ ( a$ , ">" , ">" )
a$ = StrReplace$ ( a$ , """ , CHR$ ( 34 ) )
'--- then other entities
a$ = StrReplace$ ( a$ , "|" , "|" )
a$ = StrReplace$ ( a$ , "π" , CHR$ ( 227 ) )
a$ = StrReplace$ ( a$ , "θ" , CHR$ ( 233 ) )
a$ = StrReplace$ ( a$ , "¹" , CHR$ ( 252 ) )
a$ = StrReplace$ ( a$ , "²" , CHR$ ( 253 ) )
a$ = StrReplace$ ( a$ , " " , CHR$ ( 255 ) )
2022-05-20 21:44:55 +00:00
'--- useless styles in blocks
2022-05-18 23:45:25 +00:00
a$ = StrReplace$ ( a$ , "Start}}'' ''" , "Start}}" )
a$ = StrReplace$ ( a$ , "Start}} '' ''" , "Start}}" )
a$ = StrReplace$ ( a$ , "Start}}" + CHR$ ( 10 ) + "'' ''" , "Start}}" )
a$ = StrReplace$ ( a$ , "'' ''" + CHR$ ( 10 ) + "{{" , CHR$ ( 10 ) + "{{" )
a$ = StrReplace$ ( a$ , "'' '' " + CHR$ ( 10 ) + "{{" , CHR$ ( 10 ) + "{{" )
2022-05-28 08:26:49 +00:00
a$ = StrReplace$ ( a$ , "'' ''" + CHR$ ( 10 ) + CHR$ ( 10 ) + "{{" , CHR$ ( 10 ) + "{{" )
'--- wiki redirects & crlf
2022-05-20 21:44:55 +00:00
a$ = StrReplace$ ( a$ , "#REDIRECT" , "See page" )
2022-05-28 08:26:49 +00:00
a$ = StrReplace$ ( a$ , CHR$ ( 13 ) + CHR$ ( 10 ) , CHR$ ( 10 ) )
2022-05-18 23:45:25 +00:00
'--- put a download date/time entry
2022-05-18 00:15:36 +00:00
a$ = "{{QBDLDATE:" + DATE$ + "}}" + CHR$ ( 10 ) + "{{QBDLTIME:" + TIME$ + "}}" + CHR$ ( 10 ) + a$
2022-05-10 12:43:53 +00:00
'--- now save it
OPEN outputFile$ FOR OUTPUT AS # fh
PRINT # fh , a$
2022-01-20 22:38:34 +00:00
CLOSE # fh
2022-05-10 12:43:53 +00:00
ELSE
2022-05-15 00:45:45 +00:00
'Delete page, if empty or corrupted (force re-download on next access)
2022-05-10 12:43:53 +00:00
KILL outputFile$
2022-05-19 23:41:05 +00:00
a$ = CHR$ ( 10 ) + "{{PageInternalError}}" + CHR$ ( 10 ) + _
2022-05-10 12:43:53 +00:00
"* Either the requested page is not yet available in the Wiki," + CHR$ ( 10 ) + _
"* or the download from Wiki failed and corrupted the page data." + CHR$ ( 10 ) + _
"** You may try ''Update Current Page'' from the ''Help'' menu." + CHR$ ( 10 )
2022-01-20 22:38:34 +00:00
END IF
Wiki$ = a$
2015-08-02 12:12:44 +00:00
END FUNCTION
2022-05-15 00:45:45 +00:00
SUB Help_AddTxt ( t$ , col , link ) 'Add help text, handle word wrap
2018-07-17 03:01:23 +00:00
IF t$ = CHR$ ( 13 ) THEN Help_NewLine: EXIT SUB
2015-08-02 12:12:44 +00:00
2018-07-17 03:01:23 +00:00
FOR i = 1 TO LEN ( t$ )
c = ASC ( t$ , i )
2015-08-02 12:12:44 +00:00
2022-05-10 12:43:53 +00:00
IF Help_LockParse = 0 AND Help_LockWrap = 0 THEN
2015-08-02 12:12:44 +00:00
2018-07-17 03:01:23 +00:00
IF c = 32 THEN
2022-05-10 12:43:53 +00:00
IF Help_Pos = Help_ww THEN Help_NewLine: _CONTINUE
2015-08-02 12:12:44 +00:00
2018-07-17 03:01:23 +00:00
Help_Txt_Len = Help_Txt_Len + 1 : ASC ( Help_Txt$ , Help_Txt_Len ) = 32
Help_Txt_Len = Help_Txt_Len + 1 : ASC ( Help_Txt$ , Help_Txt_Len ) = col + Help_BG_Col * 16
Help_Txt_Len = Help_Txt_Len + 1 : ASC ( Help_Txt$ , Help_Txt_Len ) = link AND 255
Help_Txt_Len = Help_Txt_Len + 1 : ASC ( Help_Txt$ , Help_Txt_Len ) = link \ 256
2015-08-02 12:12:44 +00:00
2018-07-17 03:01:23 +00:00
Help_Wrap_Pos = Help_Txt_Len 'pos to backtrack to when wrapping content
2022-05-10 12:43:53 +00:00
Help_Pos = Help_Pos + 1 : _CONTINUE
2018-07-17 03:01:23 +00:00
END IF
2015-08-02 12:12:44 +00:00
2018-07-17 03:01:23 +00:00
IF Help_Pos > Help_ww THEN
IF Help_Wrap_Pos THEN 'attempt to wrap
'backtrack, insert new line, continue
2015-08-02 12:12:44 +00:00
2018-07-17 03:01:23 +00:00
b$ = MID$ ( Help_Txt$ , Help_Wrap_Pos + 1 , Help_Txt_Len - Help_Wrap_Pos )
2015-08-02 12:12:44 +00:00
2018-07-17 03:01:23 +00:00
Help_Txt_Len = Help_Wrap_Pos
2015-08-02 12:12:44 +00:00
2018-07-17 03:01:23 +00:00
Help_NewLine
2015-08-02 12:12:44 +00:00
2018-07-17 03:01:23 +00:00
MID$ ( Help_Txt$ , Help_Txt_Len + 1 , LEN ( b$ ) ) = b$ : Help_Txt_Len = Help_Txt_Len + LEN ( b$ )
2015-08-02 12:12:44 +00:00
2018-07-17 03:01:23 +00:00
Help_Pos = Help_Pos + LEN ( b$ ) \ 4
END IF
2015-08-02 12:12:44 +00:00
END IF
2022-05-15 00:45:45 +00:00
END IF
2015-08-02 12:12:44 +00:00
2018-07-17 03:01:23 +00:00
Help_Txt_Len = Help_Txt_Len + 1 : ASC ( Help_Txt$ , Help_Txt_Len ) = c
Help_Txt_Len = Help_Txt_Len + 1 : ASC ( Help_Txt$ , Help_Txt_Len ) = col + Help_BG_Col * 16
Help_Txt_Len = Help_Txt_Len + 1 : ASC ( Help_Txt$ , Help_Txt_Len ) = link AND 255
Help_Txt_Len = Help_Txt_Len + 1 : ASC ( Help_Txt$ , Help_Txt_Len ) = link \ 256
2015-08-02 12:12:44 +00:00
2018-07-17 03:01:23 +00:00
Help_Pos = Help_Pos + 1
NEXT
2015-08-02 12:12:44 +00:00
END SUB
2022-05-15 00:45:45 +00:00
SUB Help_NewLine 'Start a new help line, apply indention (if any)
2018-07-17 03:01:23 +00:00
IF Help_Pos > help_w THEN help_w = Help_Pos
2015-08-02 12:12:44 +00:00
2018-07-17 03:01:23 +00:00
Help_Txt_Len = Help_Txt_Len + 1 : ASC ( Help_Txt$ , Help_Txt_Len ) = 13
2021-07-21 17:22:37 +00:00
Help_Txt_Len = Help_Txt_Len + 1 : ASC ( Help_Txt$ , Help_Txt_Len ) = Help_BG_Col * 16
2018-07-17 03:01:23 +00:00
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
help_h = help_h + 1
Help_Line$ = Help_Line$ + MKL$ ( Help_Txt_Len + 1 )
Help_Wrap_Pos = 0
IF Help_Underline THEN
w = Help_Pos
Help_Pos = 1
2022-05-18 00:15:36 +00:00
IF Help_Underline = Help_Col_Section THEN
Help_AddTxt STRING$ ( w - 1 , 205 ) , Help_Underline , 0
ELSE
Help_AddTxt STRING$ ( w - 1 , 196 ) , Help_Underline , 0
END IF
2022-05-10 12:43:53 +00:00
Help_Underline = 0 'keep before Help_NewLine (recursion)
2018-07-17 03:01:23 +00:00
Help_NewLine
END IF
2015-08-02 12:12:44 +00:00
Help_Pos = 1
2022-05-10 12:43:53 +00:00
IF Help_Center > 0 THEN 'center overrides regular indent
Help_NewLineIndent = 0
2022-05-13 11:53:58 +00:00
Help_AddTxt SPACE$ ( ASC ( Help_CIndent$ , 1 ) ) , Help_Col , 0
2022-05-10 12:43:53 +00:00
Help_CIndent$ = MID$ ( Help_CIndent$ , 2 )
ELSEIF Help_NewLineIndent > 0 THEN
2018-07-17 03:01:23 +00:00
Help_AddTxt SPACE$ ( Help_NewLineIndent ) , Help_Col , 0
END IF
2015-08-02 12:12:44 +00:00
END SUB
2022-05-15 00:45:45 +00:00
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
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
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
Help_Txt_Len = Help_Txt_Len - 4
help_h = help_h - 1
Help_Line$ = LEFT$ ( Help_Line$ , LEN ( Help_Line$ ) - 4 )
END IF
FOR i = Help_Txt_Len - 3 TO 1 STEP -4
IF ASC ( Help_Txt$ , i ) < > 32 THEN
Help_Txt_Len = i + 3 : EXIT FOR
END IF
NEXT
IF ASC ( Help_Txt$ , Help_Txt_Len - 3 ) < > 13 THEN Help_NewLine
END IF
END SUB
FUNCTION Help_Col 'Helps to calculate the default color
2018-07-17 03:01:23 +00:00
col = Help_Col_Normal
IF Help_Italic THEN col = Help_Col_Italic
IF Help_Bold THEN col = Help_Col_Bold 'Note: Bold overrides italic
Help_Col = col
2015-08-02 12:12:44 +00:00
END FUNCTION
2022-05-15 00:45:45 +00:00
SUB WikiParse ( a$ ) 'Wiki page interpret
2018-07-17 03:01:23 +00:00
2022-05-15 00:45:45 +00:00
'Clear info
2018-07-17 03:01:23 +00:00
help_h = 0 : help_w = 0 : Help_Line$ = "" : Help_Link$ = "" : Help_LinkN = 0
Help_Txt$ = SPACE$ ( 1000000 )
Help_Txt_Len = 0
Help_Pos = 1 : Help_Wrap_Pos = 0
Help_Line$ = MKL$ ( 1 )
2022-05-15 00:45:45 +00:00
'Word wrap locks (lock wrapping only, but continue parsing regularly)
2018-07-17 03:01:23 +00:00
Help_LockWrap = 0
2022-05-15 00:45:45 +00:00
'Parser locks (neg: soft lock, zero: unlocked, pos: hard lock)
2022-05-10 12:43:53 +00:00
'hard: 2 = inside code blocks, 1 = inside output blocks
'soft: -1 = inside text blocks, -2 = inside fixed blocks
'=> all parser locks also imply a wrapping lock
'=> 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
2018-07-17 03:01:23 +00:00
Help_Bold = 0 : Help_Italic = 0
Help_Underline = 0
Help_BG_Col = 0
2022-05-10 12:43:53 +00:00
Help_Center = 0 : Help_CIndent$ = ""
Help_DList = 0
2018-07-17 03:01:23 +00:00
2022-05-10 12:43:53 +00:00
link = 0 : elink = 0 : cb = 0 : nl = 1
2018-07-17 03:01:23 +00:00
col = Help_Col
'Syntax Notes:
2022-05-18 00:15:36 +00:00
'=============
'everywhere in text
'------------------
' ''' = bold text style
2022-05-20 21:44:55 +00:00
' '' = italic text style
2022-05-18 00:15:36 +00:00
' [url text] = external link to url with text to appear (url ends at 1st found space)
' [[page]] = link to another wikipage
' [[page|text]] = link to another wikipage with alternative text to appear
' {{templatename|param|param|param}} or simply {{templatename}} = predefined styles
'---------------------
'at start of line only
'---------------------
' * = dot list point
' ** = sub (ie. further indented) dot list point
' ;def:desc = full definition/description list
' :desc = description only, but indented as in a full def/desc list
' ;* def:desc = combi list, list dot always belongs to description
' :* desc = combi, description only
'First find and write the page title and last update
d$ = "Page not yet updated, expect visual glitches." : i = INSTR ( a$ , "{{QBDLDATE:" )
IF i > 0 THEN
d$ = "Last updated: " + MID$ ( a$ , i + 11 , INSTR ( i + 11 , a$ , "}}" ) - i - 11 )
i = INSTR ( a$ , "{{QBDLTIME:" )
IF i > 0 THEN d$ = d$ + ", at " + MID$ ( a$ , i + 11 , INSTR ( i + 11 , a$ , "}}" ) - i - 11 )
2022-05-19 23:41:05 +00:00
ELSEIF INSTR ( a$ , "{{PageInternalError}}" ) > 0 THEN
d$ = "Page not found."
2022-05-18 00:15:36 +00:00
END IF
t$ = Help_PageLoaded$ : i = INSTR ( a$ , "{{DISPLAYTITLE:" )
IF i > 0 THEN t$ = MID$ ( a$ , i + 15 , INSTR ( i + 15 , a$ , "}}" ) - i - 15 )
2022-05-20 21:44:55 +00:00
IF LEFT$ ( t$ , 4 ) = "agp@" THEN
d$ = "Auto-generated temporary page."
t$ = MID$ ( t$ , 5 )
END IF
2022-05-18 00:15:36 +00:00
i = LEN ( d$ ) : ii = LEN ( t$ )
Help_AddTxt " <20> " + STRING$ ( ii + 2 , "<22> " ) + "<22> " , 14 , 0 : Help_NewLine
Help_AddTxt " <20> " , 14 , 0 : Help_AddTxt t$ , 12 , 0 : Help_AddTxt " <20> " , 14 , 0
Help_AddTxt SPACE$ ( Help_ww - i - 2 - Help_Pos ) + CHR$ ( 4 ) , 14 , 0
2022-05-18 23:45:25 +00:00
IF LEFT$ ( d$ , 4 ) = "Page" THEN i = 8 : ELSE i = 7
Help_AddTxt " " + d$ , i , 0 : Help_NewLine
2022-05-18 00:15:36 +00:00
Help_AddTxt "<22> <> <EFBFBD> <EFBFBD> " + STRING$ ( ii + 2 , "<22> " ) + "<22> " + STRING$ ( Help_ww - ii - 7 , "<22> " ) , 14 , 0 : Help_NewLine
2018-07-17 03:01:23 +00:00
2022-05-15 00:45:45 +00:00
'Init prefetch array
2022-05-10 12:43:53 +00:00
prefetch = 20
2018-09-24 03:50:03 +00:00
DIM c$ ( prefetch )
FOR ii = 1 TO prefetch
2018-07-17 03:01:23 +00:00
c$ ( ii ) = SPACE$ ( ii )
2015-08-02 12:12:44 +00:00
NEXT
2022-05-15 00:45:45 +00:00
'BEGIN_PARSE_LOOP
2018-07-17 03:01:23 +00:00
n = LEN ( a$ )
i = 1
DO WHILE i < = n
2022-05-10 12:43:53 +00:00
'Get next char and fill prefetch array
2018-07-17 03:01:23 +00:00
c = ASC ( a$ , i ) : c$ = CHR$ ( c )
2018-09-24 03:50:03 +00:00
FOR i1 = 1 TO prefetch
2018-07-17 03:01:23 +00:00
ii = i
FOR i2 = 1 TO i1
2018-09-24 03:50:03 +00:00
IF ii < = n THEN
2018-07-17 03:01:23 +00:00
ASC ( c$ ( i1 ) , i2 ) = ASC ( a$ , ii )
ELSE
ASC ( c$ ( i1 ) , i2 ) = 32
END IF
ii = ii + 1
NEXT
NEXT
2015-08-02 12:12:44 +00:00
2022-05-15 00:45:45 +00:00
'Wiki specific code handling (no restrictions)
2022-05-10 12:43:53 +00:00
s$ = "__NOEDITSECTION__" + CHR$ ( 10 ) : IF c$ ( LEN ( s$ ) ) = s$ THEN i = i + LEN ( s$ ) - 1 : GOTO charDone
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 charDone
s$ = "__NOTOC__" : IF c$ ( LEN ( s$ ) ) = s$ THEN i = i + LEN ( s$ ) - 1 : GOTO charDone
s$ = "<nowiki>" : IF c$ ( LEN ( s$ ) ) = s$ THEN i = i + LEN ( s$ ) - 1 : GOTO charDone
s$ = "</nowiki>" : IF c$ ( LEN ( s$ ) ) = s$ THEN i = i + LEN ( s$ ) - 1 : GOTO charDone
2018-09-24 03:50:03 +00:00
2022-05-15 00:45:45 +00:00
'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
2022-05-10 12:43:53 +00:00
s$ = "<sup>" : IF c$ ( LEN ( s$ ) ) = s$ THEN Help_AddTxt "^" , col , 0 : i = i + LEN ( s$ ) - 1 : GOTO charDone
s$ = "</sup>" : IF c$ ( LEN ( s$ ) ) = s$ THEN i = i + LEN ( s$ ) - 1 : GOTO charDone
2015-08-02 12:12:44 +00:00
2022-05-13 11:53:58 +00:00
s$ = "<center>" 'centered section
2021-07-28 21:12:34 +00:00
IF c$ ( LEN ( s$ ) ) = s$ THEN
i = i + LEN ( s$ ) - 1
2022-05-10 12:43:53 +00:00
wla$ = wikiLookAhead$ ( a$ , i + 1 , "</center>" )
IF INSTR ( wla$ , "#toc" ) > 0 OR INSTR ( wla$ , "to Top" ) > 0 THEN
2022-05-11 00:01:22 +00:00
i = i + LEN ( wla$ ) + 9 'ignore TOC links
2022-05-10 12:43:53 +00:00
ELSE
Help_Center = 1 : Help_CIndent$ = wikiBuildCIndent$ ( wla$ )
2022-05-13 11:53:58 +00:00
Help_AddTxt SPACE$ ( ASC ( Help_CIndent$ , 1 ) ) , col , 0 'center content
2022-05-10 12:43:53 +00:00
Help_CIndent$ = MID$ ( Help_CIndent$ , 2 )
END IF
GOTO charDone
2021-07-28 21:12:34 +00:00
END IF
2022-05-10 12:43:53 +00:00
s$ = "</center>"
2021-07-28 21:12:34 +00:00
IF c$ ( LEN ( s$ ) ) = s$ THEN
i = i + LEN ( s$ ) - 1
2022-05-10 12:43:53 +00:00
Help_Center = 0
Help_NewLine
GOTO charDone
2021-07-28 21:12:34 +00:00
END IF
2022-05-13 11:53:58 +00:00
s$ = "<p style=" 'custom paragraph (maybe centered)
2018-07-17 03:01:23 +00:00
IF c$ ( LEN ( s$ ) ) = s$ THEN
i = i + LEN ( s$ ) - 1
2018-09-24 03:50:03 +00:00
FOR ii = i TO LEN ( a$ ) - 1
2022-05-10 12:43:53 +00:00
IF MID$ ( a$ , ii , 1 ) = ">" THEN
wla$ = wikiLookAhead$ ( a$ , ii + 1 , "</p>" )
IF INSTR ( wla$ , "#toc" ) > 0 OR INSTR ( wla$ , "to Top" ) > 0 THEN
2022-05-11 00:01:22 +00:00
i = ii + LEN ( wla$ ) + 4 'ignore TOC links
2022-05-10 12:43:53 +00:00
ELSEIF INSTR ( MID$ ( a$ , i , ii - i ) , "center" ) > 0 THEN
Help_Center = 1 : Help_CIndent$ = wikiBuildCIndent$ ( wla$ )
2022-05-13 11:53:58 +00:00
Help_AddTxt SPACE$ ( ASC ( Help_CIndent$ , 1 ) ) , col , 0 'center (if in style)
2022-05-10 12:43:53 +00:00
Help_CIndent$ = MID$ ( Help_CIndent$ , 2 )
i = ii
END IF
EXIT FOR
END IF
2018-07-17 03:01:23 +00:00
NEXT
2022-05-10 12:43:53 +00:00
GOTO charDone
2018-07-17 03:01:23 +00:00
END IF
2022-05-10 12:43:53 +00:00
s$ = "</p>"
2018-07-17 03:01:23 +00:00
IF c$ ( LEN ( s$ ) ) = s$ THEN
i = i + LEN ( s$ ) - 1
2022-05-10 12:43:53 +00:00
Help_Center = 0
Help_NewLine
GOTO charDone
2018-07-17 03:01:23 +00:00
END IF
2022-05-13 11:53:58 +00:00
s$ = "<span" 'custom inline attributes ignored
IF c$ ( LEN ( s$ ) ) = s$ THEN
i = i + LEN ( s$ ) - 1
FOR ii = i TO LEN ( a$ ) - 1
IF MID$ ( a$ , ii , 1 ) = ">" THEN i = ii: EXIT FOR
NEXT
GOTO charDone
END IF
s$ = "</span>"
IF c$ ( LEN ( s$ ) ) = s$ THEN
i = i + LEN ( s$ ) - 1
GOTO charDone
END IF
2018-07-17 03:01:23 +00:00
2022-05-13 11:53:58 +00:00
s$ = "<div" 'ignore divisions (TOC and letter links)
IF c$ ( LEN ( s$ ) ) = s$ THEN
2018-07-17 03:01:23 +00:00
i = i + LEN ( s$ ) - 1
2018-09-24 03:50:03 +00:00
FOR ii = i TO LEN ( a$ ) - 1
2022-05-10 12:43:53 +00:00
IF MID$ ( a$ , ii , 6 ) = "</div>" THEN i = ii + 5 : EXIT FOR
2018-09-24 03:50:03 +00:00
NEXT
2022-05-10 12:43:53 +00:00
GOTO charDone
2018-07-17 03:01:23 +00:00
END IF
2022-05-10 12:43:53 +00:00
s$ = "<!--" 'ignore HTML comments
2018-07-17 03:01:23 +00:00
IF c$ ( LEN ( s$ ) ) = s$ THEN
i = i + LEN ( s$ ) - 1
2022-05-10 12:43:53 +00:00
FOR ii = i TO LEN ( a$ ) - 1
IF MID$ ( a$ , ii , 3 ) = "-->" THEN i = ii + 2 : EXIT FOR
NEXT
GOTO charDone
2018-07-17 03:01:23 +00:00
END IF
2022-05-15 00:45:45 +00:00
END IF
2018-07-17 03:01:23 +00:00
2022-05-15 00:45:45 +00:00
'Wiki text styles are not handled in Code/Output blocks (hard lock),
'as they could be part of the code example itself
IF Help_LockParse < = 0 THEN
'Bold style
IF c$ ( 3 ) = "'''" THEN
i = i + 2
IF Help_Bold = 0 THEN Help_Bold = 1 ELSE Help_Bold = 0
col = Help_Col
GOTO charDone
END IF
'Italic style
IF c$ ( 2 ) = "''" THEN
i = i + 1
IF Help_Italic = 0 THEN Help_Italic = 1 ELSE Help_Italic = 0
col = Help_Col
GOTO charDone
END IF
END IF
'Wiki links ([ext], [[int]]) are not handled in Code/Output blocks (hard lock),
'as all text could be part of the code example itself
IF Help_LockParse < = 0 THEN
'External links
2022-05-20 21:44:55 +00:00
IF c$ ( 5 ) = "[http" AND elink = 0 THEN
2022-05-19 23:41:05 +00:00
elink = 1
2022-05-15 00:45:45 +00:00
elink$ = ""
GOTO charDone
END IF
2022-05-19 23:41:05 +00:00
IF elink = 1 THEN
2022-05-15 00:45:45 +00:00
IF c$ = "]" THEN
elink = 0
2022-05-19 23:41:05 +00:00
etext$ = elink$
i2 = INSTR ( elink$ , " " )
IF i2 > 0 THEN
etext$ = RIGHT$ ( elink$ , LEN ( elink$ ) - i2 )
elink$ = LEFT$ ( elink$ , i2 - 1 )
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_Bold , Help_LinkN
END IF
2022-05-15 00:45:45 +00:00
GOTO charDone
END IF
2022-05-19 23:41:05 +00:00
elink$ = elink$ + c$
GOTO charDone
2022-05-15 00:45:45 +00:00
END IF
'Internal links
IF c$ ( 2 ) = "[[" AND link = 0 THEN
i = i + 1
link = 1
link$ = ""
GOTO charDone
2018-07-17 03:01:23 +00:00
END IF
2015-08-02 12:12:44 +00:00
END IF
2022-05-15 00:45:45 +00:00
'However, the internal link logic must run always, as it also handles
'the template {{Cb|, {{Cl| and {{KW| links used in code blocks
2018-07-17 03:01:23 +00:00
IF link = 1 THEN
IF c$ ( 2 ) = "]]" OR c$ ( 2 ) = "}}" THEN
i = i + 1
link = 0
text$ = link$
i2 = INSTR ( link$ , "|" )
2022-05-10 12:43:53 +00:00
IF i2 > 0 THEN
2018-07-17 03:01:23 +00:00
text$ = RIGHT$ ( link$ , LEN ( link$ ) - i2 )
link$ = LEFT$ ( link$ , i2 - 1 )
END IF
2015-08-02 12:12:44 +00:00
2022-05-15 00:45:45 +00:00
IF INSTR ( link$ , "#" ) THEN 'local page links not supported
2018-07-17 03:01:23 +00:00
Help_AddTxt text$ , 8 , 0
2022-05-10 12:43:53 +00:00
GOTO charDone
2022-05-19 23:41:05 +00:00
ELSEIF LEFT$ ( link$ , 9 ) = "Category:" THEN 'ignore category links
Help_CheckRemoveBlankLine
GOTO charDone
2018-07-17 03:01:23 +00:00
END IF
Help_LinkN = Help_LinkN + 1
Help_Link$ = Help_Link$ + "PAGE:" + link$ + Help_Link_Sep$
2022-05-13 11:53:58 +00:00
IF Help_LockParse = 0 THEN
2018-07-17 03:01:23 +00:00
Help_AddTxt text$ , Help_Col_Link , Help_LinkN
ELSE
Help_AddTxt text$ , Help_Col_Bold , Help_LinkN
END IF
2022-05-10 12:43:53 +00:00
GOTO charDone
2018-07-17 03:01:23 +00:00
END IF
link$ = link$ + c$
2022-05-10 12:43:53 +00:00
GOTO charDone
2015-08-02 12:12:44 +00:00
END IF
2022-05-15 00:45:45 +00:00
'Wiki tables ({|...|}) are not handled in Code/Output blocks (hard lock),
'as everything could be part of the code example itself
IF Help_LockParse < = 0 THEN
'Tables (ignored, give info, if not in blocks)
IF c$ ( 2 ) = "{|" THEN
wla$ = wikiLookAhead$ ( a$ , i + 2 , "|}" ) : iii = 0
FOR ii = 1 TO LEN ( wla$ )
IF MID$ ( wla$ , ii , 1 ) = "|" AND MID$ ( wla$ , ii , 2 ) < > "|-" THEN iii = iii + 1
NEXT
i = i + 1 + LEN ( wla$ ) + 2
IF iii > 1 OR INSTR ( wla$ , "__TOC__" ) = 0 THEN 'ignore TOC only tables
IF Help_LockParse = 0 THEN
Help_AddTxt SPACE$ ( ( Help_ww - 52 ) \ 2 ) + "<22> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͻ" , 8 , 0 : Help_NewLine
Help_AddTxt SPACE$ ( ( Help_ww - 52 ) \ 2 ) + "<22> " , 8 , 0 : Help_AddTxt "The original help page has a table here, please " , 15 , 0 : Help_AddTxt " <20> " , 8 , 0 : Help_NewLine
Help_AddTxt SPACE$ ( ( Help_ww - 52 ) \ 2 ) + "<22> " , 8 , 0 : Help_AddTxt "use the " , 15 , 0 : ii = Help_BG_Col: Help_BG_Col = 3 : Help_AddTxt " View on Wiki " , 15 , 0 : Help_BG_Col = ii: Help_AddTxt " button in the upper right" , 15 , 0 : Help_AddTxt " <20> " , 8 , 0 : Help_NewLine
Help_AddTxt SPACE$ ( ( Help_ww - 52 ) \ 2 ) + "<22> " , 8 , 0 : Help_AddTxt "corner to load the page into your browser. " , 15 , 0 : Help_AddTxt " <20> " , 8 , 0 : Help_NewLine
Help_AddTxt SPACE$ ( ( Help_ww - 52 ) \ 2 ) + "<22> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͼ" , 8 , 0
END IF
2022-05-10 12:43:53 +00:00
END IF
GOTO charDone
2018-07-17 03:01:23 +00:00
END IF
END IF
2015-08-02 12:12:44 +00:00
2022-05-15 00:45:45 +00:00
'Wiki templates are handled always, as these are the basic building blocks of all
'the wiki pages, but look for special conditions inside (Help_LockParse checks)
IF c$ ( 5 ) = "{{Cb|" OR c$ ( 5 ) = "{{Cl|" OR c$ ( 5 ) = "{{KW|" THEN 'just nice wrapped links
i = i + 4 ' 'KW is deprecated (but kept for existing pages)
link = 1
link$ = ""
GOTO charDone
2022-05-11 00:01:22 +00:00
END IF
2022-05-15 00:45:45 +00:00
IF c$ ( 2 ) = "{{" THEN 'any other templates
i = i + 1
cb = 1
cb$ = ""
GOTO charDone
2018-07-17 03:01:23 +00:00
END IF
2022-05-11 00:01:22 +00:00
IF cb > 0 THEN
2018-07-17 03:01:23 +00:00
IF c$ = "|" OR c$ ( 2 ) = "}}" THEN
2022-05-11 00:01:22 +00:00
IF c$ = "|" AND cb = 2 THEN
wla$ = wikiLookAhead$ ( a$ , i + 1 , "}}" )
cb = 0 : i = i + LEN ( wla$ ) + 2 'after 1st, ignore all further template parameters
ELSEIF c$ ( 2 ) = "}}" THEN
2022-05-13 11:53:58 +00:00
IF LCASE$ ( LEFT$ ( cb$ , 5 ) ) = "small" THEN
IF ASC ( cb$ , 6 ) = 196 THEN
2022-05-18 00:15:36 +00:00
Help_AddTxt " " + STRING$ ( Help_ww - Help_Pos , 196 ) , 15 , 0
2022-05-13 11:53:58 +00:00
Help_BG_Col = 0 : col = Help_Col
ELSE
Help_Center = 0
END IF
Help_NewLine: cb$ = "" 'avoid reactivation below
END IF
2022-05-11 00:01:22 +00:00
cb = 0 : i = i + 1
END IF
IF c$ = "|" AND cb = 1 THEN cb = 2
2022-05-10 12:43:53 +00:00
2022-05-15 00:45:45 +00:00
IF Help_LockParse = 0 THEN 'no section headings in blocks
2022-05-11 00:01:22 +00:00
cbo$ = ""
2022-05-10 12:43:53 +00:00
'Standard section headings (section color, h3 w/o underline, h2 with underline)
'Recommended order of main page sections (h2) with it's considered sub-sections (h3)
IF cb$ = "PageSyntax" THEN cbo$ = "Syntax:"
IF cb$ = "PageLegacySupport" THEN cbo$ = "Legacy support" 'sub-sect
IF cb$ = "PageParameters" OR cb$ = "Parameters" THEN cbo$ = "Parameters:" 'w/o Page suffix is deprecated (but kept for existing pages)
IF cb$ = "PageDescription" THEN cbo$ = "Description:"
IF cb$ = "PageQBasic" THEN cbo$ = "QBasic/QuickBASIC" 'sub-sect
IF cb$ = "PageNotes" THEN cbo$ = "Notes" 'sub-sect
IF cb$ = "PageErrors" THEN cbo$ = "Errors" 'sub-sect
IF cb$ = "PageUseWith" THEN cbo$ = "Use with" 'sub-sect
IF cb$ = "PageAvailability" THEN cbo$ = "Availability:"
IF cb$ = "PageExamples" THEN cbo$ = "Examples:"
IF cb$ = "PageSeeAlso" THEN cbo$ = "See also:"
'Independent main page end sections (centered, no title)
IF cb$ = "PageCopyright" THEN cbo$ = "Copyright"
IF cb$ = "PageNavigation" THEN cbo$ = "" 'ignored for built-in help
'Internally used templates (not available in Wiki)
IF cb$ = "PageInternalError" THEN cbo$ = "Sorry, an error occurred:"
'----------
IF cbo$ < > "" THEN
IF RIGHT$ ( cbo$ , 1 ) = ":" THEN Help_Underline = Help_Col_Section
Help_AddTxt cbo$ , Help_Col_Section , 0 : Help_NewLine
2022-05-15 00:45:45 +00:00
IF cbo$ = "Copyright" THEN '_gl commands only
2022-05-10 12:43:53 +00:00
Help_NewLine: Help_AddTxt "1991-2006 Silicon Graphics, Inc." , 7 , 0 : Help_NewLine
Help_AddTxt "This document is licensed under the SGI Free Software B License." , 7 , 0 : Help_NewLine
Help_AddTxt "https://spdx.org/licenses/SGI-B-2.0.html https://spdx.org/licenses/SGI-B-2.0.html" , 15 , 0 : Help_NewLine
END IF
END IF
END IF
2022-05-13 11:53:58 +00:00
'Code Block
2022-05-13 20:49:53 +00:00
IF cb$ = "InlineCode" AND Help_LockParse = 0 THEN
Help_BG_Col = 1 : Help_LockParse = 2
END IF
IF cb$ = "InlineCodeEnd" AND Help_LockParse < > 0 THEN
Help_BG_Col = 0 : Help_LockParse = 0
Help_Bold = 0 : Help_Italic = 0 : col = Help_Col
END IF
2022-05-10 12:43:53 +00:00
IF cb$ = "CodeStart" AND Help_LockParse = 0 THEN
2022-05-15 00:45:45 +00:00
Help_CheckBlankLine
2022-05-10 12:43:53 +00:00
Help_BG_Col = 1 : Help_LockParse = 2
Help_AddTxt STRING$ ( Help_ww - 15 , 196 ) + " Code Block " + STRING$ ( 3 , 196 ) , 15 , 0 : Help_NewLine
2022-05-15 23:35:22 +00:00
IF c$ ( 3 ) = "}}" + CHR$ ( 10 ) THEN i = i + 1
2018-07-17 03:01:23 +00:00
END IF
2022-05-10 12:43:53 +00:00
IF cb$ = "CodeEnd" AND Help_LockParse < > 0 THEN
2022-05-15 00:45:45 +00:00
Help_CheckFinishLine: Help_CheckRemoveBlankLine
2022-05-10 12:43:53 +00:00
Help_AddTxt STRING$ ( Help_ww , 196 ) , 15 , 0 : Help_NewLine
Help_BG_Col = 0 : Help_LockParse = 0
Help_Bold = 0 : Help_Italic = 0 : col = Help_Col
END IF
2022-05-13 11:53:58 +00:00
'Output Block
2022-05-10 12:43:53 +00:00
IF LEFT$ ( cb$ , 11 ) = "OutputStart" AND Help_LockParse = 0 THEN 'does also match new OutputStartBGn templates
2022-05-15 00:45:45 +00:00
Help_CheckBlankLine
2022-05-10 12:43:53 +00:00
Help_BG_Col = 2 : Help_LockParse = 1
Help_AddTxt STRING$ ( Help_ww - 17 , 196 ) + " Output Block " + STRING$ ( 3 , 196 ) , 15 , 0 : Help_NewLine
2022-05-15 23:35:22 +00:00
IF c$ ( 3 ) = "}}" + CHR$ ( 10 ) THEN i = i + 1
2022-05-10 12:43:53 +00:00
END IF
IF cb$ = "OutputEnd" AND Help_LockParse < > 0 THEN
2022-05-15 00:45:45 +00:00
Help_CheckFinishLine: Help_CheckRemoveBlankLine
2022-05-13 11:53:58 +00:00
Help_AddTxt STRING$ ( ( Help_ww - 54 ) \ 2 , 196 ) , 15 , 0
Help_AddTxt " This block does not reflect the actual output colors " , 15 , 0
2022-05-18 00:15:36 +00:00
Help_AddTxt STRING$ ( Help_ww - Help_Pos + 1 , 196 ) , 15 , 0 : Help_NewLine
2022-05-10 12:43:53 +00:00
Help_BG_Col = 0 : Help_LockParse = 0
Help_Bold = 0 : Help_Italic = 0 : col = Help_Col
END IF
2022-05-13 11:53:58 +00:00
'Text Block
2022-05-10 12:43:53 +00:00
IF cb$ = "TextStart" AND Help_LockParse = 0 THEN
2022-05-15 00:45:45 +00:00
Help_CheckBlankLine
2022-05-10 12:43:53 +00:00
Help_BG_Col = 6 : Help_LockParse = -1
Help_AddTxt STRING$ ( Help_ww - 15 , 196 ) + " Text Block " + STRING$ ( 3 , 196 ) , 15 , 0 : Help_NewLine
2022-05-15 23:35:22 +00:00
IF c$ ( 3 ) = "}}" + CHR$ ( 10 ) THEN i = i + 1
2018-07-17 03:01:23 +00:00
END IF
2022-05-10 12:43:53 +00:00
IF cb$ = "TextEnd" AND Help_LockParse < > 0 THEN
2022-05-15 00:45:45 +00:00
Help_CheckFinishLine: Help_CheckRemoveBlankLine
2022-05-10 12:43:53 +00:00
Help_AddTxt STRING$ ( Help_ww , 196 ) , 15 , 0 : Help_NewLine
Help_BG_Col = 0 : Help_LockParse = 0
Help_Bold = 0 : Help_Italic = 0 : col = Help_Col
END IF
2022-05-13 11:53:58 +00:00
'Fixed Block
2022-05-10 12:43:53 +00:00
IF ( cb$ = "FixedStart" OR cb$ = "WhiteStart" ) AND Help_LockParse = 0 THEN 'White is deprecated (but kept for existing pages)
2022-05-15 00:45:45 +00:00
Help_CheckBlankLine
2022-05-10 12:43:53 +00:00
Help_BG_Col = 6 : Help_LockParse = -2
Help_AddTxt STRING$ ( Help_ww - 16 , 196 ) + " Fixed Block " + STRING$ ( 3 , 196 ) , 15 , 0 : Help_NewLine
2022-05-15 23:35:22 +00:00
IF c$ ( 3 ) = "}}" + CHR$ ( 10 ) THEN i = i + 1
2022-05-10 12:43:53 +00:00
END IF
IF ( cb$ = "FixedEnd" OR cb$ = "WhiteEnd" ) AND Help_LockParse < > 0 THEN 'White is deprecated (but kept for existing pages)
2022-05-15 00:45:45 +00:00
Help_CheckFinishLine: Help_CheckRemoveBlankLine
2022-05-10 12:43:53 +00:00
Help_AddTxt STRING$ ( Help_ww , 196 ) , 15 , 0 : Help_NewLine
Help_BG_Col = 0 : Help_LockParse = 0
Help_Bold = 0 : Help_Italic = 0 : col = Help_Col
END IF
2015-08-02 12:12:44 +00:00
2022-05-13 11:53:58 +00:00
'Template wrapped table
2022-05-15 00:45:45 +00:00
IF RIGHT$ ( cb$ , 5 ) = "Table" AND Help_LockParse = 0 THEN 'no table info in blocks
2022-05-10 12:43:53 +00:00
Help_AddTxt SPACE$ ( ( Help_ww - 52 ) \ 2 ) + "<22> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͻ" , 8 , 0 : Help_NewLine
Help_AddTxt SPACE$ ( ( Help_ww - 52 ) \ 2 ) + "<22> " , 8 , 0 : Help_AddTxt "The original help page has a table here, please " , 15 , 0 : Help_AddTxt " <20> " , 8 , 0 : Help_NewLine
Help_AddTxt SPACE$ ( ( Help_ww - 52 ) \ 2 ) + "<22> " , 8 , 0 : Help_AddTxt "use the " , 15 , 0 : ii = Help_BG_Col: Help_BG_Col = 3 : Help_AddTxt " View on Wiki " , 15 , 0 : Help_BG_Col = ii: Help_AddTxt " button in the upper right" , 15 , 0 : Help_AddTxt " <20> " , 8 , 0 : Help_NewLine
Help_AddTxt SPACE$ ( ( Help_ww - 52 ) \ 2 ) + "<22> " , 8 , 0 : Help_AddTxt "corner to load the page into your browser. " , 15 , 0 : Help_AddTxt " <20> " , 8 , 0 : Help_NewLine
Help_AddTxt SPACE$ ( ( Help_ww - 52 ) \ 2 ) + "<22> <> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> ͼ" , 8 , 0
END IF
2015-08-02 12:12:44 +00:00
2022-05-13 11:53:58 +00:00
'Small template text will be centered (maybe as block note)
2022-05-15 00:45:45 +00:00
IF LCASE$ ( cb$ ) = "small" AND Help_LockParse < = 0 THEN 'keep as is in Code/Output blocks
2022-05-13 11:53:58 +00:00
wla$ = wikiLookAhead$ ( a$ , i + 1 , "}}" )
Help_CIndent$ = wikiBuildCIndent$ ( wla$ ) : iii = 0
IF i > 31 AND ASC ( Help_CIndent$ , 1 ) > = Help_ww / 4 THEN
IF INSTR ( MID$ ( a$ , i - 30 , 30 ) , "{{CodeEnd}}" ) > 0 THEN iii = -1
IF INSTR ( MID$ ( a$ , i - 30 , 30 ) , "{{TextEnd}}" ) > 0 THEN iii = -6
IF INSTR ( MID$ ( a$ , i - 31 , 31 ) , "{{FixedEnd}}" ) > 0 THEN iii = -6
IF INSTR ( MID$ ( a$ , i - 31 , 31 ) , "{{WhiteEnd}}" ) > 0 THEN iii = -6
END IF
IF iii < > 0 THEN
FOR ii = Help_Txt_Len - 3 TO 1 STEP -4
IF ASC ( Help_Txt$ , ii ) = 13 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
Help_Txt_Len = ii + 3 : EXIT FOR
END IF
NEXT
Help_BG_Col = iii: cb$ = cb$ + CHR$ ( 196 ) 'special signal byte
2022-05-18 00:15:36 +00:00
Help_AddTxt STRING$ ( ASC ( Help_CIndent$ , 1 ) - 1 , 196 ) + " " , 15 , 0
2022-05-13 11:53:58 +00:00
col = 15 'further text color until closing
ELSE
Help_Center = 1 : cb$ = cb$ + CHR$ ( 0 ) 'no special signal
Help_AddTxt SPACE$ ( ASC ( Help_CIndent$ , 1 ) ) , col , 0 'center content
END IF
Help_CIndent$ = MID$ ( Help_CIndent$ , 2 )
END IF
GOTO charDone
2015-08-02 12:12:44 +00:00
END IF
2018-07-17 03:01:23 +00:00
2022-05-11 00:01:22 +00:00
IF cb = 1 THEN cb$ = cb$ + c$ 'reading macro name
IF cb = 2 THEN Help_AddTxt CHR$ ( c ) , col , 0 'copy macro'd text
2022-05-10 12:43:53 +00:00
GOTO charDone
2022-05-15 00:45:45 +00:00
END IF
2018-07-17 03:01:23 +00:00
2022-05-15 00:45:45 +00:00
'Wiki headings (==...==}) are not handled in blocks (soft- and hard lock), as it would
'disrupt the block, also in code blocks it could be part of the code example itself
IF Help_LockParse = 0 THEN
2022-05-10 12:43:53 +00:00
'Custom section headings (current color, h3 w/o underline, h2 with underline)
ii = 0
IF c$ ( 5 ) = " === " THEN ii = 4
IF c$ ( 4 ) = "=== " THEN ii = 3
IF c$ ( 4 ) = " ===" THEN ii = 3
IF c$ ( 3 ) = "===" THEN ii = 2
IF ii > 0 THEN i = i + ii: GOTO charDone
ii = 0
IF c$ ( 4 ) = " == " THEN ii = 3
IF c$ ( 3 ) = "== " THEN ii = 2
IF c$ ( 3 ) = " ==" THEN ii = 2
IF c$ ( 2 ) = "==" THEN ii = 1
IF ii > 0 THEN i = i + ii: Help_Underline = col: GOTO charDone
2015-08-02 12:12:44 +00:00
END IF
2022-05-15 00:45:45 +00:00
'Wiki/HTML rulers (----, <hr>) are not handled in blocks (soft- and hard lock), as it would
'disrupt the block, also in code blocks it could be part of the code example itself
IF Help_LockParse = 0 THEN
2022-05-10 12:43:53 +00:00
'Rulers
IF c$ ( 4 ) = "----" AND nl = 1 THEN
i = i + 3
Help_AddTxt STRING$ ( Help_ww , 196 ) , 8 , 0
GOTO charDone
2018-07-17 03:01:23 +00:00
END IF
2022-05-15 00:45:45 +00:00
IF c$ ( 4 ) = "<hr>" OR c$ ( 6 ) = "<hr />" THEN
IF c$ ( 4 ) = "<hr>" THEN i = i + 3
IF c$ ( 6 ) = "<hr />" THEN i = i + 5
Help_CheckFinishLine
Help_AddTxt STRING$ ( Help_ww , 196 ) , 8 , 0
GOTO charDone
END IF
END IF
2022-05-10 12:43:53 +00:00
2022-05-15 00:45:45 +00:00
'Wiki definition lists (;...:...) are not handled in blocks (soft- and hard lock), as it would
'disrupt the block, also in code blocks it could be part of the code example itself
IF Help_LockParse = 0 THEN
2022-05-10 12:43:53 +00:00
'Definition lists
IF c$ = ";" AND nl = 1 THEN 'definition (new line only)
2022-05-15 00:45:45 +00:00
IF c$ ( 2 ) = "; " THEN i = i + 1
2022-05-10 12:43:53 +00:00
Help_Bold = 1 : col = Help_Col: Help_DList = 1
IF c$ ( 3 ) = ";* " THEN i = i + 2 : Help_DList = 3 'list dot belongs to description
IF c$ ( 2 ) = ";*" THEN i = i + 1 : Help_DList = 2 'list dot belongs to description
GOTO charDone
END IF
IF c$ = ":" AND Help_DList > 0 THEN 'description (same or new line)
2022-05-15 00:45:45 +00:00
IF c$ ( 2 ) = ": " THEN i = i + 1
2022-05-10 12:43:53 +00:00
Help_Bold = 0 : col = Help_Col
IF nl = 0 THEN Help_NewLine
Help_AddTxt " " , col , 0
Help_NewLineIndent = Help_NewLineIndent + 3
IF Help_DList > 1 THEN
2022-05-18 00:15:36 +00:00
Help_AddTxt CHR$ ( 4 ) + " " , 14 , 0
2022-05-10 12:43:53 +00:00
Help_NewLineIndent = Help_NewLineIndent + 2
END IF
Help_DList = 0
GOTO charDone
END IF
2022-05-15 00:45:45 +00:00
IF c$ = ":" AND nl = 1 THEN 'description w/o definition (new line only)
IF c$ ( 2 ) = ": " THEN i = i + 1
2022-05-10 12:43:53 +00:00
Help_AddTxt " " , col , 0
Help_NewLineIndent = Help_NewLineIndent + 3
GOTO charDoneKnl 'keep nl state for possible <UL> list bullets
2015-08-02 12:12:44 +00:00
END IF
2022-05-15 00:45:45 +00:00
END IF
2015-08-02 12:12:44 +00:00
2022-05-15 00:45:45 +00:00
'Wiki lists (*, **) are not handled in blocks (soft- and hard lock), as it would
'disrupt the block, also in code blocks it could be part of the code example itself
IF Help_LockParse = 0 THEN
2022-05-10 12:43:53 +00:00
'Unordered lists
IF nl = 1 THEN
IF c$ ( 2 ) = "**" THEN
2022-05-15 00:45:45 +00:00
IF c$ ( 3 ) = "** " THEN i = i + 2 : ELSE i = i + 1
2022-05-18 00:15:36 +00:00
Help_AddTxt " " + CHR$ ( 4 ) + " " , 14 , 0
2022-05-10 12:43:53 +00:00
Help_NewLineIndent = Help_NewLineIndent + 5
GOTO charDone
END IF
IF c$ = "*" THEN
2022-05-15 00:45:45 +00:00
IF c$ ( 2 ) = "* " THEN i = i + 1
2022-05-18 00:15:36 +00:00
Help_AddTxt CHR$ ( 4 ) + " " , 14 , 0
2022-05-10 12:43:53 +00:00
Help_NewLineIndent = Help_NewLineIndent + 2
GOTO charDone
END IF
END IF
2015-08-02 12:12:44 +00:00
END IF
2022-05-15 00:45:45 +00:00
'Unicode handling (no restrictions)
2022-05-10 12:43:53 +00:00
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 : EXIT FOR
END IF
NEXT
GOTO charDone
2018-07-17 03:01:23 +00:00
END IF
2022-05-10 12:43:53 +00:00
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
2018-07-17 03:01:23 +00:00
i = i + 2
2022-05-10 12:43:53 +00:00
FOR ii = 0 TO wpUtfReplCnt
IF wpUtfRepl ( ii ) . utf8 = c$ ( 3 ) + CHR$ ( 0 ) THEN
Help_AddTxt RTRIM$ ( wpUtfRepl ( ii ) . repl ) , col , 0 : EXIT FOR
END IF
NEXT
GOTO charDone
2015-08-02 12:12:44 +00:00
END IF
2022-05-10 12:43:53 +00:00
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
2018-07-17 03:01:23 +00:00
i = i + 3
2022-05-10 12:43:53 +00:00
FOR ii = 0 TO wpUtfReplCnt
IF wpUtfRepl ( ii ) . utf8 = c$ ( 4 ) THEN
Help_AddTxt RTRIM$ ( wpUtfRepl ( ii ) . repl ) , col , 0 : EXIT FOR
END IF
NEXT
GOTO charDone
2015-08-02 12:12:44 +00:00
END IF
2022-05-15 00:45:45 +00:00
'Line break handling (no restrictions)
2022-05-10 12:43:53 +00:00
IF c = 10 OR c$ ( 4 ) = "<br>" OR c$ ( 6 ) = "<br />" THEN
IF c$ ( 4 ) = "<br>" THEN i = i + 3
IF c$ ( 6 ) = "<br />" THEN i = i + 5
2018-07-17 03:01:23 +00:00
Help_NewLineIndent = 0
2015-08-02 12:12:44 +00:00
2022-05-10 12:43:53 +00:00
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 Help_Center > 0 THEN Help_CIndent$ = MID$ ( Help_CIndent$ , 2 ) 'drop respective center indent
GOTO skipMultiBlanks
END IF
END IF
2018-07-17 03:01:23 +00:00
END IF
Help_AddTxt CHR$ ( 13 ) , col , 0
2015-08-02 12:12:44 +00:00
2022-05-10 12:43:53 +00:00
skipMultiBlanks:
IF Help_LockParse < > 0 THEN 'in all blocks reset styles at EOL
2022-05-13 11:53:58 +00:00
Help_Bold = 0 : Help_Italic = 0 : col = Help_Col
2022-05-18 00:15:36 +00:00
ELSE
IF c = 10 THEN Help_DList = 0 : Help_Bold = 0 : col = Help_Col 'def list incl. style ends after real new line
2022-05-10 12:43:53 +00:00
END IF
2018-07-17 03:01:23 +00:00
nl = 1
2022-05-10 12:43:53 +00:00
GOTO charDoneKnl 'keep just set nl state
2018-07-17 03:01:23 +00:00
END IF
Help_AddTxt CHR$ ( c ) , col , 0
2015-08-02 12:12:44 +00:00
2022-05-10 12:43:53 +00:00
charDone:
2018-07-17 03:01:23 +00:00
nl = 0
2022-05-10 12:43:53 +00:00
charDoneKnl: 'done, but keep nl state
i = i + 1
2018-07-17 03:01:23 +00:00
LOOP
2022-05-15 00:45:45 +00:00
'END_PARSE_LOOP
2015-08-02 12:12:44 +00:00
2018-07-17 03:01:23 +00:00
'Trim Help_Txt$
Help_Txt$ = LEFT$ ( Help_Txt$ , Help_Txt_Len ) + CHR$ ( 13 ) 'chr13 stops reads past end of content
2015-08-02 12:12:44 +00:00
2018-07-17 03:01:23 +00:00
IF Help_PageLoaded$ = "Keyword Reference - Alphabetical" THEN
2015-08-02 12:12:44 +00:00
2018-07-17 03:01:23 +00:00
fh = FREEFILE
OPEN "internal\help\links.bin" FOR OUTPUT AS # fh
a$ = SPACE$ ( 1000 )
FOR cy = 1 TO help_h
'isolate and REVERSE select link
l = CVL ( MID$ ( Help_Line$ , ( cy - 1 ) * 4 + 1 , 4 ) )
x = l
x2 = 1
c = ASC ( Help_Txt$ , x )
oldlnk = 0
lnkx1 = 0 : lnkx2 = 0
DO UNTIL c = 13
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
lnkx2 = x2: IF lnk = 0 THEN lnkx2 = lnkx2 - 1
IF lnkx1 < > 3 THEN GOTO ignorelink
2022-05-13 11:53:58 +00:00
IF ASC ( a$ , 1 ) < > 4 THEN GOTO ignorelink
2018-07-17 03:01:23 +00:00
'retrieve lnk info
lnk2 = lnk: IF lnk2 = 0 THEN lnk2 = oldlnk
l1 = 1
FOR lx = 1 TO lnk2 - 1
l1 = INSTR ( l1 , Help_Link$ , Help_Link_Sep$ ) + 1
NEXT
l2 = INSTR ( l1 , Help_Link$ , Help_Link_Sep$ ) - 1
l$ = MID$ ( Help_Link$ , l1 , l2 - l1 + 1 )
'assume PAGE
l$ = RIGHT$ ( l$ , LEN ( l$ ) - 5 )
2015-08-02 12:12:44 +00:00
2018-07-17 03:01:23 +00:00
a2$ = MID$ ( a$ , lnkx1 , lnkx2 - lnkx1 + 1 )
2015-08-02 12:12:44 +00:00
2018-07-17 03:01:23 +00:00
IF INSTR ( a2$ , "(" ) THEN a2$ = LEFT$ ( a2$ , INSTR ( a2$ , "(" ) - 1 )
IF INSTR ( a2$ , " " ) THEN a2$ = LEFT$ ( a2$ , INSTR ( a2$ , " " ) - 1 )
IF INSTR ( a2$ , "..." ) THEN
a3$ = RIGHT$ ( a2$ , LEN ( a2$ ) - INSTR ( a2$ , "..." ) - 2 )
2015-08-02 12:12:44 +00:00
2018-07-17 03:01:23 +00:00
skip = 0
2015-08-02 12:12:44 +00:00
2018-07-17 03:01:23 +00:00
IF UCASE$ ( LEFT$ ( a3$ , 3 ) ) < > "_GL" THEN
FOR ci = 1 TO LEN ( a3$ )
ca = ASC ( a3$ , ci )
IF ca > = 97 AND ca < = 122 THEN skip = 1
IF ca = 44 THEN skip = 1
NEXT
END IF
2015-08-02 12:12:44 +00:00
2018-07-17 03:01:23 +00:00
IF skip = 0 THEN PRINT # fh , a3$ + "," + l$
2015-08-02 12:12:44 +00:00
2018-07-17 03:01:23 +00:00
a2$ = LEFT$ ( a2$ , INSTR ( a2$ , "..." ) - 1 )
END IF
skip = 0
IF UCASE$ ( LEFT$ ( a2$ , 3 ) ) < > "_GL" THEN
FOR ci = 1 TO LEN ( a2$ )
ca = ASC ( a2$ , ci )
2015-08-02 12:12:44 +00:00
IF ca > = 97 AND ca < = 122 THEN skip = 1
IF ca = 44 THEN skip = 1
NEXT
END IF
2018-07-17 03:01:23 +00:00
IF skip = 0 THEN PRINT # fh , a2$ + "," + l$
oa2$ = a2$
a2$ = l$
IF INSTR ( a2$ , "(" ) THEN a2$ = LEFT$ ( a2$ , INSTR ( a2$ , "(" ) - 1 )
IF INSTR ( a2$ , " " ) THEN a2$ = LEFT$ ( a2$ , INSTR ( a2$ , " " ) - 1 )
IF INSTR ( a2$ , "..." ) THEN
a3$ = RIGHT$ ( a2$ , LEN ( a2$ ) - INSTR ( a2$ , "..." ) - 2 )
skip = 0
IF UCASE$ ( LEFT$ ( a3$ , 3 ) ) < > "_GL" THEN
FOR ci = 1 TO LEN ( a3$ )
ca = ASC ( a3$ , ci )
IF ca > = 97 AND ca < = 122 THEN skip = 1
IF ca = 44 THEN skip = 1
NEXT
END IF
IF skip = 0 THEN PRINT # fh , a3$ + "," + l$
a2$ = LEFT$ ( a2$ , INSTR ( a2$ , "..." ) - 1 )
END IF
2015-08-02 12:12:44 +00:00
skip = 0
2018-07-17 03:01:23 +00:00
IF UCASE$ ( LEFT$ ( a2$ , 3 ) ) < > "_GL" THEN
FOR ci = 1 TO LEN ( a2$ )
ca = ASC ( a2$ , ci )
2015-08-02 12:12:44 +00:00
IF ca > = 97 AND ca < = 122 THEN skip = 1
IF ca = 44 THEN skip = 1
NEXT
END IF
2018-07-17 03:01:23 +00:00
IF skip = 0 AND a2$ < > oa2$ THEN PRINT # fh , a2$ + "," + l$
2015-08-02 12:12:44 +00:00
2018-07-17 03:01:23 +00:00
ignorelink:
2015-08-02 12:12:44 +00:00
2018-07-17 03:01:23 +00:00
lnkx1 = 0 : lnkx2 = 0
2015-08-02 12:12:44 +00:00
END IF
2018-07-17 03:01:23 +00:00
x = x + 4 : c = ASC ( Help_Txt$ , x )
x2 = x2 + 1
oldlnk = lnk
LOOP
NEXT
CLOSE # fh
2015-08-02 12:12:44 +00:00
2018-07-17 03:01:23 +00:00
END IF
2015-08-02 12:12:44 +00:00
END SUB
2020-01-20 18:50:06 +00:00
2022-05-19 23:41:05 +00:00
FUNCTION wikiSafeName$ ( page$ ) 'create a unique name for both case sensitive & insensitive systems
ext$ = SPACE$ ( LEN ( page$ ) )
FOR i = 1 TO LEN ( page$ )
c = ASC ( page$ , i )
SELECT CASE c
CASE 65 TO 90 : ASC ( ext$ , i ) = 49 'upper = 1
CASE 97 TO 122 : ASC ( ext$ , i ) = 48 'lower = 0
CASE ELSE : ASC ( ext$ , i ) = c 'non-letter = take as is
END SELECT
NEXT
wikiSafeName$ = page$ + "_" + ext$
END FUNCTION
2022-05-15 00:45:45 +00:00
FUNCTION wikiLookAhead$ ( a$ , i , token$ ) 'Prefetch further wiki text
wikiLookAhead$ = "" : IF i > = LEN ( a$ ) THEN EXIT FUNCTION
j = INSTR ( i , a$ , token$ )
IF j = 0 THEN
wikiLookAhead$ = MID$ ( a$ , i )
ELSE
wikiLookAhead$ = MID$ ( a$ , i , j - i )
END IF
END FUNCTION
FUNCTION wikiBuildCIndent$ ( a$ ) 'Pre-calc center indentions
2022-05-10 12:43:53 +00:00
wikiBuildCIndent$ = "" : IF a$ = "" THEN EXIT FUNCTION
org$ = a$ : b$ = "" 'eliminate internal links
FOR i = 1 TO LEN ( org$ )
IF MID$ ( org$ , i , 2 ) = "[[" THEN
FOR ii = i + 2 TO LEN ( org$ )
IF MID$ ( org$ , ii , 1 ) = "|" THEN i = ii + 1 : EXIT FOR
IF MID$ ( org$ , ii , 2 ) = "]]" THEN i = i + 2 : EXIT FOR
NEXT
END IF
IF MID$ ( org$ , i , 2 ) = "]]" THEN i = i + 2
b$ = b$ + MID$ ( org$ , i , 1 )
NEXT
2022-05-20 21:44:55 +00:00
org$ = b$ : b$ = "" 'eliminate external links
FOR i = 1 TO LEN ( org$ )
IF MID$ ( org$ , i , 5 ) = "[http" THEN
FOR ii = i + 5 TO LEN ( org$ )
IF MID$ ( org$ , ii , 1 ) = " " THEN i = ii + 1 : EXIT FOR
IF MID$ ( org$ , ii , 1 ) = "]" THEN i = i + 1 : EXIT FOR
NEXT
END IF
IF MID$ ( org$ , i , 1 ) = "]" THEN i = i + 1
b$ = b$ + MID$ ( org$ , i , 1 )
NEXT
2022-05-10 12:43:53 +00:00
org$ = b$ : b$ = "" 'eliminate templates
FOR i = 1 TO LEN ( org$ )
IF MID$ ( org$ , i , 2 ) = "{{" THEN
FOR ii = i + 2 TO LEN ( org$ )
IF MID$ ( org$ , ii , 1 ) = "|" THEN i = ii + 1 : EXIT FOR
IF MID$ ( org$ , ii , 2 ) = "}}" THEN i = i + 2 : EXIT FOR
NEXT
END IF
IF MID$ ( org$ , i , 1 ) = "|" THEN
FOR ii = i + 1 TO LEN ( org$ )
IF MID$ ( org$ , ii , 2 ) = "}}" THEN i = ii: EXIT FOR
NEXT
END IF
IF MID$ ( org$ , i , 2 ) = "}}" THEN i = i + 2
b$ = b$ + MID$ ( org$ , i , 1 )
NEXT
2022-05-20 21:44:55 +00:00
org$ = b$ : b$ = "" 'eliminate text styles
2022-05-10 12:43:53 +00:00
FOR i = 1 TO LEN ( org$ )
IF MID$ ( org$ , i , 3 ) = "'''" THEN i = i + 3
IF MID$ ( org$ , i , 2 ) = "''" THEN i = i + 2
b$ = b$ + MID$ ( org$ , i , 1 )
NEXT
2022-05-15 23:35:22 +00:00
b$ = StrReplace$ ( b$ , "<br>" , CHR$ ( 10 ) ) 'convert HTML line breaks
b$ = StrReplace$ ( b$ , "<br />" , CHR$ ( 10 ) ) 'convert XHTML line breaks
b$ = _TRIM$ ( b$ ) + CHR$ ( 10 ) 'safety fallback
2022-05-10 12:43:53 +00:00
i = 1 : st = 1 : br = 0 : res$ = ""
WHILE i < = LEN ( b$ )
ws = INSTR ( i , b$ , " " ) : lb = INSTR ( i , b$ , CHR$ ( 10 ) )
IF lb > 0 AND ( ws > lb OR lb - st < = Help_ww ) THEN SWAP ws , lb
IF ws > 0 AND ws - st < = Help_ww THEN
br = ws: i = ws + 1
IF ASC ( b$ , ws ) < > 10 AND i < = LEN ( b$ ) THEN _CONTINUE
END IF
2022-05-15 23:35:22 +00:00
IF br = 0 THEN
IF lb < ws THEN
br = lb
ELSE
IF ws > 0 THEN br = ws: ELSE br = lb
END IF
END IF
2022-05-10 12:43:53 +00:00
ci = ( Help_ww - ( br - st ) ) \ 2 : IF ci < 0 THEN ci = 0
res$ = res$ + CHR$ ( ci )
i = br + 1 : st = br + 1 : br = 0
WEND
wikiBuildCIndent$ = res$
2021-01-24 18:49:34 +00:00
END FUNCTION