TiddlyWiki5 icon indicating copy to clipboard operation
TiddlyWiki5 copied to clipboard

Add start and end properties to WikiText AST nodes for all elements.

Open Gk0Wk opened this issue 7 months ago • 19 comments

Enhancements to WikiText Parser AST

Summary

This pull request introduces a significant enhancement to the WikiText parser by adding start and end properties to the AST nodes that did not previously have them. This update includes nodes such as lists, codeblocks, and various other elements that were lacking these properties.

Background

The ability to identify the exact substring range of a syntax subtree within the source file is crucial for advanced functionalities like section editing. While some progress had been made in the past by adding start and end properties to paragraph elements, other nodes were still missing this information.

Changes

With this PR, I've implemented a uniform check across all syntax rules during the AST generation process. Now, every node produced by the parser will have its corresponding start and end properties, marking the range of the substring it represents in the source text.

Benefits

  • Enables the implementation of more complex features such as segment editing.
  • Improves the accuracy and usefulness of the AST for further processing and manipulation.
  • Provides consistency across different types of nodes in the AST.

Testing

Before:

image

After:

image

I look forward to your feedback on these enhancements!

Gk0Wk avatar Nov 29 '23 07:11 Gk0Wk