Skip to content

Commit e5bd46e

Browse files
committed
break out html from js comments
1 parent fd52043 commit e5bd46e

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

docs/api-queries.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -679,13 +679,17 @@ getByText(node, 'text', {
679679

680680
### TextMatch Examples
681681

682-
```javascript
683-
// <div>
684-
// Hello World
685-
// </div>
682+
Given the following HTML:
686683

687-
// WILL find the div:
684+
```html
685+
<div>
686+
Hello World
687+
</div>
688+
```
688689

690+
**_Will_ find the div:**
691+
692+
```javascript
689693
// Matching a string:
690694
getByText(container, 'Hello World') // full string match
691695
getByText(container, 'llo Worl', { exact: false }) // substring match
@@ -699,11 +703,17 @@ getByText(container, /Hello W?oRlD/i) // advanced regex
699703

700704
// Matching with a custom function:
701705
getByText(container, (content, element) => content.startsWith('Hello'))
706+
```
707+
708+
**_Will not_ find the div:**
709+
710+
```javascript
711+
// full string does not match
712+
getByText(container, 'Goodbye World')
702713

703-
// WILL NOT find the div:
714+
// case-sensitive regex with different case
715+
getByText(container, /hello world/)
704716

705-
getByText(container, 'Goodbye World') // full string does not match
706-
getByText(container, /hello world/) // case-sensitive regex with different case
707717
// function looking for a span when it's actually a div:
708718
getByText(container, (content, element) => {
709719
return element.tagName.toLowerCase() === 'span' && content.startsWith('Hello')

0 commit comments

Comments
 (0)