punkish has asked for the wisdom of the Perl Monks concerning the following question:

I need some help with Text::WikiFormat. This otherwise excellent module is giving me the blues with discovering CamelCase links and with some implementing some additional formatting --

Not only my CamelCase words are becoming links (as they should), UPPERCASE words are also becoming links (as they should not). How can I prevent that from happening?

I want to implement some additional formatting that this module does not do... for example, I want to highlight any passed searchterm using a simple

s/\b($searchterm)\b/<span class="hilite">$1<\/span>/gi

At this time I am first Text::WikiFormat-ting and then running it through my own post formatting. Is there any way I can add my own method to the module so I don't have to do the pass through the text twice? The docs (and the source) seem to suggest I can, but I have been unable to take this into the "implemented and works" territory.

(besides the above highlight formatting, I have a few other additional things that I am doing similarly that T::W doesn't provide, but would be nice if I can add the functionality to it)

Update: making the following change in the regexp in the source of T::W does the trick for disabling UPPERCASE links, however, I am wondering if there is any way to "override" (is that the correct phrase I am seeking here?) the existing functionality without actually modifying the code?

#$text =~ s|(?<!["/>=])\b([A-Za-z]+(?:[A-Z]\w+)+)| # $tags->{link}->($1, $opts)|egx # if !defined $opts->{implicit_links} or $opts->{implicit_links}; $text =~ s|(?<!["/>=])\b([A-Z][a-z0-9]+([A-Z][a-z0-9]*)+)| $tags->{link}->($1, $opts)|egx if !defined $opts->{implicit_links} or $opts->{implicit_links};
--

when small people start casting long shadows, it is time to go to bed

Replies are listed 'Best First'.
Re: formatting with Text::WikiFormat
by chromatic (Archbishop) on Jul 14, 2005 at 06:44 UTC

    The uppercase linking is a bug. I've fixed it in my development version and I hope to upload a new version of the code in the next few days. (I want to write more documentation for Text::WikiFormat::Blocks first though.)

    I'm not sure the right way to accomplish the highlighting. It might be nice to have customizable line-element formatting as there is with blocks. That'll take more code from me to make work though.

      I've fixed it in my development version
      Thanks. Look forward to seeing it. In the meantime, I will work with the hack I've described above.

      It might be nice to have customizable line-element formatting as there is with blocks

      Yes. That, or some way of overriding existing methods or adding new methods. For example, besides highlighting, I also use strikeout and cleaner external links. If I depend on just T::W, an external link has to be written as [http://some.link.com] or [mailto:some@link.com] while I want to accomplish the above without the square brackets, and not have the URI scheme display.

      --

      when small people start casting long shadows, it is time to go to bed
      another "bug" --

      only two levels of nested lists work (I have tested only unordered lists)

      * this * that * other * something else * unrelated * related
      only two levels of indentation are produced. Third and higher levels of indentation are merged into the second level.
      --

      when small people start casting long shadows, it is time to go to bed

      Retitled by holli from 'nested lists don't seem to work properly'.

        I can't reproduce this, and I have tests for it with and without spaces (see t/lists-nested.t). Can you send me a test case?

Re: formatting with Text::WikiFormat
by nothingmuch (Priest) on Jul 14, 2005 at 06:57 UTC
    Consider Text::Textile - a very maturely designed wiki like markup, with bracketed links. The language itself is decribed on this page.

    Update: Actually, I'm not sure Textile itself defines a link format, but MojoMojo, the Catalyst based wiki uses Text::Textile to do it's formatting, and has sane links.

    -nuffin
    zz zZ Z Z #!perl
Re: formatting with Text::WikiFormat
by halley (Prior) on Jul 14, 2005 at 06:36 UTC
    This DoesntAnswer your question, but I FeltCompelled to inject my NotSoHumbleOpinion that what you're calling "CamelCase" is the WorstPart of WikiMarkup. I'd MuchRatherUseBracketsToMarkUpLinks than UseRandomlyCompressed phrases WhichCannotBeRoboticallyTranslated to OtherLanguages or SpellChecked or TakenSeriouslyByNormalNonGeekPeople.

    --
    [ e d @ h a l l e y . c c ]