Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
1k views
in Q2A Core by

I discovered the notice in some of my questions' html:

<!--
It's no big deal, but your HTML could not be indented properly. To fix, please:
1. Use this->output() to output all HTML.
2. Balance all paired tags like <TD>...</TD> or <DIV>...</DIV>.
3. Use a slash at the end of unpaired tags like <img/> or <input/>.
Thanks!
-->


and remembered the hack to surpress it.

However, I'd like to know what is the root of this problem. It must be the advanced theme I have created. But the error appears not in every question. How can I find the error quickly?

1. question without notice: http://www.gute-mathe-fragen.de/2972/

2. question with this notice: http://www.gute-mathe-fragen.de/2942/

 

PS: In my theme I am always using $this->output(''); and I think everything is balanced (open-closed-tags). I am also closing unpaired tags such as input. There might be another problem...

by
This could occur because of some question content, and was fixed in Q2A 1.5.3.
by
Hi gid, thx for the answer. I upgraded to 1.5.3 this morning, so this might be a bug in 1.5.1 - 1.5.3 then.
by
I swapped themes to counter check, this error only appears in my theme! The snow theme is fine. I try to figure out the problem and report back.
by
alright, found out what was causing the problem finally. It is the 'official' remove nofollow hack, see my answer below.

And again you and me get stung by the nofollow-bee...

2 Answers

0 votes
by
edited by

This error was due to the proposed hack of removing the nofollow tag from content by parsing the content.

In advanced theme:

// remove nofollow from links in content
function _remove_nofollow( $str ) {
    $search = '#<a rel="nofollow" href="http://www.echteinfach.tv("|/[^"]*")#i';
    $replace = '<a href="http://www.echteinfach.tv\1';
    return preg_replace( $search, $replace, $str );
}        
function q_view_content($q_view) {
    if (!empty($q_view['content']))
        $this->output(
            '<DIV CLASS="qa-q-view-content">',
            $this->_remove_nofollow( $q_view['content'] ),
            '</DIV>'
        );
}
function a_item_content($a_item) {
    $this->output(
        '<DIV CLASS="qa-a-item-content">',
        $this->_remove_nofollow( $a_item['content'] ),
        '</DIV>'
    );
}
function c_item_content($c_item) {
    $this->output(
        '<SPAN CLASS="qa-c-item-content">',
        $this->_remove_nofollow( $c_item['content'] ),
        '</SPAN>'
    );
}

commented out and now it works. Reduced 41 html validation errors to 25.

0 votes
by

your error is due to a unpaired tag like a <img src=""> or even <meta title=""> if you have found that your custom code is fine, then it is within the theme-base code. so lets take a look. .00.

Try using Firefox for html source checking, anything in red text in the source view is not closing properly for the browser.  Does that make sense for you . Okay so the solution.

You have to change the code in.

OPEN:

qa-theme-base.php

LINE:

185  function doctype()

ADD:

at the end on the unpaired tag add /

so it looks like this.

$this->output('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"/>');

* notice the trailing slash at the end, it was missing in the main code.

 

Hope thiswas helpful.

Please vote me as best answer if this is your fix.

 

by
Thanks for the advice. However, as I wrote, my problem came from parsing the content.

PS: <!DOCTYPE html> never has a closing tag. See http://en.wikipedia.org/wiki/Doctype#Example If you check the html source here on this site, you will see that doctype is not closed either :) ... and there is no notice in the code.
...