Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

markdown in README does not display the <file> tag #8

Open
brrf opened this issue Dec 21, 2024 · 0 comments
Open

markdown in README does not display the <file> tag #8

brrf opened this issue Dec 21, 2024 · 0 comments

Comments

@brrf
Copy link

brrf commented Dec 21, 2024

The discrepancy between the source code and how it appears in the rendered README is likely due to how the Markdown processor interprets the XML. Many Markdown renderers (like GitHub's) have specific quirks when displaying raw XML. Here's why this happens and how to fix it:

Why the Block Doesn't Show in the README
XML Tags in Markdown:

XML is interpreted as raw HTML by some Markdown renderers. Tags like might be treated as unknown HTML elements, causing their content to be hidden or stripped out.
Markdown Ignoring Unknown HTML:

If the Markdown renderer doesn't recognize as a valid HTML tag, it can ignore it altogether, making it disappear from the output.
CDATA Rendering:

Even though CDATA is valid XML, Markdown renderers might not process it correctly because they don't parse CDATA sections.
How to Fix It
To ensure the XML displays correctly in the README, you need to escape or format the XML so the renderer treats it as plain text rather than attempting to interpret it.

Solution 1: Wrap the XML in a Code Block
Use a Markdown code block (with triple backticks) to force the renderer to treat the XML as raw text:

markdown
Copy code

<code_changes>
  <changed_files>
    <file>
      <file_summary>**BRIEF CHANGE SUMMARY HERE**</file_summary>
      <file_operation>**FILE OPERATION HERE**</file_operation>
      <file_path>**FILE PATH HERE**</file_path>
      <file_code><![CDATA[
      __FULL FILE CODE HERE__
      ]]></file_code>
    </file>
    **REMAINING FILES HERE**
  </changed_files>
</code_changes>
php
Copy code

This method works in most Markdown processors, including GitHub.

---

#### Solution 2: Escape the XML Tags
If you want the XML to appear inline without using a code block, you must escape the `<` and `>` characters to ensure they aren't interpreted as HTML:
```markdown
&lt;code_changes&gt;
  &lt;changed_files&gt;
    &lt;file&gt;
      &lt;file_summary&gt;**BRIEF CHANGE SUMMARY HERE**&lt;/file_summary&gt;
      &lt;file_operation&gt;**FILE OPERATION HERE**&lt;/file_operation&gt;
      &lt;file_path&gt;**FILE PATH HERE**&lt;/file_path&gt;
      &lt;file_code&gt;&lt;![CDATA[
      __FULL FILE CODE HERE__
      ]]&gt;&lt;/file_code&gt;
    &lt;/file&gt;
    **REMAINING FILES HERE**
  &lt;/changed_files&gt;
&lt;/code_changes&gt;
The Markdown renderer will display this as plain text.

Solution 3: Use a Preformatted HTML Block
If the target audience of your README supports HTML (e.g., GitHub), you can wrap the XML in a <pre> block:

markdown
Copy code
<pre>
<code_changes>
  <changed_files>
    <file>
      <file_summary>**BRIEF CHANGE SUMMARY HERE**</file_summary>
      <file_operation>**FILE OPERATION HERE**</file_operation>
      <file_path>**FILE PATH HERE**</file_path>
      <file_code><![CDATA[
      __FULL FILE CODE HERE__
      ]]></file_code>
    </file>
    **REMAINING FILES HERE**
  </changed_files>
</code_changes>
</pre>
This ensures the XML is treated as preformatted text and displayed exactly as written.

Recommendation
The simplest and most portable approach is Solution 1 (Markdown Code Block):

markdown
Copy code
```xml
<code_changes>
  <changed_files>
    <file>
      <file_summary>**BRIEF CHANGE SUMMARY HERE**</file_summary>
      <file_operation>**FILE OPERATION HERE**</file_operation>
      <file_path>**FILE PATH HERE**</file_path>
      <file_code><![CDATA[
      __FULL FILE CODE HERE__
      ]]></file_code>
    </file>
    **REMAINING FILES HERE**
  </changed_files>
</code_changes>
scss
Copy code

This ensures that your XML is always visible in the README without requiring readers to modify or configure their Markdown viewers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant