[pmwiki-users] wiki page creation
Peter & Melodye Bowers
pbowers at pobox.com
Sat Mar 22 18:39:30 CDT 2008
> Is there an easy way to automatically create a bunch of
> wiki pages from a text file, which consists of a list of sections,
> and each section shall become a new wiki page?
>
> The sections are mainly of plain text with some wiki markup,
> the beginning of each section is determined by some text marker
> string, the end of each section by the beginning of the next.
> The wiki page name needs to be determined by a string in each section.
Another WikiSh solution, this time more efficient (only writes to each file
one time). Note that you need the most up-to-date version of WikiSh.php for
this to work - I fixed a couple bugs while working through this solution.
Same assumptions as before regarding file location and format...
===(snip)===
set -s outfile = preval
while read --stdin:TEXTFILE--foo.txt line
do
if test "${line}" ~= "/^===.*===$/"
then
if test "${outfile}" != "preval"
then
echo "Outputting to ${outfile}"
echo ${filetext} >${outfile}
fi
set -s filetext = ""
set -s outfile = `echo ${line} | sed 's/^===(.*)===$/$1/'`
else
set -s filetext .= "\n${line}"
fi
done
if test -n "${filetext}" && test ${outfile} != preval
then
echo "Outputting to ${outfile}"
echo "${filetext}" >${outfile}
fi
===(snip)===
-Peter
More information about the pmwiki-users
mailing list