Z31967

{
    "Z1K1": "Z2",
    "Z2K1": {
        "Z1K1": "Z6",
        "Z6K1": "Z31967"
    },
    "Z2K2": {
        "Z1K1": "Z14",
        "Z14K1": "Z31965",
        "Z14K3": {
            "Z1K1": "Z16",
            "Z16K1": "Z600",
            "Z16K2": "const STATE_NORMAL_TEXT = 0;\nconst STATE_IN_ANNOTATED = 1;\nconst STATE_IN_ANNOTATING = 2;\nconst CHAR_IAA = '\\uFFF9';\nconst CHAR_IAS = '\\uFFFA';\nconst CHAR_IAT = '\\uFFFB';\nconst CHAR_PS = '\\u2029';\n/**\n * handles the annotation markers, including 0, 1, or 2+ IASes and nesting, and the implicit IAT before a U+2029 paragraph separator,\n * but there's a good chance this doesn't correctly handle some other aspect of Unicode text, such as bidirectionality\n */\nfunction Z31965( Z31965K1 ) {\n\tlet str = [ ...Z31965K1 ];\n\tlet state = STATE_NORMAL_TEXT;\n\tlet segments = [];\n\twhile (str !== []) switch (state) {\n\t\tcase STATE_NORMAL_TEXT:\n\t\t\tconst iIAA = str.indexOf(CHAR_IAA);\n\t\t\tif (iIAA \u003C 0) {\n\t\t\t\t// no more segments in the rest of the string\n\t\t\t\tsegments.push([ str ]); //TODO strip IAS/IAT\n\t\t\t\tstr = [];\n\t\t\t} else {\n\t\t\t\t// jump to next segment\n\t\t\t\tsegments.push([ str.slice(0, iIAA) ]); //TODO strip IAS/IAT\n\t\t\t\tstr = str.slice(iIAA + 1);\n\t\t\t\tstate = STATE_IN_ANNOTATED;\n\t\t\t}\n\t\t\tbreak;\n\t\tcase STATE_IN_ANNOTATED:\n\t\t{\n\t\t\tconst iIAT = str.indexOf(CHAR_IAT);\n\t\t\tconst iPS = str.indexOf(CHAR_PS);\n\t\t\tlet iTerm;\n\t\t\tif (iIAT \u003C 0 \u0026\u0026 iPS \u003C 0) {\n\t\t\t\t// uhh segment extends to EOL I guess?\n\t\t\t\tiTerm = str.length;\n\t\t\t} else if (0 \u003C= iPS \u0026\u0026 (iIAT \u003C 0 || iPS \u003C= iIAT)) {\n\t\t\t\t// \"If an implementation encounters a paragraph break between an anchor and its corresponding terminator, it shall terminate any open annotations at this point.\"\n\t\t\t\tiTerm = iPS;\n\t\t\t} else {\n\t\t\t\tiTerm = iIAT;\n\t\t\t}\n\t\t\tconst iIAA = str.indexOf(CHAR_IAA);\n\t\t\tif (0 \u003C= iIAA \u0026\u0026 iIAA \u003C iTerm) return Wikifunctions.Error(\"Z516\", [ \"Z31965K1\", Z31965K1 ]); // nested annotation; explicitly allowed, but not used in the wild as far as I know, so this Function refuses them\n\t\t\tconst iIAS = str.indexOf(CHAR_IAS);\n\t\t\tif (0 \u003C= iIAS \u0026\u0026 iIAS \u003C iTerm) {\n\t\t\t\tif (0 \u003C= str.indexOf(CHAR_IAS, iIAS + 1)) return Wikifunctions.Error(\"Z516\", [ \"Z31965K1\", Z31965K1 ]); // 2+ annotating text parts\n\t\t\t\tsegments.push([ str.slice(0, iIAS), str.slice(iIAS + 1, iTerm) ]); // 1 annotating text part\n\t\t\t} else {\n\t\t\t\tsegments.push([ str.slice(0, iTerm) ]); // no annotating text parts? weird but okay\n\t\t\t}\n\t\t\tstr = str.slice(iTerm + 1);\n\t\t\tstate = STATE_NORMAL_TEXT;\n\t\t\tbreak;\n\t\t}\n\t\tcase STATE_IN_ANNOTATING:\n\t\t\t//TODO\n\t\t\tstr = [];\n\t\t\tstate = STATE_NORMAL_TEXT;\n\t\t\tbreak;\n\t}\n\treturn segments.map(([ annotated, annotating = [] ]) =\u003E new ZObject(new Map([\n\t\t[ \"Z7K1\", { \"Z1K1\": \"Z9\", \"Z9K1\": \"Z30414\" } ],\n\t\t[ \"Z30414K1\", annotated.join(\"\") ],\n\t\t[ \"Z30414K2\", annotating.join(\"\") ],\n\t]), { \"Z1K1\": \"Z9\", \"Z9K1\": \"Z7\" }));\n}"
        }
    },
    "Z2K3": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11",
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "segment String on interlinear annotation, JS"
            }
        ]
    },
    "Z2K4": {
        "Z1K1": "Z32",
        "Z32K1": [
            "Z31"
        ]
    },
    "Z2K5": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11"
        ]
    }
}