PDA

View Full Version : errors galore

ptrcao
Dec 29th, 2010, 10:45 AM
I have a dilemma. After all the hard work it took to clean up hundreds of errors, I run a program to insert equations into my html and it commits hundreds of errors.

The good thing is many of the errors are repetitive, and the solutions include replacing uppercase tag names with lowercase; this can be done hundreds at a time using a text editor's find-and-replace function. Another easy fix was to close the image tags.

One major contributor of errors is the ommission of an alt="..." in the image tags. That's tens of more errors, but unfortunately I have no way to fix this, because the names of equations are automatically generated. I would need to find a macro solution to generate corresponding alt info, but I'm unfamiliar with macros. I use Notepad++ text editor. Here I could use your help. The page link and therefore its source code are contained in the link below.

Second, I'm unsure what the remaining errors refer to. Here you can help. See the validator output via the link below.

Validator error output:
http://validator.w3.org/check?uri=http%3A%2F%2Fwww.mathannotated.com%2Fpages%2Fprobability-1%2Fintroductionerrorprone.html&charset=%28detect+automatically%29&doctype=Inline&group=0&user-agent=W3C_Validator%2F1.1

Page URL:
http://www.mathannotated.com/pages/probability-1/introductionerrorprone.html

abduraooft
Dec 29th, 2010, 10:55 AM
One major contributor of errors is the ommission of an alt="..." in the image tags. That's tens of more errors, but unfortunately I have no way to fix this, because the names of equations are automatically generated. I would need to find a macro solution to generate corresponding alt info, but I'm unfamiliar with macros. You may use a null value to that attribute, like alt="", to satisfy the validator, for the time being.

Line 80, Column 142: an attribute value specification must be an attribute value literal unless SHORTTAG YES is specified

…roduction/eqn000.gif" width=10 height=14 style="vertical-align: -1px; margin: … That means, you need to wrap the attribute values by quotes.

ptrcao
Dec 29th, 2010, 11:07 AM
You may use a null value to that attribute, like alt="", to satisfy the validator, for the time being.

Yeh, that occurred to me actually. At least it'll make appease validator as you say.

If anyone knows how to actually duplicate the image's name in alt, I would be really grateful. This would need to be an automated solution, able to execute on demand for hundreds of images.

abduraooft
Dec 29th, 2010, 11:30 AM
Do you have the corresponding code that generate those images?

ptrcao
Dec 29th, 2010, 11:31 AM
Do you have the corresponding code that generate those images?

yes, do you know perl?
it's opensource:

For Linux only.

abduraooft
Dec 29th, 2010, 11:55 AM
I'm not on Linux now, but that archive contains a file named eqn2img.c, and at line 285, there's

if(img_name)
printf("WIDTH=%i HEIGHT=%i STYLE=\"vertical-align: -%ipx; margin: 0;\"", new_width, new_height, baseline);
else /* image being written to stdout, use stderr instead */
fprintf(stderr, "WIDTH=%i HEIGHT=%i STYLE=\"vertical-align: -%ipx; margin: 0;\"", new_width, new_height, baseline);
I think, you may alter that line like

if(img_name)
printf("WIDTH=\"%i\" HEIGHT=\"%i\" alt=\"%s\" STYLE=\"vertical-align: -%ipx; margin: 0;\"", new_width, new_height, baseline,img_name);
else /* image being written to stdout, use stderr instead */
fprintf(stderr, "WIDTH=\"%i\" HEIGHT=\"%i\" STYLE=\"vertical-align: -%ipx; margin: 0;\"", new_width, new_height, baseline);
and re-make it.

PS: Untested!

ptrcao
Dec 29th, 2010, 12:11 PM
Excellent. I will try at the next opportunity.

Question:

...alt=\"%s\"...

How is "s" defined? Did you introduce "s" yourself or is it predefined somewhere?

abduraooft
Dec 29th, 2010, 12:20 PM
Excellent. I will try at the next opportunity.

Question:

