1/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2/* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6/** 7 Description: Currently only functions to enhance plain text with HTML tags. 8 <p> 9 Wrapper class for various parsing routines, that convert plain text to HTML. 10 They try to recognize cites, URLs, plain text formattting like *bold* etc. 11 See <http://www.bucksch.org/1/projects/mozilla/16507/> for a description. 12 */ 13 14#include "nsIStreamConverter.idl" 15 16%{C++ 17// {77c0e42a-1dd2-11b2-8ebf-edc6606f2f4b} 18#define MOZITXTTOHTMLCONV_CID \ 19 { 0x77c0e42a, 0x1dd2, 0x11b2, \ 20 { 0x8e, 0xbf, 0xed, 0xc6, 0x60, 0x6f, 0x2f, 0x4b } } 21 22#define MOZ_TXTTOHTMLCONV_CONTRACTID \ 23 "@mozilla.org/txttohtmlconv;1" 24 25%} 26 27[scriptable, uuid(77c0e42a-1dd2-11b2-8ebf-edc6606f2f4b)] 28interface mozITXTToHTMLConv : nsIStreamConverter { 29 const unsigned long kEntities = 0; // just convert < & > to < & and > 30 const unsigned long kURLs = 1 << 1; 31 const unsigned long kGlyphSubstitution = 1 << 2; // Smilies, ® etc. 32 const unsigned long kStructPhrase = 1 << 3; // E.g. *bold* -> <strong> 33 34/** 35 @param text: plain text to scan. May be a line, paragraph (recommended) 36 or just a substring.<p> 37 Must be non-escaped, pure unicode.<p> 38 <em>Note:</em> ScanTXT(a, o) + ScanTXT(b, o) may be != 39 Scan(a + b, o) 40 @param whattodo: Bitfield describing the modes of operation 41 @result "<", ">" and "&" are escaped and HTML tags are inserted where 42 appropriate. 43 */ 44 wstring scanTXT(in wstring text, in unsigned long whattodo); 45 46/** 47 Adds additional formatting to user edited text, that the user was too lazy 48 or "unknowledged" (DELETEME: is that a word?) to make. 49 <p> 50 <em>Note:</em> Don't use kGlyphSubstitution with this function. This option 51 generates tags, that are unuseable for UAs other than Mozilla. This would 52 be a data loss bug. 53 54 @param text: HTML source to scan. May be a line, paragraph (recommended) 55 or just a substring.<p> 56 Must be correct HTML. "<", ">" and "&" must be escaped, 57 other chars must be pure unicode.<p> 58 <em>Note:</em> ScanTXT(a, o) + ScanTXT(b, o) may be != 59 Scan(a + b, o) 60 @param whattodo: Bitfield describing the modes of operation 61 @result Additional HTML tags are inserted where appropriate. 62 */ 63 wstring scanHTML(in wstring text, in unsigned long whattodo); 64 65/** 66 @param line: line in original msg, possibly starting starting with 67 txt quote tags like ">" 68 @param logLineStart: pos in line, where the real content (logical line) 69 begins, i.e. pos after all txt quote tags. 70 E.g. position of "t" in "> > text". 71 Initial value must be 0, unless line is not real line. 72 @return Cite Level, i.e. number of txt quote tags found, i.e. number of 73 nested quotes. 74 */ 75 unsigned long citeLevelTXT(in wstring line, 76 out unsigned long logLineStart); 77 78/** 79 @param a wide string to scan for the presence of a URL. 80 @param aLength --> the length of the buffer to be scanned 81 @param aPos --> the position in the buffer to start scanning for a url 82 83 aStartPos --> index into the start of a url (-1 if no url found) 84 aEndPos --> index of the last character in the url (-1 if no url found) 85 */ 86 87 void findURLInPlaintext(in wstring text, in long aLength, in long aPos, out long aStartPos, out long aEndPos); 88}; 89