syntax-tree / hast-to-hyperscript Goto Github PK
View Code? Open in Web Editor NEWLegacy utility to transform hast to something else
Home Page: https://unifiedjs.com
Legacy utility to transform hast to something else
Home Page: https://unifiedjs.com
running something like
```testing
hi
```
through https://github.com/remarkjs/remark-react/ yields <pre><code>hi</code></pre>
, with missing language information.
It is correctly passed to HAST here (https://github.com/syntax-tree/mdast-util-to-hast/blob/master/lib/handlers/code.js) but gets lost in hast->hyperscript translation.
This issue is related to #14 regarding the properties of React elements.
My node has properties like:
{
params: ["param1", "param2", "param3"]
}
These lines in hast-to-hyperscript serializes the array into a string
if (value !== null && typeof value === 'object' && 'length' in value) {
// Accept `array`. Most props are space-separater.
value = (info.commaSeparated ? commas : spaces).stringify(value)
}
As was the case with the false values in #14 , when dealing with react elements, I would expect the properties to apply to the react element as-is. So that the react elements receive the actual properties that are present in the HAST.
Would it be possible to not transform the properties in case of react elements?
#4 is insufficient. node._owner
is not always null
.
return ReactElement(
type,
key,
ref,
self,
source,
ReactCurrentOwner.current, // โ become _owner directry
props,
);
var ReactCurrentOwner = {
/**
* @internal
* @type {ReactComponent}
*/
current: (null: null | ReactInstance | Fiber),
};
node._owner
is so unstable that it is new ReactCompositeComponentWrapper
at my local. so can't use it for detect.
React own detect its element by isValidElement function use Symbol
, But i don't know whether hast-to-hyperscript
relate it better.
sorry for the confusion. my did was superficial.
Hey,
I have html ast which i am parsing, with some of the properties being "false" (bool false not string).
they are boolean properties and i expect them to be either true or false.
After a processing of hast-to-hyperscript, those props are completely gone.
browsing the code abit, ive found those lines:
Lines 147 to 156 in 5dd6b51
(specificlly line 151 (value === false))
which i can understand why would you filter null and undefined, i don't understand why false is being filtered.
looking at the hast github again, i dont see any reasoning for that..
can you please explain this behavior? or maybe that is just a bug?
Im using rehype-react
, But when bundle with uglify (webpack -p
), style attribute stored in hast isn't reflected to view.
I looked it up, It seems the cause is node._store
.
to #L174
to #L25
result
: process.env.NODE_ENV === "development"
(work)
: process.env.NODE_ENV === "production"
(not work)
I don't know why this caused, But parseStyle
don't work because r === false
.
placeholder
I'll use this space for describing what specsare needed to add proper support for Vue.js 2 createElement.
The end goal is to code a remark-vue plugin.
Take this example style attribute, it strips the background-image
property from the semicolon forward
<span style="padding-bottom: 56.25%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAALABQDASIAAhEBAxEB/8QAFwABAQEBAAAAAAAAAAAAAAAAAAEDBf/EABUBAQEAAAAAAAAAAAAAAAAAAAAB/9oADAMBAAIQAxAAAAHtzUkUv//EABkQAQACAwAAAAAAAAAAAAAAAAEAAhASMf/aAAgBAQABBQJsjsw5n//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8BP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8BP//EABoQAAEFAQAAAAAAAAAAAAAAAAEAICIxMkH/2gAIAQEABj8CMeLJpv8A/8QAGhABAQACAwAAAAAAAAAAAAAAAREAYSBR4f/aAAgBAQABPyEgEyr3g03PMVCk1w//2gAMAwEAAgADAAAAEP8Az//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8QP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8QP//EABsQAQACAgMAAAAAAAAAAAAAAAERQQAgMVHB/9oACAEBAAE/EBA8AW6MSkU8tPrHcWkqrT//2Q=='); background-size: cover; display: block;">
Which then throws errors in the browser:
GET data:image/jpeg net::ERR_INVALID_URL
I believe the issue is here:
Line 213 in 68de5b0
When the styles get separated assuming the separator is a semicolon, which is a valid character in a base64 string.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.