When adding languages you define a function/regex to match the start and end positions of each language block. Polymode then scans the document, and runs the matchers.
e.g this matches markdown code blocks (and also extracts the language from the start to select the mode to run)
e.g this matches markdown code blocks (and also extracts the language from the start to select the mode to run)
( via https://polymode.github.io/defining-polymodes/ )