feat: Add ability to detect patches which are present in a file (#2633)

* feat: Add ability to detect patches which are present in a file

* chore: export patchDetector function

* fix: Make sure we don't attempt to call toJson on binary content

---------

Co-authored-by: Christopher Fox <cfox@homebound.com>
This commit is contained in:
zarwan-translate
2024-05-21 22:05:48 -04:00
committed by GitHub
parent f98f852a55
commit 962795743c
5 changed files with 262 additions and 3 deletions

View File

@ -15,7 +15,7 @@ const elementsToWrapper = (wrapper: ElementWrapper): readonly ElementWrapper[] =
parent: wrapper,
})) ?? [];
export const findLocationOfText = (node: Element, text: string): readonly IRenderedParagraphNode[] => {
export const traverse = (node: Element): readonly IRenderedParagraphNode[] => {
let renderedParagraphs: readonly IRenderedParagraphNode[] = [];
// eslint-disable-next-line functional/prefer-readonly-type
@ -41,5 +41,8 @@ export const findLocationOfText = (node: Element, text: string): readonly IRende
}
}
return renderedParagraphs.filter((p) => p.text.includes(text));
return renderedParagraphs;
};
export const findLocationOfText = (node: Element, text: string): readonly IRenderedParagraphNode[] =>
traverse(node).filter((p) => p.text.includes(text));