Skip to content

Commit e7a5874

Browse files
committed
Add upperDoctype option
1 parent 220fdfb commit e7a5874

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

Diff for: lib/doctype.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22

33
module.exports = doctype
44

5+
var docLower = 'doctype'
6+
var docUpper = docLower.toUpperCase()
7+
58
// Stringify a doctype `node`.
69
function doctype(ctx, node) {
10+
var doc = ctx.upperDoctype ? docUpper : docLower
711
var sep = ctx.tightDoctype ? '' : ' '
812
var name = node.name
913
var pub = node.public
1014
var sys = node.system
11-
var val = ['<!doctype']
15+
var val = ['<!' + doc]
1216

1317
if (name) {
1418
val.push(sep, name)

Diff for: lib/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ function toHtml(node, options) {
4040
alternative: smart ? alternative : null,
4141
unquoted: Boolean(settings.preferUnquoted),
4242
tight: settings.tightAttributes,
43+
upperDoctype: Boolean(settings.upperDoctype),
4344
tightDoctype: Boolean(settings.tightDoctype),
4445
tightLists: settings.tightCommaSeparatedLists,
4546
tightClose: settings.tightSelfClosing,

Diff for: readme.md

+5
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ Tag names of [*elements*][element] to stringify without closing tag
7070

7171
Not used in the SVG space.
7272

73+
###### `options.upperDoctype`
74+
75+
Use an `<!DOCTYPE…` instead of `<!doctype…`.
76+
Useless except for XHTML (`boolean`, default: `false`).
77+
7378
###### `options.quote`
7479

7580
Preferred quote to use (`'"'` or `'\''`, default: `'"'`).

Diff for: test/doctype.js

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ test('`text`', function(t) {
2323
'should stringify doctypes with `name` tightly in `tightDoctype` mode'
2424
)
2525

26+
t.deepEqual(
27+
to(u('doctype', {name: 'html'}), {upperDoctype: true}),
28+
'<!DOCTYPE html>',
29+
'should stringify uppercase doctypes in `upperDoctype` mode'
30+
)
31+
2632
t.deepEqual(
2733
to(
2834
u('doctype', {

0 commit comments

Comments
 (0)