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

Bug: < and > are removed in markdown code snippets #98

Open
markstamer opened this issue Jul 22, 2024 · 5 comments
Open

Bug: < and > are removed in markdown code snippets #98

markstamer opened this issue Jul 22, 2024 · 5 comments

Comments

@markstamer
Copy link
Collaborator

I stumbled across an issue where a code snippet in a markdown file, such as, func store(in set: inout Set<AnyCancellable>) { } is rendered as func store(in set: inout Set) { }. The generic type is simple removed from the Set. Unfortunately I could find the issue in the Ignite framework or if this is an issue with swift-markdown.

@twostraws
Copy link
Owner

I think this might affect all Markdown libraries, because it's seeing them as HTML. For example, if I paste that same thing into iA Writer on my Mac (my Markdown editor), it does exactly the same thing.

@markstamer
Copy link
Collaborator Author

Outch, so writing an article about Swift generics using the markdown content approach of Ignite could be a bit of a problem.

@markstamer
Copy link
Collaborator Author

I don't have iA Writer to see it for myself but in VSCode previews it works. Maybe there is a misunderstanding in that I meant the code is either inline code or in a code block. Being able to display HTML code in a code block should be working in every Markdown library?

@alexito4
Copy link

alexito4 commented Oct 8, 2024

I've also had some issues with Swift code, specially a for loop with x..<y. I've been digging a bit and it seems that even tho the that code is inside a <pre> tag, that doesn't stop browsers from trying to parse html tags inside it. I've found that changing

#"<pre><code class="language-\#(language.lowercased())">\#(codeBlock.code)</code></pre>"#
to escape the string from codeBlock.code solves the problems.
It's interesting that there are no more reports of this issue so maybe my conclusions are wrong.

@markstamer
Copy link
Collaborator Author

That's a great finding. I will try it out at times and maybe we can figure something out on how to fix it for Ignite.

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

3 participants