User:Devon McCormick/WikiTips

From J Wiki
Jump to navigation Jump to search

Here is a sandbox to play around with formatting you might want to do on a wiki page. The general reference guide is here but these are some of the more useful things I've found.

Otherwise, here are some pitfalls I've encountered working on wiki pages and tips for dealing with them as well as other tips.

General Tips

What I usually do is examine the source of a page that looks like what I want to accomplish. However, there are a few pitfalls I can warn you about.

Preview is Your Best Friend

Use the Preview button early and often. This will keep your lock on the page current and alert you early on when you make a mistake. [Just now, upon entering the minor header above, I discovered that a trailing space after the closing "===" marker will disable its special function.]

Uploaded files

Beware of problems with suffixes, like the .jpg file showing the APL code on the Diophantine page, have case-sensitive names and insist on a lower-case suffix like "jpg".

The wiki accepts files only for a limited number of file suffixes: .png, .txt, .pdf; the J wiki also accepts .ijs files. Other file types like .xls or .doc, cannot be uploaded "as-is". The wiki can be faked out on these by changing the suffix to an acceptable one, but the user will have to know to change it back to the proper one before using it.

Also, consider saving images, like graphs you generate in the J-language, as Portable Network Graphics or ".png" files as these are sometimes more efficient than .jpgs. Take a look at the J-language code at the top of this picture MiscPic.jpg, which is the same as the "miscellaneous picture" linked to below, for an example of saving a picture in this format.

In general, .png files are preferred as this is a more flexible format. For example, .png allows a certain palette entry to be transparent as seen in this picture of a playing card where the corners are rounded: JofSpades.png

Table of Contents

A table of contents will be inserted automatically for any page with more than three sections. If you have three or fewer headings but want to have a TOC, write either the magic word __FORCETOC__ anywhere on the page to make it display at the default location, or __TOC__ at the preferred position.

Major section titles are marked by double =s and minor ones by triple =s like this:

== Major ==
=== Minor ===

As you can see from the table-of-contents at the top of this page, the major sections are followed by their associated minor sections, indented.

User Name and Directories

Of course, you need to register to be able to edit pages. The wiki wants you to use an "initial-uppercase" name like "Devon McCormick" and this can be used as a sub-directory name, with underscores replacing spaces, to group your own pages. You create a new page simply by entering it into your browser's address bar once you've registered, like this: https://code.jsoftware.com/wiki/User:Devon_McCormick/WikiTips.

Linking and Attaching

Link to a page external to the J wiki like this:

