Markup Extensions

Summary: Talk Page for MarkupExtensions recipe
Maintainer: jr
Categories: Markup

Liantefaron 2023/01/25: Needed to switch from PHP 7.4 to PHP ≥8.0, this produced lots of Warnings on if ($MarkupExtensions[‘copy’]) and if ($MarkupExtensions[‘ref’]) lines that went away (following a hint on Stackoverflow: Dealing with PHP8.1 Warning for Undef Array) by changing all those entries to if ($MarkupExtensions[‘some_entry_or_other’] ?? false), but there are still lots of “Undefined array key 2 in $PmWikiDir/cookbook/markup.php on line 852” and I am not PHP-savvy enough to understand how I could catch undefined entries in this $m array. Would any of you care to provide a solution, please? Thanks!

HansB- 2023–02–09: I’ve uploaded an PHP 8.1 compatible update.


Twylite? 2009/11/05: Bug/Warning: MarkupExtensions ‘abbr’ support will hang your Windows-based web server if you happen to include something like COM1 in your page (for n = 1, 2, …).

Workaround: disable ‘abbr’ support by adding $MarkupExtensions[‘abbr’] = false; before you include extendmarkup.php.
Cause: ‘abbr’ will pick up any word consisting only of upper case letters plus a single lower case or digit. It then adds markup to link the abbreviation only if the page exists. On Windows this means an attempt to check if a page COM1 exists, which inevitably ends up with a file system access to COM1 (which is actually a serial port access), causing the process to hang.

Is it possible to disable the MarkupExtensions plugin, especially smart quotes just for the code and pre styles? When writing program code it’s much better to have plain quotes since at times one needs to differentiate between  and ‘.

Solved 28.11.07. In the end I figured out how to do it. Somehow I was under the impression that the @@...@@ tag was using the same style as [@...@], when in reality it wasn’t. Basically @@..@@ uses the code style while [@..@] uses the pre style. If one uses the [@...@] tag the formatting is preserved and the extended markup is not used. It would be nice if this behavior was identical in both code and pre styles.

After plugin the MarkupExtensions my trouble was the followed:

  1. Some Wikiwords no longer matched; e.g. EvMSG
  2. The Predefinition of $SpaceWikiWords in config.php has no effect.

I looked in extendmarkup.php and found, that $SpaceWikiWords and $WikiWordPattern is hardcoded. Why? (I comment the lines and now the plugin runs with complete satisfaction… :-) ) tki?

Commenting them out has no side effects. They got in during some experiments. The space wikiwords was part of testing an AlternateNamingScheme. The wikiword pattern was to test requiring a wiki word to have more than one lower case letter; many “accidental” wiki words have just one. jr

I can’t use attached images with the figure markup, because PmWiki does not recognize [[Attach:picture.jpg]], just Attach:picture.jpg. This is a pity, because I think people will want to do that.

I will investigate this. The figure markup needs refining, I think. jr

Q 20-Feb-2005 Cannot use Standard Markup [--two levels smaller text--]two levels smaller text when MarkupExtensions are active and i cannot disable them in the way you described it upper. I don’t know why its working well here?!. If i don’t use the MarkupExtensions everything works fine. The only way to disable them is to comment out the Markup("--",'inline',"/--([^-&])/",'—$1'); in the extendedmarkup.php. Thats not the way i want to do it. Any suggestions? newmy

Fixed 22-Feb-2005. It was a sequencing problem; try the latest version. jr

Q How can I over-ride a portion of the self-reference behavior? In extendmarkup.php, I commented out two lines of formatting:
>>frame margin-left=50px<<

  1. b.selflink { border-bottom: 1px dotted; }
    #@media screen{ #wikitext b.selflink { color: #e66e31; } }
    >><<

This gave me the result that I wanted, but can I do that instead via a setting in config.php? Or in my skin’s .css file?


Pico August 12, 2006, at 10:05 AMGreat recipe, thanks. I have the same request about disabling the self-reference link formatting (and moved the existing question to this section). I know that I can disable the link markup using the $MarkupExtensionsFmt array or $MarkupExtensions, but I like the automatic tooltips. Could this link item be split off into two separate items, so that one, or the other could be disabled.

  • FYI, the only reason I want to disable the link formatting is because of the way self-links display in the drop down menus of DropDownSkin. If you could tweak the self-link display to work better, then I would want to keep it).
  • Also, a suggestion for automatic tooltip links: How about using the description page variable for the tooltip? That would allow the tooltip text to be hidden on the linked page. It might also speed up the initial display of tooltips, which can often take quite a while to display the first time. If the text was using a page variable, maybe the lag might be reduced.

