[Home]DaveRaftery

UseModWiki | RecentChanges | Preferences

Hi everyone. I am very impressed with this wiki; congradulations to Clifford on a great job. I am learning to program in Squeak, a version of smalltalk; that is how I first learned about wikis. (A great introduction to Squeak is "A Quick Ttrip to Objectland" by Korinek, Wrensch and Dechow). I have set up a Use Mod wiki at work; it has been running for 10 months now and is used by about 15 people in my department at 3 different locations. I am giving lunch- time seminars at work to spread the wiki message. I am looking forward to the next release of Use Mod; I am hopeful it might include the ability to upload attachments (hint, hint).

Clifford answered some of my questions about Sub Pages. SubPage/SubPageQuestions

You may reach me at draftery@mindspring.com

http://www.rafteryfamily.swiki.net

Question on searching: Using the Search feature at the bottom of each page, can you search for multiple words or do Boolean searches? I haven't found any documentation on this yet.

It takes Perl regexes. So, the answer is yes and no.


David, I got your email asking for details on the table patch, but I don't think you were receiving my replies. (No idea why that would be the case.) So hopefully you'll see this. Sorry to clutter your home page, but this was too big to put on the patch page, and I couldn't come up with another diff format that I was certain you'd grok. -- DanMuller

By the way, WikiPatches/TableSyntax is going into the next version of UseModWiki.

