From 5f94c13b6b369bc0c68a177b3a736ed7560f9585 Mon Sep 17 00:00:00 2001 From: moodler Date: Thu, 8 May 2003 16:20:38 +0000 Subject: [PATCH] New version of Wiki stuff from Howard Miller. Some cool new features, including linking to Moodle activities! --- lang/en/help/wiki.html | 178 ++++++------ lib/wiki.php | 602 ++++++++++++++++++++++------------------- 2 files changed, 419 insertions(+), 361 deletions(-) diff --git a/lang/en/help/wiki.html b/lang/en/help/wiki.html index 835153b649..9238bfc284 100644 --- a/lang/en/help/wiki.html +++ b/lang/en/help/wiki.html @@ -1,82 +1,96 @@ -

Help on writing Wiki Formatted Pages

- -

- Wiki formatted pages provide a facility for marking up plain text with intutive human readable - conventions that will be converted to XHTML when displayed. The big advantages are that you - do not need to learn HTML to produce quite complex results, and that the text you write - looks right to the eye even before conversion. -

- -

You should enter basically plain text. There are a number of special characters you -can add to insert formatting

- -

Block level formatting

- -

- Paragraph blocks are separated by at least one blank line. To add special formatting to a paragraph - add one of the following special characters in the first character of the first line of the block followed - by a space... -

- - - - - - - - -
CharacterBlock Type
No characterOrdinary paragraph
>Quotation
SpacePreformatted Text (Monospaced)
%Preformatted and Wikki formatting is ignored
!#Heading - where # is 1-6, the heading level (1 is biggest)
- -

List formatting

- -

simple lists can be constructed easily by placing a special character at the start of each line in the list followed by a space. -The list is terminated by a blank line. At present lists cannot be intermixed or nested. Definition list -definitions and text types maybe freely intermixed to obtain the desired effect however. The special characters -are as follows...

- - - - - - - -
CharacterList itme type
*Unordered List (bullet points)
#Ordered List (1,2,3 etc)
:Definition list, definition
;Definition list, text
- -

Inline formatting

- -

Inline formmating allows part of a line to be marked as having a particular style. The special -characters used can appear anywhere on a line, but note that the formatting cannot -cross lines. Codes are as follows...

- - - - - - - - - - - - -
ExampleExampleFormatting
*hello world*hello worldStrong or Bold
/hello world/hello worldEmphasis or Italics
+hello world+hello worldInserted text
-hello world-hello worldDeleted or Strikethrough
hello ~world~hello worldSubscript
hello ^world^hello worldSuperscript
"hello world"hello worldQuoted
%hello world%hello worldCode or Monospaced
@hello world@hello worldCite
- -

Acronyms

- -

Acronym tagging is acheived by placing the acronym in capital letters followed by the description -is parenthesis. There must be no space between the acronym and the parenthesis. Example...

- -

HTML(Hypertext Markup Language)
HTML

- -

Automatic reformattion

- -

Many commonly used functions are converted into their XHTML equivalents automatically.. The main ones are as -follows...

- - - +

Help on Writing Wiki Formatted Pages

+ +

+ Wiki formatted pages provide a facility for marking up plain text with intuitive, human readable + formatting that will be converted to XHTML when displayed. The big advantages are that you + do not need to learn HTML to produce quite complex results, and that the text you write + looks good to the eye even before conversion. It is a real alternative to + saving Word files as HTML retaining the ability to edit the resource online. +

+ +

You should enter basically plain text. There are a number of special characters you +can add to insert formatting

+ +

Block level formatting

+ +

+ Paragraph blocks are separated by at least one blank line. To add special formatting to a paragraph + add one of the following special characters in the first character of the first line of the block followed + by a space... +

+ + + + + + + + +
CharacterBlock Type
No characterOrdinary paragraph
>Quotation
SpacePreformatted Text (Monospaced)
%Preformatted and Wikki formatting is ignored
!#Heading - where # is 1-6, the heading level (1 is biggest)
+ +

List Formatting

+ +

Simple lists can be constructed easily by placing a special character at the start of each line in the list followed by a space. +The list is terminated by a blank line. At present lists cannot be intermixed or nested. Definition list +definitions and text types may be freely intermixed to obtain the desired effect. The special characters +are as follows...

+ + + + + + + +
CharacterList item type
*Unordered List (bullet points)
#Ordered List (1,2,3 etc)
:Definition list, definition
;Definition list, text
+ +

Inline formatting

+ +

Inline formmating allows part of a line to be marked as having a particular style. The special +characters used can appear anywhere on a line, but note that the formatting cannot +cross lines. Codes are as follows...

+ + + + + + + + + + + + +
ExampleExampleFormatting
*hello world*hello worldStrong or Bold
/hello world/hello worldEmphasis or Italics
+hello world+hello worldInserted text
-hello world-hello worldDeleted or Strikethrough
hello ~world~hello worldSubscript
hello ^world^hello worldSuperscript
"hello world"hello worldQuoted
%hello world%hello worldCode or Monospaced
@hello world@hello worldCite
+ +

Acronyms

+ +

Acronym tagging is acheived by placing the acronym in capital letters followed by the description +is parenthesis. There must be no space between the acronym and the parenthesis. Example...

+ +

HTML(Hypertext Markup Language)
HTML

+ +

Hyper Links

+ +Links can be placed in the text and are followed (with no spaces) by the text to be displayed in brackets. Example: http://www.google.com/(Search Now) will be converted to +Search Now. + +

Moodle Module Links

+ +

If you know the Moodle id number (look for ?id=nn at the end of a module address) and +the module name, you can link directly to that resource using the syntax:

+ +

ModuleName:nn(Description Text)

+

eg, resource:36(My New Page) forum:10(Jump to forum)

+ +

Automatic reformating

+ +

Many commonly used functions are converted into their XHTML equivalents automatically.. The main ones are as +follows...

+ + + diff --git a/lib/wiki.php b/lib/wiki.php index f4b7e85b19..adb382afb2 100644 --- a/lib/wiki.php +++ b/lib/wiki.php @@ -1,279 +1,323 @@ -list_state) { - case LIST_NONE: - break; - case LIST_UNORDERED: - $ltag = "\n"; - break; - case LIST_ORDERED: - $ltag = "\n"; - break; - case LIST_DEFINITION: - $ltag = "\n"; - break; - } - $this->list_state = LIST_NONE; - - switch ($state) { - case STATE_PARAGRAPH: - return "$ltag

\n"; - break; - case STATE_BLOCKQUOTE: - return "$ltag\n"; - break; - case STATE_PREFORM: - return "$ltag\n"; - break; - case STATE_NOTIKI: - return "$ltag\n"; - break; - } - } - - - function do_replace( $line, $mark, $tag ) { - // do the regex thingy for things like bold, italic etc - // $mark is the magic character, and $tag the HTML tag to insert - - $regex = '(^| |[(.,])'.$mark.'([^'.$mark.']*)'.$mark.'($| |[.,;:)])'; - $replace = '\\1<'.$tag.'>\\2\\3'; - return eregi_replace( $regex, $replace, $line ); - } - - function do_list( $line ) { - // handle line with list character on it - - // get magic character and then delete it from the line - $listchar = $line{0}; - $line = eregi_replace( "^[*#;:] ", "", $line ); - - // if not in "list mode" then we need to drop the appropriate start tag - $tag = ""; - if ($this->list_state == LIST_NONE) { - switch ($listchar) { - case '*': - $tag = "\n"; + break; + case LIST_ORDERED: + $ltag = "\n"; + break; + case LIST_DEFINITION: + $ltag = "\n"; + break; + } + $this->list_state = LIST_NONE; + + switch ($state) { + case STATE_PARAGRAPH: + return "$ltag

\n"; + break; + case STATE_BLOCKQUOTE: + return "$ltag\n"; + break; + case STATE_PREFORM: + return "$ltag\n"; + break; + case STATE_NOTIKI: + return "$ltag\n"; + break; + } + } + + + function do_replace( $line, $mark, $tag ) { + // do the regex thingy for things like bold, italic etc + // $mark is the magic character, and $tag the HTML tag to insert + + // BODGE: replace inline $mark characters in places where we want them ignored + // they will be put back after main substitutue, stops problems with eg, and/or + $bodge = chr(1); + $line = eregi_replace( '([[:alnum:]])'.$mark.'([[:alnum:]])', '\\1'.$bodge.'\\2',$line ); + + $regex = '(^| |[(.,])'.$mark.'([^'.$mark.']*)'.$mark.'([^[:alnum:]])'; + $replace = '\\1<'.$tag.'>\\2\\3'; + $line = eregi_replace( $regex, $replace, $line ); + + // BODGE: back we go + $line = eregi_replace( $bodge, $mark, $line ); + + return $line; + } + + function do_replace_sub( $line, $mark, $tag ) { + // do regex for subscript and superscript (slightly different) + // $mark is the magic character and $tag the HTML tag to insert + + $regex = $mark.'([^'.$mark.']*)'.$mark; + $replace = '<'.$tag.'>\\1'; + return eregi_replace( $regex, $replace, $line ); + } + + function do_list( $line ) { + // handle line with list character on it + + // get magic character and then delete it from the line + $listchar = $line{0}; + $line = eregi_replace( "^[*#;:] ", "", $line ); + + // if not in "list mode" then we need to drop the appropriate start tag + $tag = ""; + if ($this->list_state == LIST_NONE) { + switch ($listchar) { + case '*': + $tag = "