Skip to content
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.

Use xhp for html rendering #27

Open
wants to merge 37 commits into
base: main
Choose a base branch
from

Conversation

lexidor
Copy link
Contributor

@lexidor lexidor commented May 27, 2023

fixes #1
fixes #14

Fixes:

  • Remove dead fixmes.
  • Lint with hhast lint.
  • Introduces IRenderer<+T> for covariant handling of Renderer.
  • Introduces HTMLXHPRenderer to render straight to XHP.
  • Introduces HTMLWithXHPInternallyRenderer to grant XHP benefits to users unable to use the xhp variant.

lexidor added 30 commits May 27, 2023 12:59
This library contain many non-final classes, all of which may have been extended elsewhere.
Accept that this library doesn't meet this strict standard and move on.
This library contains classes with duplicate names.
Example:
```
use type Facebook\Markdown\Block\ThematicBreak as ASTNode;
class ThematicBreak {}
```
The alias to ASTNode allows the UnparsedBlocks\ThematicBreak to refer to the other.
A use statement without an alias would create a name collision with the declaration.
One could choose to always refer to the other node using a qualified name:
Blocks\ThematicBreak
This linter found `$offset;`, but I can't imagine what this was supposed to do.
It's an int, so what the intent to increment / decrement it?
Thank you @ryangreenberg for adding this linter to hhast.
XHP renders `disabled={true}` as `disabled`, but the spec expects `disabled=""`.
It would be a shame if this small incompatibility would block xhp adoption.
Let's make the spec tests allow these stringless boolean attributes.
The HTMLXHPRenderer still needs to be written.
All methods have been extracted from Renderer<T>.
We need this interface to write tests again HTML(XHP)?Renderer.
This itnerface allows us to reference them as `IRenderer<XHPChild>`.
Requires disabling child validation.
Some of the specs expect invalid html.
One fewer "magic" type system lie!
Explicitly use the `->forceAttribute()` api.
This is the proper way to tell lies and will be caught when xhp attributes become sound.
We can't simply switch the HTMLRender to use HTMLXHPRenderer under the hood.
The xhp renderer has slightly different output:
 - Boolean attributes are rendered as `attr` instead of `attr=""`.
 - Void elements don't include a trailing solidus (backslash) in their open tag.
I'd not want to break test suites , bust caches, or break naive parsers.
This change should be opt-in, but low friction.
HTMLXHPRenderer had a `$node !== ''` comparison.
This is always false, but we don't case about the filter anyhow.
Joining an empty string has the same effect as not joining it.
Optimization also applied in HTMLRenderer.
Wrapping a vec of nodes in a frag is not needed if embedded in a node.
The node would unpack the frag immediately and appended the children.
This is what it does for a vec too.
The hhvm version is laughably out of date.
We don't need hhvm-autoload, HH\Facts will do.
)[]: string {
// https://stackoverflow.com/posts/1732454/revisions
// #pragma enable module(guard(superstition))
return Regex\replace_with($html, re'#<img .+?>#', $he_comes ==> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If this joke is a little much, let me know and I'll rewrite the git history so it was never here to begin with.

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

Successfully merging this pull request may close these issues.

HTML rendering should use XHP Support rendering to XHP
2 participants