Ceasar / Encyclopedia

Tool for keeping a hypermedia encyclopedia
MIT License
55 stars 7 forks source link

Make headers relative #10

Open Ceasar opened 10 years ago

Ceasar commented 10 years ago

I'm not sure the title describes the problem as I intend it to.

Problem Description

Essentially the problem is that if you write a section which has many nested sections (each beginning with a header), and then learn later than the section is at the wrong level, its header and the header of all nested section must be changed.

Example

For example, consider you have the following document structure:

Header 1
=======

Header 2
=======

Subheader 1
++++++++++

Subsubheader 1
^^^^^^^^^^^^^^^

Subheader 2
++++++++++

Subsubheader 1
^^^^^^^^^^^^^^^

If you later decide Header 2 is at the wrong level, then every header below it needs to be changed:

Header 1
=======

Header 2
+++++++

Subheader 1
^^^^^^^^^^^

Subsubheader 1
"""""""""""""""""""""

Subheader 2
^^^^^^^^^^^^

Subsubheader 1
"""""""""""""""""""""

This of course doesn't scale.

Solution

No good solution is obvious to me.

Attempt 1

One possible solution is to inject a new header level.

For example:

Header 1
=======

Header 2
************

Subheader 1
++++++++++

Subsubheader 1
^^^^^^^^^^^^^^^

Subheader 2
++++++++++

Subsubheader 1
^^^^^^^^^^^^^^^

This however does not work if Header 1 already has subsections, since it would cause an inconsistent title level.

Attempt 2

In general, if we reduce the number of title levels, we can limit the number of replacements.

Ceasar commented 10 years ago

The obvious way to do this seems to be to write a script which, given a target header, either raises or lowers all subheaders by some specified amount.