Checking heading structure

N

Neeraj

Does anyone have a clever algorithm for checking if the page has
proper heading structure. By proper structure i mean that Headings
should be properly nested. Heading 1 being main title, and the rest
flow in correct order.

Any help will be appreciated.

Thanks,
Neeraj
 
M

Mathieu Maes

 Does anyone have a clever algorithm for checking if the page has
proper heading structure. By proper structure i mean that Headings
should be properly nested. Heading 1 being main title, and the rest
flow in correct order.

What kind of heading are you talking about ? Are you trying to
validate an HTML document ? Please elaborate on what you're trying to
do.


Kind regards,
Mathew
 
M

Martin Rinehart

Are you referring to the copy editor's view that

1) There must never be a single Hx.

2) Hx can only be followed by Hx or H(x-1) or a higher Hx.

Or are you referring to the order of things in the <head> section?
 
D

Dr J R Stockton

In comp.lang.javascript message <b66d5f6f-2ba7-424c-b429-b19f41d9203a@p2
g2000prn.googlegroups.com>, Wed, 26 Nov 2008 05:18:56, Neeraj
Does anyone have a clever algorithm for checking if the page has
proper heading structure. By proper structure i mean that Headings
should be properly nested. Heading 1 being main title, and the rest
flow in correct order.

Here, mtr is 32-bit MiniTrue, see signature; but other RegExp tools
might serve. This assumes that all headings are written <H#> without,
for example, any style or class; and that <H#> does not otherwise occur.

There must always be an <H1> first.

AFAICS, the only other error is to have a heading followed by another
which is higher in number by more than 1.

Example :
MSDOS prompt mtr -o -x+ european.htm ".*<H(\d)>.*\n" = \1
result 12334354423444444334442223434555554455542334244233

shows just the numbers of the headings of that page.

The errors are having in it any of 13 14 15 16 24 25 26 35 36 46 ; the
rest is up to you.

One should be able to write a JavaScript function to do the same or
similar to document.body.innerHTML of the page that it is executed in,
and to provide it from an include file.
 
T

Thomas 'PointedEars' Lahn

Martin said:
Are you referring to the copy editor's view that

1) There must never be a single Hx.

Define that.
2) Hx can only be followed by Hx or H(x-1) or a higher Hx.
ACK.

Or are you referring to the order of things in the <head> section?

Hardly, those are falsely called headers by some people, but not headings.


PointedEars
 
S

Stor Ursa

In comp.lang.javascript message <b66d5f6f-2ba7-424c-b429-b19f41d9203a@p2
g2000prn.googlegroups.com>, Wed, 26 Nov 2008 05:18:56, Neeraj


Here, mtr is 32-bit MiniTrue, see signature; but other RegExp tools
might serve.  This assumes that all headings are written <H#> without,
for example, any style or class; and that <H#> does not otherwise occur.

There must always be an <H1> first.

AFAICS, the only other error is to have a heading followed by another
which is higher in number by more than 1.

Example :
MSDOS prompt    mtr -o -x+ european.htm ".*<H(\d)>.*\n"  = \1
result          12334354423444444334442223434555554455542334244233

shows just the numbers of the headings of that page.

The errors are having in it any of 13 14 15 16 24 25 26 35 36 46 ; the
rest is up to you.

One should be able to write a JavaScript function to do the same or
similar to document.body.innerHTML of the page that it is executed in,
and to provide it from an include file.

--
 (c) John Stockton, nr London, UK. [email protected]  Turnpike v6.05  IE 7.
 Web  <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms,& links.
 I find MiniTrue useful for viewing/searching/altering files, at a DOS prompt;
 free, DOS/Win/UNIX, <URL:http://www.idiotsdelight.net/minitrue/> unsupported.

I tip my hat to you.
 
N

Neeraj

What kind of heading are you talking about ? Are you trying to
validate an HTML document ? Please elaborate on what you're trying to
do.

Kind regards,
Mathew


Hi,
Sorry for not providing the complete information. Yes, I am trying to
validate a web page.
I wanted to check whether the heading tags i.e H1,H2,H3...H6 are
properly structured meaning that they should be in hierarchy.

Headings should be properly nested following the heading levels
represented by the numerical values of the heading elements.

