List of valid instructions
Return to Extensions Gallery
rating: +1+x

It is highly recommended that you read How to create your first extension before you read this page. It provides a quick overview of what an instruction is and how you can use it in your extension.

Instructions

Each instruction is entered on a separate line in your extension's code.

Get input from the user
Any instruction beginning with "input" allows you to retrieve input from the user and store it in a variable, to re-use later.

Any symbol that has a special meaning for regular expressions is not allowed in a variable name. That means you cannot use any of the following:

[\^$.|?*+(){}

To re-use a variable called 'my_variable', use this syntax with any instruction that supports the use of variables:

{$my_variable}

append

Since: 3.20
Description: Append some text to the end of the current document.
Displays warnings: Yes, if you use append more than 30 times.
Allowed values: Any plain text or wiki markup, including pre-defined variables using {$variable_name}.

[!-- The first line just writes some text to the editor. --]
append Hello, World!

[!-- This line writes text to STE, but inserts a variable as well. --]
append Hello, {$name}!

Comments

Since: 3.24
Description: Allows you to add a comment to your code, which will be completely ignored by the editor. Comments span one line only.
Displays warnings: Never
Usage: [!-- comment goes here --]

[!-- This is a comment --]
[!-- This is another comment, with no end tag (this is valid!)

delete

Since: 3.23
Description: Enter a RegEx in the format 'delete regex' and any part of the currently-open document that matches that regex will be deleted.
Displays warnings: Yes, if you use delete one or more times.
Allowed values: Any plain text or wiki markup, or a valid regular expression (regex).

[!-- delete all instances of the phrase "Hello" from the document --]
delete Hello

[!-- delete all email addresses from the currently open document (NOT WORKING) --]
delete [A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}

export

Since: 3.30
Description: Exports the currently-loaded page (content, title, parent and tags) to the specified site, and gives the user the option to load that page in their default web browser. Accepts variables for the site and/or page name.
Displays warnings: Yes, if you use export one or more times, a user will be informed about this before launching the extension.
Allowed values: Any valid site name and page name, separated by colons ( : ). Format is the same as when specifying a site and page name for CSIs (i.e. :site-name:category:page) - note the colon at the beginning!

[!-- Add text "Hello, World!" to the content, then export that content to Wikidot.com --]
append Hello, World!
export :site-name:category:page

input

Since: 3.23
Description: Prompts the user to enter a value, and stores that value in a variable. Replaces the deprecated input-string variable command.
Displays warnings: Yes, if you use input or input-boolean or input-int more than 10 times.
Usage: input variable_name

[!-- Ask user for a username, then use the value they entered on the next line. --]
input username
append You wrote that your Wikidot username was {$username}!

input-boolean

Since: 3.22
Description: Prompts the user to enter an boolean value, and stores it in a variable. Returns "true" or "false".
Displays warnings: Yes, if you use input or input-boolean or input-int more than 10 times.
Usage: input-boolean variable_name

[!-- Ask user for either true or false, then use the value they entered on the next line. --]
input-boolean Separate listpages results
append [[module ListPages ... separate="{$Separate listpages results}"]]

input-int

Since: 3.22
Description: Prompts the user to enter an integer value, and stores it in a variable. Returns a valid integer.
Displays warnings: Yes, if you use input or input-boolean or input-int more than 10 times.
Usage: input-int variable_name

[!-- Ask user for their age, then use the value they entered on the next line. --]
input-int age
append You wrote that you are {$age} years young!

Discussion

wdavatar?user=ed-johnson
Ed Johnson

01 Feb 2011 09:09. Edited 0 times. (Edit, Permalink)
Can comments span multiple rows?

[!--
This is a comment
This is another comment
--]

Or should we treat them like DOS batch file comments and prefix each line with the comment marker?
[!-- This is a comment
[!-- This is another comment

Included page "inc:signature" does not exist (create it now)

wdavatar?user=leiger
leiger

02 Feb 2011 00:12. Edited 0 times. (Edit, Permalink)
Nope, only one line each.

In the back-end, they are treated exactly like any other instruction, the " [!-- " part is the type of instruction, and anything following that is the content/details. So it's restricted to the same rules (i.e. one line only).

Included page "inc:signature" does not exist (create it now)

Post Reply

Add reply on "List of valid instructions"