Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🗒️ Tina Parser - Remove unindented lists #1551

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions src/services/ruleFormatter.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,12 @@
module.exports = function (md) {
md = md.replace('<!--endintro-->', '');

// unindent lists to fix parser breaking
md = unindentLists(md);

// escape the characters that Tina's martkdown parser can't handle
md = escapeInvalidChars(md);

return md;
};

const unindentLists = (md) => {
md = md.replace(/\r\n {3}-/g, '\r\n-');
md = md.replace(/\r\n {2}-/g, '\r\n-');
md = md.replace(/\r\n {2}([0-9]+)./g, (match, capture) => {
return `\r\n${capture}.`;
});
md = md.replace(/\r\n {5}([0-9]+)./g, (match, capture) => {
return `\r\n${capture}.`;
});
md = md.replace(/\r\n {2}\*/g, '\r\n*');
md = md.replace(/\r\n {3}\*/g, '\r\n*');
md = md.replace(/\r\n {4}([0-9]+)./g, (match, capture) => {
return `\r\n${capture}.`;
});
return md;
};

const escapeInvalidChars = (md) => {
md = md.replace(/> -/g, '\\> \\-');
md = md.replace(/> {2}-/g, '\\> \\-');
Expand Down