* h2 should be used as sub-heading after a h1
* h3 should be used as sub-heading after a h2
* h4 should be used as sub-heading after a h3
* h5 should be used as sub-heading after a h4
* h6 should be used as sub-heading after a h5


Thanks,
Neeraj
 
T

Thomas 'PointedEars' Lahn

Dr said:
In comp.lang.javascript message <[email protected]>, Wed, 26


NACK.

ACK, must be H(x *+* 1) and *lower* Hx instead (probably the confusion draws
from the fact that a higher-level heading has lower an x), and "followed by"
must disregard all non-Hx elements to make sense.


PointedEars
 
N

Neeraj

ACK, must be H(x *+* 1) and *lower* Hx instead (probably the confusion draws
from the fact that a higher-level heading has lower an x), and "followed by"
must disregard all non-Hx elements to make sense.

PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16


Totally agree. I need a simple help, i am unable to find out the way
to do this out through javascript. Any help regarding this will be of
great use.

Thanks,
Neeraj
 
D

Dr J R Stockton

In comp.lang.javascript message <296faacb-5c64-4f1b-8b6d-0d558509922b@l3
3g2000pri.googlegroups.com>, Sat, 29 Nov 2008 09:33:25, Neeraj
Totally agree. I need a simple help, i am unable to find out the way
to do this out through javascript. Any help regarding this will be of
great use.

It's all very well saying that you want to do it with JavaScript; but do
you want to have JavaScript called in a Web page to check that Web page
(which poses a burden on any readers that you may have), or do you want
to have JavaScript called in a Web page to check other Web pages on the
same server or on another server, or do you want to use JavaScript run
in WSH to check draft Web pages on your editing system? Whoever sets
your work should be more explicit.

Consider :

var S = document.body.innerHTML, T = [], J = -1, L, X=0, Y
while (-1 < (J = S.indexOf("<H", J+1)))
T.push([+S.substr(J+2, 1), S.substr(J, 30)])
for (J=0, L=T.length ; J<L ; J++) {
Y = T[J][0]
if (Y>X+1) alert(X+" "+Y+" "+T[J][1])
X = Y }
 
N

Neeraj

In comp.lang.javascript message <296faacb-5c64-4f1b-8b6d-0d558509922b@l3
3g2000pri.googlegroups.com>, Sat, 29 Nov 2008 09:33:25, Neeraj
<[email protected]> posted:


Totally agree. I need a simple help, i am unable to find out the way
to do this out through javascript. Any help regarding this will be of
great use.

It's all very well saying that you want to do it with JavaScript; but do
you want to have JavaScript called in a Web page to check that Web page
(which poses a burden on any readers that you may have), or do you want
to have JavaScript called in a Web page to check other Web pages on the
same server or on another server, or do you want to use JavaScript run
in WSH to check draft Web pages on your editing system? Whoever sets
your work should be more explicit.

Consider :

var S = document.body.innerHTML, T = [], J = -1, L, X=0, Y
while (-1 < (J = S.indexOf("<H", J+1)))
T.push([+S.substr(J+2, 1), S.substr(J, 30)])
for (J=0, L=T.length ; J<L ; J++) {
Y = T[J][0]
if (Y>X+1) alert(X+" "+Y+" "+T[J][1])
X = Y }

--
(c) John Stockton, nr London UK. [email protected] DOS 3.3, 6.20; WinXP.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms & links.
PAS EXE TXT ZIP via <URL:http://www.merlyn.demon.co.uk/programs/00index.htm>
My DOS <URL:http://www.merlyn.demon.co.uk/batfiles.htm> - also batprogs.htm.



Hi,
Thanks for your response. I want to have JavaScript which would check
all the web pages passed to it. If you have a javascript for such
thing then can you share it with me.

Thanks,
Neeraj
 
D

Dr J R Stockton

In comp.lang.javascript message <41765fec-8d88-4939-baec-4798b64b33d3@u1
8g2000pro.googlegroups.com>, Sun, 30 Nov 2008 04:51:07, Neeraj
Thanks for your response. I want to have JavaScript which would check
all the web pages passed to it. If you have a javascript for such
thing then can you share it with me.

When you show convincing signs of having understood the regularly-posted
newsgroup FAQ, and when you have learned to give sufficient detail when
asking a question, and when you have learned to heed what further
details have been asked for when replying, then you might become worthy
of further consideration.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,227
Latest member
Daniella65

Latest Threads

Top