[pmwiki-users] PTVs on multiple lines
Petko Yotov
5ko at 5ko.fr
Sun Oct 18 17:20:23 CDT 2015
On 2015-10-18 22:39, Hans Bracker wrote:
> Hello Petko,
>
> Sunday, October 18, 2015, 7:57:44 PM, you wrote:
>
>> (:hidden:
>> var1: value 1
>> var2: value 2
>> var3: value 3
>> etc:)
>
>> As long as the {$:hidden} variable contains all text, this is not a
>> bug.
>
> Yes the hidden PTV contains all text, and is okay.
>
> But see this as example addition at the top here (I put it with
> (:linebreaks:) to make the presentation clearer):
> http://www.pmwiki.org/wiki/Test/MultilinePTVs
>
> (:linebreaks:)
> (:hidden:
> var1: value 1
> var2: value 2
> var3: value 3
> etc:)
>
> {$:hidden}
> {$:var1}
> {$:var2}
> {$:var3}
> {$:etc}
>
> renders as
>
> var1: value 1
> var2: value 2
> var3: value 3
> etc
> value 1
> value 2
> value 3
> )
>
> The hidden PTV contains not three text PTVs, but four. The last one
> renders as the closing ')' character. I think this last etc:)
> should not render as text PTV. I see this as a bug in the text PTV
> definition. Or a bug in th eprocess how the text is scanned for
> matches to the PTV patterns.
When something works exactly the way it was intended and designed to
work, like here, I wouldn't call it a bug. :-)
If there is a potential case where a new unrequested "etc" variable will
be created with the value ")", there is also a potential case where a
required variable will start with ")". In the both cases I fail to see a
problem with the current core; if we modify the core to ignore a
variable starting with ")", I can imagine problems. I prefer not to
change it at this point.
If I fear that a multiline hidden PTV at its last line can overwrite an
earlier single-line PTV, I wouldn't write such PTVs in my pages. :-)
Moreover, if my page doesn't have name:value but only (:name:value:)
variables, the last line of the variable cannot overwrite another
variable:
(:test:single line test:)
(:test2:multi
line
test:)
In this case "{$:test}" is "single line test" and not ")". If there is a
chance for overwriting, I'd only use one type of variables in my pages.
If I use a form processor and fear that a user may write such a value, I
would select longer unique PTV names, less likely to be overwritten, eg.
"text_1337" instead of "text". It's the processor that handles it,
transparently for the user.
Or even, I can redefine $PageTextVarPatterns['(:var:...:)'] to use
something different than colons, for example (=name=value=) or
(;name;value;). That wouldn't interfere with the :name:value single line
definitions. (Make sure you also update the 'textvar:' Markup()
definition from stdmarkup.php.)
Petko
--
Change log : http://www.pmwiki.org/wiki/PmWiki/ChangeLog
Release notes : http://www.pmwiki.org/wiki/PmWiki/ReleaseNotes
If you upgrade : http://www.pmwiki.org/wiki/PmWiki/Upgrades
More information about the pmwiki-users
mailing list