// HTML-TXT.VDM - Strip HTML tags from a file.
//
// Written by Greenview Data, Inc.
// Last change: 11/20/97
//
// Modified by C.Z. 04.06.98
//
// Requires: VEDIT 5.00 or later.
//
// Description: Strips all HTML tags <...> from a file, creating a normal
// text file. Assumes each "<" has a matching ">" on the same
// line or the next line. Treats "\<" and "\>" as literal chars.
//
// See also: TXT2HTML.VDM converts a text file into an HTML file.
//
// From OS: vedit -x html-txt filename (Where 'filename' is your file.)
//
// From VEDIT: Select {MISC, Load/Execute macro}. Enter filename
// "html-txt.vdm". Use default register number "100".
//
// OR: Run this macro as a keystroke macro, e.g. . One way
// is by adding the following line to STARTUP.VDM:
//
// Key_Add("Shft-F6",'[VISUAL EXIT] Call_File(122,"html-txt.vdm")',OK)
//
// OR: Add this function to the {USER} menu by adding these lines
// to USER.TBL:
//
// 1
// HTML to text
// CallF(122,"html-txt.vdm")
//
// Resources: Numeric register 103 is modified
//
Begin_Of_File()
while (!At_EOF) {
Search("<",ERRBREAK)
if (Cur_Char(-1)=='\') { Char() Continue } // If "\<", keep looking
#103 = Cur_Line
Block_Begin(Cur_Pos)
Search("|!\>",ERRBREAK) // Search for ">", but not "\>"
if ((Cur_Line - #103) <= 1) {
Del_Block(Block_Begin,Cur_Pos+2,RESET) // Delete the entire tag
if (Match("|<|>")==0) { Del_Line() } // Delete if a blank line
}
}
//return
Out_Reg(96) Name_Write(EXTRA+NOCR+NOMSG) Out_Reg(CLEAR)
#98=Buf_Num
BS(34) // neuen Dateinamen erzeugen
Buf_Empty
RI(96, BEGIN)
BB(0) BE(EOL_POS) // Workaround: Dateiname komplett in Großbuchstaben
DOV("\ME\BEU") BB(CLEAR) // \t (nicht \T) wird in DI1() als Tab interpretiert
if(Match("<>")==0) {
Alert()
Statline_Message("Bitte erst abspeichern!")
BufQuit(OK)
BS(#98)
return
}
R(".HTM", ".TXT", BEGIN+NOERR)
if(Error_Match) {
EoL
IT(".TXT")
}
BoF
RC(96,1) // kompletten neuen Dateinamen merken
BQ(OK)
BS(#98)
File_Save_As(@96, OK+NOMSG) // sichern
BQ(OK)