Not logged in. · Lost password · Register
Forum: General Help and Support Plugins Plugin Wishlist RSS
Replace function in editor window
Avatar
rburn99 #1
Member since Mar 2017 · 27 posts
Group memberships: Members
Show profile · Link to this post
Subject: Replace function in editor window
I am converting a mediawiki import. The import was successful (all pages and media imported) but some things were either incorrectly resolved by the import script or there just is no comparable syntax for some things. I used the global file find and replace function of notepad++ to make all the blind global changes I could but I still have to go through thousands of pages and tweak things that need it.

I load a page and if it's whacked [and if a replace function helps] I copy the text from the edit window and paste it into a 3rd party text editor, do the replaces I noticed, paste back and preview, rinse and repeat until the page looks good. It would be awesome if there was a Find/Replace/Replace All function built into the page edit window.

I searched for a plugin to add that functionality but couldn't find anything that seemed like a valid solution.
Avatar
phy25 #2
Member for 2 months · 10 posts
Group memberships: Members
Show profile · Link to this post
Maybe this one? https://www.dokuwiki.org/plugin:strreplace
Avatar
rburn99 #3
Member since Mar 2017 · 27 posts
Group memberships: Members
Show profile · Link to this post
Hi, Thanks for the suggestion. I did look at strreplace. That one you go into the plugin manager and set up to 4 strings you want to replace. Then when you load the page in the editor those strings get replaced. That would require loading a page, seeing what needs to be replaced, closing the page, then going to the admin section, plugin settings and entering the strings, then loading the page again and bringing it into edit mode and the string(s) get replaced. That seems a lot more cumbersome than copy pasting back and forth between an external text editor and the edit window.

I looked at one called Replace also but it says it hasn't been developed in years, there is no easy install (copying code, editing system files), and a lot of comments about it not working right.
Avatar
andi (Administrator) #4
User title: splitbrain
Member since May 2006 · 3179 posts · Location: Berlin Germany
Group memberships: Administrators, Members
Show profile · Link to this post
https://www.dokuwiki.org/plugin:toolbox contains a search and replace dialog
Read this if you don't get any useful answers.
Lies dies wenn du keine hilfreichen Antworten bekommst.
Avatar
rburn99 #5
Member since Mar 2017 · 27 posts
Group memberships: Members
Show profile · Link to this post
excellent. Thanks :-D
Avatar
rburn99 #6
Member since Mar 2017 · 27 posts
Group memberships: Members
Show profile · Link to this post
Have to be careful with it though... There is no undo  8-(
Avatar
turnermm (Moderator) #7
Member since Oct 2009 · 3885 posts · Location: Canada
Group memberships: Global Moderators, Members, Super Mods
Show profile · Link to this post
If you are using a linux system, the linux workhorse for this kind of thing is the find->sed replace command.  See, for instance:
    http://www.brunolinux.com/02-The_Terminal/Find_and%20Repla….

Here's a modification of the script given there:
#!/bin/bash
TEXTFILES=`find . -name "*.txt"`

     for fl in $TEXTFILES
      do
        cp $fl $fl.old
#      rm -f $fl.old
#     sed 's/FINDSTRING/REPLACESTRING/g' $fl.old > $fl
#     rm -f $fl.old
     done
First create your backups, then comment out the cp $fl $fl.old and uncomment the sed line with the proper search and replace strings.  When you are satisfied you have what you want  you can  removed the *.old files by uncommenting  rm -f $fl.old.  In each case you  have to comment out the  commands which are not currently wanted.

You place this script in the  topmost directory of the the files you want to change.

I used this basic technique when I was creating the ckgdoku companion to ckgedit and wanted to replace every instance of ckgedit with ckgdoku.  There were  approximately 40,000 lines of code to parse. It was amazingly fast.
Myron Turner
github: https://github.com/turnermm
plugins, templates: http://www.mturner.org/devel
This post was edited on 2017-08-30, 03:11 by turnermm.
Avatar
turnermm (Moderator) #8
Member since Oct 2009 · 3885 posts · Location: Canada
Group memberships: Global Moderators, Members, Super Mods
Show profile · Link to this post
Of course you should never do this kind of thing without a proper bakup.
Myron Turner
github: https://github.com/turnermm
plugins, templates: http://www.mturner.org/devel
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Current time: 2017-10-24, 00:37:39 (UTC +02:00)