Version at: 23/02/2014, 17:22 vs. version at: 23/02/2014, 21:12
11# Sandbox
22
33Use this page to experiment with wiki markup.
44
55## Bulleted lists ##
66Nested bulleted list with two spaces for the second level of indentation and four spaces for the fourth:
77
88* a
99 * a.b
1010 * a.b.c
1111 * a.v
1212* z
1313
1414That list looks correct in the preview and correct in the final presentation.
1515
1616Another list where there are two spaces for each level of indentation:
1717
1818* a
1919 * a.b
2020 * a.b.c
2121 * a.v
2222* z
2323
2424Note that that list looks messed up in the preview, but correct in the final presentation.
2525
2626and one where there are four spaces for each level of indentation:
2727
2828* a
2929 * a.b
3030 * a.b.c
3131 * a.v
3232* z
3333
3434That list looks correct in both the preview and the final presentation.
3535
3636##Outlines
3737
3838Only two levels of indentation are shown in the "How to Format Text" box, but in reality, more are available:
3939
4040###Third level of indentation
4141####Fourth level of indentation
4242#####Fifth level of indentation
4343
4444However, the fifth level looks smaller than body text.
4545
4646##Code
4747
4848We need a way to present code as-is, so we want to be able to turn off wiki formatting for a block. The "code" markup (a pair of backticks) doesn't do the job.
4949
5050###Backticks
5151Code sample (note that the format differs between preview mode and final presentation):
5252
5353`
5454if (a)
5555 b
5656else
5757 c
5858`
5959
6060###Triple backticks
6161
6262This section is "fenced off" by triple backticks (see [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown)):
6363
6464```
6565if (a)
6666 b
6767else
6868 c
6969```
7070
7171but the formatting is not preserved.
7272
7373###Blockquote
7474
7575The blockquote markup doesn't do the job either, since again the format differs between preview mode and final presentation:
7676
7777>>if (a)
7878>> b
7979>>else
8080>> c
8181
8282###XML-style blockquote tag
8383Here's an attempt to use an XML-style blockquote tag:
8484
8585<blockquote>
8686if (a)
8787 b
8888else
8989 c
9090</blockquote>
9191
9292The blockquote tag disappears altogether, but does not prevent the text it surrounds from being reformatted.
9393
9494##Escaping characters
9595
9696We need ways of escaping various characters:
9797
9898###Underscore
9999Mention a name that contains a single underscore:
100100
101101a_b
102102
103103It appears correctly. But mention a name that contains an underscore twice:
104104
105105a_b a_b
106106
107107It appears as:
108108
109109ab ab
110110
111111where the first b and the second a are italicized.
112112
113113Solution: Use a backslash in front of each underscore:
114114
115115a\\\_b a\\\_b
116116
117117to produce this output:
118118
119119a\_b a\_b
120120
121121###Parenthesis
122122
123123Say that I want to write this, but in a help section, so I don't want to trigger interpretation as an actual link. Here, I've included spaces to throw off interpretation, but I want to be able to accomplish that through escape sequences instead.
124124
125125[ t e x t ] ( h t t p : / / example . com )
126126
127127Solution: put a backslash before the open-square-bracket and before the open-parenthesis and close-parenthesis. (Putting a backslash before the close-square-bracket is optional.)
128128
129129\\[text\\]\\(http://example.com\\)
130130
131131Output:
132132
133133\[text\]\(http://example.com\)
134134
135135##Bookmarklet code
136136First bookmarklet test (which succeeds in both preview and presentation modes):
137137
138138[test][1]
139139
140140 [1]: javascript:var%20p=Math.floor((Math.random()*100)+1);location.href=%22http://tatoeba.org/eng/sentences/show_all_in/epo/und/eng/indifferent/page:%22+p;
141141
142142
143143Second bookmarklet test (which succeeds only in preview mode):
144144
145145[test 2a](javascript:var%20u%20=%20%22%22;var%20e=window.prompt%28%22Enter%20URL%20or%20number%20of%22+%22%20sentence%20to%20link%20to%20this%20one%22,%22%22%29;if%28e!=null%29{var%20r=/%28http:\/\/%5B^\/%5D+\/%5Ba-z%5D{3}\/%29?%28sentences\/show\/%29?%28%5B1-9%5D%5B0-9%5D%29%28#.%29?/;var%20em=e.match%28r%29;if%28em!=null%29{var%20h=location.href;var%20hm=h.match%28r%29;u=hm%5B1%5D+%22links/add/%22+hm%5B3%5D+%22/%22+em%5B3%5D;location.href=u;}else{alert%28%22Invalid%20input.%22%29};})
146146
147147Third bookmarklet test (which succeeds only in preview mode; in presentation mode it points to http://en.wiki.tatoeba.org/articles/show/sandbox):
148148
149149[test 2][2]
150150
151151 [2]:
152152javascript:var%20u%20=%20%22%22;var%20e=window.prompt%28%22Enter%20URL%20or%20number%20of%22+%22%20sentence%20to%20link%20to%20this%20one%22,%22%22%29;if%28e!=null%29{var%20r=/%28http:\/\/%5B^\/%5D+\/%5Ba-z%5D{3}\/%29?%28sentences\/show\/%29?%28%5B1-9%5D%5B0-9%5D%29%28#.%29?/;var%20em=e.match%28r%29;if%28em!=null%29{var%20h=location.href;var%20hm=h.match%28r%29;u=hm%5B1%5D+%22links/add/%22+hm%5B3%5D+%22/%22+em%5B3%5D;location.href=u;}else{alert%28%22Invalid%20input.%22%29};}
153153
154154Fourth bookmarklet test (which fails in both preview mode and presentation mode; in presentation mode it points to http://en.wiki.tatoeba.org/articles/show/sandbox):
155155
156156[test 3][3]
157157
158158 [3]:
159159javascript:var%20u%20=%20"";var%20e=window.prompt("Enter%20URL%20or%20number%20of" +"%20sentence%20to%20link%20to%20this%20one","");if(e!=null){var%20r=/(http:\/\/[^\/]+\/[a-z]{3}\/)?(sentences\/show\/)?([1-9][0-9])(#.)?/;var%20em=e.match(r);if(em!=null){var%20h=location.href;var%20hm=h.match(r);u=hm1+"links/add/"+hm[3]+"/"+em[3];location.href=u;}else{alert("Invalid%20input.")};}
160160
161Fifth bookmarklet test, in which I use backslashes to escape all backslashes, asterisks, underscores, open-square-brackets, close-square-brackets-, open-parentheses, close-parentheses:
161Fifth bookmarklet test, in which I use backslashes to escape all backslashes, asterisks, underscores, open-square-brackets, close-square-brackets, open-parentheses, close-parentheses:
162162
163163javascript:var%20u%20=%20"";var%20e=window.prompt\("Enter%20URL%20or%20number%20of%20sentence%20to%20link%20to%20this%20one",""\);if\(e!=null\){var%20r=/\(http:\\/\\/\[^\\/\]+\\/\[a-z\]{3}\\/\)?\(sentences\\/show\\/\)?\(\[1-9\]\[0-9\]\*\)\(#.\*\)?/;var%20em=e.match\(r\);if\(em!=null\){var%20h=location.href;var%20hm=h.match\(r\);u=hm\[1\]+"links/add/"+hm\[3\]+"/"+em\[3\];location.href=u;}else{alert\("Invalid%20input."\)};}
164164
165This works. Note that replacing "\\" with "\\\\" must be the first step. After that, the other replacements can be done in any order.
165This works in terms of preserving the text. (Note that replacing "\\" with "\\\\" must be the first step. After that, the other replacements can be done in any order.)
166
167However, I'm not able to get it to work right in a link:
168
169[bookmarklet test]()
diff view generated by jsdifflib

Version at: 23/02/2014, 17:22

# Sandbox

Use this page to experiment with wiki markup. 

## Bulleted lists ##
Nested bulleted list with two spaces for the second level of indentation and four spaces for the fourth:

* a
  * a.b
      * a.b.c
  * a.v
* z  

That list looks correct in the preview and correct in the final presentation.

Another list where there are two spaces for each level of indentation:

* a
  * a.b
    * a.b.c
  * a.v
* z  

Note that that list looks messed up in the preview, but correct in the final presentation.

and one where there are four spaces for each level of indentation:

* a
    * a.b
        * a.b.c
    * a.v
* z  

That list looks correct in both the preview and the final presentation.

##Outlines

Only two levels of indentation are shown in the "How to Format Text" box, but in reality, more are available:

###Third level of indentation
####Fourth level of indentation
#####Fifth level of indentation

However, the fifth level looks smaller than body text.

##Code

We need a way to present code as-is, so we want to be able to turn off wiki formatting for a block. The "code" markup (a pair of backticks) doesn't do the job.

###Backticks
Code sample (note that the format differs between preview mode and final presentation):

`
if (a)
    b
else
    c
`

###Triple backticks

This section is "fenced off" by triple backticks (see [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown)):

```
if (a)
    b
else
    c
```

but the formatting is not preserved.

###Blockquote

The blockquote markup doesn't do the job either, since again the format differs between preview mode and final presentation:

>>if (a)
>>    b
>>else
>>    c

###XML-style blockquote tag
Here's an attempt to use an XML-style blockquote tag:

<blockquote>
if (a)
    b
else
    c
</blockquote>

The blockquote tag disappears altogether, but does not prevent the text it surrounds from being reformatted.

##Escaping characters

We need ways of escaping various characters:

###Underscore
Mention a name that contains a single underscore:

a_b

It appears correctly. But mention a name that contains an underscore twice:

a_b   a_b

It appears as:

ab ab 

where the first b and the second a are italicized. 

Solution: Use a backslash in front of each underscore:

a\\\_b a\\\_b

to produce this output:

a\_b a\_b

###Parenthesis

Say that I want to write this, but in a help section, so I don't want to trigger interpretation as an actual link. Here, I've included spaces to throw off interpretation, but I want to be able to accomplish that through escape sequences instead.

[ t e x t ] ( h t t p : / / example . com )

Solution: put a backslash before the open-square-bracket and before the open-parenthesis and close-parenthesis. (Putting a backslash before the close-square-bracket is optional.)

\\[text\\]\\(http://example.com\\)

Output:

\[text\]\(http://example.com\)

##Bookmarklet code
First bookmarklet test (which succeeds in both preview and presentation modes):

[test][1]

  [1]: javascript:var%20p=Math.floor((Math.random()*100)+1);location.href=%22http://tatoeba.org/eng/sentences/show_all_in/epo/und/eng/indifferent/page:%22+p;


Second bookmarklet test (which succeeds only in preview mode):

[test 2a](javascript:var%20u%20=%20%22%22;var%20e=window.prompt%28%22Enter%20URL%20or%20number%20of%22+%22%20sentence%20to%20link%20to%20this%20one%22,%22%22%29;if%28e!=null%29{var%20r=/%28http:\/\/%5B^\/%5D+\/%5Ba-z%5D{3}\/%29?%28sentences\/show\/%29?%28%5B1-9%5D%5B0-9%5D%29%28#.%29?/;var%20em=e.match%28r%29;if%28em!=null%29{var%20h=location.href;var%20hm=h.match%28r%29;u=hm%5B1%5D+%22links/add/%22+hm%5B3%5D+%22/%22+em%5B3%5D;location.href=u;}else{alert%28%22Invalid%20input.%22%29};})

Third bookmarklet test (which succeeds only in preview mode; in presentation mode it points to http://en.wiki.tatoeba.org/articles/show/sandbox):
 
[test 2][2]

  [2]: 
javascript:var%20u%20=%20%22%22;var%20e=window.prompt%28%22Enter%20URL%20or%20number%20of%22+%22%20sentence%20to%20link%20to%20this%20one%22,%22%22%29;if%28e!=null%29{var%20r=/%28http:\/\/%5B^\/%5D+\/%5Ba-z%5D{3}\/%29?%28sentences\/show\/%29?%28%5B1-9%5D%5B0-9%5D%29%28#.%29?/;var%20em=e.match%28r%29;if%28em!=null%29{var%20h=location.href;var%20hm=h.match%28r%29;u=hm%5B1%5D+%22links/add/%22+hm%5B3%5D+%22/%22+em%5B3%5D;location.href=u;}else{alert%28%22Invalid%20input.%22%29};}

Fourth bookmarklet test (which fails in both preview mode and presentation mode; in presentation mode it points to http://en.wiki.tatoeba.org/articles/show/sandbox):

[test 3][3]

  [3]: 
javascript:var%20u%20=%20"";var%20e=window.prompt("Enter%20URL%20or%20number%20of" +"%20sentence%20to%20link%20to%20this%20one","");if(e!=null){var%20r=/(http:\/\/[^\/]+\/[a-z]{3}\/)?(sentences\/show\/)?([1-9][0-9])(#.)?/;var%20em=e.match(r);if(em!=null){var%20h=location.href;var%20hm=h.match(r);u=hm1+"links/add/"+hm[3]+"/"+em[3];location.href=u;}else{alert("Invalid%20input.")};}

Fifth bookmarklet test, in which I use backslashes to escape all backslashes, asterisks, underscores, open-square-brackets, close-square-brackets-, open-parentheses, close-parentheses:

javascript:var%20u%20=%20"";var%20e=window.prompt\("Enter%20URL%20or%20number%20of%20sentence%20to%20link%20to%20this%20one",""\);if\(e!=null\){var%20r=/\(http:\\/\\/\[^\\/\]+\\/\[a-z\]{3}\\/\)?\(sentences\\/show\\/\)?\(\[1-9\]\[0-9\]\*\)\(#.\*\)?/;var%20em=e.match\(r\);if\(em!=null\){var%20h=location.href;var%20hm=h.match\(r\);u=hm\[1\]+"links/add/"+hm\[3\]+"/"+em\[3\];location.href=u;}else{alert\("Invalid%20input."\)};}

This works. Note that replacing "\\" with "\\\\" must be the first step. After that, the other replacements can be done in any order.

version at: 23/02/2014, 21:12

# Sandbox

Use this page to experiment with wiki markup. 

## Bulleted lists ##
Nested bulleted list with two spaces for the second level of indentation and four spaces for the fourth:

* a
  * a.b
      * a.b.c
  * a.v
* z  

That list looks correct in the preview and correct in the final presentation.

Another list where there are two spaces for each level of indentation:

* a
  * a.b
    * a.b.c
  * a.v
* z  

Note that that list looks messed up in the preview, but correct in the final presentation.

and one where there are four spaces for each level of indentation:

* a
    * a.b
        * a.b.c
    * a.v
* z  

That list looks correct in both the preview and the final presentation.

##Outlines

Only two levels of indentation are shown in the "How to Format Text" box, but in reality, more are available:

###Third level of indentation
####Fourth level of indentation
#####Fifth level of indentation

However, the fifth level looks smaller than body text.

##Code

We need a way to present code as-is, so we want to be able to turn off wiki formatting for a block. The "code" markup (a pair of backticks) doesn't do the job.

###Backticks
Code sample (note that the format differs between preview mode and final presentation):

`
if (a)
    b
else
    c
`

###Triple backticks

This section is "fenced off" by triple backticks (see [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown)):

```
if (a)
    b
else
    c
```

but the formatting is not preserved.

###Blockquote

The blockquote markup doesn't do the job either, since again the format differs between preview mode and final presentation:

>>if (a)
>>    b
>>else
>>    c

###XML-style blockquote tag
Here's an attempt to use an XML-style blockquote tag:

<blockquote>
if (a)
    b
else
    c
</blockquote>

The blockquote tag disappears altogether, but does not prevent the text it surrounds from being reformatted.

##Escaping characters

We need ways of escaping various characters:

###Underscore
Mention a name that contains a single underscore:

a_b

It appears correctly. But mention a name that contains an underscore twice:

a_b   a_b

It appears as:

ab ab 

where the first b and the second a are italicized. 

Solution: Use a backslash in front of each underscore:

a\\\_b a\\\_b

to produce this output:

a\_b a\_b

###Parenthesis

Say that I want to write this, but in a help section, so I don't want to trigger interpretation as an actual link. Here, I've included spaces to throw off interpretation, but I want to be able to accomplish that through escape sequences instead.

[ t e x t ] ( h t t p : / / example . com )

Solution: put a backslash before the open-square-bracket and before the open-parenthesis and close-parenthesis. (Putting a backslash before the close-square-bracket is optional.)

\\[text\\]\\(http://example.com\\)

Output:

\[text\]\(http://example.com\)

##Bookmarklet code
First bookmarklet test (which succeeds in both preview and presentation modes):

[test][1]

  [1]: javascript:var%20p=Math.floor((Math.random()*100)+1);location.href=%22http://tatoeba.org/eng/sentences/show_all_in/epo/und/eng/indifferent/page:%22+p;


Second bookmarklet test (which succeeds only in preview mode):

[test 2a](javascript:var%20u%20=%20%22%22;var%20e=window.prompt%28%22Enter%20URL%20or%20number%20of%22+%22%20sentence%20to%20link%20to%20this%20one%22,%22%22%29;if%28e!=null%29{var%20r=/%28http:\/\/%5B^\/%5D+\/%5Ba-z%5D{3}\/%29?%28sentences\/show\/%29?%28%5B1-9%5D%5B0-9%5D%29%28#.%29?/;var%20em=e.match%28r%29;if%28em!=null%29{var%20h=location.href;var%20hm=h.match%28r%29;u=hm%5B1%5D+%22links/add/%22+hm%5B3%5D+%22/%22+em%5B3%5D;location.href=u;}else{alert%28%22Invalid%20input.%22%29};})

Third bookmarklet test (which succeeds only in preview mode; in presentation mode it points to http://en.wiki.tatoeba.org/articles/show/sandbox):
 
[test 2][2]

  [2]: 
javascript:var%20u%20=%20%22%22;var%20e=window.prompt%28%22Enter%20URL%20or%20number%20of%22+%22%20sentence%20to%20link%20to%20this%20one%22,%22%22%29;if%28e!=null%29{var%20r=/%28http:\/\/%5B^\/%5D+\/%5Ba-z%5D{3}\/%29?%28sentences\/show\/%29?%28%5B1-9%5D%5B0-9%5D%29%28#.%29?/;var%20em=e.match%28r%29;if%28em!=null%29{var%20h=location.href;var%20hm=h.match%28r%29;u=hm%5B1%5D+%22links/add/%22+hm%5B3%5D+%22/%22+em%5B3%5D;location.href=u;}else{alert%28%22Invalid%20input.%22%29};}

Fourth bookmarklet test (which fails in both preview mode and presentation mode; in presentation mode it points to http://en.wiki.tatoeba.org/articles/show/sandbox):

[test 3][3]

  [3]: 
javascript:var%20u%20=%20"";var%20e=window.prompt("Enter%20URL%20or%20number%20of" +"%20sentence%20to%20link%20to%20this%20one","");if(e!=null){var%20r=/(http:\/\/[^\/]+\/[a-z]{3}\/)?(sentences\/show\/)?([1-9][0-9])(#.)?/;var%20em=e.match(r);if(em!=null){var%20h=location.href;var%20hm=h.match(r);u=hm1+"links/add/"+hm[3]+"/"+em[3];location.href=u;}else{alert("Invalid%20input.")};}

Fifth bookmarklet test, in which I use backslashes to escape all backslashes, asterisks, underscores, open-square-brackets, close-square-brackets, open-parentheses, close-parentheses:

javascript:var%20u%20=%20"";var%20e=window.prompt\("Enter%20URL%20or%20number%20of%20sentence%20to%20link%20to%20this%20one",""\);if\(e!=null\){var%20r=/\(http:\\/\\/\[^\\/\]+\\/\[a-z\]{3}\\/\)?\(sentences\\/show\\/\)?\(\[1-9\]\[0-9\]\*\)\(#.\*\)?/;var%20em=e.match\(r\);if\(em!=null\){var%20h=location.href;var%20hm=h.match\(r\);u=hm\[1\]+"links/add/"+hm\[3\]+"/"+em\[3\];location.href=u;}else{alert\("Invalid%20input."\)};}

This works in terms of preserving the text. (Note that replacing "\\" with "\\\\" must be the first step. After that, the other replacements can be done in any order.)

However, I'm not able to get it to work right in a link:

[bookmarklet test]()

Note

The lines in green are the lines that have been added in the new version. The lines in red are those that have been removed.