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

fix: filter out HTML #113

Merged
merged 1 commit into from
Jun 21, 2024
Merged

Conversation

dsanders11
Copy link
Member

The docs generally shouldn't include HTML directly, but HTML comments are a valid use case we may have more of in the future (see electron/electron#42113) and it's easy enough to filter them out this way. This also ends up filtering out a raw <img> tag which was finding itself into the parsed docs, so that's good as well.

@dsanders11 dsanders11 requested a review from a team as a code owner May 11, 2024 20:51
Copy link
Member

@MarshallOfSound MarshallOfSound left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this going to be a behavior change for other parts of the docs as they stand, would be interested in a diff run before/after on the current main docs

@dsanders11
Copy link
Member Author

Here's the diffs, it mostly just strips out <br /> in electron-api.json which seem to have no functional impact on electron.d.ts output. If we want we could update this change to replace <br /> with newlines.

electron.d.ts diff
--- electron.d.ts	2024-05-12 23:08:35
+++ electron.d.ts	2024-05-12 23:08:18
@@ -15738,14 +15738,8 @@
      * For a call of `win.webContents.adjustSelection({ start: 1, end: 5 })`
      *
      * Before:
-     *
-     * <img width="487" alt="Image Before Text Selection Adjustment"
-     * src="../images/web-contents-text-selection-before.png"/>
      *
      * After:
-     *
-     * <img width="487" alt="Image After Text Selection Adjustment"
-     * src="../images/web-contents-text-selection-after.png"/>
      */
     adjustSelection(options: AdjustSelectionOptions): void;
     /**
electron-api.json diff
--- electron-api.json	2024-05-12 23:00:49
+++ electron-api.json	2024-05-12 23:00:18
@@ -10249,7 +10249,7 @@
   },
   {
     "name": "ClientRequest",
-    "description": "> Make HTTP/HTTPS requests.\n\nProcess: Main, Utility<br /> _This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._\n\n`ClientRequest` implements the Writable Stream interface and is therefore an EventEmitter.",
+    "description": "> Make HTTP/HTTPS requests.\n\nProcess: Main, Utility _This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._\n\n`ClientRequest` implements the Writable Stream interface and is therefore an EventEmitter.",
     "slug": "client-request",
     "websiteUrl": "https://electronjs.org/docs/api/client-request",
     "repoUrl": "https://github.com/electron/electron/blob/v32.0.0-nightly.20240510/docs/api/client-request.md",
\ No newline at end of file
@@ -26166,7 +26166,7 @@
   },
   {
     "name": "TouchBarButton",
-    "description": "> Create a button in the touch bar for native macOS applications\n\nProcess: Main<br /> _This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._",
+    "description": "> Create a button in the touch bar for native macOS applications\n\nProcess: Main _This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._",
     "slug": "touch-bar-button",
     "websiteUrl": "https://electronjs.org/docs/api/touch-bar-button",
     "repoUrl": "https://github.com/electron/electron/blob/v32.0.0-nightly.20240510/docs/api/touch-bar-button.md",
\ No newline at end of file
@@ -26358,7 +26358,7 @@
   },
   {
     "name": "TouchBarColorPicker",
-    "description": "> Create a color picker in the touch bar for native macOS applications\n\nProcess: Main<br /> _This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._",
+    "description": "> Create a color picker in the touch bar for native macOS applications\n\nProcess: Main _This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._",
     "slug": "touch-bar-color-picker",
     "websiteUrl": "https://electronjs.org/docs/api/touch-bar-color-picker",
     "repoUrl": "https://github.com/electron/electron/blob/v32.0.0-nightly.20240510/docs/api/touch-bar-color-picker.md",
\ No newline at end of file
@@ -26451,7 +26451,7 @@
   },
   {
     "name": "TouchBarGroup",
-    "description": "> Create a group in the touch bar for native macOS applications\n\nProcess: Main<br /> _This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._",
+    "description": "> Create a group in the touch bar for native macOS applications\n\nProcess: Main _This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._",
     "slug": "touch-bar-group",
     "websiteUrl": "https://electronjs.org/docs/api/touch-bar-group",
     "repoUrl": "https://github.com/electron/electron/blob/v32.0.0-nightly.20240510/docs/api/touch-bar-group.md",
\ No newline at end of file
@@ -26494,7 +26494,7 @@
   },
   {
     "name": "TouchBarLabel",
-    "description": "> Create a label in the touch bar for native macOS applications\n\nProcess: Main<br /> _This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._",
+    "description": "> Create a label in the touch bar for native macOS applications\n\nProcess: Main _This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._",
     "slug": "touch-bar-label",
     "websiteUrl": "https://electronjs.org/docs/api/touch-bar-label",
     "repoUrl": "https://github.com/electron/electron/blob/v32.0.0-nightly.20240510/docs/api/touch-bar-label.md",
\ No newline at end of file
@@ -26587,7 +26587,7 @@
   },
   {
     "name": "TouchBarOtherItemsProxy",
-    "description": "> Instantiates a special \"other items proxy\", which nests TouchBar elements inherited from Chromium at the space indicated by the proxy. By default, this proxy is added to each TouchBar at the end of the input. For more information, see the AppKit docs on NSTouchBarItemIdentifierOtherItemsProxy\n\nNote: Only one instance of this class can be added per TouchBar.\n\nProcess: Main<br /> _This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._",
+    "description": "> Instantiates a special \"other items proxy\", which nests TouchBar elements inherited from Chromium at the space indicated by the proxy. By default, this proxy is added to each TouchBar at the end of the input. For more information, see the AppKit docs on NSTouchBarItemIdentifierOtherItemsProxy\n\nNote: Only one instance of this class can be added per TouchBar.\n\nProcess: Main _This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._",
     "slug": "touch-bar-other-items-proxy",
     "websiteUrl": "https://electronjs.org/docs/api/touch-bar-other-items-proxy",
     "repoUrl": "https://github.com/electron/electron/blob/v32.0.0-nightly.20240510/docs/api/touch-bar-other-items-proxy.md",
\ No newline at end of file
@@ -26612,7 +26612,7 @@
   },
   {
     "name": "TouchBarPopover",
-    "description": "> Create a popover in the touch bar for native macOS applications\n\nProcess: Main<br /> _This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._",
+    "description": "> Create a popover in the touch bar for native macOS applications\n\nProcess: Main _This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._",
     "slug": "touch-bar-popover",
     "websiteUrl": "https://electronjs.org/docs/api/touch-bar-popover",
     "repoUrl": "https://github.com/electron/electron/blob/v32.0.0-nightly.20240510/docs/api/touch-bar-popover.md",
\ No newline at end of file
@@ -26700,7 +26700,7 @@
   },
   {
     "name": "TouchBarScrubber",
-    "description": "> Create a scrubber (a scrollable selector)\n\nProcess: Main<br /> _This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._",
+    "description": "> Create a scrubber (a scrollable selector)\n\nProcess: Main _This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._",
     "slug": "touch-bar-scrubber",
     "websiteUrl": "https://electronjs.org/docs/api/touch-bar-scrubber",
     "repoUrl": "https://github.com/electron/electron/blob/v32.0.0-nightly.20240510/docs/api/touch-bar-scrubber.md",
\ No newline at end of file
@@ -26950,7 +26950,7 @@
   },
   {
     "name": "TouchBarSegmentedControl",
-    "description": "> Create a segmented control (a button group) where one button has a selected state\n\nProcess: Main<br /> _This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._",
+    "description": "> Create a segmented control (a button group) where one button has a selected state\n\nProcess: Main _This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._",
     "slug": "touch-bar-segmented-control",
     "websiteUrl": "https://electronjs.org/docs/api/touch-bar-segmented-control",
     "repoUrl": "https://github.com/electron/electron/blob/v32.0.0-nightly.20240510/docs/api/touch-bar-segmented-control.md",
\ No newline at end of file
@@ -27142,7 +27142,7 @@
   },
   {
     "name": "TouchBarSlider",
-    "description": "> Create a slider in the touch bar for native macOS applications\n\nProcess: Main<br /> _This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._",
+    "description": "> Create a slider in the touch bar for native macOS applications\n\nProcess: Main _This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._",
     "slug": "touch-bar-slider",
     "websiteUrl": "https://electronjs.org/docs/api/touch-bar-slider",
     "repoUrl": "https://github.com/electron/electron/blob/v32.0.0-nightly.20240510/docs/api/touch-bar-slider.md",
\ No newline at end of file
@@ -27266,7 +27266,7 @@
   },
   {
     "name": "TouchBarSpacer",
-    "description": "> Create a spacer between two items in the touch bar for native macOS applications\n\nProcess: Main<br /> _This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._",
+    "description": "> Create a spacer between two items in the touch bar for native macOS applications\n\nProcess: Main _This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._",
     "slug": "touch-bar-spacer",
     "websiteUrl": "https://electronjs.org/docs/api/touch-bar-spacer",
     "repoUrl": "https://github.com/electron/electron/blob/v32.0.0-nightly.20240510/docs/api/touch-bar-spacer.md",
\ No newline at end of file
@@ -28395,7 +28395,7 @@
   },
   {
     "name": "utilityProcess",
-    "description": "`utilityProcess` creates a child process with Node.js and Message ports enabled. It provides the equivalent of `child_process.fork` API from Node.js but instead uses Services API from Chromium to launch the child process.\n\nProcess: Main<br />",
+    "description": "`utilityProcess` creates a child process with Node.js and Message ports enabled. It provides the equivalent of `child_process.fork` API from Node.js but instead uses Services API from Chromium to launch the child process.\n\nProcess: Main",
     "slug": "utility-process",
     "websiteUrl": "https://electronjs.org/docs/api/utility-process",
     "repoUrl": "https://github.com/electron/electron/blob/v32.0.0-nightly.20240510/docs/api/utility-process.md",
\ No newline at end of file
@@ -30119,7 +30119,7 @@
       {
         "name": "adjustSelection",
         "signature": "(options)",
-        "description": "Adjusts the current text selection starting and ending points in the focused frame by the given amounts. A negative amount moves the selection towards the beginning of the document, and a positive amount moves the selection towards the end of the document.\n\nExample:\n\nFor a call of `win.webContents.adjustSelection({ start: 1, end: 5 })`\n\nBefore:\n\n<img width=\"487\" alt=\"Image Before Text Selection Adjustment\" src=\"../images/web-contents-text-selection-before.png\"/>\n\nAfter:\n\n<img width=\"487\" alt=\"Image After Text Selection Adjustment\" src=\"../images/web-contents-text-selection-after.png\"/>",
+        "description": "Adjusts the current text selection starting and ending points in the focused frame by the given amounts. A negative amount moves the selection towards the beginning of the document, and a positive amount moves the selection towards the end of the document.\n\nExample:\n\nFor a call of `win.webContents.adjustSelection({ start: 1, end: 5 })`\n\nBefore:\n\nAfter:",
         "parameters": [
           {
             "name": "options",
\ No newline at end of file
@@ -37909,7 +37909,7 @@
   {
     "name": "webviewTag",
     "extends": "HTMLElement",
-    "description": "\n\n### Warning\n\nElectron's `webview` tag is based on Chromium's `webview`, which is undergoing dramatic architectural changes. This impacts the stability of `webviews`, including rendering, navigation, and event routing. We currently recommend to not use the `webview` tag and to consider alternatives, like `iframe`, a `WebContentsView`, or an architecture that avoids embedded content altogether.\n\n### Enabling\n\nBy default the `webview` tag is disabled in Electron >= 5.  You need to enable the tag by setting the `webviewTag` webPreferences option when constructing your `BrowserWindow`. For more information see the BrowserWindow constructor docs.\n\n### Overview\n\n> Display external web content in an isolated frame and process.\n\nProcess: Renderer<br /> _This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._\n\nUse the `webview` tag to embed 'guest' content (such as web pages) in your Electron app. The guest content is contained within the `webview` container. An embedded page within your app controls how the guest content is laid out and rendered.\n\nUnlike an `iframe`, the `webview` runs in a separate process than your app. It doesn't have the same permissions as your web page and all interactions between your app and embedded content will be asynchronous. This keeps your app safe from the embedded content. **Note:** Most methods called on the webview from the host page require a synchronous call to the main process.\n\n### Example\n\nTo embed a web page in your app, add the `webview` tag to your app's embedder page (this is the app page that will display the guest content). In its simplest form, the `webview` tag includes the `src` of the web page and css styles that control the appearance of the `webview` container:\n\n```\n<webview id=\"foo\" src=\"https://www.github.com/\" style=\"display:inline-flex; width:640px; height:480px\"></webview>\n```\n\nIf you want to control the guest content in any way, you can write JavaScript that listens for `webview` events and responds to those events using the `webview` methods. Here's sample code with two event listeners: one that listens for the web page to start loading, the other for the web page to stop loading, and displays a \"loading...\" message during the load time:\n\n```\n<script>\n  onload = () => {\n    const webview = document.querySelector('webview')\n    const indicator = document.querySelector('.indicator')\n\n    const loadstart = () => {\n      indicator.innerText = 'loading...'\n    }\n\n    const loadstop = () => {\n      indicator.innerText = ''\n    }\n\n    webview.addEventListener('did-start-loading', loadstart)\n    webview.addEventListener('did-stop-loading', loadstop)\n  }\n</script>\n```\n\n### Internal implementation\n\nUnder the hood `webview` is implemented with Out-of-Process iframes (OOPIFs). The `webview` tag is essentially a custom element using shadow DOM to wrap an `iframe` element inside it.\n\nSo the behavior of `webview` is very similar to a cross-domain `iframe`, as examples:\n\n* When clicking into a `webview`, the page focus will move from the embedder frame to `webview`.\n* You can not add keyboard, mouse, and scroll event listeners to `webview`.\n* All reactions between the embedder frame and `webview` are asynchronous.\n\n### CSS Styling Notes\n\nPlease note that the `webview` tag's style uses `display:flex;` internally to ensure the child `iframe` element fills the full height and width of its `webview` container when used with traditional and flexbox layouts. Please do not overwrite the default `display:flex;` CSS property, unless specifying `display:inline-flex;` for inline layout.\n\n### Tag Attributes\n\nThe `webview` tag has the following attributes:\n\n### `src`\n\n```\n<webview src=\"https://www.github.com/\"></webview>\n```\n\nA `string` representing the visible URL. Writing to this attribute initiates top-level navigation.\n\nAssigning `src` its own value will reload the current page.\n\nThe `src` attribute can also accept data URLs, such as `data:text/plain,Hello, world!`.\n\n### `nodeintegration`\n\n```\n<webview src=\"https://www.google.com/\" nodeintegration></webview>\n```\n\nA `boolean`. When this attribute is present the guest page in `webview` will have node integration and can use node APIs like `require` and `process` to access low level system resources. Node integration is disabled by default in the guest page.\n\n### `nodeintegrationinsubframes`\n\n```\n<webview src=\"https://www.google.com/\" nodeintegrationinsubframes></webview>\n```\n\nA `boolean` for the experimental option for enabling NodeJS support in sub-frames such as iframes inside the `webview`. All your preloads will load for every iframe, you can use `process.isMainFrame` to determine if you are in the main frame or not. This option is disabled by default in the guest page.\n\n### `plugins`\n\n```\n<webview src=\"https://www.github.com/\" plugins></webview>\n```\n\nA `boolean`. When this attribute is present the guest page in `webview` will be able to use browser plugins. Plugins are disabled by default.\n\n### `preload`\n\n```\n<!-- from a file -->\n<webview src=\"https://www.github.com/\" preload=\"./test.js\"></webview>\n<!-- or if you want to load from an asar archive -->\n<webview src=\"https://www.github.com/\" preload=\"./app.asar/test.js\"></webview>\n```\n\nA `string` that specifies a script that will be loaded before other scripts run in the guest page. The protocol of script's URL must be `file:` (even when using `asar:` archives) because it will be loaded by Node's `require` under the hood, which treats `asar:` archives as virtual directories.\n\nWhen the guest page doesn't have node integration this script will still have access to all Node APIs, but global objects injected by Node will be deleted after this script has finished executing.\n\n### `httpreferrer`\n\n```\n<webview src=\"https://www.github.com/\" httpreferrer=\"https://example.com/\"></webview>\n```\n\nA `string` that sets the referrer URL for the guest page.\n\n### `useragent`\n\n```\n<webview src=\"https://www.github.com/\" useragent=\"Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko\"></webview>\n```\n\nA `string` that sets the user agent for the guest page before the page is navigated to. Once the page is loaded, use the `setUserAgent` method to change the user agent.\n\n### `disablewebsecurity`\n\n```\n<webview src=\"https://www.github.com/\" disablewebsecurity></webview>\n```\n\nA `boolean`. When this attribute is present the guest page will have web security disabled. Web security is enabled by default.\n\nThis value can only be modified before the first navigation.\n\n### `partition`\n\n```\n<webview src=\"https://github.com\" partition=\"persist:github\"></webview>\n<webview src=\"https://electronjs.org\" partition=\"electron\"></webview>\n```\n\nA `string` that sets the session used by the page. If `partition` starts with `persist:`, the page will use a persistent session available to all pages in the app with the same `partition`. if there is no `persist:` prefix, the page will use an in-memory session. By assigning the same `partition`, multiple pages can share the same session. If the `partition` is unset then default session of the app will be used.\n\nThis value can only be modified before the first navigation, since the session of an active renderer process cannot change. Subsequent attempts to modify the value will fail with a DOM exception.\n\n### `allowpopups`\n\n```\n<webview src=\"https://www.github.com/\" allowpopups></webview>\n```\n\nA `boolean`. When this attribute is present the guest page will be allowed to open new windows. Popups are disabled by default.\n\n### `webpreferences`\n\n```\n<webview src=\"https://github.com\" webpreferences=\"allowRunningInsecureContent, javascript=no\"></webview>\n```\n\nA `string` which is a comma separated list of strings which specifies the web preferences to be set on the webview. The full list of supported preference strings can be found in BrowserWindow. In addition, webview supports the following preferences:\n\n* `transparent` boolean (optional) - Whether to enable background transparency for the guest page. Default is `true`. **Note:** The guest page's text and background colors are derived from the color scheme of its root element. When transparency is enabled, the text color will still change accordingly but the background will remain transparent.\n\nThe string follows the same format as the features string in `window.open`. A name by itself is given a `true` boolean value. A preference can be set to another value by including an `=`, followed by the value. Special values `yes` and `1` are interpreted as `true`, while `no` and `0` are interpreted as `false`.\n\n### `enableblinkfeatures`\n\n```\n<webview src=\"https://www.github.com/\" enableblinkfeatures=\"PreciseMemoryInfo, CSSVariables\"></webview>\n```\n\nA `string` which is a list of strings which specifies the blink features to be enabled separated by `,`. The full list of supported feature strings can be found in the RuntimeEnabledFeatures.json5 file.\n\n### `disableblinkfeatures`\n\n```\n<webview src=\"https://www.github.com/\" disableblinkfeatures=\"PreciseMemoryInfo, CSSVariables\"></webview>\n```\n\nA `string` which is a list of strings which specifies the blink features to be disabled separated by `,`. The full list of supported feature strings can be found in the RuntimeEnabledFeatures.json5 file.",
+    "description": "\n\n### Warning\n\nElectron's `webview` tag is based on Chromium's `webview`, which is undergoing dramatic architectural changes. This impacts the stability of `webviews`, including rendering, navigation, and event routing. We currently recommend to not use the `webview` tag and to consider alternatives, like `iframe`, a `WebContentsView`, or an architecture that avoids embedded content altogether.\n\n### Enabling\n\nBy default the `webview` tag is disabled in Electron >= 5.  You need to enable the tag by setting the `webviewTag` webPreferences option when constructing your `BrowserWindow`. For more information see the BrowserWindow constructor docs.\n\n### Overview\n\n> Display external web content in an isolated frame and process.\n\nProcess: Renderer _This class is not exported from the `'electron'` module. It is only available as a return value of other methods in the Electron API._\n\nUse the `webview` tag to embed 'guest' content (such as web pages) in your Electron app. The guest content is contained within the `webview` container. An embedded page within your app controls how the guest content is laid out and rendered.\n\nUnlike an `iframe`, the `webview` runs in a separate process than your app. It doesn't have the same permissions as your web page and all interactions between your app and embedded content will be asynchronous. This keeps your app safe from the embedded content. **Note:** Most methods called on the webview from the host page require a synchronous call to the main process.\n\n### Example\n\nTo embed a web page in your app, add the `webview` tag to your app's embedder page (this is the app page that will display the guest content). In its simplest form, the `webview` tag includes the `src` of the web page and css styles that control the appearance of the `webview` container:\n\n```\n<webview id=\"foo\" src=\"https://www.github.com/\" style=\"display:inline-flex; width:640px; height:480px\"></webview>\n```\n\nIf you want to control the guest content in any way, you can write JavaScript that listens for `webview` events and responds to those events using the `webview` methods. Here's sample code with two event listeners: one that listens for the web page to start loading, the other for the web page to stop loading, and displays a \"loading...\" message during the load time:\n\n```\n<script>\n  onload = () => {\n    const webview = document.querySelector('webview')\n    const indicator = document.querySelector('.indicator')\n\n    const loadstart = () => {\n      indicator.innerText = 'loading...'\n    }\n\n    const loadstop = () => {\n      indicator.innerText = ''\n    }\n\n    webview.addEventListener('did-start-loading', loadstart)\n    webview.addEventListener('did-stop-loading', loadstop)\n  }\n</script>\n```\n\n### Internal implementation\n\nUnder the hood `webview` is implemented with Out-of-Process iframes (OOPIFs). The `webview` tag is essentially a custom element using shadow DOM to wrap an `iframe` element inside it.\n\nSo the behavior of `webview` is very similar to a cross-domain `iframe`, as examples:\n\n* When clicking into a `webview`, the page focus will move from the embedder frame to `webview`.\n* You can not add keyboard, mouse, and scroll event listeners to `webview`.\n* All reactions between the embedder frame and `webview` are asynchronous.\n\n### CSS Styling Notes\n\nPlease note that the `webview` tag's style uses `display:flex;` internally to ensure the child `iframe` element fills the full height and width of its `webview` container when used with traditional and flexbox layouts. Please do not overwrite the default `display:flex;` CSS property, unless specifying `display:inline-flex;` for inline layout.\n\n### Tag Attributes\n\nThe `webview` tag has the following attributes:\n\n### `src`\n\n```\n<webview src=\"https://www.github.com/\"></webview>\n```\n\nA `string` representing the visible URL. Writing to this attribute initiates top-level navigation.\n\nAssigning `src` its own value will reload the current page.\n\nThe `src` attribute can also accept data URLs, such as `data:text/plain,Hello, world!`.\n\n### `nodeintegration`\n\n```\n<webview src=\"https://www.google.com/\" nodeintegration></webview>\n```\n\nA `boolean`. When this attribute is present the guest page in `webview` will have node integration and can use node APIs like `require` and `process` to access low level system resources. Node integration is disabled by default in the guest page.\n\n### `nodeintegrationinsubframes`\n\n```\n<webview src=\"https://www.google.com/\" nodeintegrationinsubframes></webview>\n```\n\nA `boolean` for the experimental option for enabling NodeJS support in sub-frames such as iframes inside the `webview`. All your preloads will load for every iframe, you can use `process.isMainFrame` to determine if you are in the main frame or not. This option is disabled by default in the guest page.\n\n### `plugins`\n\n```\n<webview src=\"https://www.github.com/\" plugins></webview>\n```\n\nA `boolean`. When this attribute is present the guest page in `webview` will be able to use browser plugins. Plugins are disabled by default.\n\n### `preload`\n\n```\n<!-- from a file -->\n<webview src=\"https://www.github.com/\" preload=\"./test.js\"></webview>\n<!-- or if you want to load from an asar archive -->\n<webview src=\"https://www.github.com/\" preload=\"./app.asar/test.js\"></webview>\n```\n\nA `string` that specifies a script that will be loaded before other scripts run in the guest page. The protocol of script's URL must be `file:` (even when using `asar:` archives) because it will be loaded by Node's `require` under the hood, which treats `asar:` archives as virtual directories.\n\nWhen the guest page doesn't have node integration this script will still have access to all Node APIs, but global objects injected by Node will be deleted after this script has finished executing.\n\n### `httpreferrer`\n\n```\n<webview src=\"https://www.github.com/\" httpreferrer=\"https://example.com/\"></webview>\n```\n\nA `string` that sets the referrer URL for the guest page.\n\n### `useragent`\n\n```\n<webview src=\"https://www.github.com/\" useragent=\"Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko\"></webview>\n```\n\nA `string` that sets the user agent for the guest page before the page is navigated to. Once the page is loaded, use the `setUserAgent` method to change the user agent.\n\n### `disablewebsecurity`\n\n```\n<webview src=\"https://www.github.com/\" disablewebsecurity></webview>\n```\n\nA `boolean`. When this attribute is present the guest page will have web security disabled. Web security is enabled by default.\n\nThis value can only be modified before the first navigation.\n\n### `partition`\n\n```\n<webview src=\"https://github.com\" partition=\"persist:github\"></webview>\n<webview src=\"https://electronjs.org\" partition=\"electron\"></webview>\n```\n\nA `string` that sets the session used by the page. If `partition` starts with `persist:`, the page will use a persistent session available to all pages in the app with the same `partition`. if there is no `persist:` prefix, the page will use an in-memory session. By assigning the same `partition`, multiple pages can share the same session. If the `partition` is unset then default session of the app will be used.\n\nThis value can only be modified before the first navigation, since the session of an active renderer process cannot change. Subsequent attempts to modify the value will fail with a DOM exception.\n\n### `allowpopups`\n\n```\n<webview src=\"https://www.github.com/\" allowpopups></webview>\n```\n\nA `boolean`. When this attribute is present the guest page will be allowed to open new windows. Popups are disabled by default.\n\n### `webpreferences`\n\n```\n<webview src=\"https://github.com\" webpreferences=\"allowRunningInsecureContent, javascript=no\"></webview>\n```\n\nA `string` which is a comma separated list of strings which specifies the web preferences to be set on the webview. The full list of supported preference strings can be found in BrowserWindow. In addition, webview supports the following preferences:\n\n* `transparent` boolean (optional) - Whether to enable background transparency for the guest page. Default is `true`. **Note:** The guest page's text and background colors are derived from the color scheme of its root element. When transparency is enabled, the text color will still change accordingly but the background will remain transparent.\n\nThe string follows the same format as the features string in `window.open`. A name by itself is given a `true` boolean value. A preference can be set to another value by including an `=`, followed by the value. Special values `yes` and `1` are interpreted as `true`, while `no` and `0` are interpreted as `false`.\n\n### `enableblinkfeatures`\n\n```\n<webview src=\"https://www.github.com/\" enableblinkfeatures=\"PreciseMemoryInfo, CSSVariables\"></webview>\n```\n\nA `string` which is a list of strings which specifies the blink features to be enabled separated by `,`. The full list of supported feature strings can be found in the RuntimeEnabledFeatures.json5 file.\n\n### `disableblinkfeatures`\n\n```\n<webview src=\"https://www.github.com/\" disableblinkfeatures=\"PreciseMemoryInfo, CSSVariables\"></webview>\n```\n\nA `string` which is a list of strings which specifies the blink features to be disabled separated by `,`. The full list of supported feature strings can be found in the RuntimeEnabledFeatures.json5 file.",
     "slug": "webview-tag",
     "websiteUrl": "https://electronjs.org/docs/api/webview-tag",
     "repoUrl": "https://github.com/electron/electron/blob/v32.0.0-nightly.20240510/docs/api/webview-tag.md",

@MarshallOfSound
Copy link
Member

Looking at the diffs, dropping the image tags makes sense 👍 I think replacing the br with \n probably is a better fix than just removing them completely. Those don't impact the .d.ts output because the only seem to appear in class descriptions which I guess don't get rendered in the typings file?

@dsanders11 dsanders11 force-pushed the fix/filter-out-html branch from 9e72c1f to 6d81b1b Compare May 13, 2024 12:52
@dsanders11
Copy link
Member Author

Updated to convert <br> (and variations) to \n and made sure the tests were also using MarkdownIt({ html: true })

@erickzhao erickzhao requested a review from MarshallOfSound May 14, 2024 17:20
break;
case 'html_inline':
// Replace <br> elements with a newline
if (tokenToCheck.content.match(/<br\s*\/?>/)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the $ and ^ anchors here? Worst case we get a bunch of newlines but not sure how this works 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my testing on https://markdown-it.github.io/ (need to toggle the html option), html_inline is always going to have a token that starts with < and ends with >, so I don't think we need anchors.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, I was just thinking about some truly garbage HTML
image
Or some less garbage HTML that's just nested
image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are both html_block so they'll get chomped entirely by this change, which is I think what we want?

@dsanders11 dsanders11 merged commit 43b5393 into electron:main Jun 21, 2024
3 checks passed
@dsanders11 dsanders11 deleted the fix/filter-out-html branch June 21, 2024 06:09
Copy link

🎉 This PR is included in version 1.2.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants