File: man-to-html.c

package info (click to toggle)
gxemul 0.7.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 12,152 kB
  • sloc: ansic: 111,065; sh: 972; exp: 354; makefile: 118
file content (35 lines) | stat: -rw-r--r-- 469 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Usage:
// troff -man -Tascii gxemul.1 | grotty -c | ./man-to-html > gxemul.1.html

#include <stdio.h>

int main()
{
	char lastc = 0;

	printf("<pre>");

	while (!feof(stdin))
	{
		char c = fgetc(stdin);

		if (c == '\b') {
			char c2 = fgetc(stdin);
			if (lastc == '_')
				printf("<i>%c</i>", c2);
			else
				printf("<b>%c</b>", c2);

			c = fgetc(stdin);
		} else if (lastc != 0) {
			printf("%c", lastc);
		}

		lastc = c;
	}

	printf("</pre>");

	return 0;
}