Welcome to Inkbunny...
Allowed ratings
To view member-only content, create an account. ( Hide )
yfelgor

new idea, and 'storc.c'

In case anyone wants it, this is the source for my markdownish-to-bbcode program:
(seems like ib has no codeblock support, so this will look all fucked up. sorry)
"
#include <ctype.h>
#include <stdio.h>

enum status {
S_TITL = 1 << 0,
S_BOLD = 1 << 1,
S_ITAL = 1 << 2,
S_UNDE = 1 << 3,
S_STRI = 1 << 4,
};

int
dotag(int flag, const char *t, int s)
{
if (s & flag)
printf("[/%s]", t);
else
printf("[%s]", t);
return s ^= flag;
}

/* just put file through stdin. it's easier (for me :3) */
int
main(void)
{
int c, tmp;
int s = 0; /* status of text */
int newpara = 1; /* if we are at a new line */

/* "if you need more than 3 levels of indentation, you’re screwed
* anyway, and should fix your program." - linux kernel style guide */
while ((c = getchar()) != EOF) {
switch(c) {
case '*':
s = dotag(S_BOLD, "b", s);
break;
case '_':
s = dotag(S_ITAL, "i", s);
break;
case '\t':
if (newpara) {
s = dotag(S_TITL, "t", s);
while (isspace(tmp = getchar())); /* vim :center */
ungetc(tmp, stdin); /* put back non-ws */
}
break;
case '\n':
if (s & S_TITL)
s = dotag(S_TITL, "t", s);
if ((tmp = getchar()) == '\n') {
/* new paragraph */
puts("\n"); /* does two newlines */
newpara = 1;
goto nosetpara;
} else {
ungetc(tmp, stdin);
putchar(' ');
}
break;
default:
putchar(c);
break;
}
newpara = 0;
nosetpara:
}

return 0;
}


Additionally, I have another new silly overambitious idea, which is a full furry remake/completion of Marquis de Sade's 120 Days of Sodom. I am considering posting more journals to track my progress, maybe it will help me commit to things and get shit done. I will probably write it as some kind of serial instead of posting it all at once. It will also probably be useful as writing practice.

Comment creepy nonsequitur shit if you want. Thanks
Viewed: 4 times
Added: 9 months ago
 
yfelgor
9 months ago
of course it just ignores all the indentation. wonderful
New Comment:
Move reply box to top
Log in or create an account to comment.