[{"data":1,"prerenderedAt":1086},["ShallowReactive",2],{"lit-docx-doc:\u002Fen\u002Fguide\u002Flitast":3},{"id":4,"title":5,"body":6,"description":1073,"extension":1074,"keywords":1075,"locale":1078,"meta":1079,"navigation":1080,"order":205,"path":1081,"section":1082,"seo":1083,"stem":1084,"__hash__":1085},"docs\u002Fguide\u002Flitast.en.md","The LitAST node model",{"type":7,"value":8,"toc":1062},"minimark",[9,26,31,34,137,154,161,165,168,347,351,518,522,564,573,618,622,645,649,684,691,698,709,713,751,757,765,769,786,945,956,960,966,1055,1058],[10,11,12,13,17,18,21,22,25],"p",{},"LitAST is a tree of plain JSON objects. You can save it with ",[14,15,16],"code",{},"JSON.stringify"," and later hand the ",[14,19,20],{},"JSON.parse"," result to ",[14,23,24],{},"generateDocx",".",[27,28,30],"h2",{"id":29},"common-fields","Common fields",[10,32,33],{},"Any node may carry these fields:",[35,36,37,50],"table",{},[38,39,40],"thead",{},[41,42,43,47],"tr",{},[44,45,46],"th",{},"Field",[44,48,49],{},"Meaning",[51,52,53,64,74,84,98,109,124],"tbody",{},[41,54,55,61],{},[56,57,58],"td",{},[14,59,60],{},"type",[56,62,63],{},"Node type, required",[41,65,66,71],{},[56,67,68],{},[14,69,70],{},"children",[56,72,73],{},"Child nodes",[41,75,76,81],{},[56,77,78],{},[14,79,80],{},"attrs",[56,82,83],{},"Node attributes, such as paragraph alignment, table column widths or image size",[41,85,86,91],{},[56,87,88],{},[14,89,90],{},"marks",[56,92,93,94,97],{},"Only on ",[14,95,96],{},"text",": formatting such as bold or links",[41,99,100,104],{},[56,101,102],{},[14,103,96],{},[56,105,93,106,108],{},[14,107,96],{},": the characters",[41,110,111,116],{},[56,112,113],{},[14,114,115],{},"rawXml",[56,117,118,119],{},"OOXML kept verbatim; see ",[120,121,123],"a",{"href":122},"\u002Fen\u002Fguide\u002Fround-trip","Round trips and preservation",[41,125,126,131],{},[56,127,128],{},[14,129,130],{},"meta",[56,132,133,134,136],{},"Extra data; the root's ",[14,135,130],{}," holds package-level data",[10,138,139,142,143,146,147,149,150,153],{},[14,140,141],{},"parseDocx"," returns mutable ",[14,144,145],{},"LitNode","s; ",[14,148,24],{}," accepts read-only ",[14,151,152],{},"LitAstNode","s. Both have the same structure.",[10,155,156,157,160],{},"Attributes starting with an underscore (such as ",[14,158,159],{},"_pPrPreservation",") are internal data kept for writing the original file back. Ignore them when reading; keep them when editing so the original formatting is written back intact.",[27,162,164],{"id":163},"an-example","An example",[10,166,167],{},"A paragraph with bold text:",[169,170,175],"pre",{"className":171,"code":172,"language":173,"meta":174,"style":174},"language-json shiki shiki-themes github-light github-light github-dark","{\n  \"type\": \"document\",\n  \"attrs\": { \"version\": 1 },\n  \"children\": [\n    {\n      \"type\": \"paragraph\",\n      \"children\": [\n        { \"type\": \"text\", \"text\": \"Hello \" },\n        { \"type\": \"text\", \"text\": \"world\", \"marks\": [{ \"type\": \"bold\" }] }\n      ]\n    }\n  ]\n}\n","json","",[14,176,177,186,203,223,232,238,251,259,285,323,329,335,341],{"__ignoreMap":174},[178,179,182],"span",{"class":180,"line":181},"line",1,[178,183,185],{"class":184},"sVPnS","{\n",[178,187,189,193,196,200],{"class":180,"line":188},2,[178,190,192],{"class":191},"sUNQB","  \"type\"",[178,194,195],{"class":184},": ",[178,197,199],{"class":198},"s-HEn","\"document\"",[178,201,202],{"class":184},",\n",[178,204,206,209,212,215,217,220],{"class":180,"line":205},3,[178,207,208],{"class":191},"  \"attrs\"",[178,210,211],{"class":184},": { ",[178,213,214],{"class":191},"\"version\"",[178,216,195],{"class":184},[178,218,219],{"class":191},"1",[178,221,222],{"class":184}," },\n",[178,224,226,229],{"class":180,"line":225},4,[178,227,228],{"class":191},"  \"children\"",[178,230,231],{"class":184},": [\n",[178,233,235],{"class":180,"line":234},5,[178,236,237],{"class":184},"    {\n",[178,239,241,244,246,249],{"class":180,"line":240},6,[178,242,243],{"class":191},"      \"type\"",[178,245,195],{"class":184},[178,247,248],{"class":198},"\"paragraph\"",[178,250,202],{"class":184},[178,252,254,257],{"class":180,"line":253},7,[178,255,256],{"class":191},"      \"children\"",[178,258,231],{"class":184},[178,260,262,265,268,270,273,276,278,280,283],{"class":180,"line":261},8,[178,263,264],{"class":184},"        { ",[178,266,267],{"class":191},"\"type\"",[178,269,195],{"class":184},[178,271,272],{"class":198},"\"text\"",[178,274,275],{"class":184},", ",[178,277,272],{"class":191},[178,279,195],{"class":184},[178,281,282],{"class":198},"\"Hello \"",[178,284,222],{"class":184},[178,286,288,290,292,294,296,298,300,302,305,307,310,313,315,317,320],{"class":180,"line":287},9,[178,289,264],{"class":184},[178,291,267],{"class":191},[178,293,195],{"class":184},[178,295,272],{"class":198},[178,297,275],{"class":184},[178,299,272],{"class":191},[178,301,195],{"class":184},[178,303,304],{"class":198},"\"world\"",[178,306,275],{"class":184},[178,308,309],{"class":191},"\"marks\"",[178,311,312],{"class":184},": [{ ",[178,314,267],{"class":191},[178,316,195],{"class":184},[178,318,319],{"class":198},"\"bold\"",[178,321,322],{"class":184}," }] }\n",[178,324,326],{"class":180,"line":325},10,[178,327,328],{"class":184},"      ]\n",[178,330,332],{"class":180,"line":331},11,[178,333,334],{"class":184},"    }\n",[178,336,338],{"class":180,"line":337},12,[178,339,340],{"class":184},"  ]\n",[178,342,344],{"class":180,"line":343},13,[178,345,346],{"class":184},"}\n",[27,348,350],{"id":349},"node-types","Node types",[35,352,353,363],{},[38,354,355],{},[41,356,357,360],{},[44,358,359],{},"Category",[44,361,362],{},"Types",[51,364,365,384,420,436,476,505],{},[41,366,367,370],{},[56,368,369],{},"Structure",[56,371,372,275,375,275,378,275,381],{},[14,373,374],{},"document",[14,376,377],{},"section",[14,379,380],{},"header",[14,382,383],{},"footer",[41,385,386,389],{},[56,387,388],{},"Blocks",[56,390,391,275,394,275,397,275,400,275,403,275,406,275,409,275,412,275,414,275,417],{},[14,392,393],{},"paragraph",[14,395,396],{},"heading",[14,398,399],{},"blockquote",[14,401,402],{},"codeBlock",[14,404,405],{},"horizontalRule",[14,407,408],{},"list",[14,410,411],{},"listItem",[14,413,35],{},[14,415,416],{},"tableRow",[14,418,419],{},"tableCell",[41,421,422,425],{},[56,423,424],{},"Breaks",[56,426,427,275,430,275,433],{},[14,428,429],{},"pageBreak",[14,431,432],{},"columnBreak",[14,434,435],{},"lastRenderedPageBreak",[41,437,438,441],{},[56,439,440],{},"Inline",[56,442,443,275,445,275,448,275,451,275,454,457,458,275,461,275,464,275,467,275,470,275,473],{},[14,444,96],{},[14,446,447],{},"image",[14,449,450],{},"textBox",[14,452,453],{},"field",[14,455,456],{},"sdt"," (content control), ",[14,459,460],{},"footnoteRef",[14,462,463],{},"endnoteRef",[14,465,466],{},"math",[14,468,469],{},"ruby",[14,471,472],{},"watermark",[14,474,475],{},"backgroundImage",[41,477,478,481],{},[56,479,480],{},"Range markers",[56,482,483,486,487,275,490,486,493,275,496,486,499,275,502],{},[14,484,485],{},"commentStart"," \u002F ",[14,488,489],{},"commentEnd",[14,491,492],{},"bookmarkStart",[14,494,495],{},"bookmarkEnd",[14,497,498],{},"permStart",[14,500,501],{},"permEnd",[14,503,504],{},"revision",[41,506,507,510],{},[56,508,509],{},"Unrecognized",[56,511,512,275,515],{},[14,513,514],{},"unknownBlock",[14,516,517],{},"unknownInline",[27,519,521],{"id":520},"mark-types","Mark types",[10,523,524,275,527,275,530,275,533,275,536,275,539,275,542,275,545,275,547,275,550,275,553,556,557,486,560,563],{},[14,525,526],{},"bold",[14,528,529],{},"italic",[14,531,532],{},"underline",[14,534,535],{},"strike",[14,537,538],{},"doubleStrike",[14,540,541],{},"superscript",[14,543,544],{},"subscript",[14,546,14],{},[14,548,549],{},"link",[14,551,552],{},"highlight",[14,554,555],{},"textStyle",", plus ",[14,558,559],{},"insertion",[14,561,562],{},"deletion"," for tracked changes.",[10,565,566,567,569,570,572],{},"Font size, color, font family and similar properties live in the ",[14,568,80],{}," of a ",[14,571,555],{}," mark, for example:",[169,574,576],{"className":171,"code":575,"language":173,"meta":174,"style":174},"{ \"type\": \"textStyle\", \"attrs\": { \"fontSize\": \"14pt\", \"color\": \"#C00000\" } }\n",[14,577,578],{"__ignoreMap":174},[178,579,580,583,585,587,590,592,595,597,600,602,605,607,610,612,615],{"class":180,"line":181},[178,581,582],{"class":184},"{ ",[178,584,267],{"class":191},[178,586,195],{"class":184},[178,588,589],{"class":198},"\"textStyle\"",[178,591,275],{"class":184},[178,593,594],{"class":191},"\"attrs\"",[178,596,211],{"class":184},[178,598,599],{"class":191},"\"fontSize\"",[178,601,195],{"class":184},[178,603,604],{"class":198},"\"14pt\"",[178,606,275],{"class":184},[178,608,609],{"class":191},"\"color\"",[178,611,195],{"class":184},[178,613,614],{"class":198},"\"#C00000\"",[178,616,617],{"class":184}," } }\n",[27,619,621],{"id":620},"paragraphs-and-headings","Paragraphs and headings",[10,623,624,625,627,628,275,631,634,635,638,639,641,642,25],{},"Paragraph formatting lives in ",[14,626,80],{},", for example ",[14,629,630],{},"textAlign",[14,632,633],{},"spacing"," and ",[14,636,637],{},"indent",". A ",[14,640,396],{}," stores its level (1–6) in ",[14,643,644],{},"attrs.level",[27,646,648],{"id":647},"lists","Lists",[10,650,651,652,655,656,659,660,662,663,275,665,667,668,670,671,674,675,677,678,680,681,683],{},"Lists are ",[14,653,654],{},"list > listItem",", with ",[14,657,658],{},"list.attrs.ordered"," telling ordered from unordered. Each ",[14,661,411],{}," is one numbered paragraph and holds inline nodes (",[14,664,96],{},[14,666,453],{}," and so on) directly, without a wrapping ",[14,669,393],{},". An item's depth is ",[14,672,673],{},"listItem.attrs.level",", starting at 0. Items at different levels or with different numbering definitions are split into adjacent ",[14,676,408],{}," nodes rather than nesting a ",[14,679,408],{}," inside a ",[14,682,411],{},":",[169,685,689],{"className":686,"code":688,"language":96,"meta":174},[687],"language-text","list {\"ordered\":true}\n  listItem {\"level\":0} > text \"one\"\nlist {\"ordered\":false}\n  listItem {\"level\":1} > text \"nested\"\nlist {\"ordered\":true}\n  listItem {\"level\":0} > text \"two\"\n",[14,690,688],{"__ignoreMap":174},[10,692,693,694,697],{},"Pass ",[14,695,696],{},"numberingMode: \"flat-numbered-paragraphs\""," when parsing to keep Word's flat numbered paragraphs instead.",[10,699,700,701,703,704,680,706,708],{},"Use the same shape when generating. Do not put block nodes such as ",[14,702,393],{}," or ",[14,705,408],{},[14,707,411],{},"; that produces invalid nested paragraphs.",[27,710,712],{"id":711},"phonetic-guides","Phonetic guides",[10,714,715,717,718,720,721,724,725,727,728,275,731,734,735,738,739,742,743,746,747,750],{},[14,716,469],{}," is an inline node: ",[14,719,70],{}," holds the annotated base text and ",[14,722,723],{},"attrs.rubyText"," holds the annotation.\nBoth are arrays of inline nodes with their own text formatting. The other ",[14,726,80],{}," are Word's guide\nproperties: ",[14,729,730],{},"rubyAlign",[14,732,733],{},"hps"," (annotation size), ",[14,736,737],{},"hpsRaise"," (raise), ",[14,740,741],{},"hpsBaseText"," (reference base size),\n",[14,744,745],{},"lid"," (language) and ",[14,748,749],{},"dirty","; sizes and distances are in half-points:",[169,752,755],{"className":753,"code":754,"language":96,"meta":174},[687],"ruby {\"rubyAlign\":\"center\",\"hps\":12,\"hpsRaise\":24,\"hpsBaseText\":24,\"lid\":\"zh-CN\",\"rubyText\":[text \"hàn\"]}\n  text \"汉\"\n",[14,756,754],{"__ignoreMap":174},[10,758,759,760,764],{},"lit-docx never infers pronunciation; it reads and writes the annotation stored in the file. See\n",[120,761,763],{"href":762},"\u002Fen\u002Fguide\u002Fgenerating#phonetic-guides","Generating DOCX"," to create one.",[27,766,768],{"id":767},"sections","Sections",[10,770,771,772,774,775,778,779,783,784,683],{},"A ",[14,773,377],{}," is not a container around content but a sibling in ",[14,776,777],{},"document.children",": it ends the section formed by the content ",[780,781,782],"strong",{},"before"," it and carries that section's page setup. Every Word document ends with at least one ",[14,785,377],{},[169,787,789],{"className":171,"code":788,"language":173,"meta":174,"style":174},"{\n  \"type\": \"section\",\n  \"attrs\": {\n    \"pageWidth\": 11906, \"pageHeight\": 16838, \"orientation\": \"portrait\", \"paperSize\": \"A4\",\n    \"margins\": { \"top\": 1440, \"right\": 1440, \"bottom\": 1440, \"left\": 1440, \"header\": 708, \"footer\": 708, \"gutter\": 0 }\n  },\n  \"children\": []\n}\n",[14,790,791,795,806,813,855,929,934,941],{"__ignoreMap":174},[178,792,793],{"class":180,"line":181},[178,794,185],{"class":184},[178,796,797,799,801,804],{"class":180,"line":188},[178,798,192],{"class":191},[178,800,195],{"class":184},[178,802,803],{"class":198},"\"section\"",[178,805,202],{"class":184},[178,807,808,810],{"class":180,"line":205},[178,809,208],{"class":191},[178,811,812],{"class":184},": {\n",[178,814,815,818,820,823,825,828,830,833,835,838,840,843,845,848,850,853],{"class":180,"line":225},[178,816,817],{"class":191},"    \"pageWidth\"",[178,819,195],{"class":184},[178,821,822],{"class":191},"11906",[178,824,275],{"class":184},[178,826,827],{"class":191},"\"pageHeight\"",[178,829,195],{"class":184},[178,831,832],{"class":191},"16838",[178,834,275],{"class":184},[178,836,837],{"class":191},"\"orientation\"",[178,839,195],{"class":184},[178,841,842],{"class":198},"\"portrait\"",[178,844,275],{"class":184},[178,846,847],{"class":191},"\"paperSize\"",[178,849,195],{"class":184},[178,851,852],{"class":198},"\"A4\"",[178,854,202],{"class":184},[178,856,857,860,862,865,867,870,872,875,877,879,881,884,886,888,890,893,895,897,899,902,904,907,909,912,914,916,918,921,923,926],{"class":180,"line":234},[178,858,859],{"class":191},"    \"margins\"",[178,861,211],{"class":184},[178,863,864],{"class":191},"\"top\"",[178,866,195],{"class":184},[178,868,869],{"class":191},"1440",[178,871,275],{"class":184},[178,873,874],{"class":191},"\"right\"",[178,876,195],{"class":184},[178,878,869],{"class":191},[178,880,275],{"class":184},[178,882,883],{"class":191},"\"bottom\"",[178,885,195],{"class":184},[178,887,869],{"class":191},[178,889,275],{"class":184},[178,891,892],{"class":191},"\"left\"",[178,894,195],{"class":184},[178,896,869],{"class":191},[178,898,275],{"class":184},[178,900,901],{"class":191},"\"header\"",[178,903,195],{"class":184},[178,905,906],{"class":191},"708",[178,908,275],{"class":184},[178,910,911],{"class":191},"\"footer\"",[178,913,195],{"class":184},[178,915,906],{"class":191},[178,917,275],{"class":184},[178,919,920],{"class":191},"\"gutter\"",[178,922,195],{"class":184},[178,924,925],{"class":191},"0",[178,927,928],{"class":184}," }\n",[178,930,931],{"class":180,"line":240},[178,932,933],{"class":184},"  },\n",[178,935,936,938],{"class":180,"line":253},[178,937,228],{"class":191},[178,939,940],{"class":184},": []\n",[178,942,943],{"class":180,"line":261},[178,944,346],{"class":184},[10,946,947,948,486,950,952,953,25],{},"The section's headers and footers are its ",[14,949,380],{},[14,951,383],{}," children. For units, see ",[120,954,763],{"href":955},"\u002Fen\u002Fguide\u002Fgenerating",[27,957,959],{"id":958},"document-metadata","Document metadata",[10,961,962,963,965],{},"The root's ",[14,964,130],{}," holds package-level data that is not body content. Common keys:",[35,967,968,978],{},[38,969,970],{},[41,971,972,975],{},[44,973,974],{},"Key",[44,976,977],{},"Contents",[51,979,980,1002,1012,1022,1032,1042],{},[41,981,982,987],{},[56,983,984],{},[14,985,986],{},"rawXmlFiles",[56,988,989,990,275,993,275,996,634,999],{},"Part XML kept verbatim, with keys such as ",[14,991,992],{},"stylesXml",[14,994,995],{},"numberingXml",[14,997,998],{},"settingsXml",[14,1000,1001],{},"fontTableXml",[41,1003,1004,1009],{},[56,1005,1006],{},[14,1007,1008],{},"coreProperties",[56,1010,1011],{},"Core properties such as creator, last modifier, created and modified times, and revision",[41,1013,1014,1019],{},[56,1015,1016],{},[14,1017,1018],{},"settings",[56,1020,1021],{},"Document settings",[41,1023,1024,1029],{},[56,1025,1026],{},[14,1027,1028],{},"fieldData",[56,1030,1031],{},"Core properties, custom properties and document variables that fields can reference",[41,1033,1034,1039],{},[56,1035,1036],{},[14,1037,1038],{},"comments",[56,1040,1041],{},"Comment contents",[41,1043,1044,1052],{},[56,1045,1046,486,1049],{},[14,1047,1048],{},"footnotes",[14,1050,1051],{},"endnotes",[56,1053,1054],{},"Footnote and endnote contents",[10,1056,1057],{},"A key appears only when the document actually contains that data.",[1059,1060,1061],"style",{},"html pre.shiki code .sVPnS, html code.shiki .sVPnS{--shiki-default:#24292E;--shiki-light:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sUNQB, html code.shiki .sUNQB{--shiki-default:#005CC5;--shiki-light:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .s-HEn, html code.shiki .s-HEn{--shiki-default:#032F62;--shiki-light:#032F62;--shiki-dark:#9ECBFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":174,"searchDepth":188,"depth":188,"links":1063},[1064,1065,1066,1067,1068,1069,1070,1071,1072],{"id":29,"depth":188,"text":30},{"id":163,"depth":188,"text":164},{"id":349,"depth":188,"text":350},{"id":520,"depth":188,"text":521},{"id":620,"depth":188,"text":621},{"id":647,"depth":188,"text":648},{"id":711,"depth":188,"text":712},{"id":767,"depth":188,"text":768},{"id":958,"depth":188,"text":959},"Common node fields, node and mark types, and how paragraphs, lists, sections and document metadata are represented.","md",[1076,1077,90,377,408,130],"LitAST","nodes","en",{},true,"\u002Fen\u002Fguide\u002Flitast","Guides",{"title":5,"description":1073},"guide\u002Flitast.en","riQJbDrYqaDz5gqll0EEnt8kIlyQeKhXwu4on2FC_DQ",1793045343967]