Ampersands?

29 views
Skip to first unread message

jgill

unread,
Feb 17, 2020, 10:13:17 AM2/17/20
to BBEdit Talk
Hi,

I'm writing a web page that inserts specific emoji into a text box with Javascript.

<a href="javascript:doEmoji('&#x1F536')">&#x1F536</a> &nbsp;

This works perfectly as expected but BBEdit is insisting that I need to change the ampersands to &amp; and if I format the page, it changes all my ampersands to &amp; and breaks the Javascript.

How can I write this to make the syntax checker happy?

Tia.

Joe

Kerri Hicks

unread,
Feb 17, 2020, 10:25:03 AM2/17/20
to bbe...@googlegroups.com
Hi Joe,

I copied your code into a new BBEdit HTML document. When I added a semicolon to the end of that entity (as is customary for entities), the syntax checker found no errors, and the emoji rendered as expected.

Hope this helps.
--Kerri

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbedit/ef2e9d15-222e-4aab-b8bc-686a8d8a40d4%40googlegroups.com.

jgill

unread,
Feb 17, 2020, 10:29:46 AM2/17/20
to BBEdit Talk
Slaps head!

Thank you Kerri, I should have spotted that.

On Monday, February 17, 2020 at 3:25:03 PM UTC, Kerri Hicks wrote:
Hi Joe,

I copied your code into a new BBEdit HTML document. When I added a semicolon to the end of that entity (as is customary for entities), the syntax checker found no errors, and the emoji rendered as expected.

Hope this helps.
--Kerri

On Mon, Feb 17, 2020 at 10:13 AM jgill <joegille...@gmail.com> wrote:
Hi,

I'm writing a web page that inserts specific emoji into a text box with Javascript.

<a href="javascript:doEmoji('&#x1F536')">&#x1F536</a> &nbsp;

This works perfectly as expected but BBEdit is insisting that I need to change the ampersands to &amp; and if I format the page, it changes all my ampersands to &amp; and breaks the Javascript.

How can I write this to make the syntax checker happy?

Tia.

Joe

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbe...@googlegroups.com.

Sam Hathaway

unread,
Feb 17, 2020, 10:30:04 AM2/17/20
to BBEdit Talk

I agree with Kerri that you need semicolons at the ends of your entities.

But to avoid multi-level escaping confusion altogether, use JavaScript string literal unicode escapes in your JavaScript code, like so:

<a href="javascript:doEmoji('\u{1F536}')">&#x1F536;</a> &nbsp;

Hope this helps.
-sam

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+un...@googlegroups.com.

jgill

unread,
Feb 17, 2020, 10:35:42 AM2/17/20
to BBEdit Talk
Great suggestion, Sam. Thanks.


On Monday, February 17, 2020 at 3:30:04 PM UTC, Sam Hathaway wrote:

I agree with Kerri that you need semicolons at the ends of your entities.

But to avoid multi-level escaping confusion altogether, use JavaScript string literal unicode escapes in your JavaScript code, like so:

<a href="javascript:doEmoji('\u{1F536}')">&#x1F536;</a> &nbsp;

Hope this helps.
-sam

On 17 Feb 2020, at 10:13, jgill wrote:

Hi,

I'm writing a web page that inserts specific emoji into a text box with Javascript.

<a href="javascript:doEmoji('&#x1F536')">&#x1F536</a> &nbsp;

This works perfectly as expected but BBEdit is insisting that I need to change the ampersands to &amp; and if I format the page, it changes all my ampersands to &amp; and breaks the Javascript.

How can I write this to make the syntax checker happy?

Tia.

Joe

--
This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "sup...@barebones.com" rather than posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
---
You received this message because you are subscribed to the Google Groups "BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages