• I tried to create a FAQ with some XML examples. The editor handles them fine, and I can see that it converts all the ‘<‘ and ‘>’ to appropriate HTML entities.
    However, when viewing the FAQ, all of that content is stripped.
    I tracked it down to calling html_entity_decode on the post content in View.FAQ.class.php:
    $this->faq_answer = apply_filters( ‘the_content’, html_entity_decode( $this->post->post_content ) );

    If I remove “html_entity_decode”, my content shows up, and no other HTML seems to be affected.

    Are you sure you should be calling that? If so, how can I get my XML examples to appear?

    Here is the example page. But note that I’ve already removed the decode call:
    https://www.dragonframe.com/blog/ufaqs/how-does-dragonframe-store-timeline-frame-edits-edit-decision-list/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Support jaysupport

    (@jaysupport)

    Hi dyam,

    We have a filter in the plugin (added in version 2.1.7 earlier this year) that lets you manually specify allowed HTML tags and attributes in the FAQ answer/body.

    Here’s an example of how to use it: https://pastebin.com/ehrKmqK0

    Thread Starter dyamized

    (@dyamized)

    That is not the same issue. But I tested your proposed solution and it did not work.

    I am not trying to get html tags into my FAQ answer.
    I write an answer in the visual editor. For example: “Here is a line with <test> in it.”
    The editor correctly converts the “<” and “>” to html entities and stores it in the database that way. If I switch over to the “Edit as HTML” mode, I see the html entities. This is all correct.

    However, when I view the FAQ elsewhere, “<test>” is completely removed. The raw html should have “<test>”. Instead, it has nothing.

    It should be: “<p>Here is a line with <test> in it.</p>”
    It is: “<p>Here is a line with in it.</p>”

    • This reply was modified 2 years, 1 month ago by dyamized.
    Plugin Support jaysupport

    (@jaysupport)

    What is <test>? Is this a custom HTML element that you have declared somewhere?

    When an HTML tag is allowed in the plugin, it is allowed for rendering. It does not show the raw tag on the front, but, rather, renders it. If <test> does not exist or does not render anything, then, of course, it will not show on the front end.

    The better test would be to try it with an actual HTML element and see if what you would like renders on the front end.

    Also, make sure you are correctly inserting it on the FAQ edit screen. For example, with Gutenberg, you can/should be using the “Custom HTML” block.

    Thread Starter dyamized

    (@dyamized)

    You have it absolutely backwards. You are not listening to me.

    Please look at this page now:
    https://www.dragonframe.com/blog/ufaqs/how-does-dragonframe-store-timeline-frame-edits-edit-decision-list/

    It shows how I want it to show.
    It doesn’t matter what “<test>” is. “<test>” is something that I want to appear, as text, in the final output. It is not an HTML tag, and I do not want it inserted raw into the source output.

    In my example page, I have xsd elements, such as “<scen:edl>”, that I am trying to show to the user, as text. You can see it.
    This page only works and displays “<scen:edl>” properly if I remove the “html_entity_decode” from the file I mentioned.

    Just try to make an FAQ answer that shows what you just wrote to me: “What is <test>?”
    See if it renders.

    Plugin Support jaysupport

    (@jaysupport)

    Oh, okay, then the “issue” is just that what you are adding is being interpreted as an HTML tag, which is only natural because it’s in HTML tag format and is being used in content that is being output as HTML…

    In that case, the answer is simple: There’s no built-in option to do what you want. The plugin is meant to output text/HTML in the FAQ answer, and, if something is in HTML format, it will be interpreted as HTML. The only way you’re going to get it to behave in the custom way you want is to modify the code in the exact fashion you already have.

    Thread Starter dyamized

    (@dyamized)

    This is a very odd response. No other WordPress plugin handles content this way.
    I can write any post, page, etc, and if I use the visual editor and add things with “<” characters, that gets escaped in the database. In fact, the same thing happens with your plugin. I can see that the my code is escaped (properly) in the database.

    When this is rendered, it should be left escaped, so that visually it shows the “<” characters. It should not be converted back to “<” in the raw HTML or stripped from the output.

    What you are saying is that it is impossible to write an FAQ response about an HTML or XML topic.

    For example: Question: “How do a I specify the title of an HTML page?” Answer: “With the <title> tag, inside of a <head> tag.”

    Will you acknowledge that you can’t write this very simple answer with the plugin? And then tell me, with a straight face, that it is a non issue?

    Plugin Support jaysupport

    (@jaysupport)

    Of course it’s possible to display this. You don’t even need to modify the code. You mentioned HTML entities earlier. If you replace the greater/less than signs included in your code with those, it will display without you even needing to modify our plugin code as you did. Otherwise, if you would prefer to not use the entities, you can modify the plugin code as you did.

    You can see the following FAQ on our demo site for an example of HTML tags being displayed in an FAQ. And we have made no modifications to the plugin on that site. Just used the entities.

    https://www.etoilewebdesign.com/ultimate-faq-demo/single-faq/can-i-give-code-examples-in-an-faq/

    For reference, the HTML entity for < is

    &lt ;

    (with no space before the semicolon).

    And for > it is

    &gt ;

    • This reply was modified 2 years, 1 month ago by jaysupport.
    • This reply was modified 2 years, 1 month ago by jaysupport.
    Thread Starter dyamized

    (@dyamized)

    I think you know that you shouldn’t have to write out HTML entities in the VISUAL EDITOR, which is the only way to to do it with your plugin. But it doesn’t seem like you are interested in making it work the way it is supposed to.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Escaped XML/HTML gets removed from output’ is closed to new replies.