Skip to content

Commit d3536fe

Browse files
committed
document smart quotes function
1 parent e58ffaf commit d3536fe

File tree

1 file changed

+15
-5
lines changed
  • packages/site-kit/src/lib/markdown

1 file changed

+15
-5
lines changed

packages/site-kit/src/lib/markdown/utils.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,24 @@ export const slugify = (str: string) => {
4242
.replace(/-$/, '');
4343
};
4444

45+
/**
46+
* Replace dumb quotes with smart quotes. This isn't a perfect algorithm — it
47+
* wouldn't correctly handle `That '70s show` or `My country 'tis of thee` but
48+
* a) it's very unlikely they'll occur in our docs, and
49+
* b) they can be dealt with manually
50+
*/
4551
export function smart_quotes(
4652
str: string,
47-
{ first = true, html = false }: { first?: boolean; html?: boolean } = {}
53+
{
54+
first = true,
55+
html = false
56+
}: {
57+
/** True if the string is the entire sentence or false if it's a substring. @default true */
58+
first?: boolean;
59+
/** True if the string has HTML entities. @default false */
60+
html?: boolean;
61+
} = {}
4862
) {
49-
// replace dumb quotes with smart quotes. This isn't a perfect algorithm — it
50-
// wouldn't correctly handle `That '70s show` or `My country 'tis of thee`
51-
// but a) it's very unlikely they'll occur in our docs, and
52-
// b) they can be dealt with manually
5363
let open_quote = false;
5464
let res = '';
5565
const len = str.length;

0 commit comments

Comments
 (0)