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/. */
7 Description: Currently only functions to enhance plain text with HTML tags.
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.
14 #include
"nsIStreamConverter.idl"
18 #define MOZ_TXTTOHTMLCONV_CONTRACTID \
19 "@mozilla.org/txttohtmlconv;1"
23 [scriptable
, uuid(77c0e42a
-1dd2
-11b2
-8ebf
-edc6606f2f4b
)]
24 interface mozITXTToHTMLConv
: nsIStreamConverter
{
25 const unsigned long kEntities
= 0; // just convert < & > to < & and >
26 const unsigned long kURLs
= 1 << 1;
27 const unsigned long kGlyphSubstitution
= 1 << 2; // Smilies, ® etc.
28 const unsigned long kStructPhrase
= 1 << 3; // E.g. *bold* -> <strong>
31 @param text: plain text to scan. May be a line, paragraph (recommended)
32 or just a substring.<p>
33 Must be non-escaped, pure unicode.<p>
34 <em>Note:</em> ScanTXT(a, o) + ScanTXT(b, o) may be !=
36 @param whattodo: Bitfield describing the modes of operation
37 @result "<", ">" and "&" are escaped and HTML tags are inserted where
40 AString scanTXT
(in AString text
, in unsigned long whattodo
);
43 Adds additional formatting to user edited text, that the user was too lazy
44 or "unknowledged" (DELETEME: is that a word?) to make.
46 <em>Note:</em> Don't use kGlyphSubstitution with this function. This option
47 generates tags, that are unuseable for UAs other than Mozilla. This would
50 @param text: HTML source to scan. May be a line, paragraph (recommended)
51 or just a substring.<p>
52 Must be correct HTML. "<", ">" and "&" must be escaped,
53 other chars must be pure unicode.<p>
54 <em>Note:</em> ScanTXT(a, o) + ScanTXT(b, o) may be !=
56 @param whattodo: Bitfield describing the modes of operation
57 @result Additional HTML tags are inserted where appropriate.
59 AString scanHTML
(in AString text
, in unsigned long whattodo
);
62 @param line: line in original msg, possibly starting starting with
63 txt quote tags like ">"
64 @param logLineStart: pos in line, where the real content (logical line)
65 begins, i.e. pos after all txt quote tags.
66 E.g. position of "t" in "> > text".
67 Initial value must be 0, unless line is not real line.
68 @return Cite Level, i.e. number of txt quote tags found, i.e. number of
71 unsigned long citeLevelTXT
(in wstring line
,
72 out unsigned long logLineStart
);
75 @param a wide string to scan for the presence of a URL.
76 @param aLength --> the length of the buffer to be scanned
77 @param aPos --> the position in the buffer to start scanning for a url
79 aStartPos --> index into the start of a url (-1 if no url found)
80 aEndPos --> index of the last character in the url (-1 if no url found)
83 void findURLInPlaintext
(in wstring text
, in long aLength
, in long aPos
, out long aStartPos
, out long aEndPos
);