Skip to content

Commit 7053956

Browse files
committed
add docs for html language service apis
1 parent 22a9e66 commit 7053956

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,49 @@ Defines the supported CSS modes for the `getAllSymbols` function. Includes:
126126
```javascript
127127
console.log(CSSLanguageService.CSS_MODES.CSS); // Output: "CSS"
128128
```
129+
130+
## HTMLLanguageService API
131+
132+
The `HTMLLanguageService` provides utility functions for parsing and operating on HTML/PHP/HTML Like content.
133+
134+
### Methods
135+
136+
#### `getAllDocumentLinks(text, htmlMode, filePath)`
137+
138+
Extracts all links from the provided HTML text.
139+
140+
**Parameters**:
141+
142+
- `text` (`string`): The CSS code to analyze.
143+
- `cssMode` (`string`): The mode of the HTML document. This should correspond to one of the supported HTML modes (e.g., HTML, PHP, XHTML, HTM) defined in `HTML_MODES`.
144+
- `filePath` (`string`): Optional. The path of the html file, used for resolving relative URLs within the CSS. Defaults to `"file:///placeholder.html"`.
145+
146+
**Returns**:
147+
148+
- `Array[string]`: An array containing all the html links found in the document.
149+
150+
**Example Usage**:
151+
152+
```javascript
153+
const htmlContent = `<a href="http://example.com">Visit Example</a>`;
154+
const links = HTMLLanguageService.getAllDocumentLinks(htmlContent,
155+
HTMLLanguageService.HTML_MODES.HTML, "file:///your-path.html");
156+
console.log(links); // Output: ["http://example.com"]
157+
```
158+
159+
### Constants
160+
161+
#### `CSSLanguageService.HTML_MODES`
162+
163+
Defines the supported HTML modes. Includes:
164+
165+
- `HTML`: Standard HTML documents.
166+
- `XHTML`: XHTML documents.
167+
- `HTM`: HTM files, commonly an alternate extension for HTML files.
168+
- `PHP`: PHP files that contain HTML content.
169+
170+
**Example**:
171+
172+
```javascript
173+
console.log(HTMLLanguageService.HTML_MODES.HTML); // Output: "HTML"
174+
```

0 commit comments

Comments
 (0)