[pmwiki-users] Special monospace requirement

Allister Jenks zkarj at me.com
Sun Sep 23 17:21:25 CDT 2012


I have now implemented this and it looks gorgeous!

I changed the (:terminal:) directive to the shorter (:5250:) - which is the protocol name for these screens - and the delimiter to ~ and also found I had to re-specify the font for the <tt> elements, but then it worked a treat with out any other changes.

Thanks so much. I was sure it could be done but ran out of talent/time to make it happen on my own.


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/54e534d8/attachment.html>


More information about the pmwiki-users mailing list