Subj : TYPEHTML.SRC
To : All
From : Digital Man
Date : Mon Oct 09 2000 11:41 am
I'm converting my "working documents" for Synchronet (to-do list, FAQs, etc) to
HTML and needed an easy way to "share" these files with the users on the BBS,
without requiring them to download them and view them in a web browser.
So, I spent "some time" today creating this little "diddy" in Baja and just
thought I'd post the source here since it's probably the most intense Baja
coding I've done since QNET.SRC (QWK networking module for SBBS v2). I'll be
putting this on Vertrauen for download too.
It only handles BASIC HTML right now, so don't be too shocked if it doesn't
print your more elaborate HTML files very nicely. Obviously, things like
graphics and fonts can't be well represented on a typical telnet terminal.
(HTML to RIP anyone?)
Well, here it is:
# TypeHTML
# Synchronet Baja Modules to Display HTML files to TTY/ANSI users
# Created October 09, 2000 by Rob Swindell
!include file_io.inc
!include sbbsdefs.inc
# Color Attributes for HTML type styles
!define NORMAL "\1N\1H"
!define HEADING1 "\1H\1Y"
!define HEADING2 "\1H\1C"
!define HEADING3 "\1H\1M"
!define HEADING4 "\1H\1G"
!define HEADING5 "\1H\1B"
!define HEADING6 "\1H\1R"
!define BOLD "\1H\1C\x014"
!define ITALIC "\1H\1G\x012"
!define UNDERLINE "\1H\1W\x016"
!define STRIKE_THROUGH "\1N\1K\x017"
!define LIST_ITEM " \1H\1Wo \1G"
str filename
str href
str tmp
int i
int file
int hlevel # header level
int col # current cursor column
int last_line_len # length of last line printed
int lines # total lines printed
int printing # printing on
int newline # new line read from html file
set col 0 # reset column counter
set last_line_len 0 # reset last line length
set lines 0 # reset line counter
set printing 1 # printing by default
cls # clear screen
print NORMAL # normal color
:next_line
# Check abort flag
copy i _sys_status
and i SS_ABORT
compare i 0
if_not_equal # user aborting listing
return
end_if
# Read a line
fread_line file str
if_false # end of file
crlf
pause
return
end_if
# Show hyper-link
compare_word "/A>"
if_true
compare href ""
if_false
strlen i href
add i 3
add col i
compare col 79
if_equal_or_greater
call crlf
sub i 1
copy col i
else
print " "
end_if
printf "<%s>" href
end_if
set href ""
end_if
call find_close_bracket
goto next_char
return
# Carriage-return/Line-feed with column reset
:crlf
copy last_line_len col
crlf
set col 0
add lines 1
return
# Shift str past first close bracket
:find_close_bracket
compare_str ""
if_true
return
end_if