|
Home Pages Pidgin Azarennya (S|N) Mac Textanium Reference ToDo Food Local Edit Local: Hide Weather • GoWhere? • YahooMaps (mine) • GoogleMaps • Metro (map) • FairfaxConnector • GreaterGreaterWashington • DCMetrocentric • WhatsUpArlington • Restonian • BeyondDC • BaconsRebellion Language: Hide Fantasy: Hide • AnnalsOfArda • Arda • SilmarillionChronology • TolkienGateway • SciFi: Hide • CentauriDreams • ColdNavy • ConceptShips • RavenstarStudios • SkyscraperPage • StarTrek • StarTrekVsStarWars • Film: Hide IMDB • BigHollywood • DKnowsAll • Jabootu • KyleSmith Music: Hide REALbasic: Hide • Resources • Garage • University • WebRing • Forums: • REAL • ElfData • Plugins and Code: • BKeeney • DeclareSub • Einhugur • Joe • Restrepo • Tempelmann • ZAZ Coding: Hide Forums: • PowWeb • PHP • Webmaster • Coding • Walkers • Perl • Intro • Monks • PHP • JavaScript • Toolbox • UnobtrusiveJavaScript • JavaScriptCompressor • RegularExpressions (test) • JSLint • SQL • Cocoa • CocoaBuilder • CocoaDev • CocoaLab • AppleScript • BBS • Userland • Faqintosh • FileMaker • FileMakerTips • FileMakerWorld • FileMakerPlugins Science: Hide DarwinCentral • PhysOrg • PandasThumb • TalkOrigins • TalkRational • AstronomyDailyPics • Curmudgeon • SmallThings • ArchaeoBlog • AntiEvolution.org • SkepticsGuide • EvC • BadAstronomer • PhysicsForum • SlashdotScience • JunkScience • Engadget • Thunderbolts • Icecap • CentauriDreams • NewScientist • Gizmodo • CO2Science • ClimateDebate • ScienceDaily • Nrich • Math • TalkOrigins • GoodMathBadMath • Magazines • AmericanScientist • NationalGeographic • Space.com History: Hide • 1421 News/Politics: Hide WideAwakes • Anchoress • Lucianne • Strata • AceOfSpades • BigLizards • BlackAndRight • Cannonfire • DrSanity • FloppingAces • GatewayPundit • HillBuzz • HotAir • Husaria • JawaReport • JimTreacher • JsCafeNette • LittleGreenFootballs • MyVRWC • Newsbusters • Pal2Pal • PinkFlamingo • PowerLine • RachelLucas • RogerLSimon • SisterToldjah • StolenThunder • SultanKnish • TCSDaily • UppityWoman • Wizbang • NewsGroper • NewsRightNow • OriginalSignal • Blogs... Cults/Crime: Hide Miscellaneous: Hide Fun: Agony ICanHas? ObSkills Snopes Pix: Deviant Places Renderosity Blender Artists X86: OSX86 ArsTech OSNews TUAW Tools: Calculator AsciiArt XMLVal FunStuff: Pictures: Photobucket (eg Dubai) Videos: YouTube Subtitler InterestingThings: LibraryThing FlashCards GoogleDocs Wowio Bubbl.us Colemak Audible PodioBooks WonderfulInfo BooksOnline AboutUs.org |
Wiki /
MarkupLinoleumJustTextAndTablesSuppose Linoleum 0.1 supports only text and tables. Table cell lines begin with '%' ('' starts a new row, and '%' starts a header row), while text lines can begin with anything else. What does the code look like that processes lines of Wiki text? (Could use a PHPCompressor?.)
$marks = array('%', '\\');
// for each line
$trimmed = trim($line);
$c = $trimmed{0};
if (!in_array($c, $marks)) $c = '\\';
// If the mark character is '%',
// count how many mark characters begin the line.
if ($c == '%') {
$marksize = 1;
while ($trimmed{$marksize} == $c) ++$marksize;
}
// Get actual text from line; convert special characters.
$text = htmlspecialchars(substr($trimmed, $marksize), ENT_NOQUOTES);
// If a closing tag has been pushed onto the stack, and the
// current tag differs from the previous tag, then pop the
// closing tag from the stack and send it to output.
if ($prev_c != '' && $c != $prev_c) {
$tag = $stack[$sp--]; // pop the closing-tag stack
$output .= $tag . "\n";
if ($tag == '</td>' or $tag == '</th>') {
$output .= '</tr></table>';
}
}
// Whether or not a closing tag has been pushed onto the
// stack, if the current tag differs from the previous tag,
// send the opening tag to output and push the closing tag
// onto the stack.
if ($c != $prev_c) {
if ($c == '%') {
$output .= "<table><tr>\n";
if ($marksize < 3) {
$output .= "<td>\n";
$stack[++$sp] = "</td>";
} else {
$output .= "<th>\n";
$stack[++$sp] = "</th>";
}
} else {
$output .= "<p>\n";
$stack[++$sp] = "</p>";
}
}
// Now output the text.
$output .= $text . "\n";
}
// If there's anything left on the stack,
// pop it and add it to output here.
|