Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Wiki (ish) formatting outside of a wiki

by swiftone (Curate)
on Aug 16, 2004 at 14:55 UTC ( #383318=perlquestion: print w/replies, xml ) Need Help??
swiftone has asked for the wisdom of the Perl Monks concerning the following question:

I have a project where users are uploading text to be displayed on the web. This text is intended to be plain text, but some minor markup on the web pages would be fine. Some of the wikis I've seen use intuitive plain text standards (e.g. *bold*, /italics/) so I'd like to tap into those.

Here's the problem. The site isn't intended as a wiki. So I have either full-blown configurable wikis that don't have (documented) interfaces for outside control, or stand-alone modules that don't let me (easily) pick/alter their formatting choices.

  • Kwiki (and its predecessor CGI::Kwiki) seems like it has all the configurability I want, along with an almost "correct" set of defaults, but it's so interwoven with the undocumented Spoon/Spiffy set that I was unable to find an easy interface to just steal the formatting.
  • Text::WikiFormat is standalone just like I want, but it doesn't appear to let me easily change it's formatting rules, and it's defaults aren't obvious to my non-technical audience. (I want the wiki-text to look, well, normal, before formatting.)
  • Text::Tiki is in much the same boat. I like its default text handlers, but its image and hyperlinking isn't what I'm looking for, and it doesn't let me tweak any of that easily.
  • CGI::Wiki, CGI::pWiki. and the others don't seem useful for this problem either.
So does someone know how I can do what I want, or will I have to steal the regexes etc. from the above and reinvent my wheel, or twist a wiki to the behavior I want?
  • Comment on Wiki (ish) formatting outside of a wiki

Replies are listed 'Best First'.
Re: Wiki (ish) formatting outside of a wiki
by dragonchild (Archbishop) on Aug 16, 2004 at 15:10 UTC
    A 3-second perusal of the source for Text::WikiFormat reveals that the tags are listed in a package variable called ... wait for it ... %tags. It's a hash of names mapped to regexen that parse to that tag. So, you can easily change them and/or add to the tags.

    Not to mention that there is a documented second argument to format() that allows you to modify the set of tags that are used. Read a little further down in the POD.

    I haven't looked at the others. Remember - opensource doesn't make everything easy to use, but it provides all the power you would even want to use ... if you're willing to put a little time and elbow-grease into it.

    We are the carpenters and bricklayers of the Information Age.

    Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

    I shouldn't have to say this, but any code, unless otherwise stated, is untested

      d'oh, I stopped reading when it said only Strong and emphasized were configurable. I misunderstood what it was saying. Thanks for pointing it out.

      Though it does lack table support entirely. I might look into hacking that in if nothing else works for me.

Re: Wiki (ish) formatting outside of a wiki
by itub (Priest) on Aug 16, 2004 at 15:57 UTC
    CGI::Kwiki does not use Spiffy or Spoon. The formatting module basically applies a bunch of regexes, contained in small methods, to the text. It has trouble with complicated cases such as table cells that have further formatting inside, but in general it works. You can override the rules by creating a derived formatting class.
Re: Wiki (ish) formatting outside of a wiki
by Aristotle (Chancellor) on Aug 17, 2004 at 10:22 UTC

    I am a fan of Markdown. Its syntax is simple, effective, and very complete, without the plaintext getting too ugly for more complex cases.

    Makeshifts last the longest.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://383318]
Approved by Mr_Person
[marto]: I'm so glad today is Friday.

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2017-01-20 10:01 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (174 votes). Check out past polls.