How is "s" defined? Did you introduce "s" yourself or is it predefined somewhere?
Lol, it's not introduced by me, refer the table under the line "Type can be any of:" at http://en.wikipedia.org/wiki/Printf Or http://www.cplusplus.com/reference/clibrary/cstdio/printf/

ptrcao
Dec 29th, 2010, 12:28 PM
Lol, it's not introduced by me, refer the table under the line "Type can be any of:" at http://en.wikipedia.org/wiki/Printf Or http://www.cplusplus.com/reference/clibrary/cstdio/printf/

I have to profess. I am not a programmer of any persuasion... I have only ever modified code under another's direction before.

It's a bit like wading into a minefield...

I'll try after I've studied the code a bit more...

ptrcao
Dec 29th, 2010, 01:39 PM
I'm not on Linux now, but that archive contains a file named eqn2img.c, and at line 285, there's

if(img_name)
printf("WIDTH=%i HEIGHT=%i STYLE=\"vertical-align: -%ipx; margin: 0;\"", new_width, new_height, baseline);
else /* image being written to stdout, use stderr instead */
fprintf(stderr, "WIDTH=%i HEIGHT=%i STYLE=\"vertical-align: -%ipx; margin: 0;\"", new_width, new_height, baseline);
I think, you may alter that line like

if(img_name)
printf("WIDTH=\"%i\" HEIGHT=\"%i\" alt=\"%s\" STYLE=\"vertical-align: -%ipx; margin: 0;\"", new_width, new_height, baseline,img_name);
else /* image being written to stdout, use stderr instead */
fprintf(stderr, "WIDTH=\"%i\" HEIGHT=\"%i\" STYLE=\"vertical-align: -%ipx; margin: 0;\"", new_width, new_height, baseline);
and re-make it.

PS: Untested!

I still basically need to figure out how to make the program generate an alt label that is the same as the image name. How do I do this?

sarenarichard
Dec 29th, 2010, 01:56 PM
Excellent, i will try this code.

teedoff
Dec 29th, 2010, 02:22 PM
Set the image name variable as the alt variable as well. Where are the dynamic image names coming from?

ptrcao
Dec 29th, 2010, 02:26 PM
Set the image name variable as the alt variable as well. Where are the dynamic image names coming from?

It's automatically generated; this program was written in perl which I have not learnt yet. You can download it and inspect the perl code then explain to me.

abduraooft
Dec 29th, 2010, 03:06 PM
Try
if(img_name)
printf("WIDTH=\"%i\" HEIGHT=\"%i\" alt=\"%s\" STYLE=\"vertical-align: -%ipx; margin: 0;\"", new_width, new_height, baseline,optarg);
else /* image being written to stdout, use stderr instead */
fprintf(stderr, "WIDTH=\"%i\" HEIGHT=\"%i\" STYLE=\"vertical-align: -%ipx; margin: 0;\"", new_width, new_height, baseline);

ptrcao
Dec 29th, 2010, 03:19 PM
Try
if(img_name)
printf("WIDTH=\"%i\" HEIGHT=\"%i\" alt=\"%s\" STYLE=\"vertical-align: -%ipx; margin: 0;\"", new_width, new_height, baseline,optarg);
else /* image being written to stdout, use stderr instead */
fprintf(stderr, "WIDTH=\"%i\" HEIGHT=\"%i\" STYLE=\"vertical-align: -%ipx; margin: 0;\"", new_width, new_height, baseline);

optarg? i'm not sure what it means. by appending optarg to that line, what have you done exactly?

abduraooft
Dec 29th, 2010, 04:31 PM
You need to reinstall (re-make ) the program (after making the changes given), to regenerate the html files. Have you done that?

abduraooft
Dec 29th, 2010, 04:53 PM

This version of gladTeX is different from gladTeX 0.3 in the following ways:
........
Adds alt property to <img> tags.
The alt property specifies a text equivalent for an image, which is important for visually impaired users, or for display on alternate devices or text-only browsers. The alt property is required under HTML 4.01. This version of GladTeX automatically adds the LaTeX form of the equation as the alt property. You can see the alt text by hovering your mouse over the equation image in many browsers.

