Blog »

New OborWiki feature: grep-based transclusion

December 26, 2017, at 12:51 AM by Obormot in Features, Updates (0 comments)

The Grep recipe is now installed on OborWiki (off by default; you can enable it via the Configurator). It lets you use regular expressions to specify text to include from a page or section, and also to transform the included text.

Here’s a simple example. Suppose we want to include, from the text of Robert E. Howard’s short story “Black Colossus” (archived here on OborWiki), the first five lines which contain the word “Conan”; and we’d like to highlight, in bold, the first appearance of “Conan” in each line:

(:grep Archive/BlackColossus pat="^(.*?)(Conan)(.*)$" repl="\n$1'''$2'''$3\n" match=1 limit=5:)

Conan, a captain of the mercenary spearmen,” he answered, emptying the wine-cup at a gulp and holding it out for more. “I was born in Cimmeria.”

Conan of Cimmeria,” she said, “you said I needed aid. Why?”

“Why are my soldiers deserting, Conan?” she asked.

“I place my trust in Mitra,” she said, bending her gaze on Conan, who was now devouring the food placed before him by the trembling Vateesa. “You have seen much war?”

Jerking aside the velvet curtains she dramatically indicated the Cimmerian. It was perhaps not an entirely happy moment for the disclosure. Conan was sprawled in his chair, his feet propped on the ebony table, busily engaged in gnawing a beef-bone which he gripped firmly in both hands. He glanced casually at the astounded nobles, grinned faintly at Amalric, and went on munching with undisguised relish.

See the Grep recipe info page for documentation/instructions.

Note on custom join functions

If you’d like to provide a custom match processing function that should be used for Grep on your wiki, let me know; this is something only I can configure, as it requires editing of your wiki’s config.php.

Leave a reply
Your name (required):

Your comment (required):

Enter value: Captcha