[pmwiki-users] convert pagename when converting from pmwiki 1 or below

John Rankin john.rankin at affinity.co.nz
Thu Mar 30 18:55:35 CST 2006


On Friday, 31 March 2006 2:03 AM, Patrick R. Michaud <pmichaud at pobox.com> wrote:
>On Thu, Mar 30, 2006 at 09:52:42AM +1200, John Rankin wrote:
>> Is there a way to tell the convert function that page names 
>> of the form Page_Name should be saved in the new wiki.d as
>>  PageName?
>
>If you're using the compat1x.php script, it might be as "simple"
>as
>
>    include_once('scripts/compat1x.php');
>    $WikiWordPattern =
>'[[:upper:]]\\w*(?:[[:upper:]][[:lower:]0-9_]|[[:lower:]0-9_][[:upper:]])\\w*';
>    $Compat1x["/$WikiWordPattern/e"] = "str_replace('_', '',
>'$0')";
>
>which basically scans the text for any wikiwords (including inside
>of [[...]] links) and removes any underscores it finds.
>
>If this doesn't work, send me a few examples of things it's getting wrong
>and I'll help tweak the pattern.
>
>Pm
>
I don't think that's quite what I need in this case. The problem is not 
the markup, which is converting just fine, but the pagename itself.

1. In old/wiki.d is a file called, for example, 

   Grid.F-I-4-1_Compliance


2. In new 2dot1/wiki.d we want the file to be called

   Grid.F-I-4-1Compliance


3. Old references are typically of the form 

   {{F-I-4-1 Compliance}}, which resolves to Grid.F-I-4-1_Compliance


4. Converted references are correct and typically of the form 

   [[F-I-4-1 Compliance]] and these resolve to Grid.F-I-4-1Compliance

So, correctly converted link references don't find the existing file.


5. I have a temporary fix in place that causes references to 

   [[F-I-4-1 Compliance]] to find Grid.F-I-4-1_Compliance if it exists 

but only after it has looked for and not found Grid.F-I-4-1Compliance.
This is not a good thing to do, because it recognises a page with a
name that violates $NamePattern.


6. *The problem*: my next conversion test goal is

   - edit the page named old/wiki.d/Grid.F-I-4-1_Compliance

   - save the page as 2dot1/wiki.d/Grid.F-I-4-1Compliance

   - lose the underscore from the pagename

   I can edit and preview the page with no problem in 2.1,
   but its name is still Grid.F-I-4-1_Compliance. I want to
   end up with old/wiki.d/Grid.F-I-4-1_Compliance and
   2dot1/wiki.d/Grid.F-I-4-1Compliance.


7. What I think I need: 

   - either a way to browse and edit Grid.F-I-4-1Compliance
     while using the contents of Grid.F-I-4-1_Compliance

   - or a way to browse and edit Grid.F-I-4-1_Compliance,
     but save it as Grid.F-I-4-1Compliance

   - or if all else fails I can convert
       old/wiki.d/Grid.F-I-4-1_Compliance to
       2dot1/wiki.d/Grid.F-I-4-1_Compliance
     and rename them all manually...

But I hoped there might be an easier way.


8. Will the Convert function actually convert all pages in
   old/wiki.d or only those with names matching $NamePattern?
   I have assumed, perhaps incorrectly, that the local
   $MakePageNameFunction will apply during a convert and
   turn old/wiki.d/Grid.F-I-4-1_Compliance into
   2dot1/wiki.d/Grid.F-I-4-1_Compliance


Thanks for any insights.
-- 
JR
--
John Rankin






More information about the pmwiki-users mailing list