9

I found this question, which seems to suggest I can just paste in my HTML, but when I try that it just looks like HTML, it does not render. Below is what I am pasting in:

<pre style="background:rgba(238,238,238,0.92);color:#000">&lt;?php
$stmt <span style="color:#00f">=</span> $dbConnection<span style="color:#00f">-></span>prepare(<span style="color:#093">'<span style="color:#00f">SELECT</span> <span style="color:#00f">*</span> <span style="color:#00f">FROM</span> employees <span style="color:#00f">WHERE</span> name <span style="color:#00f">=</span> ?'</span>);
$stmt<span style="color:#00f">-></span>bind_param(<span style="color:#093">'s'</span>, $name);

$stmt<span style="color:#00f">-></span>execute();

$result <span style="color:#00f">=</span> $stmt<span style="color:#00f">-></span>get_result();
<span style="color:#00f">while</span> ($row <span style="color:#00f">=</span> $result<span style="color:#00f">-></span>fetch_assoc()) {
    <span style="color:#06f;font-style:italic">// do something with $row</span>
}
?>
</pre>

Does anyone know what I need to do to get it to actually render?

  • 1
    Are you actually trying to embed some PHP code with highlighting? – Tom Horwood Oct 4 '13 at 12:30
  • Yes exactly. Just to clarify, I don't expect it to execute or anything. I just want to have PHP code on the page with colored text. – Abe Miessler Oct 4 '13 at 15:07
3

Google docs won't actually render HTML, or execute any code pasted into it. What you can do is view your HTML as a page in the browser, which will show:

php code

Copy it from the web page, then paste into your document - it will look like this:

PHP pasted to Google docs

The question you referred to was for people who wanted to present their HTML code within the document with syntax highlighting, not have it rendered.

1

I always do this and it works for me.

  1. Save the HTML file as it is, just save it as HTML.
  2. Open the saved file (HTML) with Word.
  3. Save it as Word format i.e DOC or DOCX.
  4. Upload the saved word file into Google Docs.

That's it.

0

Open the page in the browser so it renders normally. Then press ctrl+A and ctrl+C in the browser. Now go to Google Docs and press ctrl+V.

Google Docs will try to render the html as it is seen in the browser, but is not perfect. You will need to make manual adjustments to get it exactly right.

New contributor
async3 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
-2

Add Editey apps to your Google Drive. (Editey, CSS Editey, HTML Editey and JsEditey).

"editEy apps on google drine

  • Why don't you show us an example of prettified HTML code in a Google Document? – Jacob Jan Tuinstra Jan 4 '14 at 18:41
  • Are you affiliated with this product? If so, you need to disclose that in your post. Please see the help center. – ale Jan 4 '14 at 19:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.