Code Monkey home page Code Monkey logo

Comments (11)

anthonyjb avatar anthonyjb commented on September 28, 2024

Ahh - it should strip HTML commends before attempting to parse inner HTML but perhaps it's failing if there's nothing in the comment - this is an issue with HTMLString. I'll resolve ASAP, thanks for highlighting.

from contenttools.

bfintal avatar bfintal commented on September 28, 2024

Even if there's content in it, it's still failing :)

from contenttools.

anthonyjb avatar anthonyjb commented on September 28, 2024

Hmmm... that's odd - I don't think there's a test spec for this so will add one at the same time.

from contenttools.

anthonyjb avatar anthonyjb commented on September 28, 2024

OK that now correctly removes comments before parsing (my RegExp was incorrect). There's now comments in the test spec data.

Only down side is any comments you add will be removed as soon as the element containing them is edited and saved, I hadn't considered supporting comments within the editable regions up to this point and I'm not entirely sure how they would be catered for when a user edits the content - but happy to consider arguments for supporting them :)

from contenttools.

bfintal avatar bfintal commented on September 28, 2024

The reason I'm actually using comments is that I needed to add some sort of hidden marker inside the html. So for if I generate <!--marker1--> ...unknown html... <!--/marker1-->, I can get the insides of those comments when saving and process them in a different way.

from contenttools.

anthonyjb avatar anthonyjb commented on September 28, 2024

Can you place those markers outside of the editable regions? For example:

<!--marker1--><div data-editable="marker1">
    <p>
        Here goes my editable content...
    </p>
</div><!--/marker1-->

I actually do something very similar with Jinja2 templates for the getcontenttools.com website.

from contenttools.

anthonyjb avatar anthonyjb commented on September 28, 2024

If they need to be inside of the editable element one option would be to consider using a span tag:

<div data-editable="my-region">
    <p>
        Here <span class="marker1">goes my editable content...</span>
    </p>
</div>

It should still be relatively easy to extract this content safely.

from contenttools.

bfintal avatar bfintal commented on September 28, 2024

Right now as an alternative I'm wrapping the content inside a div with a data-ce-tag="static", although the thing is I don't know what will be inside that so I might be messing up the content by adding a div. The best thing I thought was to add starting & ending comment tags so I can keep track of them. They need to be inside the editable content though.

from contenttools.

anthonyjb avatar anthonyjb commented on September 28, 2024

Ah OK that makes a lot of sense - if you use a static element then the content inside wont be parsed by the editor, however one thing to be aware of is since the library basically relies on the browsers innerHTML output for static elements it might come back a little bit different once saved and across different browsers - but it should still be valid HTML of course.

from contenttools.

bfintal avatar bfintal commented on September 28, 2024

So will comments not be stripped out anymore? :)

from contenttools.

anthonyjb avatar anthonyjb commented on September 28, 2024

So if you use comments in static elements they shouldn't be stripped - they certainly aren't in Chrome - however as I say it does depend on the innerHTML output of each browser.

from contenttools.

Related Issues (20)

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.