Reviving this old topic. I made a crude attempt, hard-coded etc., to just rewrite the section definitions via regex search and replace. Works just on a single .tex file (I don't see a benefit to using multiple input files when managing things via Leo anyway), but it's still useful in my case.
How would I add Undo to this? Any other obvious improvements to make? Cheers @language python """ Changes LaTeX section definition levels in the subtree of an @clean file node to their subtree level. Only one LaTeX section level can therefore be used within a single node body. """ import re section_levels = { 1: 'chapter', 2: 'section', 3: 'subsection', 4: 'subsubsection', 5: 'paragraph', 6: 'subparagraph' } def latex_convert_section_levels(body, adjusted_level_name): """ Replaces LaTeX section definition levels found on a single line (re multiline mode). Returns the modified node body.""" newbody = re.sub(r'\\(chapter|section|subsection|subsubsection|paragraph|subparagraph)(\[.*?\])?({.*})', r'\\'+adjusted_level_name+r'\g<2>\g<3>', body, re.M) return(newbody) if re.match(r'@clean [A-Za-z\./]+\.tex', p.h): root_level = p.level() for node in p.subtree(): level = node.level() - root_level if level < 7: level_name = section_levels[level] else: level_name = 'subparagraph' node.b = latex_convert_section_levels(node.b, level_name) g.es('Updated section levels based on outline structure.') else: g.es('not a LaTeX file node?') -- 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 leo-editor+unsubscr...@googlegroups.com. To post to this group, send email to leo-editor@googlegroups.com. Visit this group at https://groups.google.com/group/leo-editor. For more options, visit https://groups.google.com/d/optout.