More documentation; fixed dosurround

This commit is contained in:
gottox@work 2008-01-28 14:10:32 +01:00
parent c87f6e21b6
commit fc9310966e
2 changed files with 51 additions and 41 deletions

View file

@ -29,14 +29,24 @@ There are several pattern you can use to highlight your text:
* Surround your text with `**` or `__` to get **strong** text:
This **is** cool.
This __is__ cool, too.
* Surround your text with `***` or `___` to get ***strong and emphasis*** text:
This ***is*** cool.
This ___is___ cool, too.
* But this example won't work as expected:
***Hello** you*
This is a wontfix bug because it would make the source to complex.
Use this instead:
***Hello*** *you*
* inline Code
You can produce inline code with surrounding `\`` or `\`\``
Use `rm -rf /` if you're a N00b.
Use ``rm -rf /`` if you're a N00b.
`\`\`` makes it possible to use Backticks without backslashing them.
`\`\`ABC\`\`` makes it possible to use Backticks without backslashing them.
Titles
@ -177,7 +187,8 @@ Other interesting stuff
Hello2</p>
* You can escape the following pattern to avoid them from being interpreted:
`` \ ` * _ { } [ ] ( ) # + - . ! ``
\ ` * _ { } [ ] ( ) # + - . !
* To force a linebreak simple add two spaces to the end of the line:

23
smu.c
View file

@ -433,29 +433,28 @@ doshortlink(const char *begin, const char *end, int newblock) {
int
dosurround(const char *begin, const char *end, int newblock) {
unsigned int i, l;
const char *p, *ps, *q, *qend;
const char *p, *start, *stop;
for(i = 0; i < LENGTH(surround); i++) {
l = strlen(surround[i].search);
if(end - begin < l || strncmp(begin, surround[i].search, l) != 0)
if(end - begin < 2*l || strncmp(begin, surround[i].search, l) != 0)
continue;
for(ps = surround[i].search; *ps == '\n'; ps++);
l = strlen(ps);
p = begin + strlen(surround[i].search) - 1;
start = begin + l;
p = start - 1;
do {
p = strstr(p + 1, ps);
p = strstr(p + 1, surround[i].search);
} while(p && p[-1] == '\\');
if(!p || p == end)
if(!p || p >= end)
continue;
fputs(surround[i].before, stdout);
for(q = begin + strlen(surround[i].search); *q == ' '; q++);
for(qend = p-1; *qend == ' '; qend--);
if(!(stop = strstr(start, surround[i].search)) || stop >= end)
continue;
if(surround[i].process)
process(q, qend + 1, 0);
process(start, stop, 0);
else
hprint(q, qend + 1);
hprint(start, stop);
fputs(surround[i].after, stdout);
return p - begin + l;
return stop - begin + l;
}
return 0;
}