* -Thtml: Use hexadecimal character references
@ 2017-07-14 1:05 Anthony J. Bentley
2017-07-14 12:37 ` Ingo Schwarze
0 siblings, 1 reply; 2+ messages in thread
From: Anthony J. Bentley @ 2017-07-14 1:05 UTC (permalink / raw)
To: tech
Hi,
Since Unicode codepoints are universally referred to in hexadecimal,
this would make the HTML source easier to reason about while debugging.
I have learned many hexadecimal codepoints over the years, but not a
single one in decimal.
The longest character reference, "", is the same length as
"", so numbuf doesn't need to be increased in size.
Index: html.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/html.c,v
retrieving revision 1.85
diff -u -p -r1.85 html.c
--- html.c 23 Jun 2017 02:31:39 -0000 1.85
+++ html.c 13 Jul 2017 16:11:23 -0000
@@ -451,7 +451,7 @@ print_encode(struct html *h, const char
(c > 0x7E && c < 0xA0))
c = 0xFFFD;
if (c > 0x7E) {
- (void)snprintf(numbuf, sizeof(numbuf), "&#%d;", c);
+ (void)snprintf(numbuf, sizeof(numbuf), "&#x%x;", c);
print_word(h, numbuf);
} else if (print_escape(h, c) == 0)
print_byte(h, c);
@@ -514,7 +514,7 @@ print_otag(struct html *h, enum htmltag
print_indent(h);
else if ((h->flags & HTML_NOSPACE) == 0) {
if (h->flags & HTML_KEEP)
- print_word(h, " ");
+ print_word(h, " ");
else {
if (h->flags & HTML_PREKEEP)
h->flags |= HTML_KEEP;
@@ -777,7 +777,7 @@ print_text(struct html *h, const char *w
h->flags |= HTML_KEEP;
print_endword(h);
} else
- print_word(h, " ");
+ print_word(h, " ");
}
assert(NULL == h->metaf);
--
To unsubscribe send an email to tech+unsubscribe@mandoc.bsd.lv
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: -Thtml: Use hexadecimal character references
2017-07-14 1:05 -Thtml: Use hexadecimal character references Anthony J. Bentley
@ 2017-07-14 12:37 ` Ingo Schwarze
0 siblings, 0 replies; 2+ messages in thread
From: Ingo Schwarze @ 2017-07-14 12:37 UTC (permalink / raw)
To: Anthony J. Bentley; +Cc: tech
Hi,
Anthony J. Bentley wrote on Thu, Jul 13, 2017 at 07:05:36PM -0600:
> Since Unicode codepoints are universally referred to in hexadecimal,
> this would make the HTML source easier to reason about while debugging.
> I have learned many hexadecimal codepoints over the years, but not a
> single one in decimal.
I agree. But codepoints conventionally use capital hex digits
and at least four of them.
Feel free to commit in the following form, if you agree,
and i'll merge to bsd.lv and adjust the test suite.
Thanks,
Ingo
Index: html.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/html.c,v
retrieving revision 1.85
diff -u -p -r1.85 html.c
--- html.c 23 Jun 2017 02:31:39 -0000 1.85
+++ html.c 14 Jul 2017 12:33:16 -0000
@@ -451,7 +451,7 @@ print_encode(struct html *h, const char
(c > 0x7E && c < 0xA0))
c = 0xFFFD;
if (c > 0x7E) {
- (void)snprintf(numbuf, sizeof(numbuf), "&#%d;", c);
+ (void)snprintf(numbuf, sizeof(numbuf), "&#x%.4X;", c);
print_word(h, numbuf);
} else if (print_escape(h, c) == 0)
print_byte(h, c);
@@ -514,7 +514,7 @@ print_otag(struct html *h, enum htmltag
print_indent(h);
else if ((h->flags & HTML_NOSPACE) == 0) {
if (h->flags & HTML_KEEP)
- print_word(h, " ");
+ print_word(h, " ");
else {
if (h->flags & HTML_PREKEEP)
h->flags |= HTML_KEEP;
@@ -777,7 +777,7 @@ print_text(struct html *h, const char *w
h->flags |= HTML_KEEP;
print_endword(h);
} else
- print_word(h, " ");
+ print_word(h, " ");
}
assert(NULL == h->metaf);
--
To unsubscribe send an email to tech+unsubscribe@mandoc.bsd.lv
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-07-14 12:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-14 1:05 -Thtml: Use hexadecimal character references Anthony J. Bentley
2017-07-14 12:37 ` Ingo Schwarze
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).