Skip to content

Commit 7f91d06

Browse files
committed
Change fences default to true
Closes GH-49.
1 parent 019f25f commit 7f91d06

File tree

4 files changed

+38
-32
lines changed

4 files changed

+38
-32
lines changed

lib/types.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,8 @@
344344
* Marker to use for emphasis (default: `'*'`).
345345
* @property {'`' | '~' | null | undefined} [fence='`']
346346
* Marker to use for fenced code (default: ``'`'``).
347-
* @property {boolean | null | undefined} [fences=false]
348-
* Whether to use fenced code always (default: `false`).
347+
* @property {boolean | null | undefined} [fences=true]
348+
* Whether to use fenced code always (default: `true`).
349349
*
350350
* The default is to use fenced code if there is a language defined, if the
351351
* code is empty, or if it starts or ends in blank lines.

lib/util/format-code-as-indented.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111
export function formatCodeAsIndented(node, state) {
1212
return Boolean(
13-
!state.options.fences &&
13+
state.options.fences === false &&
1414
node.value &&
1515
// If there’s no info…
1616
!node.lang &&

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ Marker to use for fenced code (``'`'`` or `'~'`, default: ``'`'``).
374374

375375
###### `options.fences`
376376

377-
Whether to use fenced code always (`boolean`, default: `false`).
377+
Whether to use fenced code always (`boolean`, default: `true`).
378378
The default is to use fenced code if there is a language defined, if the code is
379379
empty, or if it starts or ends in blank lines.
380380

test/index.js

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,17 @@ test('core', async function (t) {
117117
'should inject HTML comments between lists and an indented code',
118118
async function () {
119119
assert.equal(
120-
to({
121-
type: 'root',
122-
children: [
123-
{type: 'code', value: 'a'},
124-
{type: 'list', children: [{type: 'listItem', children: []}]},
125-
{type: 'code', value: 'b'}
126-
]
127-
}),
120+
to(
121+
{
122+
type: 'root',
123+
children: [
124+
{type: 'code', value: 'a'},
125+
{type: 'list', children: [{type: 'listItem', children: []}]},
126+
{type: 'code', value: 'b'}
127+
]
128+
},
129+
{fences: false}
130+
),
128131
' a\n\n*\n\n<!---->\n\n b\n'
129132
)
130133
}
@@ -134,13 +137,16 @@ test('core', async function (t) {
134137
'should inject HTML comments between adjacent indented code',
135138
async function () {
136139
assert.equal(
137-
to({
138-
type: 'root',
139-
children: [
140-
{type: 'code', value: 'a'},
141-
{type: 'code', value: 'b'}
142-
]
143-
}),
140+
to(
141+
{
142+
type: 'root',
143+
children: [
144+
{type: 'code', value: 'a'},
145+
{type: 'code', value: 'b'}
146+
]
147+
},
148+
{fences: false}
149+
),
144150
' a\n\n<!---->\n\n b\n'
145151
)
146152
}
@@ -371,10 +377,13 @@ test('blockquote', async function (t) {
371377
'should support code (flow, indented) in a block quote',
372378
async function () {
373379
assert.equal(
374-
to({
375-
type: 'blockquote',
376-
children: [{type: 'code', value: 'a\nb\n\nc'}]
377-
}),
380+
to(
381+
{
382+
type: 'blockquote',
383+
children: [{type: 'code', value: 'a\nb\n\nc'}]
384+
},
385+
{fences: false}
386+
),
378387
'> a\n> b\n>\n> c\n'
379388
)
380389
}
@@ -799,14 +808,11 @@ test('code (flow)', async function (t) {
799808
)
800809

801810
await t.test('should support code w/ a value (indent)', async function () {
802-
assert.equal(to({type: 'code', value: 'a'}), ' a\n')
811+
assert.equal(to({type: 'code', value: 'a'}, {fences: false}), ' a\n')
803812
})
804813

805814
await t.test('should support code w/ a value (fences)', async function () {
806-
assert.equal(
807-
to({type: 'code', value: 'a'}, {fences: true}),
808-
'```\na\n```\n'
809-
)
815+
assert.equal(to({type: 'code', value: 'a'}), '```\na\n```\n')
810816
})
811817

812818
await t.test('should support code w/ a lang', async function () {
@@ -904,7 +910,7 @@ test('code (flow)', async function (t) {
904910
'should use more grave accents for fences if there are streaks of grave accents in the value (fences)',
905911
async function () {
906912
assert.equal(
907-
to({type: 'code', value: '```\nasd\n```'}, {fences: true}),
913+
to({type: 'code', value: '```\nasd\n```'}),
908914
'````\n```\nasd\n```\n````\n'
909915
)
910916
}
@@ -914,7 +920,7 @@ test('code (flow)', async function (t) {
914920
'should use more tildes for fences if there are streaks of tildes in the value (fences)',
915921
async function () {
916922
assert.equal(
917-
to({type: 'code', value: '~~~\nasd\n~~~'}, {fence: '~', fences: true}),
923+
to({type: 'code', value: '~~~\nasd\n~~~'}, {fence: '~'}),
918924
'~~~~\n~~~\nasd\n~~~\n~~~~\n'
919925
)
920926
}
@@ -963,7 +969,7 @@ test('code (flow)', async function (t) {
963969
'should use an indent if the value is indented',
964970
async function () {
965971
assert.equal(
966-
to({type: 'code', value: ' a\n\n b'}),
972+
to({type: 'code', value: ' a\n\n b'}, {fences: false}),
967973
' a\n\n b\n'
968974
)
969975
}
@@ -4501,7 +4507,7 @@ test('roundtrip', async function (t) {
45014507
''
45024508
].join('\n')
45034509

4504-
assert.equal(to(from(doc)), doc)
4510+
assert.equal(to(from(doc), {fences: false}), doc)
45054511
}
45064512
)
45074513

0 commit comments

Comments
 (0)