tracknut
Dec 29th, 2010, 05:08 PM
I have a dilemma. After all the hard work it took to clean up hundreds of errors, I run a program to insert equations into my html and it commits hundreds of errors.

The good thing is many of the errors are repetitive, and the solutions include replacing uppercase tag names with lowercase; this can be done hundreds at a time using a text editor's find-and-replace function. Another easy fix was to close the image tags.

Just a note if it was not clear, the program you're using to create the equations is generating html, whereas your page is written in xhtml. An html doctype would not have generated the errors on the uppercase and closing tags. So another option you have (aside from the issue of alt tag, of course) is to use an html doctype instead. Unless there's some other need you have for xhtml?

Dave

ptrcao
Dec 29th, 2010, 11:45 PM
This version of gladTeX is different from gladTeX 0.3 in the following ways:
........
Adds alt property to <img> tags.
The alt property specifies a text equivalent for an image, which is important for visually impaired users, or for display on alternate devices or text-only browsers. The alt property is required under HTML 4.01. This version of GladTeX automatically adds the LaTeX form of the equation as the alt property. You can see the alt text by hovering your mouse over the equation image in many browsers.

Is this an option that has to be turned on somehow? By a commandline switch like "-a" or something?
All I know is it doesn't insert alt tags in by default, for whatever reason.
Another possibility is it could be a broken aspect of the program. I have encountered broken aspects before in this program...
Maybe someone could take a closer look and answer some of these questions.

EDIT: There is no reference to "alt" that I have seen in the program code anywhere.

ptrcao
Dec 29th, 2010, 11:53 PM
Just a note if it was not clear, the program you're using to create the equations is generating html, whereas your page is written in xhtml. An html doctype would not have generated the errors on the uppercase and closing tags. So another option you have (aside from the issue of alt tag, of course) is to use an html doctype instead. Unless there's some other need you have for xhtml?

Dave

I basically use strict xhtml because I don't ever want to have to rewrite a site that is tens of thousands of words long in case less strict html is phased out of use and no longer supported by browsers of the future.

I'll suggest to the developer to cater to to strictest case scenario for html so that way, it will be usable by all html coders.

For now I need some short-term solutions.

ptrcao
Dec 30th, 2010, 04:54 AM
You need to reinstall (re-make ) the program (after making the changes given), to regenerate the html files. Have you done that?

abduraooft,

So far I have tested inserting the double quotes before and after attribute values, and that seemed to do the trick. :)

However, I don't understand the oparg and img_name modifications you've made, and would try, but I don't know what to look out for because I don't know what these code edits are supposed to achieve. Could you please explain your modifications here...?

Thanks.

abduraooft
Dec 30th, 2010, 01:25 PM
Could you please explain your modifications here...? I'll try to explain, after you got it work. :)

<img width="87" height="47"
Though, I don't think the above change in the code would produce a result as shown in that site.

ptrcao
Dec 30th, 2010, 01:36 PM
I'll try to explain, of it works for you. :)

fair enough :) i'm not on a linux now though, so i'll get back to you soon on the results

ptrcao
Dec 30th, 2010, 03:24 PM
I'll try to explain, after you got it work. :)

Though, I don't think the above change in the code would produce a result as shown in that site.

Ok, with
if(img_name)
printf("WIDTH=\"%i\" HEIGHT=\"%i\" alt=\"%s\" STYLE=\"vertical-align: -%ipx; margin: 0;\"", new_width, new_height, baseline);
else /* image being written to stdout, use stderr instead */
fprintf(stderr, "WIDTH=\"%i\" HEIGHT=\"%i\" STYLE=\"vertical-align: -%ipx; margin: 0;\"", new_width, new_height, baseline);, I can't get beyond make and sudo make install without some warnings.

[email protected]:~/Downloads/gladtex-1.2$make gcc -O2 -DGIF -c eqn2img.c eqn2img.c: In function ‘main’: eqn2img.c:286: warning: format ‘%s’ expects type ‘char *’, but argument 4 has type ‘int’ eqn2img.c:286: warning: too few arguments for format gcc -O2 -DGIF -o eqn2img -lm -lz -lgif -lpng eqn2img.o [email protected]:~/Downloads/gladtex-1.2$ sudo make install
gcc -O2 -DGIF -c eqn2img.c
eqn2img.c: In function ‘main’:
eqn2img.c:286: warning: format ‘%s’ expects type ‘char *’, but argument 4 has type ‘int’
eqn2img.c:286: warning: too few arguments for format
gcc -O2 -DGIF -o eqn2img -lm -lz -lgif -lpng eqn2img.o
install -d /usr/local/bin
install -d /usr/local/share/man/man1
install -m 755 -s -t /usr/local/bin eqn2img
install -m 755 -t /usr/local/bin gladtex
install -m 644 -t /usr/local/share/man/man1 gladtex.1

And the execution fails:

[email protected]:~/eqns/pages/probability-1gladtex -v -f gif -d /home/peter/eqns/images/pages/probability-1/introduction introduction.htex Processing 1 files introduction.htex -> introduction.html Processing equation at line(s) 81 to 81: /home/peter/eqns/images/pages/probability-1/introduction/eqn001: tex -> dvi -> ps -> png -> Writing gif imageSegmentation fault Error processing equation starting at line 81: 0 Now, with if(img_name) printf("WIDTH=\"%i\" HEIGHT=\"%i\" alt=\"%s\" STYLE=\"vertical-align: -%ipx; margin: 0;\"", new_width, new_height, baseline, optarg); else /* image being written to stdout, use stderr instead */ fprintf(stderr, "WIDTH=\"%i\" HEIGHT=\"%i\" STYLE=\"vertical-align: -%ipx; margin: 0;\"", new_width, new_height, baseline); The make and sudo make install yields: [email protected]:~/Downloads/gladtex-1.2 make
gcc -O2 -DGIF -c eqn2img.c
eqn2img.c: In function ‘main’:
eqn2img.c:286: warning: format ‘%s’ expects type ‘char *’, but argument 4 has type ‘int’
eqn2img.c:286: warning: format ‘%i’ expects type ‘int’, but argument 5 has type ‘char *’
gcc -O2 -DGIF -o eqn2img -lm -lz -lgif -lpng eqn2img.o

[email protected]:~/Downloads/gladtex-1.2$sudo make install gcc -O2 -DGIF -o eqn2img -lm -lz -lgif -lpng eqn2img.o install -d /usr/local/bin install -d /usr/local/share/man/man1 install -m 755 -s -t /usr/local/bin eqn2img install -m 755 -t /usr/local/bin gladtex install -m 644 -t /usr/local/share/man/man1 gladtex.1 And execution fails: [email protected]:~/eqns/pages/probability-1$ gladtex -v -f gif -d /home/peter/eqns/images/pages/probability-1/introduction introduction.htex
Processing 1 files

introduction.htex -> introduction.html
Processing equation at line(s) 81 to 81:
/home/peter/eqns/images/pages/probability-1/introduction/eqn000: tex -> dvi -> ps -> png -> Writing gif imageSegmentation fault
Error processing equation starting at line 81:
0

Well, what do you make of it abduraooft?

By the way, do you know Latex markup for math? You can try directly a very simple series of equations in a html file yourself, enclosed inside <eq> ... </eq> and Gladtex will produce the corresponding image tags, if it is programmed correctly.

The main thing at this stage, to refocus our efforts, is I want the generated alt labels to be the same as for the generated image names. That's the goal.

ptrcao
Dec 30th, 2010, 03:43 PM
I should clarify.

The image names, automatically generated, are of the form "eqnXXX", where "XXX" is "001", "002", "003", ... etc.

I want automatically generated alt labels of the form "eqnXXX.gif". For example, alt="eqn001.gif" would feature in the first image tag.

abduraooft
Dec 30th, 2010, 04:48 PM
By the way, do you know Latex markup for math? You can try directly a very simple series of equations in a html file yourself, enclosed inside <eq> ... </eq> and Gladtex will produce the corresponding image tags, if it is programmed correctly.
I know the basics, but I need to switch to an Ubuntu machine and then configure latex and other Gif packages there to run this program

My assumptions on the function getopt() and value of optarg were wrong. :-(

Running out of time. Here's another trial for you

if(img_name)
printf("WIDTH=\"%i\" HEIGHT=\"%i\" alt=\"%s\" STYLE=\"vertical-align: -%ipx; margin: 0;\"", new_width, new_height, baseline, argv[2]);

You'd need to test by incrementing the reference of array argv, depending upon how the program is getting called by the Perl script (which I'm not sure about)

ptrcao
Dec 30th, 2010, 11:42 PM
You'd need to test by incrementing the reference of array argv, depending upon how the program is getting called by the Perl script (which I'm not sure about)

I don't know enough about Perl or programming in general to follow what you are saying here. :( All I can do is follow your directions - and they have to be explicit - including any special additional measures that need to be taken regarding incrementing...

ptrcao
Dec 31st, 2010, 02:22 AM
Ok, this is with

if(img_name)
printf("WIDTH=\"%i\" HEIGHT=\"%i\" alt=\"%s\" STYLE=\"vertical-align: -%ipx; margin: 0;\"", new_width, new_height, baseline, argv[2]);

[email protected]:~/Downloads/gladtex-1.2$make gcc -O2 -DGIF -c eqn2img.c eqn2img.c: In function ‘main’: eqn2img.c:286: warning: format ‘%s’ expects type ‘char *’, but argument 4 has type ‘int’ eqn2img.c:286: warning: too few arguments for format gcc -O2 -DGIF -o eqn2img -lm -lz -lgif -lpng eqn2img.o [email protected]:~/Downloads/gladtex-1.2$ sudo make install
gcc -O2 -DGIF -o eqn2img -lm -lz -lgif -lpng eqn2img.o
install -d /usr/local/bin
install -d /usr/local/share/man/man1
install -m 755 -s -t /usr/local/bin eqn2img
install -m 755 -t /usr/local/bin gladtex
install -m 644 -t /usr/local/share/man/man1 gladtex.1
[email protected]:~/Downloads/gladtex-1.2$make gcc -O2 -DGIF -c eqn2img.c eqn2img.c: In function ‘main’: eqn2img.c:286: warning: format ‘%s’ expects type ‘char *’, but argument 4 has type ‘int’ eqn2img.c:286: warning: format ‘%i’ expects type ‘int’, but argument 5 has type ‘char *’ gcc -O2 -DGIF -o eqn2img -lm -lz -lgif -lpng eqn2img.o [email protected]:~/Downloads/gladtex-1.2$ sudo make install
gcc -O2 -DGIF -o eqn2img -lm -lz -lgif -lpng eqn2img.o
install -d /usr/local/bin
install -d /usr/local/share/man/man1
install -m 755 -s -t /usr/local/bin eqn2img
install -m 755 -t /usr/local/bin gladtex
install -m 644 -t /usr/local/share/man/man1 gladtex.1

[email protected]:~/eqns/pages/probability-1gladtex -v -f gif -d /home/peter/eqns/images/pages/probability-1/introduction introduction.htex Processing 1 files introduction.htex -> introduction.html Processing equation at line(s) 81 to 81: /home/peter/eqns/images/pages/probability-1/introduction/eqn000: tex -> dvi -> ps -> png -> Writing gif imageSegmentation fault Error processing equation starting at line 81: 0 Now, I don't know if this helps since I didn't increment the reference of array argv because I don't know what that means! abduraooft Dec 31st, 2010, 10:15 AM eqn2img.c - line 285 if(img_name) printf("width=\"%i\" height=\"%i\" style=\"vertical-align: -%ipx; margin: 0;\" ", new_width, new_height, baseline); gladtex- line 306 print OUTPUT "<img src=\"".img_src.$history{$equation}->{"img"}."\" "
.$history{$equation}->{"dim"}." alt=\"$img_name.$format\">";

