01337: [[Cookbook/PmForm]] parses page text variables differently from PmWiki
Description: PmForm uses a different algorithm for determining the page text variable value than PmWiki. PmWiki uses the last occurance it finds in its algorithm, while PmForm stops after it finds the first matching variable.
This can be a problem when, inadvertently, a duplicate page text variable exists on a page: PmForm will allow the user to change the first occurance of a variable (e.g. "Summary: …") but PmWiki will use the last occurance.
Depending on the placement and usage of the PTVs, a page's presentation can be corrupted, or a user who relies on PmForm to edit pages could be unable to update a PTV.
One near-workaround is to put this in the config file (unfortunately if the text-to-replace begins a new paragraph, this removes the preceding blank line - if you know how to fix that, please do so below) :
$PmFormPostPatterns['/^:*\\s*(\\w[-\\w]*)\\s*:/m'] = '[==]$0';
The above prevents a user's text from becoming a PTV by causing [==]
markup to be inserted, similar to how directives are currently blocked by the insertion of spaces. Unfortunately, PmWiki markup may be exactly what PmForm was being used to avoid in the first place. The next time a user edits using the form, the [==]
markup will appear.
Another solution would be to define all PTVs as directives, and then include them all on the page using false conditionals to hide them. That seems like a lot of extra markup, especially if there are a lot of PTVs - it could be error prone.
The cleanest solution is for PmForm and PmWiki to use the same method for determining the page text variable. - RandyB February 11, 2014, at 10:13 PM
I started working on this and I found another inconsistency: the form "source=" parameter also sets the first PTV it finds as a value in the form, instead of the last one, which is the actual string displayed with {$:Var}. That is, even if PmForm modifies the actual (last) PTV, when the dataform is loaded, it will be filled with the first one. I'll have to think about how to fix this. --Petko February 12, 2014, at 04:13 AM
The source= inconsistency will be fixed for 2.2.67:
* Two definitions of PTVs: :MyPTV:Test1 :MyPTV:Test2 * Display MyPTV: "{$:MyPTV}" should be "Test2" * Test InputDefault: (:input default source=01337:)(:input text $:MyPTV:) should contain "Test2" |
|
This should have fixed the problem with PmForm, can you please test and report? --Petko August 02, 2014, at 12:12 PM
Thanks for the fix. It seems to work. If I run in to any problems, I'll report them. -- RandyB August 03, 2014, at 10:32 AM