mozITXTToHTMLConv.idl 3.6 KB

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