public static List <PageFragment> ParseScript(this ScriptContext context, ReadOnlyMemory <char> text)
        {
            var                   to             = new List <PageFragment>();
            ScriptLanguage        scriptLanguage = null;
            ReadOnlyMemory <char> modifiers      = default;
            ReadOnlyMemory <char> prevBlock      = default;
            int                   startBlockPos  = -1;
            var                   cursorPos      = 0;
            var                   lastBlockPos   = 0;

            const int delim = 3; // '```'.length

            while (text.TryReadLine(out var line, ref cursorPos))
            {
                var lineLength = line.Length;
                line = line.AdvancePastWhitespace();
                var leftIndent = lineLength - line.Length;

                if (line.StartsWith("```"))
                {
                    if (startBlockPos >= 0 && line.Slice(delim).AdvancePastWhitespace().IsEmpty) //is end block
                    {
                        var templateFragments = ScriptTemplate.Language.Parse(context, prevBlock);
                        to.AddRange(templateFragments);

                        var blockBody      = text.ToLineStart(cursorPos, lineLength, startBlockPos);
                        var blockFragments = scriptLanguage.Parse(context, blockBody, modifiers);
                        to.AddRange(blockFragments);

                        prevBlock      = default;
                        startBlockPos  = -1;
                        scriptLanguage = null;
                        modifiers      = null;
                        lastBlockPos   = cursorPos;
                        continue;
                    }

                    if (line.SafeGetChar(delim + 1).IsValidVarNameChar())
                    {
                        line = line.Slice(delim).ParseVarName(out var blockNameSpan);

                        var blockName = blockNameSpan.ToString();
                        scriptLanguage = context.GetScriptLanguage(blockName);
                        if (scriptLanguage == null)
                        {
                            continue;
                        }

                        modifiers     = line.AdvancePastChar('|');
                        prevBlock     = text.ToPreviousLine(cursorPos, lineLength);
                        startBlockPos = cursorPos;
                    }
                }
            }

            var remainingBlock = text.Slice(lastBlockPos);

            if (!remainingBlock.IsEmpty)
            {
                var templateFragments = ScriptTemplate.Language.Parse(context, remainingBlock);
                to.AddRange(templateFragments);
            }

            return(to);
        }