Created
April 28, 2017 05:50
-
-
Save jbdietrich/f0468502d05a874fffe2c5fc5ea493d8 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 "rinku.h" | |
#include "autolink.h" | |
int main() { | |
printf("Stinku!\n"); | |
static const char *SKIP_TAGS[] = {"a", "pre", "code", "kbd", "script", NULL}; | |
while(true) { | |
struct buf *output_buf = bufnew(32); | |
size_t count; | |
FILE *stream = stdin; | |
size_t buf_cap = 0; | |
char *input_buf = NULL; | |
ssize_t bytes_read = getline(&input_buf, &buf_cap, stream); | |
if (bytes_read == -1) break; | |
count = rinku_autolink( | |
output_buf, | |
(const uint8_t *)input_buf, | |
(size_t)bytes_read, | |
AUTOLINK_ALL, | |
0, | |
NULL, | |
SKIP_TAGS, | |
NULL, | |
(void*)NULL); | |
if (count == 0) | |
printf("No links found!\n"); | |
else { | |
printf("Links found!\n"); | |
} | |
free(input_buf); | |
bufrelease(output_buf); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment