Created
April 14, 2013 00:00
-
-
Save neilisaac/5380691 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <ctype.h> | |
#define LINESIZE 256 | |
int main(int argc, char **argv){ | |
printf("\\documentclass{article}\n\n"); | |
char author[64]; | |
char title[64]; | |
fgets(author, 64, stdin); | |
fgets(title, 64, stdin); | |
*strchr(author, '\n') = '\0'; | |
*strchr(title, '\n') = '\0'; | |
printf("\\author{%s}\n\\title{%s}\n\\date{}\n\n", author, title); | |
printf("\\usepackage{dropping}\n\n"); | |
printf("\\begin{document}\n\\maketitle\n"); | |
char *line = calloc(LINESIZE, sizeof(char)); | |
while(fgets(line, LINESIZE, stdin)){ | |
if(!*line || *line == '\n') | |
continue; | |
else if(isdigit(*line)){ | |
int n; | |
sscanf(line, "%d", &n); | |
printf("\\section*{Chapter %d}\n", n); | |
} | |
else if(*line && isspace(*line)) | |
printf("\n%s", line); | |
else | |
printf("%s", line); | |
} | |
printf("\\end{document}\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment