User talk:The Transhumanist/ConvertNavBoxToOutline.js


 * I'm using this page as a workspace. The talk page portion of it starts at, below.

(Script under development - not yet functional)

navbox2OL.js = Convert navbox footer to outline

= Script's workshop =
 * This is the work area for developing the script and its documentation. The talk page portion of this page starts at, below.

Description / instruction manual
(Script under development - not yet functional)

navbox2OL = Copy and convert navigation footer to outline.

This script is for converting the wikisource of nav footers, that use the navbox template, to outline format.

Initially, the user will need to copy and paste the wiki code into the destination file, and then run the script on that.

Later versions may make the entire conversion, starting at the source page.

Note: This script might also work on sidebar boxes, with little or no modification.

Note: A more advanced version might be called HarvestNavboxToOutline.js, which would create the outline if it did not exist, and if it did exist, would integrate the links from the navbox into it.

Desired features

 * Ask for the name of the page to be created, and then create that page in draft space.

Rough rough talk-through
The navbox template maintains a hierarchy of topics, but does not support annotations. Outlines are an alternative for presenting topics hierarchically, and they support annotations. But outlines, like nav footers, are tedious and time-consuming to build. If tree-building work has already taken place for a subject in the form of a nav footer, it makes sense to make use of that work rather than restart over from scratch. Converting manually is daunting, and much time could be saved if a script could do it.

When a menu item/hotkey is pushed, it will first suggest a name for the new page to be created.


 * So, it is going to need addPortletLink to create a menu item/hotkey.


 * Check to see if the page exists (in main space and draft space). If it doesn't, proceed.


 * A prompt pops up asking if that name is acceptable.


 * If it is, proceed.


 * If it isn't, ask for another name.

Then the script will convert the nav footer to an outline.

Put it in edit mode.

Then it needs to strip out the template formatting, but not before using that coding to determine the level of the data.


 * Navbox maintains hierarchy through numbering, but it awkwardly just starts counting over when it goes down a level, and each level ends in double-curly brackets.


 * By maintaining some counts, the program should know what to do with the current entry that it is on. Count what? Levels


 * Going through some loops, each line can be processed via various regexes.


 * Once the data format has been converted, then the standard opening and closing sections can be added to the page.

Delete via regex everything from "{{navbox" to "|group1"

Strip out all the lines with "|listn = "

Then process each line, with the process depending upon the level counter and what script finds on the line.


 * If double closing curlies, adjust level up one, and remove the line.

When the page is complete, it will be saved as an article in draft space.

Once the data format has been converted, then the standard opening and closing sections can be added to the page.

Script dependencies
= Discussions =