"Context-sensitivity" of headers

Lasar Liepins lasar at liepins.net
Wed Mar 9 13:48:34 EST 2005


Hello again.

I apologize for flooding the lists with my stuff, it's just that I need 
get a few ideas regarding MarkDown out of my system. On to the next 
idea...

I will often run into the "problem" that MarkDowned text files which
usually stand on their own will at some point be put into in a web page.
In this case the web page will have its own title as a H1 tag. However 
the
"MarkDowned" text file will also begin with its own H1 tag. In the site
context this should be "degraded" to a H2 tag. Likewise all other
headings should be "degraded" by one level.

I did build a little PHP function which goes through HTML code and
changes all Header tags to a smaller header by a definable "level",
stopping at 6 of course.

	<?php
	function downsize ( $code, $level=1 ) {
		for ( $h=5; $h>=1; $h-- ) {
			$newlevel = $h+$level;
			if ( $newlevel>6 ) { $newlevel=6; }
			$code = preg_replace ( "/<(\/*)h".$h.">/", "<\\1h".$newlevel.">", 
$code );
		}
		return $code;
	}
	?>

This works fine for me, but I am curious as to whether it would be
interesting or feasible  to incorporate this sort of thing into the
MarkDown codebase as an option. I'm sure I am not the only one with
this issue.

What is semantically more logical here? To use second level headers in
the text file all along, or to dynamically downgrade these headers to
the next level?

Also I'm not sure how options to change MarkDown's output fit into the
philosophy of MarkDown, since currently there are none.

Thanks,

_Lasar


-- 
_Lasar Liepins                     0: http://liepins.net/
  lasar at liepins.de                  1: http://liepins.de/
                                    n: http://w42.de/
Nur was nicht ist, ist möglich. (Einstuerzende Neubauten)



More information about the Markdown-Discuss mailing list