-
Notifications
You must be signed in to change notification settings - Fork 48
feat: Improve RichView image loading, text size, and UI fixes #73
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,7 +88,8 @@ public class HTMLToMarkdownConverter { | |
| result += "*\(content)*" | ||
|
|
||
| case "a": | ||
| let text = try convertElement(childElement) | ||
| // Get raw text without escaping for links | ||
| let text = try childElement.text() | ||
| if let href = try? childElement.attr("href") { | ||
| result += "[\(text)](\(href))" | ||
| } else { | ||
|
|
@@ -213,14 +214,16 @@ public class HTMLToMarkdownConverter { | |
|
|
||
| /// Escape special Markdown characters | ||
| private func escapeMarkdown(_ text: String) -> String { | ||
| // Only escape if not already in a code context | ||
| // This is a simplified version - a full implementation would track context | ||
| // Only escape characters that would cause markdown parsing issues | ||
| // Don't escape common characters like . and - as they rarely cause problems | ||
| // and escaping them breaks URLs and normal text readability | ||
| var escaped = text | ||
|
|
||
| // Don't escape inside code blocks (this is simplified) | ||
| // Don't escape inside code blocks | ||
| if !text.contains("```") && !text.contains("`") { | ||
| // Escape special Markdown characters | ||
| let charactersToEscape = ["\\", "*", "_", "[", "]", "(", ")", "#", "+", "-", ".", "!"] | ||
| // Only escape the most problematic markdown characters | ||
| // Avoid escaping . and - as they appear frequently in URLs and text | ||
| let charactersToEscape = ["\\", "*", "_", "[", "]"] | ||
|
||
| for char in charactersToEscape { | ||
| escaped = escaped.replacingOccurrences(of: char, with: "\\\(char)") | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing from
convertElement(childElement)tochildElement.text()prevents nested formatting in link text from being preserved. For example,<a href="..."><strong>Bold Link</strong></a>would previously render as[**Bold Link**](...)but now renders as[Bold Link](...). If this behavior change is intentional to fix URL escaping issues, consider documenting it or adding a test case to verify the expected behavior for links with nested formatting.