Would it be possible to remove the “multiple dd in dl” stuff, because (a) PmWiki currently (2.1.x) does support multiple dd in dl (with the ": :second definition") format, and (b) even worse, it doesn’t actually create a second dd in dl, instead it adds an indented div, which is NOT what we want. Kathryn Andersen September 21, 2006, at 09:14 PM


Q 20/04/2005 Beware of extendmarkup.php, which defines some localized variables ($RecentChangesFmt, $DefaultPageTextFmt…).

You may loose recent changes informations.

Bravo pour ces “Sticky Notes” qui marchent même avec des lettres accentuées… et n’acceptent pas les ;-)

Version 2.0.55 fixes the backslash problem in sticky note text.

Attention


popup definition to a term, pops up when moused over.

popup defintion for a link

Small caps

outdented 1. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi fermentum nunc a tellus. Nam in turpis. Praesent tellus urna, convallis vel, pretium id, tincidunt et, lorem. Fusce eu tortor a urna dapibus fermentum. Curabitur nec eros. Nulla consectetuer elit a ante. Etiam pede erat, interdum nec, volutpat non, consequat vitae, arcu. Vestibulum blandit, dolor mollis laoreet porttitor, ipsum mi interdum eros, id pellentesque diam eros vitae nisl.
outdented 2. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi fermentum nunc a tellus. Nam in turpis. Praesent tellus urna, convallis vel, pretium id, tincidunt et, lorem. Fusce eu tortor a urna dapibus fermentum. Curabitur nec eros. Nulla consectetuer elit a ante. Etiam pede erat, interdum nec, volutpat non, consequat vitae, arcu. Vestibulum blandit, dolor mollis laoreet porttitor, ipsum mi interdum eros, id pellentesque diam eros vitae nisl.
outdented 3. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi fermentum nunc a tellus. Nam in turpis. Praesent tellus urna, convallis vel, pretium id, tincidunt et, lorem. Fusce eu tortor a urna dapibus fermentum. Curabitur nec eros. Nulla consectetuer elit a ante. Etiam pede erat, interdum nec, volutpat non, consequat vitae, arcu. Vestibulum blandit, dolor mollis laoreet porttitor, ipsum mi interdum eros, id pellentesque diam eros vitae nisl.

Feel free to experiment with extended markup here.

An automatic anchor

##This heading generates a visible anchor, numbered automatically

Infer an external reference 1

Talk about something else vague 2

And then sound like you are really keyed in w/o really saying anything. Scroll down to see footnote text. 3

This is a test refference footnote 4


Does smart quotes work? “Why?” I ask.


I’m a bit confused on the value of the abbreviation notation. Let’s talk about the [IETF|Internet Engineering Task Force] for instance. Now when I use IETF in raw format, will something happen? Or do I need to mark up [IETF] in some way. I’m a bit confused. Ok, I see, it puts “hover” help text. Would be interesting to have define once use many times semantics for this…

