Coder Social home page Coder Social logo

Improving documentation about htmlclean HOT 5 CLOSED

anseki avatar anseki commented on June 1, 2024
Improving documentation

from htmlclean.

Comments (5)

trompx avatar trompx commented on June 1, 2024

I have another case which is a bit annoying. I have the following:

Input:

<span><span>in </span><span class="dynamic"></span></span>

Output:

<span><span>in</span><span class="dynamic"></span></span>

I populate the dynamic span with javascript on user action, but as there is no html when htmlclean runs, the whitespace after in is removed.
What would you advice for that use case?

Another info, if I have php code between <?php ... ?> tags. After the php tag, the indentation is preserved (i.e. if I had the <?php tag indented by 8 tabs, all the compressed html after the php tag is indented with 8 tabs too).

from htmlclean.

anseki avatar anseki commented on June 1, 2024

Hi @trompx, thank you for the comment.

That seems correct behavior because htmlclean should remove unneeded whitespaces.
Web browsers ignore whitespaces between block elements such as <div>, and htmlclean removes those correctly.
See: https://github.com/anseki/htmlclean
If you replace the nested <div> with <span>, the whitespaces are kept.

And also, your HTML is incorrect (elements are not closed correctly), htmlclean and other programs such as web browsers may not be able to parse those.
See: https://github.com/anseki/htmlclean#malformed-nested-tags-and-close-tags-in-script

htmlclean tries to remove unneeded whitespaces. Therefore, the space is removed correctly if <span class="dynamic"> is empty when the source was given to htmlclean.
Insert something in <span class="dynamic"> like <span class="dynamic">|</span> to indicate that it is not empty.

from htmlclean.

trompx avatar trompx commented on June 1, 2024

Hey @anseki,

Thanks for the answer, I would not rather put any character until user input.
My bad I forgot to add the closing div but they are well present in my code.

Looks like I will have to add css margin to overcome this.

from htmlclean.

anseki avatar anseki commented on June 1, 2024

You can specify protect option for your special rule.

from htmlclean.

anseki avatar anseki commented on June 1, 2024

Unfortunately, no reply came, and I close this issue.

from htmlclean.

Related Issues (11)

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.