Jump to content
porton

XML in plaintext, what to do with it?

Recommended Posts

I want to extend XHTML with tags like

<pre syntax:format="python">
# Some Python code
def f():
    pass
</pre>

The text in <pre> tag should be "enriched" with <span> HTML tags with classes, to highlight the syntax of the text inside <pre>.

What my code should do if the processed <pre> tag already contains some XML tags? Example:

<pre syntax:format="python">
# Some Python code
def f():
    <em>pass</em>
</pre>

The variants I thought of:

  1. first remove the tags (like <em> in the above example)
  2. leave the content of the <pre> tag as is (just remove syntax:format argument)
  3. terminate my pipeline processing with an error
Edited by porton

Share this post


Link to post
Share on other sites

A pre tag means the contents are pre-formatted, so the correct behavior is to print out any tags that appear in the pre block instead of rendering them.

Share this post


Link to post
Share on other sites

@justsomeguy You confuse between pre-formatted and plain text. <pre> in HTML can contain any formatting tags (<em>, <strong>, etc.)

I decide to raise an exception in this case, because other ways do not work for me.

Share this post


Link to post
Share on other sites

It looks like that's correct, several tags are allowed in a pre block.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×