Skip to content

feat: Refactor italic node to support nested inline elements#20

Merged
boojack merged 3 commits intousememos:mainfrom
singhanubhavme:main
Mar 28, 2025
Merged

feat: Refactor italic node to support nested inline elements#20
boojack merged 3 commits intousememos:mainfrom
singhanubhavme:main

Conversation

@singhanubhavme
Copy link
Contributor

This PR introduces a significant improvement to the italic node structure by refactoring it to use a child-based content representation instead of a simple string. This change enables better support for nested inline elements within italic text.

Key changes:

  • Modified ast.Italic struct to use Children []Node instead of Content string
  • Updated the italic parser to parse nested inline elements (links, text) within italic content
  • Updated HTML and String renderers to handle the new node structure
  • Fixed related test cases in ordered list items

Benefits:

  • Better support for complex markdown structures
  • More consistent with the AST design pattern used elsewhere in the codebase
  • Improved extensibility for future inline element additions
  • Maintains backward compatibility with existing markdown parsing

The changes have been tested thoroughly with various markdown inputs, including:

  • Basic italic text with asterisks and underscores
  • Nested inline elements (links within italic text)
  • Mixed content with spaces and special characters

Other Changes:

  • Bold and Italic via underscores supported, empty blockquotes allowed.

Note:
This change also required a corresponding update in the main repository [https://github.com/usememos/memos], where this package is being used. A PR has been created there as well to ensure compatibility with the new Italic node structure.

Copy link
Member

@boojack boojack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@boojack boojack merged commit c9fa41c into usememos:main Mar 28, 2025
5 checks passed
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

Successfully merging this pull request may close these issues.

3 participants