-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Add "allowHTML" option for Markdoc with HTML parsing/processing #7597
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
e0ba388
7576 - initial support for HTML inside Markdoc.
alex-sherwin 0dcae1a
7576 - fixed issues with whitespace preservation
alex-sherwin ce50bb5
7576 - detailed nested HTML test coverage
alex-sherwin 9e27802
7576 - component + HTML interleaved tests
alex-sherwin 45fb081
7576 - fix lint problems from previous changes
alex-sherwin 9dcc077
7576 - some commentary
alex-sherwin 567fb67
7576 - file naming, refactor html under imports, package.json export…
alex-sherwin 691e5ca
7576
alex-sherwin 80f4d37
7576
alex-sherwin f98e90a
7576 - fixed test before/after for DRY'ness
alex-sherwin b30c79b
7576 - no need to React-ify HTML attribute case
alex-sherwin 2e70bff
7576 - rename "enableHTML" option to "allowHTML"
alex-sherwin dc8ff5b
Added Markdoc allowHTML feature changeset
alex-sherwin 2180bf5
7576 - updated README with allowHTML info
alex-sherwin d252368
7576 - fixed changeset typo
alex-sherwin a85bd78
7576 - minor edits based on PR feedback for docs
alex-sherwin af54e3c
7576 - minor edits based on PR feedback for docs
alex-sherwin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| --- | ||
| '@astrojs/markdoc': patch | ||
| --- | ||
|
|
||
| Adds an "allowHTML" Markdoc integration option. | ||
|
|
||
| When enabled, all HTML in Markdoc files will be processed, including HTML elements within Markdoc tags and nodes. | ||
|
|
||
| Enable this feature in the `markdoc` integration configuration: | ||
|
|
||
| ```js | ||
| // astro.config.mjs | ||
| export default defineConfig({ | ||
| integrations: [markdoc({ allowHTML: true })], | ||
| }); | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
packages/integrations/markdoc/src/html/css/parse-inline-css-to-react.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
|
|
||
| import { styleToObject } from "./style-to-object.js"; | ||
|
|
||
| export function parseInlineCSSToReactLikeObject(css: string | undefined | null): React.CSSProperties | undefined { | ||
| if (typeof css === "string") { | ||
| const cssObject: Record<string, string> = {}; | ||
| styleToObject(css, (originalCssDirective: string, value: string) => { | ||
| const reactCssDirective = convertCssDirectiveNameToReactCamelCase(originalCssDirective); | ||
| cssObject[reactCssDirective] = value; | ||
| }); | ||
| return cssObject; | ||
| } | ||
|
|
||
| return undefined; | ||
| } | ||
|
|
||
| function convertCssDirectiveNameToReactCamelCase(original: string): string { | ||
| // capture group 1 is the character to capitalize, the hyphen is omitted by virtue of being outside the capture group | ||
| const replaced = original.replace(/-([a-z0-9])/ig, (_match, char) => { | ||
| return char.toUpperCase(); | ||
| }); | ||
| return replaced; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.