Here is [https://finance.yahoo.com/quote/%5EGSPC/history?p=%255EGSPC the price history] of the S&P 500.

Which gives us this:

Here is the price history of the S&P 500.

Everything after the space following the URL until the terminal square bracket shows up in blue as part of the link.

Short (Internal) Links

Double brackets allow abbreviated (local) links but require a pipe to separate the associated text, so this
[[NYCJUG/2021-11-09#Building_a_GUI_Interface_in_J:_What_it_Looks_Like|Building a GUI in J]]
looks like this, linking to a page on this wiki,
Building a GUI in J.

This prefixes "NYCJUG" with the current high-level URL "http://code.jsoftware.com/mediawiki" and will make the text after the "pipe" a blue link as seen in the reference to "linearDiophantineEquations" above.

In general, you can represent a link by a "blue" word by bracketing the wiki command with a word or phrase following it, separated by a pipe, e.g.

[[attachment:miscPic.jpg|miscellanous picture]]

looks like this: miscellanous picture.

Note that this method used with a picture makes it a link on which one must click rather than showing it in-line, using syntax like the following (be sure not to put a space between the colon and the file name):

{{attachment:sineEyesWBrows_66.jpg}}

like this SineEyesWBrows 66.jpg.

Linking Within a Page

You can establish an anchor-point in the middle of a page to allow references directly to a sub-section:

<<Anchor(anchorExample)>>

and link to it like this:

[[User:Devon McCormick/WikiTips#anchorExample]]
  • the <<Anchor>> is not necessary to jump to sections, their anchors are automatically generated with heading name as in HelpOnLinking#Anchors to jump to "Anchors" section. -- Oleg Kobchenko <<DateTime(2009-09-23T20:08:27-0500)>>
  • However, <<Anchor>> is useful for jumping to a point within a section, as shown in the following example. -- Devon McCormick <<DateTime(2010-01-16T14:34:00-0500)>>

This links to the bottom of my test page.

Different Ways to Link to a Section on a Page

This links, by means of an anchor point, to an example of symbolic understanding using an explanation of dyadic transpose.
This links, by using the section name including embedded spaces, to an example of symbolic understanding using an explanation of dyadic transpose.
This links, by means of the section title with "%20" replacing the embedded spaces, to an example of symbolic understanding using an explanation of dyadic transpose.

You have to save the "from" page in order to test linking to the anchor.

Tables

You can insert a table

Date Page Change
20090907 WikiTips Added examples of anchors and tables
20090903 NYCJUG/2009-08-11 Updated "Terser Is Better" essay

like this:

{| class="wikitable"
!Date!!Page!!Change
|-
|20090907||[[User:Devon McCormick/WikiTips#Table|WikiTips]]||Added examples of anchors and tables
|-
||20090903||[[NYCJUG/2009-08-11]]||Updated "Terser Is Better" essay
|}

Note how the headers are delimited with "!" (which defaults to bolded entries) whereas the table entries are delimited with "|" and rows are separated by "|-". In each case, the row begins with a single delimiter and continues with doubled delimiters.

You can also create your table in MS Word and import it in the GUI editing mode but this brings in a lot of cruft. Do this only for large or complex tables which you do not plan to edit in the wiki text-editing mode.

Format Cells in Table and Make Sortable

If we want to make a table sortable and align numbers on the right, we can do this:

{|class="wikitable sortable"
!Text !! Numbers
|-
|Fourscore and || style="text-align:right;" | 80
|-
|seven || style="text-align:right;" | 7
|-
| style="text-align:center;" |center|| style="text-align:right;" | 1234
|}

This also centers the text in the first cell of the last row.

Text Numbers
Fourscore and 80
seven 7
center 1234

Now each column header has an indicator to the right of the text indicating that the table is sortable by a column and the text is left-aligned, the default, except where centered but the numbers are right-aligned.

The sorting toggles between the initial ordering, descending, ascending, and back to initial.

Special Characters

This wiki has a number of conventions for entering "special" characters - I'm still unaware of most of them. However, the ones with which I'm familiar are mentioned here. The tag pair <nowiki></nowiki> can be put around a phrase to prevent the wiki from interpreting it as a wiki command.

Emphasis

Italics are applied to text delimited by pairs of single quotes (''text to italicize''); bolding requires triplets of single quotes ( '''text to bold''').

Entering Code

Enter code or anything else you want to see "as is", like the wiki markup above, by enclosing it in a pair of "pre" tags like this:

<pre>

NB.* MyStrings.ijs: (text) string handling fns.

tc =: # (i.~{.]) [: }. (,#) {~^:a: 0:

NB.* lineNoWiderThan: Given: a string of words separated by blanks and a positive integer w of the desired width. Replace appropriate blanks in the string by the newline character LF , so that lines are no wider than w and each line contains all the words that fit within the line.

NB. This is a renamed "fmt" function from an essay on text formatting by
NB. Roger Hui, at http://www.jsoftware.com/jwiki/Essays/Text_Formatting.
lineNoWiderThan=: 4 : 0
 e=. (' ' I.@:= y),#y
 LF (e {~ <: tc e I. (x+2)+}:_1,e)} y
)

end =: #@] ,~ ' ' I.@:= ]
candidates =: ] I. 2&+@[ + }:@(_1&,)@]
ix =: [ (<:@tc@candidates { ]) end
NB.* lineNoWiderThant: tacit version of "lineNoWiderThan".
lineNoWiderThant =: LF"_`ix`]

</pre>

In-line Code

Most simply, you can use the HTML tag <tt> (teletype text) for inline code. For example, "the J expression <:+:%. 10 10?@$0 creates a 10x10 table of numbers between _1 and 1" has the embedded J code between <tt> and </tt> tags.

You can also embed an inline piece of code with fixed-width section starting with something like <span style="font-family: 'Courier';"> (assuming Courier is a good font for what you want to do) and terminated by </span>. This does not work well with multi-line code.

APL Code

APL code can be entered with little difficulty by simply embedding the Unicode characters. A full set of the APL characters can be found here. Most of them are as shown here:

∊⍳⍷⍸≠=/⍵⍴⍺?⋆
\‾↓↑→←!≥≤×÷>
<∧∨⊗⊕∼¨_⊃⊂∪∩
∣⋄⎕⊣⊢⍙∵≡⍂⌻⌷∘
⌶⊥⊤⍝⍕⍎⍱⍲⍀⌿⌹⍞
⊖⍟⍉⌽○⍋∆⍒⍫∇⌊⌈

We will just have to live with losing the niceness of the appearance of the APL characters as these Unicode versions were not created with the careful design that went into the APL character set.

Subscript and Superscript

We may designate partitions from to . We can indicate transpose by using a superscript like this: .

We may designate partitions from <math>a_1</math> to <math>a_m</math>.
We can indicate <i>transpose</i> by using a superscript like this: <math>A^T</math>.

Group multi-character subscripts in curly braces, i.e.

<math> \theta_{i+1} = \theta_i + r_i \times v_i </math>

, for this:

We can also do this outside the "math" tags, e.g. "Xi+1", thusly:

X<sub>i+1</sub>

Symbolic Notation

We used to be able to insert mathematical symbols using a "LaTex" insertion but this extension seems to have been left out of the J wiki with the 2015 upgrade. However, there is an extension to support the "math" tag to let us insert special characters.

So, this

<math>\alpha \beta \Gamma \gamma \Delta \delta </math>

gives us this:

And this -

<math>\phi \neq 0</math>

give us this:

Integral Notation

We can accomplish this

with this

<math>\int_a^b \! f(x) \, \mathrm{d}x</math>

Other Special Effects

Though it's simpler, thus probably better to simple use the <tt> tag as indicated here, more sophisticated font effects are also possible. Particular fonts and font size may be invoked by using tags like this: <span style="font-family:Garamond;"><div style="font-size:180%;"> This is another way to insert code in-line, e.g. by changing the font to something fixed-width like Courier.

So, a phrase like
"The J expression for computing arithmetic average, (+/%#), is an example of a fork"
could be written like this:
The J expression for computing arithmetic average, <span style="font-family:Courier;"> (+/%#)</span>, is an example of a ''fork''

Footnotes

To insert footnotes, bracket the text of the footnote with a <ref>...</ref> after the phrase in the body of the text to which you want to insert a footnote. Each footnote will then appear in a section denoted by </reference>, presumably at the end of the text.

Date and Time

Enter four tildes (~) to insert a signature showing the last editor's name with a timestamp showing when the page was last saved.

The substitution is made when the page is saved, so this will have to be re-entered, after deleting the previous insertion of the signature and timestamp, each time you want to save the page with this information.

  12:13:00-0500 - create anchor "#time":
[[#time:1|12:13:00-0500]]
  <<DateTime(2013-06-06T12:08:00-0500)>> - OK:
<<DateTime(2013-06-06T12:08:00-0500)>>

Devon McCormick (talk) 02:55, 23 May 2022 (UTC)