[pmwiki-users] Special monospace requirement

Allister Jenks zkarj at me.com
Sun Sep 23 17:41:27 CDT 2012


Oops. I have a problem.

When I tested on my Sandbox page it was all fine, but now I tried it in the midst of a real page it's not behaving well.

It appears that the markup is picking up everything from the following [@ to the last @] on the page, instead of just the next one. The result is most of the rest of my page is included in the <pre> tags.

I guess it's something in the Markup definition. Can you please advise how to fix this?


On 21 Sep, 2012,at 02:05 PM, Petko Yotov <5ko at 5ko.fr> wrote:

Let's say you use the normal [@...@] markup for the terminal block, but 
precede it with (:terminal:) so you'll have in a wiki page:

(:terminal:) [@
here the 80x25 code
@]

Then, to highlight/underline editable fields, you just insert some character 
or combination which you know you wouldn't have in your terminal:

(:terminal:)[@
Name . . : @@ @@ Code. . . : @@ @@
Date . . : @@ @@
@]

In this example, I have used @@...@@ to delimit the editable zones. You can 
change it to a different combination, even to a single character if you'll 
never have it inside the terminal window.

To achieve this, I have in config.php the following:

Markup('terminal', '>markupend', "/\\(:terminal:\\) *\\[@(.*)@\\]/sei",
"MarkupTerminal(\$pagename, PSS('$1'))");

function MarkupTerminal($pagename, $text) {
$delimiter = '@@';
$dx = preg_quote($delimiter, "/");
$text = preg_replace("/$dx(.*?)$dx/", '<tt>$1</tt>', $text);
return PreserveText('@', $text, '');
}


This will cause the @@...@@ text to be wrapped in <tt> tags, and save 
everything in a <pre> block. So, in pub/css/local.css, I can add for 
example:

pre tt {background: #eee; text-decoration: underline;}

See the result here:
http://galleries.accent.bg/Cookbook/Terminal

As you noticed in your message, inserting the delimiters of the editable 
areas will shift the wikicode of that line, so editing may not be very nice.

But if you can find a single character that will NEVER appear on your 
terminal, use it as a delimiter, and you can even add 2 spaces in the 
replacement, so everything will be aligned. Use something like this in 
MarkupTerminal() :

$delimiter = '@'; # single @...@ -or-
$delimiter = '_'; # single _..._ -or-
$delimiter = '$'; # single $...$
...
$text = preg_replace("/$dx(.*?)$dx/", '<tt>$1 </tt>', $text);
# ^^2 spaces at the end

This can be fun. :-)

Petko


_______________________________________________
pmwiki-users mailing list
pmwiki-users at pmichaud.com
http://www.pmichaud.com/mailman/listinfo/pmwiki-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.pmichaud.com/pipermail/pmwiki-users/attachments/20120923/b98cd4da/attachment.html>


More information about the pmwiki-users mailing list