SignalWhenMarkup
PmWiki version 2.2.110 and newer have the variable $MarkupMarkupLevel
which has exactly the same value as this recipe ($SignalMarkupMarkup).
To use the core feature with old recipes relying on the old variable, try adding this to config.php:
$MarkupMarkupLevel = 0; $SignalMarkupMarkup = &$MarkupMarkupLevel;
Please report if it works. --Petko
Questions answered by this recipe
How can I tell whether my markup function is called within (:markup:)
source code?
Description
The script sets a global variable, $SignalMarkupMarkup
, that tells you whether and how deep the 'markup chain' (MarkupToHTML / MarkupTable execution)
is inside a (:markup:)
code sequence.
Some cookbooks like SlimTableOfContents, TitleMarkup, SectionEdit
need to know or should at least care about that.
They should / should not / should differently execute their code inside (:markup:)
page source text.
Activation
Download signalwhenmarkup.phpΔ into your cookbook folder an activate it as usual by adding the following line to your local/config.php:
include_once("$FarmD/cookbook/signalwhenmarkup.php");
signalwhenmarkup_php55.patch.txtΔ Patch for PHP 5.5 compatibility, contributed by Jean-Pierre Chrétien.
Usage
Whenever you need to know whether your own markup is evaluated within (:markup:)
code,
check the value of global $SignalMarkupMarkup
:
$SignalMarkupMarkup == 0 - we are NOT in a (:markup:) sequence $SignalMarkupMarkup == 1...n we are in the n'th level
Notes
Works by redirecting the markups 'markup' and 'markupend'.
Release Notes
- (2009-02-01) Initial version
- (2016-10-23) Update for PHP 5.5 compatibility (by Siegfried Seibert)
* (2019-01-26) Update for PHP 7.2 compatibility (by Siegfried Seibert)
See Also
Contributors
Comments
See discussion at SignalWhenMarkup-Talk
User notes +1: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.