mirror of
https://github.com/LukeHagar/prettier-plugin-openapi.git
synced 2025-12-06 04:21:03 +00:00
Refactor prettier-markdown utilities for improved error handling and consistency in quote usage
This commit is contained in:
@@ -53,7 +53,7 @@ if (!utils) {
|
|||||||
const hasSingle = str.includes("'");
|
const hasSingle = str.includes("'");
|
||||||
const hasDouble = str.includes('"');
|
const hasDouble = str.includes('"');
|
||||||
if (hasSingle && !hasDouble) return '"';
|
if (hasSingle && !hasDouble) return '"';
|
||||||
return "'";
|
return '"';
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ function createParse({ isMDX }) {
|
|||||||
return processor.runSync(processor.parse(text));
|
return processor.runSync(processor.parse(text));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function noop() {}
|
function noop() {}
|
||||||
|
|
||||||
|
|||||||
@@ -186,9 +186,17 @@ function getOrderedListItemInfo(orderListItem, options) {
|
|||||||
orderListItem.position.end.offset,
|
orderListItem.position.end.offset,
|
||||||
);
|
);
|
||||||
|
|
||||||
const { numberText, leadingSpaces } = text.match(
|
const m = text.match(
|
||||||
/^\s*(?<numberText>\d+)(\.|\))(?<leadingSpaces>\s*)/u,
|
/^\s*(?<numberText>\d+)(\.|\))(?<leadingSpaces>\s*)/u,
|
||||||
).groups;
|
);
|
||||||
|
|
||||||
|
if (!m) {
|
||||||
|
throw new Error(
|
||||||
|
`Failed to parse ordered list item: expected pattern matching /^\\s*(?<numberText>\\d+)(\\.|\\))(?<leadingSpaces>\\s*)/u, but got: ${JSON.stringify(text)}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const { numberText, leadingSpaces } = m.groups;
|
||||||
|
|
||||||
return { number: Number(numberText), leadingSpaces };
|
return { number: Number(numberText), leadingSpaces };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user