Git Product home page Git Product logo

html-node's Introduction

html-node's People

Contributors

conner-pys avatar dependabot[bot] avatar ttwno avatar vidhanio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

html-node's Issues

Attribute String keeps my Hyperscript Formatting - Boo - NBD

Really minor enhancement I think.

So I have decided Hyperscript is a good idea. Upon using it with html-node, it actually works great, except the html generated keeps newlines, useless space characters, and I suppose tabs if I was using them. Ultimately, my html is tidy when it is sent off by the server, except for the formatting I've entered in the attribute string.

This isn't a particularly huge deal. A few spaces never killed anyone. It's more like I see it and my brain says no.

Attributes have not had formatted code placed into them in the past, so this wasn't really a thing.

So something like this:

<button _="on click set :dialog to the closest <dialog/>
           then set :video to the next <video/>
           then repeat in :video.srcObject.getTracks()
               call it.stop()
           end
           then send reset to the next <canvas/>
           then call :dialog.close()">

That will be sent over the wire with the formatting.

impl Display for Element {
    /// Format as an HTML element.
    fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
        write!(f, "<{}", self.name)?;

        for (key, value) in &self.attributes {
            write!(f, " {key}")?;

            if let Some(value) = value {
                let encoded_value = html_escape::encode_double_quoted_attribute(value);
                write!(f, r#"="{encoded_value}""#)?;
            }
        }
        write!(f, ">")?;

        if let Some(children) = &self.children {
            write_children(f, children, false)?;

            write!(f, "</{}>", self.name)?;
        };

        Ok(())
    }
}

Looks like this piece of code here one could just add something which removes this type of whitespace from the value variable before passing it to encode_double_quoted_attribute. Specifically, replace all newlines + zero or more spaces + zero or more tabs with one space. Something like that. That assumes I'm even looking in the right spot.

I'm willing to implement this myself. Feedback?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.