1 /*
2 * Copyright (C) 1991,1992 NEC Corporation.
3 */
4 #ifndef lint
5 static char rcsid[] =
6 "$Id: plaintxt.c,v 2.12 1994/04/19 10:16:59 uchida Exp $ (NEC)";
7 #endif
8
9 #include <stdio.h>
10 #include "plain2.h"
11 /*
12 * Quoted region.
13 * >> quoted
14 * >> lines
15 */
quotedText(begin,end)16 quotedText(begin, end)
17 int begin;
18 int end;
19 {
20 int l1, l2, l3;
21 char topchar, secondchar;
22 struct textBlock *tbp;
23 DBG2(7, "markIfQuote (%d-%d)\n", begin , end);
24 for (l1 = begin; l1 < end - 1; l1++) {
25 secondchar = 0;
26 if (texts[l1]->block)
27 continue;
28 topchar = *texts[l1]->body;
29 secondchar = *(texts[l1]->body+1);
30 if (topchar != '>' && topchar != ':')
31 continue;
32 for (l2 = l1 + 1; l2 < end; l2++) {
33 if (texts[l2]->block || texts[l2]->indent != 0)
34 break;
35 if (*texts[l2]->body != topchar
36 || *(texts[l2]->body+1) != secondchar)
37 break;
38 }
39 if (l2 > l1 + 1 /* More than 3 lines */ ||
40 (prevLine(l1)->blank && texts[l2]->blank &&
41 topchar == '>' && secondchar == '>')) {
42 tbp = newTextBlock(l1, l2, TB_QUOTE);
43 MSG2("%d-%d ", l1, l2 - 1);
44 for (l3 = l1; l3 < l2; l3++)
45 texts[l3]->block = tbp;
46 }
47 l1 = l2 - 1;
48 }
49 }
50
51 /*
52 * Plain text
53 * block is separated at each indented line.
54 * - - - - - - <- top of plain text block
55
56 naturl
57 * - - - - - - -
58 * - - - - - - -
59 * - - - - - - <- also top of plain text block
60 * - - - - - - -
61 * - - - - - - -
62 */
markAsPlain(begin,end)63 markAsPlain(begin, end)
64 int begin;
65 int end;
66 {
67 int l, indent;
68 struct textBlock *tbp;
69 DBG2(7, "markAsPlain (%d-%d)\n", begin , end);
70 indent = texts[begin]->indent;
71 tbp = newTextBlock(begin, -1, TB_PLAIN);
72 for (l = begin; l < end; l++) {
73 if (texts[l]->blank || texts[l]->block
74 || texts[l]->indent <= indent - MIN_INDENT
75 || texts[l]->indent > indent)
76 return;
77 if (texts[l]->indent < indent)
78 indent = texts[l]->indent;
79 texts[l]->block = tbp;
80 tbp->rend = l + 1;
81 }
82 return;
83 }
plainText(begin,end)84 plainText(begin, end)
85 int begin;
86 int end;
87 {
88 int l;
89 for (l = begin; l < end; l++) {
90 if (texts[l]->block == NULL
91 && !texts[l]->blank)
92 markAsPlain(l, end);
93 }
94 }
95