User talk:The Transhumanist/OutlineViewConventional.js

{{User:The Transhumanist/Workshop boilerplate/Lead hatnote}}

:This script is under development, and is not yet functional

When completed,

this script will change the viewed formatting of the current outline into that of a conventionally indented outline, without headings. A textual tree; that is,

an indented item list.

= Script's workshop =

: This is the work area for developing the script and its documentation. The talk page portion of this page starts at #Discussions, below.

Description / instruction manual for ''{{{1}}}''

:This script is under development, and is not yet functional

When completed,

this script will change the viewed formatting of the current outline into that

of a conventionally indented outline, without headings. A textual tree; that is,

an indented item list.

{{User:The Transhumanist/Workshop boilerplate/Install}}

{{User:The Transhumanist/Workshop boilerplate/Explanatory notes}}

= General approach =

(general approach goes here)

More specifically, starting at the beginning...

{{User:The Transhumanist/Workshop boilerplate/Aliases}}

{{User:The Transhumanist/Workshop boilerplate/Bodyguard function}}

{{User:The Transhumanist/Workshop boilerplate/The ready event listener-handler}}

{{User:The Transhumanist/Workshop boilerplate/Only activate for vector skin}}

Change log for ''{{{1}}}''

Task list

= Bugs reports =

= Desired/completed features =

: Completed features are marked with {{done}}

Development notes for ''{{{1}}}''

Article format has headings, conventional outline format does not. The challenge is to convert back and forth. Therefore, the heading information must be saved somehow so that headings can be restored as needed. That could be done by adding class names during the initial regex operation. Also, there are the opening and closing tags.

The heading/lead item pairs are a problem, because they have to be integrated into one for the conventional view, and restored to duality for the article view.

This script needs to work with the other view mode scripts.

= Rough rough talk-through =

{{Further|Pseudocode}}

Change

,

, ...,

tags to
    ,
      , ...,

        To do this, use regex with outerhtml to change the whole item. That way, you can get the closing tag in the same search/replace.

        Reversing it will be the same type of operation.

        This is similar to injecting tags, like in OutlineViewAnnotationToggler.js:

        var cont = document.getElementById('mw-content-text');

        // wrap the annotations in spans with class "anno"

        cont.outerHTML = cont.outerHTML.replace(/(

      • .*?)( –.*)/g,'$1$2');

        Like this:

        var cont = document.getElementById('mw-content-text');

        // change the heading wrappers to classed ul wrappers

        cont.outerHTML = cont.outerHTML.replace(/()(.*?)(<\/h[1-6]>)/g,'

          $2
        ');

        To change them back, you reverse the process:

        // change the classed ul wrappers back to heading wrappers

        cont.outerHTML = cont.outerHTML.replace(/

          (.*?)<\/ul>/g,'<$1>$2<\/$1>');

Script dependencies

= Discussions =

: This is where the actual talk page starts for {{SUBPAGENAME}}. Please post your discussion threads below...

Script to convert headings to list items (and back again) in outlines

Outlines (e.g., Outline of Japan) are essentially big long bullet lists broken up by headings.

I'd like a viewing script (that does not edit the page's saved wikicode), that does the following to viewed outlines:

On "Outline of" pages only, I'd like a menu item toggle that converts the headings so that they are integrated into the overall bullet list on the page, as list items. Clicking the menu item again would turn the page back to normal (to heading format). Like my other scripts, the status should be remembered between pages (so that all outlines get viewed the same way).

When turned on, the page's content will be one long indented bullet list. H2 headings would be converted to list items with one bullet, H3 with two bullets, etc. The subsection edit link should be retained.

Any bullet item trees beneath a converted heading would have to also be adjusted to start out with one more bullet than the heading they belong to, otherwise, the level indications will be off.

I started picking away at this project in User:The Transhumanist/OutlineViewConventional.js, but have realized it is way beyond my skill level. The Transhumanist 23:34, 3 December 2017 (UTC)

:{{ping|The Transhumanist}} That does seem a bit complicated. If I understand correctly, you want to do the following sort of transformation to the page html:

class=wikitable style=width:100%

!style=width:50%|Before (HTML)

! Before (rendered)

Some heading

  • List item 1
  • List item 2
  • List item 3 with sub-list

    • Sub-list item 3.1
    • Sub-list item 3.2

    A sub-heading

    • Sub-heading list item 1
    • Sub-heading list item 2

    Next heading

    ...more lists...

|

{{fakeheading|sub=2|Some heading}}

  • List item 1
  • List item 2
  • List item 3 with sub-list

    • Sub-list item 3.1
    • Sub-list item 3.2

    {{fakeheading|sub=3|A sub-heading}}

    • Sub-heading list item 1
    • Sub-heading list item 2

    {{fakeheading|sub=2|Next heading}}

    ...more lists...

After (HTML)After (rendered)

  • Some heading

    • List item 1
    • List item 2
    • List item 3 with sub-list

      • Sub-list item 3.1
      • Sub-list item 3.2

      • A sub-heading

        • Sub-heading list item 1
        • Sub-heading list item 2

    • Next heading

      ...more lists...

|

  • Some heading

    • List item 1
    • List item 2
    • List item 3 with sub-list

      • Sub-list item 3.1
      • Sub-list item 3.2

      • A sub-heading

        • Sub-heading list item 1
        • Sub-heading list item 2

    • Next heading


      ...more lists...

:If so, then the basic approach would be to get all the content between heading tags of the same level, and wrap it inside list tags like

  • heading text and
(doing the same for all headings on the page). Going back would be a matter of moving the heading text back into appropriate heading tags, and removing the added
    and
  • tags (but not the original content). Does that give you some ideas? - Evad37 [talk] 08:52, 5 December 2017 (UTC)

    :: I missed the li part. Thank you. By the way, what about the rest of the bullets? Will their indents be adjusted automatically? The Transhumanist 05:04, 6 December 2017 (UTC)

    :::Yes, indentation is automatic - Evad37 [talk] 05:52, 6 December 2017 (UTC)

    :::: Thank you. The Transhumanist 12:05, 7 December 2017 (UTC)