ptrcao
Dec 31st, 2010, 11:24 AM
eqn2img.c - line 285
if(img_name)
printf("width=\"%i\" height=\"%i\" style=\"vertical-align: -%ipx; margin: 0;\" ", new_width, new_height, baseline);

print OUTPUT "<img src=\"".$img_src.$history{$equation}->{"img"}."\" " .$history{$equation}->{"dim"}." alt=\"$img_name.format\">"; Seems like that's done it! abduraooft you genius. As always one needs to be vigilant for bugs following changes, but so far so good. Every post will be credited with Thanks. To you and all other guru regulars (perhaps Excavator deserves particular mention) reading this, thanks a lot for your help this year and Happy 2011! Where I am the countdown and fireworks is only a couple of hours away. I will no doubt see you folks again over the other side of 2010. :) EDIT: Sorry! Spoke too soon. There is a discrepancy, read the next post. The saga continues! ptrcao Dec 31st, 2010, 11:51 AM eqn2img.c - line 285 if(img_name) printf("width=\"%i\" height=\"%i\" style=\"vertical-align: -%ipx; margin: 0;\" ", new_width, new_height, baseline); gladtex- line 306 print OUTPUT "<img src=\"".img_src.$history{$equation}->{"img"}."\" "
.$history{$equation}->{"dim"}." alt=\"$img_name.$format\">";

Ah, but wait, there is a minor oversight! There is a discrepancy in images that are reused.

Check out the source code at http://www.mathannotated.com/pages/probability-1/introduction.html and see what I mean. Just keep reading until you see a discrepancy between alt and image src.

See, some images get recycled when they recur. The program is smart enough not to regenerate identical images, and reuses old images. We would need to make the alt match to what is actually used, not the current counting order. It seems that whenever the image gets recycled, the img_name reiterates whatever was the last count, while the image src corresponds to a previous image. Here a discrepancy arises.

Help?

abduraooft
Dec 31st, 2010, 12:45 PM
print OUTPUT "<img src=\"".$img_src.$history{$equation}->{"img"}."\" " .$history{$equation}->{"dim"}." alt=\"".$history{$equation}->{"img"}."\">";? ptrcao Dec 31st, 2010, 01:03 PM print OUTPUT "<img src=\"".$img_src.$history{$equation}->{"img"}."\" "
.$history{$equation}->{"dim"}." alt=\"".$history{$equation}->{"img"}."\">";?

Haha. Very good abduraooft, seems to have done the trick. :D I salute you.

abduraooft
Jan 17th, 2011, 02:01 PM
A little late, though I think you might get interested in MathJax (http://www.mathjax.org/)

ptrcao
Jan 17th, 2011, 06:39 PM
A little late, though I think you might get interested in MathJax (http://www.mathjax.org/)

It's never too late abduraooft. :) Surprised I haven't heard of it before as I've been on the scene a little while now. Well-spotted abduraooft. If it is a server run program that automatically applys latex markup then you have solved a major problem of mine. As you know GladTEX is not a server-side program, and this creates the problem for me of having to maintain and manually update two separate versions of all my html pages (one with image tags and another with the original markup). This issue has hampered my site's development for some time now, so I hope MathJax does do its job as a server-side application. Then I could just leave all my files in markup, knowing it'll be rendered on demand. Though I worry a little that this will create more work for my server. I will definitely look furhter into this. Thanks a dozen abduraooft. :)

ptrcao
Jan 17th, 2011, 06:49 PM
btw i posted a description of the limitations of current solutions in a related thread:

http://www.codingforums.com/showpost.php?p=1040479&postcount=12

if anyone solves this long-running problem for me, i'll make a personal mention of them by way of thanks on my website.

abduraooft
Jan 18th, 2011, 07:59 AM
Mathjax is not a serverside program. It's a javascript program that dynamically creates html elements and then apply some position and other styles at the browser/client side.