Skip to content

Commit 0c99615

Browse files
fix(markdown-satteri): clarify smartPunctuation default (#17314)
Co-authored-by: Princesseuh <[email protected]>
1 parent 8797754 commit 0c99615

4 files changed

Lines changed: 26 additions & 2 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@astrojs/markdown-satteri': patch
3+
---
4+
5+
Fixes the editor tooltip for `smartPunctuation` claiming it defaults to `false` when Astro enables it by default.

packages/markdown/satteri/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export {
1414
export {
1515
isSatteriProcessor,
1616
satteri,
17+
type SatteriFeatures,
1718
type SatteriProcessorOptions,
1819
type SatteriResolvedOptions,
1920
} from './processor.js';

packages/markdown/satteri/src/processor.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,19 @@ import type {
88
} from 'satteri';
99
import { createSatteriMarkdownProcessor } from './satteri-processor.js';
1010

11+
export interface SatteriFeatures extends Omit<Features, 'smartPunctuation'> {
12+
/**
13+
* Smart punctuation à la SmartyPants.
14+
*
15+
* Default: `true` in Astro.
16+
*/
17+
smartPunctuation?: Features['smartPunctuation'];
18+
}
19+
1120
export interface SatteriProcessorOptions {
1221
mdastPlugins?: MdastPluginList;
1322
hastPlugins?: HastPluginList;
14-
features?: Features;
23+
features?: SatteriFeatures;
1524
}
1625

1726
/**
@@ -21,7 +30,7 @@ export interface SatteriProcessorOptions {
2130
export interface SatteriResolvedOptions {
2231
mdastPlugins: MdastPluginEntry[];
2332
hastPlugins: HastPluginEntry[];
24-
features: Features;
33+
features: SatteriFeatures;
2534
}
2635

2736
/**

packages/markdown/satteri/test/markdown.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ describe('satteri markdown', () => {
5050
assert.ok(code.includes('"hello"'));
5151
});
5252

53+
it('accepts a granular options object for `smartPunctuation`', async () => {
54+
const renderer = await satteri({
55+
features: { smartPunctuation: { dashes: false } },
56+
}).createRenderer({});
57+
const { code } = await renderer.render('He said "hello" -- really');
58+
assert.match(code, /hello/);
59+
assert.ok(code.includes('--'));
60+
});
61+
5362
it('collects local image paths into metadata', async () => {
5463
const processor = await createSatteriMarkdownProcessor();
5564
const { metadata } = await processor.render('![alt](./local.png)');

0 commit comments

Comments
 (0)