Closed Jwaegebaert closed 1 year ago
This PR is on-hold to start with until we have a clear view of what all the adjusted syntaxes are. Related to: #4574
New syntaxes to keep in mind:
md
to mdx
Change extension names at src/cli/Cli.ts
lines 683
, 687
, 690
login.mdx
In src/utils/md.ts
function removeFrontmatter(md: string): string {
return md.replace(/^---[\s\S]*?---/gm, '').trim();
}
In src/utils/md.ts
function removeImports(md: string): string {
return md.replace(/^import .+;$/gms, '').trim();
}
plan-add.mdx
In src/utils/md.ts
update the method convertContentTabs
!!! Change the order in convertFunctions
that convertCodeFences
happens first and then convertContentTabs
function convertContentTabs(md: string): string {
return md
.replace(/<TabItem value="([^"]+)">/gm, '$1')
.replace(/.*<\/?(Tabs|TabItem)>.*\n?/g, '')
.replace(/```(?:\w+)?\s*([\s\S]*?)\s*```/g, '$1')
.trim();
}
Already done thanks to the function convertCodeFences
in the file src/utils/md.ts
<Global />
and <CLISettings />
are rendered correctlyIn src/utils/md.ts
update the method includeContent
function includeContent(md: string, rootFolder: string): string {
const mdxImports = [
{ tag: "<Global />", location: "docs/cmd/_global.mdx" },
{ tag: "<CLISettings />", location: "docs/_clisettings.mdx" }
];
mdxImports.forEach(mdxImport => {
md = md.replace(mdxImport.tag, () => {
return fs.readFileSync(path.join(rootFolder, mdxImport.location), 'utf8');
}).replace(/(```\r\n)\r\n(```md defintion-list\r\n)/g, "$1$2");
});
return md;
}
In src/utils/md.ts
update the method convertAdmonitions
function convertAdmonitions(md: string): string {
const regex = new RegExp(/^:::(\w+)([\s\S]*?):::$/, 'gm');
return md.replace(regex, (_, label: string, content: string) => label.toLocaleUpperCase() + EOL + EOL + content.trim());
}
@pnp/cli-for-microsoft-365-maintainers I've updated the help output to accommodate the changes made by Docusaurus.
I've created a diffchecker
link that provides a quick overview how this change will look like. https://www.diffchecker.com/VgO6k3Uu
The left is our current output with MKDocs
and on the right we have the new output based from Docusaurus
too me it looks pretty much the same 👍 awesome work @Jwaegebaert 👍 you rock 🤩
Because our syntaxes will change for certain markdown elements, our code to print the
--help
output needs to be adjusted for this change.Changed syntaxes:
Note!
When making a PR for this issue, make sure you target the branch
docs-migration
.Related to #4396