Influencing the encoding for pages served by meteor? - meteor

How can I set a encoding for my pages served with meteor? Currently my Firefox keeps on outputting this warning:
The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must to be declared in the document or in the transfer protocol.

Just set your encoding inside any <head> section of a html file:
<head>
<meta charset="UTF-8">
<title>Whatever</title>
</head>
From Meteor's documentation:
HTML files in a Meteor application are treated quite a bit differently
from a server-side framework. Meteor scans all the HTML files in your
directory for three top-level elements: <head>, <body>, and
<template>. The head and body sections are separately concatenated
into a single head and body, which are transmitted to the client on
initial page load.

Related

Knitr XHTML won't render in browser when MIME is XHTML

The header of a Knitr generated HTML file states the resulting document is XHTML-compliant:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
However, if the MIME type is reported as XHTML to IE/Chrome/Firefox browsers it will not render due to XML errors. Easily confirmed by changing the extension of a generated file to xhtml and opening directly in a browser.
Normally this isn't an issue as the extension is set to html. But we have automated processes on our servers to generate knitr files and autodetect the MIME type by examining the file and checking whether it claims to be XHTML, then set the MIME accordingly. Which causes the knitr files to fail to render in browsers for the reasons stated above.
How can I drop the xmlns attribute from knitr generated files?

How does Meteor decide the order of HTML elements?

Meteor parses all of the HTML files in your app folder and identifies
three top-level tags: <head>, <body>, and <template>. Everything
inside any <head> tags is added to the head section of the HTML sent
to the client, and everything inside <body> tags is added to the body
section, just like in a regular HTML file.
My question is, if I have a.html:
<body><h1>Hello</h1></body>
and b.html:
<body><h1>Goodbye</h1></body>
How does Meteor figure out the order of elements to load?

Formatting Text in Resource file

I have a site that sends a variety of different emails. these are stored in a resx file. (The emails are sent as text not html, or else I suspect that what I am asking would be a lot easier)
I have now been asked to make some of the text in one of the emails bold. so that, for example I can have
We can accept your decision now... instead of We can accept your decision now...
I have tried creating my formatted text in word, and then cutting / pasting it into the resource file, but that strips out all the encoding.
Is there any way of storing formatting within the file, or do I need to rethink my approach? (In which case, I guess I either split the email into fragments, and when I am assembling the final string, I apply a font style to the relevent fragments, or I store my formatted emails in files and folders, and load them as required.)
You should insert HTML in your text , "<b> We can ac...</b>" will result in bold text in the receivers end.
If you don't want to use a HTML format, you should create your email in a RTF format. It is not possible to bold your text if you are sending just a plain email. How to send it depends on the library you use for sending emails.
I've sent a RTF formatted email (with normal and bold text) from MS Outlook 2013, and the source code looks like that (similar like in HTML):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-2">
<META NAME="Generator" CONTENT="MS Exchange Server version rmj.rmm.rup.rpr">
<TITLE>Test</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->
<P DIR=LTR><SPAN LANG="pl"></SPAN><SPAN LANG="en-us"><FONT FACE="Calibri">We can accept your decision now...</FONT></SPAN><SPAN LANG="pl"></SPAN><SPAN LANG="en-us"></SPAN></P>
<P DIR=LTR><SPAN LANG="pl"><B></B></SPAN><B><SPAN LANG="en-us"><FONT FACE="Calibri">We can accept your decision now...</FONT></SPAN></B><SPAN LANG="pl"><B></B></SPAN><B><SPAN LANG="en-us"></SPAN></B></P>
</BODY>
</HTML>

Meta tag not in first 1024 bytes

Caveat: Before someone goes and marks this as duplicate of this, please understand that it is not. The accepted answer is exactly what I am doing, yet I am facing the following issue.
HTML file in client folder looks like this:
<head>
<meta charset="utf-8"/>
<title>blah-blah</title>
---
The message I am getting in the firebug console is:
The character encoding declaration of the HTML document
was not found when prescanning the first 1024 bytes of
the file. When viewed in a differently-configured browser,
this page will reload automatically. The encoding
declaration needs to be moved to be within the first
1024 bytes of the file.
When I do a view source, between the head and the meta charset element, I see a whole bunch of link stylesheet and script tags.
If I remove the meta charset, I get this in the firebug console:
The character encoding of the HTML document was not
declared. The document will render with garbled text
in some browser configurations if the document
contains characters from outside the US-ASCII range.
The character encoding of the page must to be declared
in the document or in the transfer protocol.
How do I get the meta charset tag to appear right after the head?
What I did was edit /usr/lib/meteor/app/lib/app.html.in, and add the meta charset line so that the file now looks like this:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/> //**Added this line**
{{#each stylesheets}} <link rel="stylesheet" href="{{this}}">
{{/each}}
...
And of course I removed the meta charset line from my html files.
I think right now, this would be the way to go and this will be resolved in future revisions.
I had the problem in IE to force to use the latest version.
I had to add
<meta http-equiv="x-ua-compatible" content="IE=edge">
Directly behind the tag. And app.html.in seems not to be used anymore.
So I did this on tools/latest/tools/bundler.js
Line 783
'<head><meta http-equiv="x-ua-compatible" content="IE=edge">\n');
That forced it to add it in the html boilerplate.

Why single textarea mess all following xhtml?

I encounter a problem in my web program. I got a textarea in my form, sometimes there is nothing in textarea, so genshi template engine just output it as
<textarea xxxx />
and here comes the problem, all following tags are in the textarea. Why all browser can't handle single textarea correctly?
If I write it as
<textarea xxxx></textarea>
and everything works fine. Why a single textarea messes following tags in xhtml?
Because you are, presumably, serving your XHTML with a text/html Content-type and causing it to be processed as HTML. XML style self-closing tags do not exist in HTML (so you have to use explicit start and end tags, except where they are forbidden (e.g. end tags on img) or optional (e.g. start and end tags on the body element).
If you want to have your pages processed as XHTML then serve as application/xhtml+xml (and kiss goodbye to support from Internet Explorer).
(This is why I stick to HTML 4.01 for most projects)
See http://www.w3.org/TR/xhtml-media-types/ for more details (including the full set of compatibility guidelines to munge your XHTML into a shape where HTML user agents can cope with it).

Resources