On Thursday, August 7, 2025 at 5:59:47 AM UTC-5 Edward K. Ream wrote: > On second thought, PR #4412 <https://github.com/leo-editor/leo-editor/pull/4412> will just rewrite Leo's existing parse-body command.
Yesterday was one of those rare golden days of programming. Everything I did seemed to have second sight. I started with a vague direction and a limited purpose: to get parse-body working for Python. At day's end, I had a general framework in which supporting a new language required two statements: an import statement and a new dictionary entry. The result is a thorough re-imagining of Leo's importers. The new parse-body command uses only two importer methods: *x.delete_comments_and_strings* and *x.find_blocks*. The base Importer class defines these two methods, so *all* importers define these methods. The only other requirement is that the importer must define *x.block_patterns*, a list of tuples. The PR adds this list for the Rust importer. Along the way, I discovered a spectacularly easy way of moving blank lines from the start of a node (where they are always annoying) to the end of the previous (sibling) node, where they are practically invisible. See * ic.preprocess_blocks* if you are interested. This is the way it is written in The Book. I won't generalize the code further. Please let me know if you would like parse-body to support other languages. Edward -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/leo-editor/b287faee-3424-4a34-b7c7-54c50790ac9en%40googlegroups.com.
