cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Is it possible to store/display html markup in node value?

kave
Node Clone

Greetings,

I am using GrapheneDB Neo4j 3.2 and node.js on heroku.

Is it possible to store html markup in a node's property in order to have that html displayed/respected in the app displaying this node/property?

Match (n:Term)
Set n.Notes = 'Here is some text.<br>Here is some text on another line.'

Then in the app display the above text would show on 2 different lines?

Many Thanks,

Keith

1 ACCEPTED SOLUTION

Yes, you can definitely store html markup in a property. You'd probably use <br> tags to separate lines or use escape character \n.

More on escape characters:
https://neo4j.com/docs/cypher-manual/current/syntax/expressions/#cypher-expressions-string-literals

View solution in original post

3 REPLIES 3

Yes, you can definitely store html markup in a property. You'd probably use <br> tags to separate lines or use escape character \n.

More on escape characters:
https://neo4j.com/docs/cypher-manual/current/syntax/expressions/#cypher-expressions-string-literals

Thanks so much for the help Ryan!

I've improved my original question (needed to escape the <br> code there so the tag would show in my question).

So it's normal to put html markup in a Neo4j node property and have it respected by an 'app'?
Is it more likely that my Node.js is not respecting the html? If that's the case, I'll switch forums.

It’s not abnormal in smaller quantities.

I’m not a node.js expert, but i’d guess that something is treating your html as “unsafe” user input and automatically escaping it in order to prevent some types of attacks (user-written html infecting harmful javascript code as an example)

If you know it is safe, you sometimes need to indicate that to templating languages (ie python flask requires that you indicate the template variables are safe content, else it’ll be escaped)

Cheers
Ryan

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online