Here's an improved version that can detect more common languages - STYLE = ('LeoQTextBrowser {' 'font-family: Corbel, "Opens Sans","Sans-serif";' 'font-size: 12pt;}') NOSTYLE = 'LeoQTextBrowser {}' DIRECT = ('@language rest', '@language md', '@language asciidoc', '@language text', '@language plain', '@rest', '@md', '@rst', '@adoc', ':id:', ':ref:')
def has_direct(s, h): lines = s[:1000].splitlines() for line in lines: for d in DIRECT: if h.startswith(d) or line.startswith(d): return True return False def set_alt_body_font(tag, keys): c = keys['c'] css = NOSTYLE for p in c.p.self_and_parents(): if has_direct(p.b, p.h): css = STYLE break editor = c.frame.body.wrapper.widget editor.setStyleSheet(css) ud = g.user_dict ud['alt_body_font_proc'] = set_alt_body_font g.registerHandler('select3', ud['alt_body_font_proc']) On Friday, February 17, 2023 at 6:00:48 PM UTC-5 Thomas Passin wrote: Here is a script so you can see if you like the effect of having a non-monospaced font for non-code bodies. It only works for @language rest nodes. Copy the script below into a node in your workbook. Run it with CTRL-B. After that, any time you switch to an *@language rest* node, it will use the alternate font. It hooks *select3* so it won't detect if you change the *@language* directive until you switch nodes again. [snip] -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/5b936a1a-44fc-4c62-9fc7-567a49861d3dn%40googlegroups.com.