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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...