GedzyukAnatolyu / phpquery

Automatically exported from code.google.com/p/phpquery
0 stars 0 forks source link

xhtml tags getting converted to html #133

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create a pq object from '<br/>'.
2. Print the object.
SAMPLE CODE
$content = phpQuery::newDocument('<br/>');
print $content;

What is the expected output? What do you see instead?
expected: <br/>
actual: <br>
For full XHTML pages, this causes serious formatting problems.

What version of the product are you using? On what operating system?
0.9.5.386

Original issue reported on code.google.com by adamp...@gmail.com on 19 Sep 2009 at 6:12

GoogleCodeExporter commented 8 years ago
Try this one:
- $content = phpQuery::newDocument('<br/>');
+ $content = phpQuery::newDocumentXML('<br/>');

http://www.google.com/codesearch?q=newdocumentxml+package%3Ahttp%3A%2F%2Fphpquer
y\.googlecode\.com&origq=newdocumentxml&btnG=Search+Trunk

Original comment by tobiasz....@gmail.com on 19 Sep 2009 at 6:06

GoogleCodeExporter commented 8 years ago
Ah.  Thanks.  Not sure that will solve my problem, but at least that explains 
what's
going on.  

Original comment by adamp...@gmail.com on 20 Sep 2009 at 4:00

GoogleCodeExporter commented 8 years ago
Expired. Please reopen if proposed solution doesn't work.

In future it's possible to implement dirty XML-autodetection by strpos of "/>". 
But
for now dedicated methods, XML declaration checking and MIME type dispatching 
should
be enough.

Original comment by tobiasz....@gmail.com on 10 Oct 2009 at 9:01

GoogleCodeExporter commented 8 years ago
I'm experiencing this same issue. I'm using phpQuery to load partial XHTML 
chunks
(template markup--just what's in the body, navigation lists, other chunks of 
markup).
I then combine them all into a single document that's output inside a standard
html/head wrapper that has an XHTML doctype.

phpQuery wouldn't let me load the template markup as XML or XHTML. Both said 
they
were invalid. There is a wrapping div, but that didn't seem to be the problem.

What I've done for now is use the tidy extension to cleanup the markup...which 
is
another processing hit, so not ideal.

Here's the code ($t is a phpQuery object with the combined template markup):
<code>
$tidy_config = array('output-xhtml'   => true);

$tidy = new tidy;
$tidy->parseString($t->htmlOuter(), $tidy_config, 'utf8');
$tidy->cleanRepair();

// Output
$final = phpQuery::newDocumentXHTML($tidy);
print $final['body']->html();
</code>

Not ideal, but we're validating now. I'd love to see a configuration option or a
method that would output any markup as XHTML. I often get markup from various
sources, but I always want them out as XHTML.

Thanks, Tobiasz.

Original comment by bigbluehat on 11 Nov 2009 at 3:52

GoogleCodeExporter commented 8 years ago
Please provide XML markup that causes the problem for the reference.

I suppose what you need is customizable output covered by issue 85. Performance 
overhead there could be (probably) reduced by making the copy on nodes level, 
instead 
of string markup.

In this issue please report valid XML code that's not handled properly.

Original comment by tobiasz....@gmail.com on 11 Nov 2009 at 4:33

GoogleCodeExporter commented 8 years ago
Here's the XML markup I'm currently fighting. After looking through the 
attached code
again, it may be the &'s and named entities that are causing the issue.

Sorry I missed issue 85 earlier. That's exactly what I need, I think.

Original comment by bigbluehat on 13 Nov 2009 at 3:05

Attachments: