From 494185a606e13d26710d9dac1d153eb184686d7b Mon Sep 17 00:00:00 2001
From: akabeko
+ --hard-line-breaks Add
at the position of hard line breaks, without needing spaces
Examples
$ vfm input.md
@@ -38,7 +38,7 @@ const cli = meow(
language: {
type: 'string',
},
- autoLineBreaks: {
+ hardLineBreaks: {
type: 'boolean',
},
},
@@ -53,7 +53,7 @@ function compile(input: string) {
style: cli.flags.style,
title: cli.flags.title,
language: cli.flags.language,
- autoLineBreaks: cli.flags.autoLineBreaks,
+ hardLineBreaks: cli.flags.hardLineBreaks,
}),
);
}
@@ -64,7 +64,7 @@ function main(
partial: { type: 'boolean'; alias: string };
title: { type: 'string' };
language: { type: 'string' };
- autoLineBreaks: { type: 'boolean' };
+ hardLineBreaks: { type: 'boolean' };
}>,
) {
try {
diff --git a/src/index.ts b/src/index.ts
index ee31e39..f04549e 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -21,8 +21,8 @@ export interface StringifyMarkdownOptions {
language?: string;
/** Replacement handler for HTML string. */
replace?: ReplaceRule[];
- /** Converts line breaks to `
`. */
- autoLineBreaks?: boolean;
+ /** Add `
` at the position of hard line breaks, without needing spaces. */
+ hardLineBreaks?: boolean;
}
export interface Hooks {
@@ -40,10 +40,10 @@ export function VFM({
title = undefined,
language = undefined,
replace = undefined,
- autoLineBreaks = false,
+ hardLineBreaks = false,
}: StringifyMarkdownOptions = {}): Processor {
const processor = unified()
- .use(markdown({ autoLineBreaks }))
+ .use(markdown({ hardLineBreaks }))
.data('settings', { position: false })
.use(html);
diff --git a/src/revive-parse.ts b/src/revive-parse.ts
index debe565..b528c66 100644
--- a/src/revive-parse.ts
+++ b/src/revive-parse.ts
@@ -18,8 +18,8 @@ import { inspect } from './utils/debug';
* Options for Markdown conversion.
*/
export interface MarkdownOptions {
- /** Converts line breaks to `
`. */
- autoLineBreaks: boolean;
+ /** Add `
` at the position of hard line breaks, without needing spaces. */
+ hardLineBreaks: boolean;
}
/**
@@ -33,7 +33,7 @@ export const reviveParse = (
[markdown, { gfm: true, commonmark: true }],
fencedBlock,
ruby,
- ...(options.autoLineBreaks ? [breaks] : []),
+ ...(options.hardLineBreaks ? [breaks] : []),
[footnotes, { inlineNotes: true }],
math,
attr,
diff --git a/tests/block/line-breaks.test.ts b/tests/block/line-breaks.test.ts
index 5012acd..3c2c90b 100644
--- a/tests/block/line-breaks.test.ts
+++ b/tests/block/line-breaks.test.ts
@@ -1,7 +1,7 @@
import { stripIndent } from 'common-tags';
import { buildProcessorTestingCode } from '../utils';
-// remark-parse GFM seems to support only EOL space, so backslash is excluded.
+// remark-parse GFM seems to support only EOL two-spaces, so backslash is excluded.
it(
'default: GFM (EOL two-spaces)',
buildProcessorTestingCode(
@@ -26,7 +26,7 @@ it(
);
it(
- 'optional: auto line breaks with GFM (EOL tow-spaces)',
+ 'optional: hard line breaks with GFM (EOL tow-spaces)',
buildProcessorTestingCode(
stripIndent`
a
@@ -47,6 +47,6 @@ it(
b
c
{a
\nb|c}