// HTML2TXT.VDM - Strip HTML tags from a file. // // Written by Greenview Data, Inc. // Last change: 03/16/01 // // modified by Christian Ziemski 02/25/2005: German umlauts etc. // if file was .htm[l] saves it as .txt // // 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. // // Also adds extra blank line for
and

thru

. // // See also: TXT2HTML.VDM converts a text file into an HTML file. // // From OS: vpw -x html2txt filename (Where 'filename' is your file.) // // From VEDIT: Select {MISC, Load/Execute macro}. Enter filename // "html2txt.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,"html2txt.vdm")',OK) // // OR: Add this function to the {USER} menu by adding these lines // to USER.MNU: // // 1 // HTML to text // CallF(122,"html2txt.vdm") // // Resources: Numeric registers 103 and are modified // ///////////////////////////////////////////////// // // Add extra blank line for
and

thru

. // Replace("|< Replace("^{\ 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 // CZ: added #103=Reg_Free CALLF(#103, "HTM2TXTD.VDM", NOERR) // replaces German umlauts etc. like // Replace("ä" , "ä", BEGIN+ALL+NOERR) // Save file as .txt #104=Buf_Num Out_Reg(#103) Name_Read(EXTRA+NOMSG+NOCR) Out_Reg(CLEAR) Buf_Switch(Buf_Free) Reg_Ins(#103) BoF if(Match("<>")==0) { Buf_Quit(OK) Buf_Switch(#104) } else { Replace(".htm|[l]|>", ".txt", BEGIN+NOERR) if (! Error_Flag) { Reg_Copy_Block(#103, 0, EoL_Pos) Buf_Quit(OK) Buf_Switch(#104) File_Save_As(@#103, OK+NOMSG) } else { Buf_Quit(OK) Buf_Switch(#104) } Reg_Empty(#103) }