Inline XML code is not displayed #54

Closed
PrimaryFeather opened this Issue Jan 23, 2011 · 3 comments

Comments

Projects
None yet
2 participants

If I want to display a sample XML document in the class description, it is not visible in the output HTML.

Here is a sample:

/** ------------------------------------------------------------------------------------------------

Here is a sample XML:

<font>
  <info face="BranchingMouse" size="40" />
  <!-- ... -->
</font>

------------------------------------------------------------------------------------------------- */

The output does not show the XML data. Looking at the source shows that the XML is added to the HTML directly, surrounded with <pre>, but without escaping the "<" and ">"s.

Owner

tomaz commented Jan 24, 2011

Right, this one is due to appledoc preventing template engine doing any stripping to allow embedding arbitrary HTML constructs within comment text, like this:

some text <span class="something">marked text</span> etc. etc.

But you're right, this should be handled for example sections. There are two approaches: manually escape example blocks or change how they are handled in template. The first would be cleaner to implement but second would give more customization power. Will investigate a bit and decide which way to go with.

Owner

tomaz commented Jan 24, 2011

Fixed HTML and XML handling within example blocks. Closed by d7ece46.

The problem was two fold: template engine is specifically instructed to prevent any HTML escaping (otherwise using custom HTML tags within comment code wouldn't be possible), but this renders example blocks containing XML or HTML useless. To overcome this, example blocks are manually escaped by appledoc. Note that this required updating example blocks unit tests - changing to real settings provider as mock didn't do escaping...

Second: GBTokenizer marked HTML/XML opening comment marker &lt;!-- as a delimiter and removed it from the string, leaving only the remaining text. This interfered with example blocks processing later on. This was actually a bug as delimiter should only be considered a line containing ONLY delimiter chars (at present the regex used was matching only from start of line)!

Also added few more unit tests for validating example blocks prefixed with spaces are detected.

Increased build number to 525.

Works like a charm! Thx!

@tonklon tonklon pushed a commit to tonklon/appledoc that referenced this issue Mar 8, 2012

@tomaz tomaz Fixed HTML and XML handling within example blocks. Closes #54.
The problem was two fold: template engine is specifically instructed to prevent any HTML escaping (otherwise using custom HTML tags within comment code wouldn't be possible), but this renders example blocks containing XML or HTML useless. To overcome this, example blocks are manually escaped by appledoc. Note that this required updating example blocks unit tests - changing to real settings provider as mock didn't do escaping...

Second: GBTokenizer marked HTML/XML opening comment marker `<!--` as a delimiter and removed it from the string, leaving only the remaining text. This interfered with example blocks processing later on. This was actually a bug as delimiter should only be considered a line containing ONLY delimiter chars (at present the regex used was matching only from start of line)!

Also added few more unit tests for validating example blocks prefixed with spaces are detected.

Increased build number to 525.
d7ece46

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment