More documentation; fixed dosurround
This commit is contained in:
parent
c87f6e21b6
commit
fc9310966e
2 changed files with 51 additions and 41 deletions
|
@ -22,21 +22,31 @@ Inline pattern
|
||||||
|
|
||||||
There are several pattern you can use to highlight your text:
|
There are several pattern you can use to highlight your text:
|
||||||
|
|
||||||
* Emphasis
|
* Emphasis
|
||||||
* Surround your text with `*` or `_` to get *emphasis* text:
|
* Surround your text with `*` or `_` to get *emphasis* text:
|
||||||
This *is* cool.
|
This *is* cool.
|
||||||
This _is_ cool, too.
|
This _is_ cool, too.
|
||||||
* Surround your text with `**` or `__` to get **strong** text:
|
* Surround your text with `**` or `__` to get **strong** text:
|
||||||
This **is** cool.
|
This **is** cool.
|
||||||
This __is__ cool, too.
|
This __is__ cool, too.
|
||||||
* inline Code
|
* 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 `\`\``
|
You can produce inline code with surrounding `\`` or `\`\``
|
||||||
|
|
||||||
Use `rm -rf /` if you're a N00b.
|
Use `rm -rf /` if you're a N00b.
|
||||||
|
|
||||||
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
|
Titles
|
||||||
|
@ -164,7 +174,7 @@ block.
|
||||||
Other interesting stuff
|
Other interesting stuff
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
* to insert a horizontal rule simple add `- - -` into an empty line:
|
* to insert a horizontal rule simple add `- - -` into an empty line:
|
||||||
|
|
||||||
Hello
|
Hello
|
||||||
- - -
|
- - -
|
||||||
|
@ -176,10 +186,11 @@ Other interesting stuff
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
Hello2</p>
|
Hello2</p>
|
||||||
* You can escape the following pattern to avoid them from being interpreted:
|
* 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:
|
\ ` * _ { } [ ] ( ) # + - . !
|
||||||
|
|
||||||
|
* To force a linebreak simple add two spaces to the end of the line:
|
||||||
|
|
||||||
No linebreak
|
No linebreak
|
||||||
here.
|
here.
|
||||||
|
|
23
smu.c
23
smu.c
|
@ -433,29 +433,28 @@ doshortlink(const char *begin, const char *end, int newblock) {
|
||||||
int
|
int
|
||||||
dosurround(const char *begin, const char *end, int newblock) {
|
dosurround(const char *begin, const char *end, int newblock) {
|
||||||
unsigned int i, l;
|
unsigned int i, l;
|
||||||
const char *p, *ps, *q, *qend;
|
const char *p, *start, *stop;
|
||||||
|
|
||||||
for(i = 0; i < LENGTH(surround); i++) {
|
for(i = 0; i < LENGTH(surround); i++) {
|
||||||
l = strlen(surround[i].search);
|
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;
|
continue;
|
||||||
for(ps = surround[i].search; *ps == '\n'; ps++);
|
start = begin + l;
|
||||||
l = strlen(ps);
|
p = start - 1;
|
||||||
p = begin + strlen(surround[i].search) - 1;
|
|
||||||
do {
|
do {
|
||||||
p = strstr(p + 1, ps);
|
p = strstr(p + 1, surround[i].search);
|
||||||
} while(p && p[-1] == '\\');
|
} while(p && p[-1] == '\\');
|
||||||
if(!p || p == end)
|
if(!p || p >= end)
|
||||||
continue;
|
continue;
|
||||||
fputs(surround[i].before, stdout);
|
fputs(surround[i].before, stdout);
|
||||||
for(q = begin + strlen(surround[i].search); *q == ' '; q++);
|
if(!(stop = strstr(start, surround[i].search)) || stop >= end)
|
||||||
for(qend = p-1; *qend == ' '; qend--);
|
continue;
|
||||||
if(surround[i].process)
|
if(surround[i].process)
|
||||||
process(q, qend + 1, 0);
|
process(start, stop, 0);
|
||||||
else
|
else
|
||||||
hprint(q, qend + 1);
|
hprint(start, stop);
|
||||||
fputs(surround[i].after, stdout);
|
fputs(surround[i].after, stdout);
|
||||||
return p - begin + l;
|
return stop - begin + l;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue