fix: remove preprocessor-specific attributes#653
Open
dummdidumm wants to merge 2 commits intomainfrom
Open
Conversation
- global for style tags - src for script/style tags fixes #652
dominikg
reviewed
Aug 28, 2024
| /** Add a custom language preprocessor */ | ||
| potatoLanguage({ content, filename, attributes }) { | ||
| const { code, map } = require('potato-language').render(content); | ||
| const { src, ...cleanedAttributes } = attributes; |
There was a problem hiding this comment.
this example does not make sense as i assume potato-language uses the lang attribute value.
If you want to show it here, the preprocessor would have to use a custom potato attribute that then gets filtered
dominikg
reviewed
Aug 28, 2024
| }; | ||
| }; | ||
|
|
||
| export const removeSrcAttribute = (attributes: Record<string, any>) => { |
There was a problem hiding this comment.
should this be a generic util?
export const filterAttributes(attributes: Record<string,any>, filterFn: (a:string) => boolean) {
return Object.fromEntries(Object.entries(attributes).filter(([a])=>filterFn(a)))
}usage:
const cleanAttributes = filterAttributes(attributes, a => a !=='src');
// or
const attributesToRemove = ['foo','bar'];
const cleanMultipleAttributes = filterAttributes(attributes, a => !attributesToRemove.includes(a))that can be reused for global and potentially others?
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
fixes #652
@dominikg does this fix the v-p-s issue?
Before submitting the PR, please make sure you do the following
pnpm lint!)Tests
npm testorpnpm test