sub CommonMarkup {
  my ($text, $useImage, $doLines) = @_;
  local $_ = $text;

  if ($doLines < 2) { # 2 = do line-oriented only
    # The <nowiki> tag stores text with no markup (except quoting HTML)
    s/\<nowiki\>((.|\n)*?)\<\/nowiki\>/&StoreRaw($1)/ige;
    # The <pre> tag wraps the stored text with the HTML <pre> tag
    s/\<pre\>((.|\n)*?)\<\/pre\>/&StorePre($1, "pre")/ige;
    s/\<code\>((.|\n)*?)\<\/code\>/&StorePre($1, "code")/ige;
    if ($HtmlTags) {
      my ($t);
      foreach $t (@HtmlPairs) {
        s/\<$t(\s[^<>]+?)?\>(.*?)\<\/$t\>/<$t$1>$2<\/$t>/gis;
      }
      foreach $t (@HtmlSingle) {
        s/\<$t(\s[^<>]+?)?\>/<$t$1>/gi;
      }
    } else {
      # Note that these tags are restricted to a single line
      s/\<b\>(.*?)\<\/b\>/<b>$1<\/b>/gi;
      s/\<i\>(.*?)\<\/i\>/<i>$1<\/i>/gi;
      s/\<strong\>(.*?)\<\/strong\>/<strong>$1<\/strong>/gi;
      s/\<em\>(.*?)\<\/em\>/<em>$1<\/em>/gi;
    }
    s/\<tt\>(.*?)\<\/tt\>/<tt>$1<\/tt>/gis;  # <tt> (MeatBall)
    if ($HtmlLinks) {
      s/\<A(\s[^<>]+?)\>(.*?)\<\/a\>/&StoreHref($1, $2)/gise;
    }
    if ($FreeLinks) {
      # Consider: should local free-link descriptions be conditional?
      # Also, consider that one could write [[Bad Page|Good Page]]?
      s/\[\[$FreeLinkPattern\|([^\]]+)\]\]/&StorePageOrEditLink($1, $2)/geo;
      s/\[\[$FreeLinkPattern\]\]/&StorePageOrEditLink($1, "")/geo;
    }
    if ($BracketText) {  # Links like [URL text of link]
      s/\[$UrlPattern\s+([^\]]+?)\]/&StoreBracketUrl($1, $2)/geos;
      s/\[$InterLinkPattern\s+([^\]]+?)\]/&StoreBracketInterPage($1, $2)/geos;
      if ($WikiLinks && $BracketWiki) {  # Local bracket-links
        s/\[$LinkPattern\s+([^\]]+?)\]/&StoreBracketLink($1, $2)/geos;
      }
    }
    s/\[$UrlPattern\]/&StoreBracketUrl($1, "")/geo;
    s/\[$InterLinkPattern\]/&StoreBracketInterPage($1, "")/geo;
    s/$UrlPattern/&StoreUrl($1, $useImage)/geo;
    s/$InterLinkPattern/&StoreInterPage($1)/geo;
    if ($WikiLinks) {
      s/$LinkPattern/&GetPageOrEditLink($1, "")/geo;
    }
    s/$RFCPattern/&StoreRFC($1)/geo;
    s/$ISBNPattern/&StoreISBN($1)/geo;
    if ($ThinLine) {
      s/----+/<hr noshade size=1>/g;
      s/====+/<hr noshade size=2>/g;
    } else {
      s/----+/<hr>/g;
    }
  }
  if ($doLines) { # 0 = no line-oriented, 1 or 2 = do line-oriented
    # The quote markup patterns avoid overlapping tags (with 5 quotes)
    # by matching the inner quotes for the strong pattern.
    s/('*)'''(.*?)'''/$1<strong>$2<\/strong>/g;
    s/''(.*?)''/<em>$1<\/em>/g;
    if ($UseHeadings) {
      s/(^|\n)\s*(\=+)\s+([^\n]+)\s+\=+/&WikiHeading($1, $2, $3)/geo;
    }
    ## Tables:
    s/^\|([^|]*)\s*/<TR><TD>$1<\/TD>\n/g; # start of line; new table-row
    s/\|([^|]*)\s*/<td>$1<\/td>\n/g; # new field
  }
  return $_;
}

sub WikiLinesToHtml {
  my ($pageText) = @_;
  my ($pageHtml, @htmlStack, $code, $depth, $oldCode);
  my ($tag);

  @htmlStack = ();
  $depth = 0;
  $pageHtml = "";
  foreach (split(/\n/, $pageText)) {  # Process lines one-at-a-time
    $_ .= "\n";
    if (s/^(\;+)([^:]+\:?)\:/<dt>$2<dd>/) {
      $code = "DL";
      $depth = length $1;
    } elsif (s/^(\:+)/<dt><dd>/) {
      $code = "DL";
      $depth = length $1;
    } elsif (s/^(\*+)/<li>/) {
      $code = "UL";
      $depth = length $1;
    } elsif (s/^(\#+)/<li>/) {
      $code = "OL";
      $depth = length $1;
    } elsif (/^[ \t].*\S/) {
      $code = "PRE";
      $depth = 1;
    } elsif (/^[\|\+].*\S/) {
      $code = "TABLE";
      $depth = 1;
    } else {
      $depth = 0;
    }
    while (@htmlStack > $depth) {   # Close tags as needed
      $tag = pop(@htmlStack);
      if ($tag eq "TABLE") {
        $pageHtml .= "</TR>\n";
        $tag = "table";
      }
      $pageHtml .= "</" . $tag . ">\n";
    }
    if ($depth > 0) {
      $depth = $IndentLimit  if ($depth > $IndentLimit);
      if (@htmlStack) {  # Non-empty stack
        $oldCode = pop(@htmlStack);
        if ($oldCode ne $code) {
          $pageHtml .= "</$oldCode><$code>\n";
        }
        push(@htmlStack, $code);
      }
      while (@htmlStack < $depth) {
        push(@htmlStack, $code);
        if ($code eq "TABLE") {
          $pageHtml .= "<TABLE BORDER=2>\n";
        } else {
          $pageHtml .= "<$code>\n";
        }
      }
    }
    s/^\s*$/<p>\n/;                        # Blank lines become <p> tags
    $pageHtml .= &CommonMarkup($_, 1, 2);  # Line-oriented common markup
  }
  while (@htmlStack > 0) {       # Clear stack
    $pageHtml .=  "</" . pop(@htmlStack) . ">\n";
  }
  return $pageHtml;
}


UseModWiki | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited September 19, 2007 8:53 pm by JuanmaMP (diff)
Search: