Skip to content

Commit

Permalink
fix: replace # => ##
Browse files Browse the repository at this point in the history
  • Loading branch information
snomiao committed Apr 23, 2022
1 parent 5ce7a6f commit bfc6e79
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/md-aggregate/cli.mjs
Expand Up @@ -46,7 +46,7 @@ export const cli = async (rawArgv) => {
const lines = srcContent
.trim()
.split("\n")
.map((e) => e.replace(/^#/g, "##"));
.map((e) => e.replace(/^#/gim, "##"));

// TODO: handle \r\n
const matchStartPattern = `\n${escapeStringRegexp(lines[0])}$`;
Expand All @@ -57,9 +57,10 @@ export const cli = async (rawArgv) => {
const startPattern = `${matchStartPattern}|${eofPattern}`;
const anyPattern = `[\\s\\S]*?`;
const endPattern = `${eofPattern}|${sectionStartPattern}`;
const replacedContent = lines.join("\n");
dstContent = dstContent.replace(
RegExp(`(${startPattern})${anyPattern}(?=${endPattern})`, "m"),
`\n${lines.join("\n")}\n`,
`\n${replacedContent}\n`,
);
};
await Promise.all(srcs.map(srcProcess));
Expand Down

0 comments on commit bfc6e79

Please sign in to comment.