Skip to content

Commit

Permalink
fix(md): ensure </details> tag is on newline (#458)
Browse files Browse the repository at this point in the history
fix(md): ensure </details> is on newline
  • Loading branch information
erickzhao authored Oct 17, 2023
1 parent 1ae5aab commit 329c555
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions scripts/tasks/md-fixers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,19 @@ const newLineOnAdmonition = (line: string) => {
return line;
};

/**
* MDX requires </details> tag to be on its own line for some reason.
* @param line
*/
const newLineOnDetails = (line: string) => {
if (line.trim().endsWith(' </details>')) {
const restOfContent = line.trim().split(' </details>')[0];
return `${restOfContent}\n</details>`;
}

return line;
};

/**
* Applies any transformation that can be executed line by line on
* the document to make sure it is ready to be consumed by
Expand All @@ -125,6 +138,7 @@ const transform = (doc: string) => {
fiddleTransformer,
newLineOnHTMLComment,
newLineOnAdmonition,
newLineOnDetails,
];

for (const line of lines) {
Expand Down

0 comments on commit 329c555

Please sign in to comment.