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:
|
||||
|
||||
* Emphasis
|
||||
* Surround your text with `*` or `_` to get *emphasis* text:
|
||||
This *is* cool.
|
||||
This _is_ cool, too.
|
||||
* Surround your text with `**` or `__` to get **strong** text:
|
||||
This **is** cool.
|
||||
This __is__ cool, too.
|
||||
* inline Code
|
||||
* Emphasis
|
||||
* Surround your text with `*` or `_` to get *emphasis* text:
|
||||
This *is* cool.
|
||||
This _is_ cool, too.
|
||||
* 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*
|
||||
|
||||
You can produce inline code with surrounding `\`` or `\`\``
|
||||
Use `rm -rf /` if you're a N00b.
|
||||
* inline Code
|
||||
|
||||
Use ``rm -rf /`` if you're a N00b.
|
||||
You can produce inline code with surrounding `\`` or `\`\``
|
||||
|
||||
`\`\`` makes it possible to use Backticks without backslashing them.
|
||||
Use `rm -rf /` if you're a N00b.
|
||||
|
||||
Use ``rm -rf /`` if you're a N00b.
|
||||
|
||||
`\`\`ABC\`\`` makes it possible to use Backticks without backslashing them.
|
||||
|
||||
|
||||
Titles
|
||||
|
@ -164,27 +174,28 @@ block.
|
|||
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
|
||||
- - -
|
||||
Hello2
|
||||
Hello
|
||||
- - -
|
||||
Hello2
|
||||
|
||||
Result:
|
||||
<p>
|
||||
Hello
|
||||
<hr />
|
||||
Result:
|
||||
<p>
|
||||
Hello
|
||||
<hr />
|
||||
|
||||
Hello2</p>
|
||||
* You can escape the following pattern to avoid them from being interpreted:
|
||||
`` \ ` * _ { } [ ] ( ) # + - . ! ``
|
||||
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:
|
||||
\ ` * _ { } [ ] ( ) # + - . !
|
||||
|
||||
No linebreak
|
||||
here.
|
||||
But here is
|
||||
one.
|
||||
* To force a linebreak simple add two spaces to the end of the line:
|
||||
|
||||
No linebreak
|
||||
here.
|
||||
But here is
|
||||
one.
|
||||
|
||||
embed HTML
|
||||
----------
|
||||
|
|
23
smu.c
23
smu.c
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue