The following QuickBASIC program is based on mE123's QBasic program above, but it
reads the command line for the input file name, then writes the output file to C:\WINDOWS\TEMP\PREVIEW.HTM.
After doing so, it automatically executes a new window of EXPLORER.EXE to view the document. It's not quite Netscape-friendly,
but this can easily be changed by putting in the full path to NETSCAPE.EXE or whatever the
main executable is in place of the word "EXPLORER" at the "SHELL" command.
The main function of this program is to allow one to "preview" a node without actually
submitting it. If on-line, you can follow the links and see if they actually go anywhere before
submitting. It's not a perfect preview by any means, but it will help one find misplaced hard link brackets, and it provides a general run-down of how the write-up will appear.
Note that there are some tags that aren't supported by E2, so make sure the tags you're using are in E2 HTML Tags.
Also note that while it is odd to use an ancient DOS programming language to call a windows application, it won't cause your computer to explode or create any sort of quantum-space-time-collapse effect.
The bold is my added/revised code, the rest is mE123's...
DECLARE FUNCTION everything2html$ (words$)
DECLARE FUNCTION makelink$ (words$)
ON ERROR GOTO death
CLS
rFileName$ = COMMAND$
wFileName$ = "C:\windows\temp\preview.htm"
readme = FREEFILE
OPEN rFileName$ FOR INPUT AS readme
writeme = FREEFILE
OPEN wFileName$ FOR OUTPUT AS writeme
DO
LINE INPUT #readme, In$
PRINT #writeme, everything2html$(In$)
LOOP UNTIL EOF(readme)
CLOSE readme
CLOSE writeme
SHELL "Explorer " + wFileName$
SYSTEM
death:
PRINT "Syntax: E2P <inputfile>"
END
FUNCTION everything2html$ (words$)
link = 0
link$ = ""
out$ = ""
FOR a = 1 TO LEN(words$)
IF MID$(words$, a, 1) = "[" THEN
link = 1
ELSEIF MID$(words$, a, 1) = "]" THEN
link = 0
out$ = out$ + makelink$(link$)
link$ = ""
ELSEIF link = 1 THEN
link$ = link$ + MID$(words$, a, 1)
ELSE
out$ = out$ + MID$(words$, a, 1)
END IF
NEXT
everything2html$ = out$
END FUNCTION
FUNCTION makelink$ (words$)
link$ = ""
out$ = ""
FOR a = 1 TO LEN(words$)
IF MID$(words$, a, 1) = "|" THEN
out$ = "<A HREF=" + CHR$(34) + "http://everything2.com/index.pl?node=" + link$ + CHR$(34) + " >"
out$ = out$ + RIGHT$(words$, LEN(words$) - a) + "</A>"
EXIT FOR
ELSE
link$ = link$ + MID$(words$, a, 1)
END IF
NEXT
IF out$ = "" THEN
out$ = "<A HREF=" + CHR$(34) + "http://everything2.com/index.pl?node=" + link$ + CHR$(34) + " >"
out$ = out$ + link$ + "</A>"
END IF
makelink$ = out$
END FUNCTION