tohtml.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <bio.h>
  4. #include <String.h>
  5. #include <thread.h>
  6. #include "wiki.h"
  7. /*
  8. * Get HTML and text templates from underlying file system.
  9. * Caches them, which means changes don't take effect for
  10. * up to Tcache seconds after they are made.
  11. *
  12. * If the files are deleted, we keep returning the last
  13. * known copy.
  14. */
  15. enum {
  16. WAIT = 60
  17. };
  18. static char *name[2*Ntemplate] = {
  19. [Tpage] "page.html",
  20. [Tedit] "edit.html",
  21. [Tdiff] "diff.html",
  22. [Thistory] "history.html",
  23. [Tnew] "new.html",
  24. [Toldpage] "oldpage.html",
  25. [Twerror] "werror.html",
  26. [Ntemplate+Tpage] "page.txt",
  27. [Ntemplate+Tdiff] "diff.txt",
  28. [Ntemplate+Thistory] "history.txt",
  29. [Ntemplate+Toldpage] "oldpage.txt",
  30. [Ntemplate+Twerror] "werror.txt",
  31. };
  32. static struct {
  33. RWLock;
  34. String *s;
  35. ulong t;
  36. Qid qid;
  37. } cache[2*Ntemplate];
  38. static void
  39. cacheinit(void)
  40. {
  41. int i;
  42. static int x;
  43. static Lock l;
  44. if(x)
  45. return;
  46. lock(&l);
  47. if(x){
  48. unlock(&l);
  49. return;
  50. }
  51. for(i=0; i<2*Ntemplate; i++)
  52. if(name[i])
  53. cache[i].s = s_copy("");
  54. x = 1;
  55. unlock(&l);
  56. }
  57. static String*
  58. gettemplate(int type)
  59. {
  60. int n;
  61. Biobuf *b;
  62. Dir *d;
  63. String *s, *ns;
  64. if(name[type]==nil)
  65. return nil;
  66. cacheinit();
  67. rlock(&cache[type]);
  68. if(0 && cache[type].t+Tcache >= time(0)){
  69. s = s_incref(cache[type].s);
  70. runlock(&cache[type]);
  71. return s;
  72. }
  73. runlock(&cache[type]);
  74. // d = nil;
  75. wlock(&cache[type]);
  76. if(0 && cache[type].t+Tcache >= time(0) || (d = wdirstat(name[type])) == nil)
  77. goto Return;
  78. if(0 && d->qid.vers == cache[type].qid.vers && d->qid.path == cache[type].qid.path){
  79. cache[type].t = time(0);
  80. goto Return;
  81. }
  82. if((b = wBopen(name[type], OREAD)) == nil)
  83. goto Return;
  84. ns = s_reset(nil);
  85. do
  86. n = s_read(b, ns, Bsize);
  87. while(n > 0);
  88. Bterm(b);
  89. if(n < 0)
  90. goto Return;
  91. s_free(cache[type].s);
  92. cache[type].s = ns;
  93. cache[type].qid = d->qid;
  94. cache[type].t = time(0);
  95. Return:
  96. free(d);
  97. s = s_incref(cache[type].s);
  98. wunlock(&cache[type]);
  99. return s;
  100. }
  101. /*
  102. * Write wiki document in HTML.
  103. */
  104. static String*
  105. s_escappend(String *s, char *p, int pre)
  106. {
  107. char *q;
  108. while(q = strpbrk(p, pre ? "<>&" : " <>&")){
  109. s = s_nappend(s, p, q-p);
  110. switch(*q){
  111. case '<':
  112. s = s_append(s, "&lt;");
  113. break;
  114. case '>':
  115. s = s_append(s, "&gt;");
  116. break;
  117. case '&':
  118. s = s_append(s, "&amp;");
  119. break;
  120. case ' ':
  121. s = s_append(s, "\n");
  122. }
  123. p = q+1;
  124. }
  125. s = s_append(s, p);
  126. return s;
  127. }
  128. static char*
  129. mkurl(char *s, int ty)
  130. {
  131. char *p, *q;
  132. if(strncmp(s, "http:", 5)==0
  133. || strncmp(s, "ftp:", 4)==0
  134. || strncmp(s, "mailto:", 7)==0
  135. || strncmp(s, "telnet:", 7)==0
  136. || strncmp(s, "file:", 5)==0)
  137. return estrdup(s);
  138. if(strchr(s, ' ')==nil && strchr(s, '@')!=nil){
  139. p = emalloc(strlen(s)+8);
  140. strcpy(p, "mailto:");
  141. strcat(p, s);
  142. return p;
  143. }
  144. if(ty == Toldpage)
  145. p = smprint("../../%s", s);
  146. else
  147. p = smprint("../%s", s);
  148. for(q=p; *q; q++)
  149. if(*q==' ')
  150. *q = '_';
  151. return p;
  152. }
  153. String*
  154. pagehtml(String *s, Wpage *wtxt, int ty)
  155. {
  156. int inlist, inpre, inpara;
  157. char *p, tmp[40];
  158. Wpage *w;
  159. inlist = 0;
  160. inpre = 0;
  161. inpara = 0;
  162. for(w=wtxt; w; w=w->next){
  163. switch(w->type){
  164. case Wheading:
  165. if(!inpara){
  166. inpara = 1;
  167. s = s_append(s, "\n<p>\n");
  168. }
  169. s = s_appendlist(s, "<b>", w->text, "</b>\n<p>\n", nil);
  170. break;
  171. case Wpara:
  172. if(inlist){
  173. inlist = 0;
  174. s = s_append(s, "\n</ul>\n");
  175. }
  176. if(inpre){
  177. inpre = 0;
  178. s = s_append(s, "</pre>\n");
  179. }
  180. if(!inpara){
  181. inpara = 1;
  182. s = s_append(s, "\n<p>\n");
  183. }
  184. break;
  185. case Wbullet:
  186. if(inpre){
  187. inpre = 0;
  188. s = s_append(s, "</pre>\n");
  189. }
  190. if(!inlist){
  191. inlist = 1;
  192. s = s_append(s, "\n<ul>\n");
  193. }
  194. if(inpara)
  195. inpara = 0;
  196. s = s_append(s, "\n<li>\n");
  197. break;
  198. case Wlink:
  199. if(inpara)
  200. inpara = 0;
  201. if(w->url == nil)
  202. p = mkurl(w->text, ty);
  203. else
  204. p = w->url;
  205. s = s_appendlist(s, "<a href=\"", p, "\">", nil);
  206. s = s_escappend(s, w->text, 0);
  207. s = s_append(s, "</a>");
  208. if(w->url == nil)
  209. free(p);
  210. break;
  211. case Wman:
  212. if(inpara)
  213. inpara = 0;
  214. sprint(tmp, "%d", w->section);
  215. s = s_appendlist(s,
  216. "<a href=\"http://plan9.bell-labs.com/magic/man2html/",
  217. tmp, "/", w->text, "\"><i>", w->text, "</i>(",
  218. tmp, ")</a>", nil);
  219. break;
  220. case Wpre:
  221. if(inpara)
  222. inpara = 0;
  223. if(inlist){
  224. inlist = 0;
  225. s = s_append(s, "\n</ul>\n");
  226. }
  227. if(!inpre){
  228. inpre = 1;
  229. s = s_append(s, "\n<pre>\n");
  230. }
  231. s = s_escappend(s, w->text, 1);
  232. s = s_append(s, "\n");
  233. break;
  234. case Wplain:
  235. if(inpre){
  236. inpre = 0;
  237. s = s_append(s, "</pre>\n");
  238. }
  239. if(inpara)
  240. inpara = 0;
  241. s = s_escappend(s, w->text, 0);
  242. break;
  243. }
  244. }
  245. if(inlist)
  246. s = s_append(s, "\n</ul>\n");
  247. if(inpre)
  248. s = s_append(s, "</pre>\n");
  249. if(!inpara)
  250. s = s_append(s, "\n<p>\n");
  251. return s;
  252. }
  253. static String*
  254. grey(String *s)
  255. {
  256. return s_append(s, "<font color=#777777>");
  257. }
  258. static String*
  259. ungrey(String *s)
  260. {
  261. return s_append(s, "</font>");
  262. }
  263. static String*
  264. copythru(String *s, char **newp, int *nlinep, int l)
  265. {
  266. char *oq, *q, *r;
  267. int ol;
  268. q = *newp;
  269. oq = q;
  270. ol = *nlinep;
  271. while(ol < l){
  272. if(r = strchr(q, '\n'))
  273. q = r+1;
  274. else{
  275. q += strlen(q);
  276. break;
  277. }
  278. ol++;
  279. }
  280. if(*nlinep < l)
  281. *nlinep = l;
  282. *newp = q;
  283. return s_nappend(s, oq, q-oq);
  284. }
  285. static int
  286. dodiff(char *f1, char *f2)
  287. {
  288. int p[2];
  289. if(pipe(p) < 0){
  290. return -1;
  291. }
  292. switch(fork()){
  293. case -1:
  294. return -1;
  295. case 0:
  296. close(p[0]);
  297. dup(p[1], 1);
  298. execl("/bin/diff", "diff", f1, f2, nil);
  299. _exits(nil);
  300. }
  301. close(p[1]);
  302. return p[0];
  303. }
  304. /* print document i grayed out, with only diffs relative to j in black */
  305. static String*
  306. s_diff(String *s, Whist *h, int i, int j)
  307. {
  308. char *p, *q, *pnew;
  309. int fdiff, fd1, fd2, n1, n2;
  310. Biobuf b;
  311. char fn1[40], fn2[40];
  312. String *new, *old;
  313. int nline;
  314. if(j < 0)
  315. return pagehtml(s, h->doc[i].wtxt, Tpage);
  316. strcpy(fn1, "/tmp/wiki.XXXXXX");
  317. strcpy(fn2, "/tmp/wiki.XXXXXX");
  318. if((fd1 = opentemp(fn1)) < 0 || (fd2 = opentemp(fn2)) < 0){
  319. close(fd1);
  320. s = s_append(s, "\nopentemp failed; sorry\n");
  321. return s;
  322. }
  323. new = pagehtml(s_reset(nil), h->doc[i].wtxt, Tpage);
  324. old = pagehtml(s_reset(nil), h->doc[j].wtxt, Tpage);
  325. write(fd1, s_to_c(new), s_len(new));
  326. write(fd2, s_to_c(old), s_len(old));
  327. fdiff = dodiff(fn2, fn1);
  328. if(fdiff < 0)
  329. s = s_append(s, "\ndiff failed; sorry\n");
  330. else{
  331. nline = 0;
  332. pnew = s_to_c(new);
  333. Binit(&b, fdiff, OREAD);
  334. while(p = Brdline(&b, '\n')){
  335. if(p[0]=='<' || p[0]=='>' || p[0]=='-')
  336. continue;
  337. p[Blinelen(&b)-1] = '\0';
  338. if((q = strpbrk(p, "acd")) == nil)
  339. continue;
  340. switch(*q){
  341. case 'a':
  342. case 'c':
  343. n1 = atoi(q+1);
  344. if(q = strchr(q, ','))
  345. n2 = atoi(q+1);
  346. else
  347. n2 = n1;
  348. s = grey(s);
  349. s = copythru(s, &pnew, &nline, n1-1);
  350. s = ungrey(s);
  351. s = copythru(s, &pnew, &nline, n2);
  352. break;
  353. }
  354. }
  355. close(fdiff);
  356. s = grey(s);
  357. s = s_append(s, pnew);
  358. s = ungrey(s);
  359. }
  360. s_free(new);
  361. s_free(old);
  362. close(fd1);
  363. close(fd2);
  364. return s;
  365. }
  366. static String*
  367. diffhtml(String *s, Whist *h)
  368. {
  369. int i;
  370. char tmp[50];
  371. char *atime;
  372. for(i=h->ndoc-1; i>=0; i--){
  373. s = s_append(s, "<hr>\n");
  374. if(i==h->current)
  375. sprint(tmp, "index.html");
  376. else
  377. sprint(tmp, "%lud", h->doc[i].time);
  378. atime = ctime(h->doc[i].time);
  379. atime[strlen(atime)-1] = '\0';
  380. s = s_appendlist(s,
  381. "<a href=\"", tmp, "\">",
  382. atime, "</a>", nil);
  383. if(h->doc[i].author)
  384. s = s_appendlist(s, ", ", h->doc[i].author, nil);
  385. if(h->doc[i].conflict)
  386. s = s_append(s, ", conflicting write");
  387. s = s_append(s, "\n");
  388. if(h->doc[i].comment)
  389. s = s_appendlist(s, "<br><i>", h->doc[i].comment, "</i>\n", nil);
  390. s = s_append(s, "<br><hr>");
  391. s = s_diff(s, h, i, i-1);
  392. }
  393. s = s_append(s, "<hr>");
  394. return s;
  395. }
  396. static String*
  397. historyhtml(String *s, Whist *h)
  398. {
  399. int i;
  400. char tmp[40];
  401. char *atime;
  402. s = s_append(s, "<ul>\n");
  403. for(i=h->ndoc-1; i>=0; i--){
  404. if(i==h->current)
  405. sprint(tmp, "index.html");
  406. else
  407. sprint(tmp, "%lud", h->doc[i].time);
  408. atime = ctime(h->doc[i].time);
  409. atime[strlen(atime)-1] = '\0';
  410. s = s_appendlist(s,
  411. "<li><a href=\"", tmp, "\">",
  412. atime, "</a>", nil);
  413. if(h->doc[i].author)
  414. s = s_appendlist(s, ", ", h->doc[i].author, nil);
  415. if(h->doc[i].conflict)
  416. s = s_append(s, ", conflicting write");
  417. s = s_append(s, "\n");
  418. if(h->doc[i].comment)
  419. s = s_appendlist(s, "<br><i>", h->doc[i].comment, "</i>\n", nil);
  420. }
  421. s = s_append(s, "</ul>");
  422. return s;
  423. }
  424. String*
  425. tohtml(Whist *h, Wdoc *d, int ty)
  426. {
  427. char *atime;
  428. char *p, *q, ver[40];
  429. int nsub;
  430. Sub sub[3];
  431. String *s, *t;
  432. t = gettemplate(ty);
  433. if(p = strstr(s_to_c(t), "PAGE"))
  434. q = p+4;
  435. else{
  436. p = s_to_c(t)+s_len(t);
  437. q = nil;
  438. }
  439. nsub = 0;
  440. if(h){
  441. sub[nsub] = (Sub){ "TITLE", h->title };
  442. nsub++;
  443. }
  444. if(d){
  445. sprint(ver, "%lud", d->time);
  446. sub[nsub] = (Sub){ "VERSION", ver };
  447. nsub++;
  448. atime = ctime(d->time);
  449. atime[strlen(atime)-1] = '\0';
  450. sub[nsub] = (Sub){ "DATE", atime };
  451. nsub++;
  452. }
  453. s = s_reset(nil);
  454. s = s_appendsub(s, s_to_c(t), p-s_to_c(t), sub, nsub);
  455. switch(ty){
  456. case Tpage:
  457. case Toldpage:
  458. s = pagehtml(s, d->wtxt, ty);
  459. break;
  460. case Tedit:
  461. s = pagetext(s, d->wtxt, 0);
  462. break;
  463. case Tdiff:
  464. s = diffhtml(s, h);
  465. break;
  466. case Thistory:
  467. s = historyhtml(s, h);
  468. break;
  469. case Tnew:
  470. case Twerror:
  471. break;
  472. }
  473. if(q)
  474. s = s_appendsub(s, q, strlen(q), sub, nsub);
  475. s_free(t);
  476. return s;
  477. }
  478. enum {
  479. LINELEN = 70,
  480. };
  481. static String*
  482. s_appendbrk(String *s, char *p, char *prefix, int dosharp)
  483. {
  484. char *e, *w, *x;
  485. int first, l;
  486. Rune r;
  487. first = 1;
  488. while(*p){
  489. s = s_append(s, p);
  490. e = strrchr(s_to_c(s), '\n');
  491. if(e == nil)
  492. e = s_to_c(s);
  493. else
  494. e++;
  495. if(utflen(e) <= LINELEN)
  496. break;
  497. x = e; l=LINELEN;
  498. while(l--)
  499. x+=chartorune(&r,x);
  500. x = strchr(x, ' ');
  501. if(x){
  502. *x = '\0';
  503. w = strrchr(e, ' ');
  504. *x = ' ';
  505. }else
  506. w = strrchr(e, ' ');
  507. if(w-s_to_c(s) < strlen(prefix))
  508. break;
  509. x = estrdup(w+1);
  510. *w = '\0';
  511. s->ptr = w;
  512. s_append(s, "\n");
  513. if(dosharp)
  514. s_append(s, "#");
  515. s_append(s, prefix);
  516. if(!first)
  517. free(p);
  518. first = 0;
  519. p = x;
  520. }
  521. if(!first)
  522. free(p);
  523. return s;
  524. }
  525. static void
  526. s_endline(String *s, int dosharp)
  527. {
  528. if(dosharp){
  529. if(s->ptr == s->base+1 && s->ptr[-1] == '#')
  530. return;
  531. if(s->ptr > s->base+1 && s->ptr[-1] == '#' && s->ptr[-2] == '\n')
  532. return;
  533. s_append(s, "\n#");
  534. }else{
  535. if(s->ptr > s->base+1 && s->ptr[-1] == '\n')
  536. return;
  537. s_append(s, "\n");
  538. }
  539. }
  540. String*
  541. pagetext(String *s, Wpage *page, int dosharp)
  542. {
  543. int inlist, inpara;
  544. char *prefix, *sharp, tmp[40];
  545. String *t;
  546. Wpage *w;
  547. inlist = 0;
  548. inpara = 0;
  549. prefix = "";
  550. sharp = dosharp ? "#" : "";
  551. s = s_append(s, sharp);
  552. for(w=page; w; w=w->next){
  553. switch(w->type){
  554. case Wheading:
  555. if(inlist){
  556. prefix = "";
  557. inlist = 0;
  558. }
  559. s_endline(s, dosharp);
  560. if(!inpara){
  561. inpara = 1;
  562. s = s_appendlist(s, "\n", sharp, nil);
  563. }
  564. s = s_appendlist(s, w->text, "\n", sharp, "\n", sharp, nil);
  565. break;
  566. case Wpara:
  567. s_endline(s, dosharp);
  568. if(inlist){
  569. prefix = "";
  570. inlist = 0;
  571. }
  572. if(!inpara){
  573. inpara = 1;
  574. s = s_appendlist(s, "\n", sharp, nil);
  575. }
  576. break;
  577. case Wbullet:
  578. s_endline(s, dosharp);
  579. if(!inlist)
  580. inlist = 1;
  581. if(inpara)
  582. inpara = 0;
  583. s = s_append(s, " *\t");
  584. prefix = "\t";
  585. break;
  586. case Wlink:
  587. if(inpara)
  588. inpara = 0;
  589. t = s_append(s_copy("["), w->text);
  590. if(w->url == nil)
  591. t = s_append(t, "]");
  592. else{
  593. t = s_append(t, " | ");
  594. t = s_append(t, w->url);
  595. t = s_append(t, "]");
  596. }
  597. s = s_appendbrk(s, s_to_c(t), prefix, dosharp);
  598. s_free(t);
  599. break;
  600. case Wman:
  601. if(inpara)
  602. inpara = 0;
  603. s = s_appendbrk(s, w->text, prefix, dosharp);
  604. sprint(tmp, "(%d)", w->section);
  605. s = s_appendbrk(s, tmp, prefix, dosharp);
  606. break;
  607. case Wpre:
  608. if(inlist){
  609. prefix = "";
  610. inlist = 0;
  611. }
  612. if(inpara)
  613. inpara = 0;
  614. s_endline(s, dosharp);
  615. s = s_appendlist(s, "! ", w->text, "\n", sharp, nil);
  616. break;
  617. case Wplain:
  618. if(inpara)
  619. inpara = 0;
  620. s = s_appendbrk(s, w->text, prefix, dosharp);
  621. break;
  622. }
  623. }
  624. s_endline(s, dosharp);
  625. s->ptr--;
  626. *s->ptr = '\0';
  627. return s;
  628. }
  629. static String*
  630. historytext(String *s, Whist *h)
  631. {
  632. int i;
  633. char tmp[40];
  634. char *atime;
  635. for(i=h->ndoc-1; i>=0; i--){
  636. if(i==h->current)
  637. sprint(tmp, "[current]");
  638. else
  639. sprint(tmp, "[%lud/]", h->doc[i].time);
  640. atime = ctime(h->doc[i].time);
  641. atime[strlen(atime)-1] = '\0';
  642. s = s_appendlist(s, " * ", tmp, " ", atime, nil);
  643. if(h->doc[i].author)
  644. s = s_appendlist(s, ", ", h->doc[i].author, nil);
  645. if(h->doc[i].conflict)
  646. s = s_append(s, ", conflicting write");
  647. s = s_append(s, "\n");
  648. if(h->doc[i].comment)
  649. s = s_appendlist(s, "<i>", h->doc[i].comment, "</i>\n", nil);
  650. }
  651. return s;
  652. }
  653. String*
  654. totext(Whist *h, Wdoc *d, int ty)
  655. {
  656. char *atime;
  657. char *p, *q, ver[40];
  658. int nsub;
  659. Sub sub[3];
  660. String *s, *t;
  661. t = gettemplate(Ntemplate+ty);
  662. if(p = strstr(s_to_c(t), "PAGE"))
  663. q = p+4;
  664. else{
  665. p = s_to_c(t)+s_len(t);
  666. q = nil;
  667. }
  668. nsub = 0;
  669. if(h){
  670. sub[nsub] = (Sub){ "TITLE", h->title };
  671. nsub++;
  672. }
  673. if(d){
  674. sprint(ver, "%lud", d->time);
  675. sub[nsub] = (Sub){ "VERSION", ver };
  676. nsub++;
  677. atime = ctime(d->time);
  678. atime[strlen(atime)-1] = '\0';
  679. sub[nsub] = (Sub){ "DATE", atime };
  680. nsub++;
  681. }
  682. s = s_reset(nil);
  683. s = s_appendsub(s, s_to_c(t), p-s_to_c(t), sub, nsub);
  684. switch(ty){
  685. case Tpage:
  686. case Toldpage:
  687. s = pagetext(s, d->wtxt, 0);
  688. break;
  689. case Thistory:
  690. s = historytext(s, h);
  691. break;
  692. case Tnew:
  693. case Twerror:
  694. break;
  695. }
  696. if(q)
  697. s = s_appendsub(s, q, strlen(q), sub, nsub);
  698. s_free(t);
  699. return s;
  700. }
  701. String*
  702. doctext(String *s, Wdoc *d)
  703. {
  704. char tmp[40];
  705. sprint(tmp, "D%lud", d->time);
  706. s = s_append(s, tmp);
  707. if(d->comment){
  708. s = s_append(s, "\nC");
  709. s = s_append(s, d->comment);
  710. }
  711. if(d->author){
  712. s = s_append(s, "\nA");
  713. s = s_append(s, d->author);
  714. }
  715. if(d->conflict)
  716. s = s_append(s, "\nX");
  717. s = s_append(s, "\n");
  718. s = pagetext(s, d->wtxt, 1);
  719. return s;
  720. }