How about something like [:abbr IETF | Internet Engineering Task Force:] to define the abbreviation once (e.g. in a GroupHeader), then [IETF|] or [|IETF|] to use the abbreviation afterwards? One could even do a ‘define and display’ markup as [|IETF|Internet Engineering Task Force|] to do both in one step. (For some reason I’m not too keen on the [abbr|text] markup — maybe because it’s used be?

Well, it’s a ritorical rhetorical question5.


Q Do the Markup Extensions change anything about the way skins/templates are handled? —Henning May 27, 2005, at 07:40 AM

If you notice a change in the appearance of your pages after installing the Markup Extensions, that was probably caused by enabling markup.css by adding $MarkupCss = true; to local/config.php. —Henning May 27, 2005, at 11:55 AM


Q What are the benefits of enabling markup.css? —Henning May 27, 2005, at 11:55 AM


Q How does one implement a multi-line markup? I haven’t found a way to have markup work past a carriage return.

Q Why doesn’t the following line work to turn off spacing of wiki-titles?

Markup(‘spaced’,′); # Don’t use the spaced titles feature

Q The feature “lazy urls” seem to break the urlapprove feature of PmWiki! The lazy url’s can not be approved!

—[(approve links) edit diff] Aug 1, 2005, at 14:01 AM


The footnote markup backlinks seem to be messed up - they go to the wrong number (clicking on 1 goes to 2, 2 goes to 3, etc.). I’d show you on this page except backlinks aren’t enabled. Jon?

I’m unable to reproduce this — it looks fine to me. Can you provide a link to a page exhibiting this behaviour?

I had a problem with multiple sets of footnotes on my wiki. Based on a suggestion from PM on the mailinglist, I came up with this altered version of the Footnote function:

function Footnote($foottext) {
  static $fncount, $fncountgroup, $fntext;
  if ($foottext == "#") {
     $fncountgroup++;
     $fncount = 0;
     $r = "<div class='footnote'>&nbsp;</div>$fntext";
     $fntext = '';
  } else {
     $fncount++;
     $fnote = "_".$fncountgroup."_".$fncount;
     $r = "<a name='fnr$fnote' id='fnr$fnote'></a>".
        "<sup><a href='#fn$fnote'>$fncount</a></sup>";
     $foottext = stripslashes($foottext);
     $fntext .= "<p class='footnote'><a name='fn$fnote' id='fn$fnote'></a>".
        "<sup>(<a href='#fnr$fnote'>$fncount</a>)</sup> $foottext</p>";
  }
  return $r;
}

As you can see I’ve implemented a group counter that is not reset. This way the anchors are unique and the links are reset per each [^#^] directive. /Peter Brink

Fixed (slightly differently — start the group counter at 1 rather than 0) 29 Aug. The current version puts the footnote return link at the end of the footnote, rather than the beginning jr

Tst

ECU

ECU
Electronic Control Unit::more definition
  • list item

    continued item

    continued item

term
first definition
second definition
Look what happens if I end with another set of double colons
<
vspace>

I had created a one page printable contract with lines such as the following:
:'''Dates of exhibition''':_______________________________________________________\\

When I added extendedmarkup and breakpage, my one page form turned into a 167 page document. I’m not sure what in my syntax is causing all these page breaks. Is there a way to turn off extended markup for specific pages? StaceyM?

I believe it’s the underscores in your contract - the break_page.php recipe uses those to …yep, break the page up. See Cookbook.BreakPage. I haven’t checked this page MarkupExtensions to see if there’s an explanation of why break_page.php is part of this installation, or of which variant(s) is/are best to use with it - you could try disabling the break_page.php recipe on your installation and see if that fixes your problem without creating others. — Tegan Dowling


Feature Request

Print page break feature → For printing output only.

  • I have several pages that I want to include in one page using :include: I want to include all pages on one wiki page and then print them out. However the page breaks where ever it wants to. I suggest “using CSS” a way to insert a simple <div style=“page-break-after:always”></div> feature.
    • By: Navet October 27, 2005, at 03:18 PM
  • OK, I’ve created my own markup in the my config.php file, and it works great. Does not affect the text on the screen and prints just like expected. I have several pages included into one PmWiki page and wanted the print out for the next chapter to start on a new sheet of paper. By using the <hr /> rule markup example I created the page-break. Looks like this:

Markup('^]]]]','>^->','/^]]]]+/','<:block><div style="page-break-after:always;"></div>'); \\ Navet October 27, 2005, at 08:31 PM

  • I think it would make more sense to do <hr style="@media screen{display:none;}; page-break-after:always" /> from a semantic CSS perspective. — Carl

I think that there needs to be more documentation on how to use this, how do I attach classes to the dd items within my definition list?


#teaserfmt

This pagelist format is used below to generate a list of pages with teaser texts.

[[#teaserfmt]]* {=$FullName}, {=$Name}, (:para {=$FullName}:)
[[#teaserfmtend]]

(:pagelist markupextensions teaser group=Cookbook fmt=Cookbook.MarkupExtensions#teaserfmt count=10:)

Page names:  Cookbook.MarkupExtensions, Cookbook.MarkupExtensions-Talk, Cookbook.MarkupExtensionsChangeLog


Bug: using MarkupExtensions with 2.1 prevents the “title=“ line from being written to the file, which breaks [[PageName|+]].

I think this is really fixed in version 2.0.59 — if there is still a problem, set $MarkupExtensions[‘mac’] = false; as this seems to be the cause of the problem, owing to the changes to the way PmWiki handles title markup. — jr

Proposed Footnote() function update :

function Footnote($foottext) {
	static $fngroup, $fncount, $fntext, $fnnext = false;
	if ($foottext == "#") {
		$fncount = 0; $fngroup++;
		$r = "<div class='footnote'>&nbsp;</div>$fntext";
		$fntext = '';
	} else {
		$fncount++;
		$fnid = $fngroup+1 . '_' . $fncount;
		$r = "<a name='fnr$fnid' id='fnr$fnid'></a>".
		"<sup><a href='#fn$fnid'>$fncount</a></sup>";
		if($foottext != '+')
		{
			if($fntext)
			{
				$fntext .= '</p>';
				$fnnext = false;
			}
			$foottext = stripslashes($foottext);
			$fntext .= "<p class='footnote'><a name='fn$fnid' id='fn$fnid'></a>".
			"<sup>$fncount</sup> $foottext <a href='#fnr$fnid'>(&uarr;)</a></p>";
		}
		else
		{
			if($fnnext)
			{
				$fntext .= ", <a name='fn$fnid' id='fn$fnid'></a>".
				"<sup>$fncount</sup> <a href='#fnr$fnid'>(&uarr;)</a> ";
			}
			else
			{
				$fnnext = true;
				$fntext .= "<p class='footnote'><a name='fn$fnid' id='fn$fnid'></a>".
				"<sup>$fncount</sup> <a href='#fnr$fnid'>(&uarr;)</a>";
			}
		}
	}
	return $r;
}

Thus to allow multiple footnotes links for the same definition. See http://kzar.net/wiki/Multipla/SitesInternet for example.


Q How do you get it to not display any REVISIONS? All my efforts just managed to turn off the ability to toggle revisions. If I could make the the default to be HIDE REVISIONS for all pages on my site, that would also suffice. But it appears the default is to show them and when you toggle it off it only works for that page. ~Steve June 5, 2006


Drop capstext.


Q Am I the only one with this error regarding extendmarkup.php:

PHP Parse error: parse error, unexpected T_IF in /var/www/html/cookbook/extendmarkup.php on line 354

(using Centos 4.3, PHP version php-4.3.9–3.15)


Used with monobook skin, I tried using extendedmarkup for the footnote option, but found it broke the WPCategories recipe that I also have installed. Specifically, the categories are collected and displayed, but the formatting of the box that they are displayed inside is lost. Des August 19, 2006, at 05:02 AM

For information: worked through the recipe script, and found that removing the section for Smart Quotes restored normal operation of WPCategories, which is fine for my use. Des August 19, 2006, at 06:38 PM

No. Sorry, cancel the above. When I looked at a page with multiple categories listed, some were being placed outside and above the formatted box they should be contained in. Obviously there’s a number of conflicts here, so best abandoned for the moment Des August 19, 2006, at 07:44 PM

Hi; I’ve managed to modify WPCategories in a way which seems to allow peaceful coexistence of both recipes :) MateuszCzaplinski October 07, 2007, at 01:42 PM

Would you consider adding the following, or something similar? I use it to create the <acronym> html tag.
James F Mason November 16, 2006, at 04:36 PM

Markup('acronym', 'inline', '/\\(:acro ([^|]*?)\\|(.*?):\\)/', '<acronym title="$2">$1</acronym>');

For some reason this extension is preventing my group pages from using a pre-set template. How can I fix this? I’m using PmWiki version 2.1.27
Laura Pope Robbins Oct 17, 2007


I found that MarkupExtensions causes my Site/PageNotFound page to be ignored unless I comment out the line in extendmarkup.php defining the default text. Is this intentional? To me, the resulting PmWiki behaviour appeared confusing and the cause hard to find. (I’m using 2.1.27 - perhaps my observation is related to Laura’s problem?) —Henning November 30, 2007, at 11:59 AM


I was wondering whether it is difficult to alter the behaviour of the Em dash markup, so that two consecutive hyphens not only get marked up as an Em dash, but the spaces either side of them get turned into thin spaces. Is this easy to do? (Thanks for bringing ‘proper’ characters to my wiki, by the way!) —Sam Wilson June 07, 2008, at 05:20 PM


This seems to cause underline markup text to have a background color of yellow. I am using gemini skin. Does anyone else have this issue? or a solution :-)

That is because there is no standard wiki syntax for underline. {+ +} is originally “inserted text” <ins> which is made yellow here by pub/css/markup.css. So either edit this stylesheet, or introduce a different sytax like __underline__, as in this article by Pm or by enabling Creole. Frank January 08, 2010, at 11:18 AM

Thank you so much for this, solved my problem as well!’ —donovan 7/23/2011


Ran into PITS 01319, the preg_replace /e depreciation issue with php 5.5.7 and pmwiki 2.2.61. Markup still works without issue, but the errors will print unless turned off. One example is in function Macronise(), line 255. rsanders? 10 Feb 2014

Talk page for the MarkupExtensions recipe (users).