{"id":497478,"date":"2026-10-06T06:05:16","date_gmt":"2026-10-06T06:05:16","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=497478"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2026-10-06T06:05:16","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=497478","title":{"rendered":"\u041a\u043e\u0434 \u0432 Word \u0431\u0435\u0437 \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a: \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0430 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u0447\u0435\u0440\u0435\u0437 python-docx \u0438 Pygments"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h2>\u041a\u043e\u0434 \u0432 Word \u0431\u0435\u0437 \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a: \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0430 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u0447\u0435\u0440\u0435\u0437 python-docx \u0438 Pygments<\/h2>\n<p><em>\u041e\u043a\u043e\u043b\u043e \u0441\u0442\u0430 \u0441\u0442\u0440\u043e\u043a \u043d\u0430 Python \u2013 \u0438 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0438 \u0432 .docx \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043a\u0430\u043a \u0432 IDE, \u043a\u043e\u043f\u0438\u0440\u0443\u044e\u0442\u0441\u044f, \u0438\u0449\u0443\u0442\u0441\u044f \u0438 \u043d\u0443\u043c\u0435\u0440\u0443\u044e\u0442\u0441\u044f \u0441\u0430\u043c\u0438.<\/em><\/p>\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/articles\/906470\/\" rel=\"noopener nofollow\">\u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a> \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u043f\u0440\u043e \u00ab\u041e\u0442\u0447\u0435\u0442 Creator\u00bb \u2013 \u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u043e\u0442\u0447\u0435\u0442\u044b \u043f\u043e \u043b\u0430\u0431\u0430\u043c \u0441\u043e Stepik \u0432 Word. \u041a\u043e\u0434 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043e\u043d \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u043b <strong>\u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430\u043c\u0438<\/strong>, \u0438 \u043f\u0435\u0440\u0432\u044b\u0439 \u0436\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u043f\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0435\u0439 \u0431\u044b\u043b: \u00ab\u041a\u043e\u0434 \u0440\u0438\u0441\u0443\u043d\u043a\u0430\u043c\u0438 \u2013 \u0431\u0440\u0440\u00bb.<\/p>\n<p>\u0421\u043f\u043e\u0440\u0438\u0442\u044c \u0431\u044b\u043b\u043e \u0441\u043b\u043e\u0436\u043d\u043e. \u041d\u043e \u0442\u043e\u0433\u0434\u0430 \u044f \u0447\u0435\u0441\u0442\u043d\u043e \u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e <code>python-docx<\/code> \u043f\u043e-\u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u043d\u0435 \u0443\u043c\u0435\u0435\u0442. \u0421 \u044d\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 \u044f \u0432\u043e\u043e\u0431\u0449\u0435 \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0441\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e: \u0432 2024 \u0433\u043e\u0434\u0443 \u0441\u043f\u0440\u043e\u0441\u0438\u043b \u0443 ChatGPT, \u0447\u0435\u043c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c Word-\u0444\u0430\u0439\u043b\u044b \u0438\u0437 Python, \u043e\u043d \u043d\u0430\u0437\u0432\u0430\u043b <code>python-docx<\/code> \u2013 \u0442\u0430\u043a \u0438 \u043f\u043e\u0448\u043b\u043e. \u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u044f \u0442\u043e\u0433\u0434\u0430 \u0447\u0438\u0442\u0430\u043b \u043f\u043e \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u0438, \u0440\u043e\u0432\u043d\u043e \u0434\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u00ab\u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0432\u0441\u0442\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u2013 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u00bb.<\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u044f \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0441\u0435\u043b \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f. \u0412\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u043a\u043e\u0434 \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u0441 \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u043e\u0439 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0443 \u0440\u0430\u0437 \u0441\u043f\u0443\u0441\u0442\u0438\u0442\u044c\u0441\u044f \u0432 XML \u0438 \u043d\u0430\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0433\u0440\u0430\u0431\u043b\u0435\u0439. \u0412\u0441\u0435 \u044d\u0442\u043e \u044f \u0441\u043e\u0431\u0440\u0430\u043b \u0432 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0431\u0440\u0430\u0442\u044c \u0432 \u043b\u044e\u0431\u043e\u0439 \u0441\u0432\u043e\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432: \u043e\u0442\u0447\u0435\u0442\u044b, \u043a\u0443\u0440\u0441\u043e\u0432\u044b\u0435, \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e.<\/p>\n<p>\u0412\u043e\u0442 \u043a\u0430\u043a \u0431\u044b\u043b\u043e:<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/82\/bf\/73\/82bf738d8f0ccf5f9b84bac7baef71f6.png\" alt=\"\u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u043e\u0442\u0447\u0435\u0442\u0430, \u043a\u043e\u0434 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u043e\u0439\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/82\/bf\/73\/82bf738d8f0ccf5f9b84bac7baef71f6.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/82\/bf\/73\/82bf738d8f0ccf5f9b84bac7baef71f6.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u043e\u0442\u0447\u0435\u0442\u0430, \u043a\u043e\u0434 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u043e\u0439<\/figcaption><\/div>\n<\/figure>\n<p>\u0410 \u0432\u043e\u0442 \u043a\u0430\u043a \u0441\u0442\u0430\u043b\u043e:<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/1d\/bf\/93\/1dbf93a7c05f25b397743c61191a1aa9.png\" alt=\"\u0414\u0432\u0430 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0430, \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0442\u0435\u043a\u0441\u0442\u043e\u043c: Python \u0438 C++\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/1d\/bf\/93\/1dbf93a7c05f25b397743c61191a1aa9.png 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/1d\/bf\/93\/1dbf93a7c05f25b397743c61191a1aa9.png 781w\" loading=\"lazy\" decode=\"async\"\/><\/p>\n<div><figcaption>\u0414\u0432\u0430 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0430, \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0442\u0435\u043a\u0441\u0442\u043e\u043c: Python \u0438 C++<\/figcaption><\/div>\n<\/figure>\n<p>\u041e\u0434\u043d\u043e\u0433\u0440\u0443\u043f\u043f\u043d\u0438\u043a\u0438 \u0438 \u043f\u0440\u0435\u043f\u043e\u0434\u0430\u0432\u0430\u0442\u0435\u043b\u0438, \u043c\u044f\u0433\u043a\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0443\u0434\u0438\u0432\u0438\u043b\u0438\u0441\u044c \u0442\u0430\u043a\u043e\u043c\u0443 \u0437\u0430\u0432\u043e\u0437\u0443: \u043a\u043e\u0434 \u0432 \u043e\u0442\u0447\u0435\u0442\u0430\u0445 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c, \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0431\u0435\u0437 \u043b\u0443\u043f\u044b, \u0430 \u0441\u0430\u043c\u0438 \u0444\u0430\u0439\u043b\u044b \u0437\u0430\u043c\u0435\u0442\u043d\u043e \u043f\u043e\u0445\u0443\u0434\u0435\u043b\u0438.<\/p>\n<h3>\u0427\u0435\u043c \u043f\u043b\u043e\u0445\u0438 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438<\/h3>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\n<\/th>\n<th>\n<p align=\"left\">\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0422\u0435\u043a\u0441\u0442<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0421\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043d\u0435\u043b\u044c\u0437\u044f<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043c\u043e\u0436\u043d\u043e<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041d\u0430\u0439\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 Ctrl+F<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043d\u0435\u043b\u044c\u0437\u044f<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u043c\u043e\u0436\u043d\u043e<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0427\u0435\u0442\u043a\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u043f\u0435\u0447\u0430\u0442\u0438 \u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0435<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0432\u0441\u0435\u0433\u0434\u0430 \u0447\u0435\u0442\u043a\u043e<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0448\u0440\u0438\u0444\u0442 \u0438\u043b\u0438 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432 Word<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0435\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c<\/p>\n<\/td>\n<td>\n<p align=\"left\">\u0447\u0435\u0440\u0435\u0437 \u0441\u0442\u0438\u043b\u044c, \u0437\u0430 \u0441\u0435\u043a\u0443\u043d\u0434\u0443<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0418 \u0435\u0449\u0435 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c. \u0414\u043b\u044f \u0447\u0435\u0441\u0442\u043d\u043e\u0433\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u044f \u0432\u0437\u044f\u043b 30 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u043e\u0432 \u043f\u043e 14 \u0441\u0442\u0440\u043e\u043a \u0438 \u0441\u043e\u0431\u0440\u0430\u043b \u0438\u0437 \u043d\u0438\u0445 \u0434\u0432\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430: \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u043a\u043e\u0434 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u043d \u0447\u0435\u0440\u0435\u0437 Pillow (JetBrains Mono, 64 px, \u043a\u0430\u043a \u0432 \u0441\u0442\u0430\u0440\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438), \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0442\u0435\u043a\u0441\u0442\u043e\u043c.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<th>\n<p align=\"left\">\u0421\u043f\u043e\u0441\u043e\u0431<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0412\u0440\u0435\u043c\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438<\/p>\n<\/th>\n<th>\n<p align=\"left\">\u0420\u0430\u0437\u043c\u0435\u0440 .docx<\/p>\n<\/th>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 (Pillow)<\/p>\n<\/td>\n<td>\n<p align=\"left\">4,1 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">130 \u041a\u0411<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p align=\"left\">\u0422\u0435\u043a\u0441\u0442 (python-docx + Pygments)<\/p>\n<\/td>\n<td>\n<p align=\"left\">0,6 \u0441<\/p>\n<\/td>\n<td>\n<p align=\"left\">39 \u041a\u0411<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u041f\u0443\u0441\u0442\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u0441\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435 \u0432\u0435\u0441\u0438\u0442 \u043e\u043a\u043e\u043b\u043e 36 \u041a\u0411, \u0442\u0430\u043a \u0447\u0442\u043e 30 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u043e\u0432 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442 \u043a \u043d\u0435\u043c\u0443 \u0432\u0441\u0435\u0433\u043e \u043f\u0430\u0440\u0443 \u043a\u0438\u043b\u043e\u0431\u0430\u0439\u0442.<\/p>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 LaTeX \u0438\u043b\u0438 pandoc? \u0418\u0445 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043a \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0442\u043e\u0436\u0435 \u0441\u043e\u0432\u0435\u0442\u043e\u0432\u0430\u043b\u0438, \u0438 \u044d\u0442\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b. \u041d\u043e \u043a\u0430\u0444\u0435\u0434\u0440\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e .docx \u043f\u043e \u0441\u0432\u043e\u0435\u043c\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u0443, \u0430 \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u0447\u0443\u0436\u043e\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u0438\u0437 pandoc \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0447\u0435\u043c \u0434\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0442\u043e \u0441\u0442\u0440\u043e\u043a.<\/p>\n<h3>\u0428\u0430\u0433 1. \u0421\u0442\u0438\u043b\u044c \u0434\u043b\u044f \u043a\u043e\u0434\u0430<\/h3>\n<p>\u041f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0430 \u0438\u0437 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432: \u0432 Word \u0434\u043b\u044f \u043a\u043e\u0434\u0430 \u0437\u0430\u0432\u043e\u0434\u044f\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u0442\u0438\u043b\u044c, \u043a\u0430\u043a \u0438 \u0434\u043b\u044f \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432. \u0422\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e, \u0430 \u0448\u0440\u0438\u0444\u0442 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435.<\/p>\n<pre><code class=\"python\">from docx.enum.style import WD_STYLE_TYPEfrom docx.shared import PtCODE_STYLE = \"Code\"def ensure_code_style(doc, font=\"Courier New\", size=10):    if CODE_STYLE in [s.name for s in doc.styles]:        return    style = doc.styles.add_style(CODE_STYLE, WD_STYLE_TYPE.PARAGRAPH)    style.base_style = doc.styles[\"Normal\"]    style.font.size = Pt(size)    style.font.no_proof = True  # \u0431\u0435\u0437 \u043a\u0440\u0430\u0441\u043d\u044b\u0445 \u0432\u043e\u043b\u043d\u0438\u0441\u0442\u044b\u0445 \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u043d\u0438\u0439    _set_all_fonts(style.element.get_or_add_rPr(), font)    pf = style.paragraph_format    pf.first_line_indent = Pt(0)  # \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u0445 \u043f\u043e \u0413\u041e\u0421\u0422\u0443 \u043e\u0431\u044b\u0447\u043d\u043e \u0435\u0441\u0442\u044c \u043a\u0440\u0430\u0441\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430    pf.left_indent = Pt(0)    pf.line_spacing = 1.0         # \u0430 \u0435\u0449\u0435 \u043f\u043e\u043b\u0443\u0442\u043e\u0440\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b    pf.space_before = Pt(0)    pf.space_after = Pt(0)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper\"><\/span><\/a><\/div><\/pre>\n<p>\u0421\u0442\u0440\u043e\u0447\u043a\u0430 \u0441 <code>no_proof<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043e\u0442\u043a\u0440\u043e\u0435\u0448\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u0431\u0435\u0437 \u043d\u0435\u0435. Word \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0440\u0435\u0436\u0438\u043c \u0441\u0442\u0440\u043e\u0433\u043e\u0439 \u0443\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u0438\u0446\u044b \u0440\u0443\u0441\u0441\u043a\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430: <code>def<\/code> \u2013 \u043e\u0448\u0438\u0431\u043a\u0430, <code>popleft<\/code> \u2013 \u043e\u0448\u0438\u0431\u043a\u0430, <code>elif<\/code> \u2013 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u043e \u0447\u0442\u043e. \u0427\u0435\u0440\u0435\u0437 \u043f\u0430\u0440\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u043b\u0438\u0441\u0442\u0438\u043d\u0433 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 \u0441\u043e\u0447\u0438\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u043e\u0435\u0447\u043d\u0438\u043a\u0430, \u0447\u0435\u043c \u043d\u0430 \u043a\u043e\u0434. <code>no_proof<\/code> \u2013 \u044d\u0442\u043e \u0433\u0430\u043b\u043e\u0447\u043a\u0430 \u00ab\u041d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043f\u0440\u0430\u0432\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u00bb, \u0438 \u0441\u0442\u043e\u0438\u0442 \u043e\u043d\u0430 \u0441\u0440\u0430\u0437\u0443 \u043d\u0430 \u0432\u0435\u0441\u044c \u0441\u0442\u0438\u043b\u044c.<\/p>\n<p>\u0421\u043e \u0448\u0440\u0438\u0444\u0442\u043e\u043c \u043f\u043e\u0434\u0432\u043e\u0445 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0440\u043e\u0434\u0430. \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c <code>style.font.name = \"Courier New\"<\/code>, python-docx \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u0442 \u0448\u0440\u0438\u0444\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043b\u0430\u0442\u0438\u043d\u0438\u0446\u044b (\u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b <code>w:ascii<\/code> \u0438 <code>w:hAnsi<\/code>). \u0414\u043b\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u043e\u0432 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 Word \u0432\u043e\u0437\u044c\u043c\u0435\u0442 \u0448\u0440\u0438\u0444\u0442 \u0438\u0437 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0441\u0442\u0438\u043b\u044f \u2013 \u0438 \u0432 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043c\u043e\u0433\u0443\u0442 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c\u0441\u044f \u0434\u0432\u0430 \u0448\u0440\u0438\u0444\u0442\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u0434\u0430\u0435\u043c \u0432\u0441\u0435 \u0447\u0435\u0442\u044b\u0440\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430:<\/p>\n<pre><code class=\"python\">from docx.oxml.ns import qndef _set_all_fonts(rpr, name):    rfonts = rpr.get_or_add_rFonts()    for attr in (\"w:ascii\", \"w:hAnsi\", \"w:cs\", \"w:eastAsia\"):        rfonts.set(qn(attr), name)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 Courier New, \u0430 \u043d\u0435 JetBrains Mono, \u043a\u0430\u043a \u0431\u044b\u043b\u043e \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430\u0445? \u0415\u0433\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c: \u043e\u043d \u0435\u0441\u0442\u044c \u0432 Windows \u0438 macOS, \u0438 \u0443 \u043f\u0440\u0435\u043f\u043e\u0434\u0430\u0432\u0430\u0442\u0435\u043b\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u043e\u0442\u043a\u0440\u043e\u0435\u0442\u0441\u044f \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0443 \u043c\u0435\u043d\u044f.<\/p>\n<h3>\u0428\u0430\u0433 2. \u0420\u0430\u043c\u043a\u0430 \u0438 \u0437\u0430\u043b\u0438\u0432\u043a\u0430<\/h3>\n<p>\u0427\u0442\u043e\u0431\u044b \u043b\u0438\u0441\u0442\u0438\u043d\u0433 \u0447\u0438\u0442\u0430\u043b\u0441\u044f \u043a\u0430\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0431\u043b\u043e\u043a, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u0442\u0438\u043b\u044e \u0441\u0432\u0435\u0442\u043b\u0443\u044e \u0437\u0430\u043b\u0438\u0432\u043a\u0443 \u0438 \u0442\u043e\u043d\u043a\u0443\u044e \u0440\u0430\u043c\u043a\u0443. \u0413\u043e\u0442\u043e\u0432\u043e\u0433\u043e API \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 python-docx \u043d\u0435\u0442, \u0442\u0430\u043a \u0447\u0442\u043e \u043b\u0435\u0437\u0435\u043c \u0432 XML:<\/p>\n<pre><code class=\"python\">from docx.oxml import OxmlElementdef _add_box(ppr, fill=\"F6F8FA\", border=\"D0D7DE\"):    pbdr = OxmlElement(\"w:pBdr\")    for side in (\"top\", \"left\", \"bottom\", \"right\"):        el = OxmlElement(f\"w:{side}\")        el.set(qn(\"w:val\"), \"single\")        el.set(qn(\"w:sz\"), \"4\")      # \u0432 \u0432\u043e\u0441\u044c\u043c\u044b\u0445 \u0434\u043e\u043b\u044f\u0445 \u043f\u0443\u043d\u043a\u0442\u0430: 4 = 0,5 pt        el.set(qn(\"w:space\"), \"4\")        el.set(qn(\"w:color\"), border)        pbdr.append(el)    ppr.insert_element_before(pbdr, \"w:shd\", *_PPR_TAIL)    shd = OxmlElement(\"w:shd\")    shd.set(qn(\"w:val\"), \"clear\")    shd.set(qn(\"w:color\"), \"auto\")    shd.set(qn(\"w:fill\"), fill)    ppr.insert_element_before(shd, *_PPR_TAIL)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0421\u0430\u043c\u043e\u0435 \u043a\u043e\u0432\u0430\u0440\u043d\u043e\u0435 \u0437\u0434\u0435\u0441\u044c \u2013 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u0412\u043d\u0443\u0442\u0440\u0438 <code>&lt;w:pPr&gt;<\/code> \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u0442\u0435\u0433\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0434\u0442\u0438 \u0441\u0442\u0440\u043e\u0433\u043e \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0434\u0430\u0435\u0442 \u0441\u0445\u0435\u043c\u0430 OOXML. \u0415\u0441\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e <code>ppr.append(shd)<\/code>, \u0437\u0430\u043b\u0438\u0432\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0441\u043b\u0435 <code>&lt;w:spacing&gt;<\/code>. LibreOffice \u0442\u0430\u043a\u043e\u0435 \u043c\u043e\u043b\u0447\u0430 \u043f\u0440\u043e\u0433\u043b\u043e\u0442\u0438\u0442, \u0430 Word \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e \u00ab\u043d\u0435\u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435\u00bb. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0447\u0435\u0440\u0435\u0437 <code>insert_element_before<\/code> \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0442\u0435\u0433\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u044f\u0437\u0430\u043d\u044b \u0438\u0434\u0442\u0438 \u043f\u043e\u0441\u043b\u0435 \u043d\u0430\u0448\u0435\u0433\u043e:<\/p>\n<pre><code class=\"python\">_PPR_TAIL = (    \"w:tabs\", \"w:suppressAutoHyphens\", \"w:kinsoku\", \"w:wordWrap\",    \"w:overflowPunct\", \"w:topLinePunct\", \"w:autoSpaceDE\", \"w:autoSpaceDN\",    \"w:bidi\", \"w:adjustRightInd\", \"w:snapToGrid\", \"w:spacing\", \"w:ind\",    \"w:contextualSpacing\", \"w:mirrorIndents\", \"w:suppressOverlap\", \"w:jc\",    \"w:textDirection\", \"w:textAlignment\", \"w:textboxTightWrap\",    \"w:outlineLvl\", \"w:divId\", \"w:cnfStyle\", \"w:rPr\", \"w:sectPr\", \"w:pPrChange\",)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0421\u043f\u0438\u0441\u043e\u043a \u044f \u043f\u043e\u0434\u0441\u043c\u043e\u0442\u0440\u0435\u043b \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u0445 \u0441\u0430\u043c\u043e\u0439 python-docx, \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 <code>CT_PPr<\/code>: \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0445\u0440\u0430\u043d\u0438\u0442 \u0435\u0433\u043e \u0440\u043e\u0432\u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0446\u0435\u043b\u0438.<\/p>\n<h3>\u0428\u0430\u0433 3. \u041f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0430: \u0438\u0437 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0432\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b<\/h3>\n<p>\u0410\u0431\u0437\u0430\u0446 \u0432 Word \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u0432 \u2013 runs, \u0438 \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0432\u043e\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. Pygments \u0440\u0435\u0436\u0435\u0442 \u043a\u043e\u0434 \u043d\u0430 \u0442\u043e\u043a\u0435\u043d\u044b \u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u0446\u0432\u0435\u0442, \u0436\u0438\u0440\u043d\u043e\u0441\u0442\u044c \u0438 \u043a\u0443\u0440\u0441\u0438\u0432. \u041e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u043e\u0434\u043d\u043e \u0432 \u0434\u0440\u0443\u0433\u043e\u0435:<\/p>\n<pre><code class=\"python\">from pygments import lexfrom pygments.lexers import get_lexer_by_namefrom pygments.styles import get_style_by_namedef _runs(code, language, style_name):    style = get_style_by_name(style_name)    chunks = []    lexer = get_lexer_by_name(language, ensurenl=False)    for token_type, value in lex(code, lexer):        s = style.style_for_token(token_type)        fmt = (s[\"color\"], s[\"bold\"], s[\"italic\"])        if chunks and (chunks[-1][1] == fmt or value.isspace()):            chunks[-1][0] += value  # \u0441\u043a\u043b\u0435\u0438\u0432\u0430\u0435\u043c \u0441 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u043c        else:            chunks.append([value, fmt])    return chunks<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0434\u0435\u043b\u0430\u043b\u0430 \u043f\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0443 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0442\u043e\u043a\u0435\u043d, \u0438 \u044d\u0442\u043e \u0440\u0430\u0441\u0442\u043e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e: Pygments \u0434\u0440\u043e\u0431\u0438\u0442 \u043a\u043e\u0434 \u043e\u0447\u0435\u043d\u044c \u043c\u0435\u043b\u043a\u043e, \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0440\u043e\u0431\u0435\u043b \u0438 \u043a\u0430\u0436\u0434\u0430\u044f \u0437\u0430\u043f\u044f\u0442\u0430\u044f \u2013 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0442\u043e\u043a\u0435\u043d. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u044b \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u0441\u0442\u0438\u043b\u0435\u043c \u0441\u043a\u043b\u0435\u0438\u0432\u0430\u044e\u0442\u0441\u044f, \u0430 \u043f\u0440\u043e\u0431\u0435\u043b\u044b (\u0438\u043c \u0446\u0432\u0435\u0442 \u043d\u0435 \u0432\u0430\u0436\u0435\u043d) \u043f\u0440\u0438\u043b\u0438\u043f\u0430\u044e\u0442 \u043a \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c\u0443 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0443. \u0414\u043b\u044f \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0430 \u0441 \u043f\u043e\u0438\u0441\u043a\u043e\u043c \u0432 \u0448\u0438\u0440\u0438\u043d\u0443 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f 57 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u043c\u0435\u0441\u0442\u043e 147, \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043d\u0430 C++ \u2013 39 \u0432\u043c\u0435\u0441\u0442\u043e 103. \u041c\u0435\u043d\u044c\u0448\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u0432 \u2013 \u043c\u0435\u043d\u044c\u0448\u0435 XML \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0435.<\/p>\n<p><code>ensurenl=False<\/code> \u2013 \u043c\u0435\u043b\u043e\u0447\u044c, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u043d\u0430\u0448\u0435\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0432\u043d\u0438\u0437\u0443 \u043a\u0430\u0436\u0434\u043e\u0439 \u0440\u0430\u043c\u043a\u0438. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e Pygments \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0432 \u043a\u043e\u043d\u0435\u0446 \u043a\u043e\u0434\u0430 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0440\u043e\u043a\u0438, \u044d\u0442\u0430 \u043e\u043f\u0446\u0438\u044f \u0435\u0433\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442.<\/p>\n<p>\u0421\u0430\u043c\u0430 \u0432\u0441\u0442\u0430\u0432\u043a\u0430:<\/p>\n<pre><code class=\"python\">from docx.shared import RGBColordef add_code(doc, code, language=\"python\", style_name=\"friendly\"):    ensure_code_style(doc)    p = doc.add_paragraph(style=CODE_STYLE)    for text, (color, bold, italic) in _runs(code.strip(\"\\n\"), language, style_name):        run = p.add_run(text)        if color:            run.font.color.rgb = RGBColor.from_string(color)        run.bold = bold        run.italic = italic    return p<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0412\u0435\u0441\u044c \u043b\u0438\u0441\u0442\u0438\u043d\u0433 \u2013 <strong>\u043e\u0434\u0438\u043d \u0430\u0431\u0437\u0430\u0446<\/strong>. <code>add_run<\/code> \u0441\u0430\u043c \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>\\n<\/code> \u0432 \u0440\u0430\u0437\u0440\u044b\u0432 \u0441\u0442\u0440\u043e\u043a\u0438 <code>&lt;w:br\/&gt;<\/code>, \u0430 <code>\\t<\/code> \u2013 \u0432 \u0442\u0430\u0431\u0443\u043b\u044f\u0446\u0438\u044e \u0438 \u0441\u0442\u0430\u0432\u0438\u0442 <code>xml:space=\"preserve\"<\/code>, \u0442\u0430\u043a \u0447\u0442\u043e \u043e\u0442\u0441\u0442\u0443\u043f\u044b \u0432 Python \u043d\u0435 \u0442\u0435\u0440\u044f\u044e\u0442\u0441\u044f. \u0415\u0441\u043b\u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e \u0430\u0431\u0437\u0430\u0446\u0443 \u043d\u0430 \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u043a\u043e\u0434\u0430, \u0440\u0430\u043c\u043a\u0430 \u043d\u0430\u0440\u0438\u0441\u0443\u0435\u0442\u0441\u044f \u0432\u043e\u043a\u0440\u0443\u0433 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u0430 \u043c\u0435\u0436\u0434\u0443 \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b \u0438\u0437 \u0448\u0430\u0431\u043b\u043e\u043d\u0430.<\/p>\n<h3>\u0428\u0430\u0433 4. \u041f\u043e\u0434\u043f\u0438\u0441\u044c \u0441 \u0430\u0432\u0442\u043e\u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u0435\u0439<\/h3>\n<p>\u041d\u043e\u043c\u0435\u0440 \u0432 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u043c\u043e\u0436\u043d\u043e \u0432\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u043e\u043c: \u00ab\u041b\u0438\u0441\u0442\u0438\u043d\u0433 3\u00bb. \u041d\u043e \u0441\u0442\u043e\u0438\u0442 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043b\u0438\u0441\u0442\u0438\u043d\u0433 \u0432 \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0443 \u2013 \u0438 \u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u0435\u0434\u0435\u0442. \u0412 Word \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u0435 <code>SEQ<\/code>, \u0442\u043e \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0443\u043d\u043a\u0442 \u00ab\u0421\u0441\u044b\u043b\u043a\u0438 \u2192 \u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u00bb. \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0435\u0433\u043e \u0440\u0443\u043a\u0430\u043c\u0438:<\/p>\n<pre><code class=\"python\">def _add_field(paragraph, instr, cached):    def fld(kind):        r = paragraph.add_run()        el = OxmlElement(\"w:fldChar\")        el.set(qn(\"w:fldCharType\"), kind)        r._r.append(el)    fld(\"begin\")    r = paragraph.add_run()    instr_el = OxmlElement(\"w:instrText\")    instr_el.set(qn(\"xml:space\"), \"preserve\")    instr_el.text = f\" {instr} \"    r._r.append(instr_el)    fld(\"separate\")    paragraph.add_run(cached)  # \u0442\u043e, \u0447\u0442\u043e \u0432\u0438\u0434\u043d\u043e \u0434\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439    fld(\"end\")def add_listing(doc, code, title, number, language=\"python\"):    caption = doc.add_paragraph(\"\u041b\u0438\u0441\u0442\u0438\u043d\u0433 \")    _add_field(caption, \"SEQ \u041b\u0438\u0441\u0442\u0438\u043d\u0433 \\\\* ARABIC\", str(number))    caption.add_run(f\" \u2013 {title}\")    caption.paragraph_format.keep_with_next = True    add_code(doc, code, language)<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u041f\u043e\u043b\u0435 \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u043a\u0430\u043a \u0431\u0443\u0442\u0435\u0440\u0431\u0440\u043e\u0434 \u0438\u0437 \u0442\u0440\u0435\u0445 <code>fldChar<\/code>: \u043d\u0430\u0447\u0430\u043b\u043e, \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c, \u043a\u043e\u043d\u0435\u0446. \u041c\u0435\u0436\u0434\u0443 \u043d\u0430\u0447\u0430\u043b\u043e\u043c \u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0435\u043c \u043b\u0435\u0436\u0438\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f, \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0435\u043c \u0438 \u043a\u043e\u043d\u0446\u043e\u043c \u2013 \u0437\u0430\u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u0415\u0433\u043e \u043c\u044b \u0441\u0440\u0430\u0437\u0443 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c \u043d\u043e\u043c\u0435\u0440\u043e\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0438 \u0431\u0435\u0437 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439. \u0410 \u0435\u0441\u043b\u0438 \u043f\u043e\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0438 \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u0445\u0432\u0430\u0442\u0438\u0442 Ctrl+A \u0438 F9 \u2013 Word \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u043d\u043e\u043c\u0435\u0440\u0430 \u0441\u0430\u043c.<\/p>\n<p><code>keep_with_next<\/code> \u043d\u0443\u0436\u0435\u043d, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u043f\u0438\u0441\u044c \u043d\u0435 \u043e\u0441\u0442\u0430\u043b\u0430\u0441\u044c \u0441\u0438\u0440\u043e\u0442\u043e\u0439 \u0432\u043d\u0438\u0437\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u043f\u043e\u043a\u0430 \u043a\u043e\u0434 \u0443\u0435\u0445\u0430\u043b \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e.<\/p>\n<h3>\u041a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f<\/h3>\n<pre><code class=\"python\">from pathlib import Pathfrom docx import Documentfrom docx_code import add_listingdoc = Document(\"template.docx\")  # \u0432\u0430\u0448 \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u043e \u0413\u041e\u0421\u0422\u0443add_listing(doc, Path(\"bfs.py\").read_text(encoding=\"utf-8\"), \"\u041f\u043e\u0438\u0441\u043a \u0432 \u0448\u0438\u0440\u0438\u043d\u0443\", 1)add_listing(doc, Path(\"main.cpp\").read_text(encoding=\"utf-8\"), \"\u0427\u0442\u0435\u043d\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\", 2, language=\"cpp\")doc.save(\"report.docx\")<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p><code>encoding=\"utf-8\"<\/code> \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u0434\u043b\u044f \u043a\u0440\u0430\u0441\u043e\u0442\u044b: \u043d\u0430 Windows <code>open()<\/code> \u0431\u0435\u0437 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0438 \u0447\u0438\u0442\u0430\u0435\u0442 \u0444\u0430\u0439\u043b \u0432 cp1251, \u0438 \u0440\u0443\u0441\u0441\u043a\u0438\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0432 \u043a\u043e\u0434\u0435 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u044e\u0442\u0441\u044f \u0432 \u043a\u0440\u0430\u043a\u043e\u0437\u044f\u0431\u0440\u044b.<\/p>\n<p>\u0427\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c:<\/p>\n<ul>\n<li>\n<p><strong>\u042f\u0437\u044b\u043a<\/strong> \u2013 \u043b\u044e\u0431\u043e\u0439 \u0438\u0437 <a href=\"https:\/\/pygments.org\/languages\/\" rel=\"noopener nofollow\">500+ \u043b\u0435\u043a\u0441\u0435\u0440\u043e\u0432 Pygments<\/a>: <code>\"cpp\"<\/code>, <code>\"java\"<\/code>, <code>\"sql\"<\/code>, <code>\"bash\"<\/code>, <code>\"go\"<\/code>. \u0415\u0441\u043b\u0438 \u044f\u0437\u044b\u043a \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043d\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d, \u0435\u0441\u0442\u044c <code>guess_lexer(code)<\/code>, \u043d\u043e \u0443\u0433\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u043e\u043d \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p><strong>\u0426\u0432\u0435\u0442\u043e\u0432\u0430\u044f \u0441\u0445\u0435\u043c\u0430.<\/strong> <code>\"friendly\"<\/code> \u0445\u043e\u0440\u043e\u0448\u043e \u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0441\u044f \u043d\u0430 \u0441\u0432\u0435\u0442\u043b\u043e\u043c \u0444\u043e\u043d\u0435. \u0414\u043b\u044f \u0447\u0435\u0440\u043d\u043e-\u0431\u0435\u043b\u043e\u0439 \u043f\u0435\u0447\u0430\u0442\u0438 \u0435\u0441\u0442\u044c <code>\"bw\"<\/code> \u2013 \u0442\u043e\u043b\u044c\u043a\u043e \u0436\u0438\u0440\u043d\u044b\u0439 \u0438 \u043a\u0443\u0440\u0441\u0438\u0432. \u041e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0445\u0435\u043c\u044b \u2013 \u043d\u0430 <a href=\"https:\/\/pygments.org\/styles\/\" rel=\"noopener nofollow\">pygments.org\/styles<\/a>.<\/p>\n<\/li>\n<li>\n<p><strong>\u0428\u0440\u0438\u0444\u0442 \u0438 \u0440\u0430\u0437\u043c\u0435\u0440<\/strong> \u2013 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b <code>ensure_code_style<\/code>. \u0415\u0441\u043b\u0438 \u0441\u0442\u0438\u043b\u044c <code>Code<\/code> \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u0435, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0435\u0433\u043e \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u0435\u0442, \u0442\u0430\u043a \u0447\u0442\u043e \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u0446\u0435\u043b\u0438\u043a\u043e\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0432 \u0441\u0430\u043c\u043e\u043c Word.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0427\u0442\u043e \u043f\u043e\u043a\u0430 \u043d\u0435 \u0438\u0434\u0435\u0430\u043b\u044c\u043d\u043e<\/h3>\n<p>\u0414\u043b\u0438\u043d\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 Word \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442 \u043f\u043e \u0448\u0438\u0440\u0438\u043d\u0435 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u0438 \u043e\u0442\u0441\u0442\u0443\u043f \u0443 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u044f \u0442\u0435\u0440\u044f\u0435\u0442\u0441\u044f. \u041f\u0440\u043e\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043a\u043e\u0434 \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 80 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 \u0438\u043b\u0438 \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u0448\u0440\u0438\u0444\u0442 \u0434\u043e 9 pt.<\/p>\n<p>\u041d\u043e\u043c\u0435\u0440\u0430 \u0441\u0442\u0440\u043e\u043a \u044f \u0432 \u043c\u043e\u0434\u0443\u043b\u044c \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u043b. \u0412\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u0430\u044f \u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u044f Word (<code>lnNumType<\/code>) \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u0441\u0442\u0440\u043e\u043a\u0438 \u043d\u0430 \u0432\u0435\u0441\u044c \u0440\u0430\u0437\u0434\u0435\u043b, \u0430 \u043d\u0435 \u043d\u0430 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043b\u0438\u0441\u0442\u0438\u043d\u0433, \u0442\u0430\u043a \u0447\u0442\u043e \u0441\u0430\u043c\u044b\u0439 \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u2013 \u0442\u0430\u0431\u043b\u0438\u0446\u0430 \u0438\u0437 \u0434\u0432\u0443\u0445 \u043a\u043e\u043b\u043e\u043d\u043e\u043a: \u043d\u043e\u043c\u0435\u0440\u0430 \u0438 \u043a\u043e\u0434.<\/p>\n<p>\u0418 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e: LibreOffice \u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430, Word \u2013 \u043d\u0435\u0442. \u0415\u0441\u043b\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u0441\u0434\u0430\u0447\u0438, \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0439\u0442\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0432 Word.<\/p>\n<h3>\u0413\u0434\u0435 \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/h3>\n<p>\u041c\u043e\u0434\u0443\u043b\u044c \u0443\u0436\u0435 \u0436\u0438\u0432\u0435\u0442 \u0432 <a href=\"https:\/\/github.com\/viteax\/stepik-report-creator\" rel=\"noopener nofollow\">\u00ab\u041e\u0442\u0447\u0435\u0442 Creator\u00bb<\/a>: \u043e\u0442\u0447\u0435\u0442 \u043f\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0443 \u043a\u0443\u0440\u0441\u0430 \u0441\u043e Stepik \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0441 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0430\u043c\u0438 \u0442\u0435\u043a\u0441\u0442\u043e\u043c, \u0430 \u0441\u0442\u0430\u0440\u044b\u0439 \u0440\u0435\u0436\u0438\u043c \u0441 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430\u043c\u0438 \u043e\u0441\u0442\u0430\u043b\u0441\u044f \u0437\u0430 \u0444\u043b\u0430\u0433\u043e\u043c <code>--images<\/code> \u2013 \u0432\u0434\u0440\u0443\u0433 \u043a\u043e\u043c\u0443-\u0442\u043e \u0442\u0430\u043a \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u0435\u0435. \u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043c\u043e\u0434\u0443\u043b\u044f \u2013 \u0432 \u0444\u0430\u0439\u043b\u0435 <a href=\"https:\/\/github.com\/viteax\/stepik-report-creator\/blob\/master\/docx_code.py\" rel=\"noopener nofollow\"><code>docx_code.py<\/code><\/a>.<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e <a class=\"mention\" href=\"\/users\/milssky\">@milssky<\/a> \u0437\u0430 \u0438\u0434\u0435\u044e \u0441\u043e \u0441\u0442\u0438\u043b\u0435\u043c \u0438 <a class=\"mention\" href=\"\/users\/Andrey_Solomatin\">@Andrey_Solomatin<\/a> \u0437\u0430 Pygments \u2013 \u0431\u0435\u0437 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u043a \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044d\u0442\u043e\u0433\u043e \u0442\u0435\u043a\u0441\u0442\u0430 \u0431\u044b \u043d\u0435 \u0431\u044b\u043b\u043e. \u0415\u0441\u043b\u0438 \u0437\u043d\u0430\u0435\u0442\u0435, \u043a\u0430\u043a \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u043e\u043c\u0435\u0440\u0430 \u0441\u0442\u0440\u043e\u043a \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441 \u0434\u043b\u0438\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u043e\u0442\u0441\u0442\u0443\u043f\u0430, \u2013 \u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/p>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1090756\/\">https:\/\/habr.com\/ru\/articles\/1090756\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041a\u043e\u0434 \u0432 Word \u0431\u0435\u0437 \u043a\u0430\u0440\u0442\u0438\u043d\u043e\u043a: \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0430 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u0447\u0435\u0440\u0435\u0437 python-docx \u0438 Pygments\u041e\u043a\u043e\u043b\u043e \u0441\u0442\u0430 \u0441\u0442\u0440\u043e\u043a \u043d\u0430 Python \u2013 \u0438 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0438 \u0432 .docx \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043a\u0430\u043a \u0432 IDE, \u043a\u043e\u043f\u0438\u0440\u0443\u044e\u0442\u0441\u044f, \u0438\u0449\u0443\u0442\u0441\u044f \u0438 \u043d\u0443\u043c\u0435\u0440\u0443\u044e\u0442\u0441\u044f \u0441\u0430\u043c\u0438.\u0412 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b \u043f\u0440\u043e \u00ab\u041e\u0442\u0447\u0435\u0442 Creator\u00bb \u2013 \u0441\u043a\u0440\u0438\u043f\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442 \u043e\u0442\u0447\u0435\u0442\u044b \u043f\u043e \u043b\u0430\u0431\u0430\u043c \u0441\u043e Stepik \u0432 Word. \u041a\u043e\u0434 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043e\u043d \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u043b \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430\u043c\u0438, \u0438 \u043f\u0435\u0440\u0432\u044b\u0439 \u0436\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u043f\u043e\u0434 \u0441\u0442\u0430\u0442\u044c\u0435\u0439 \u0431\u044b\u043b: \u00ab\u041a\u043e\u0434 \u0440\u0438\u0441\u0443\u043d\u043a\u0430\u043c\u0438 \u2013 \u0431\u0440\u0440\u00bb.\u0421\u043f\u043e\u0440\u0438\u0442\u044c \u0431\u044b\u043b\u043e \u0441\u043b\u043e\u0436\u043d\u043e. \u041d\u043e \u0442\u043e\u0433\u0434\u0430 \u044f \u0447\u0435\u0441\u0442\u043d\u043e \u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e python-docx \u043f\u043e-\u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u043d\u0435 \u0443\u043c\u0435\u0435\u0442. \u0421 \u044d\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 \u044f \u0432\u043e\u043e\u0431\u0449\u0435 \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0441\u044f \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u043e: \u0432 2024 \u0433\u043e\u0434\u0443 \u0441\u043f\u0440\u043e\u0441\u0438\u043b \u0443 ChatGPT, \u0447\u0435\u043c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c Word-\u0444\u0430\u0439\u043b\u044b \u0438\u0437 Python, \u043e\u043d \u043d\u0430\u0437\u0432\u0430\u043b python-docx \u2013 \u0442\u0430\u043a \u0438 \u043f\u043e\u0448\u043b\u043e. \u0414\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u044f \u0442\u043e\u0433\u0434\u0430 \u0447\u0438\u0442\u0430\u043b \u043f\u043e \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u0438, \u0440\u043e\u0432\u043d\u043e \u0434\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u00ab\u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430 \u0432\u0441\u0442\u0430\u0432\u0438\u043b\u0430\u0441\u044c \u2013 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u00bb.\u041f\u043e\u0441\u043b\u0435 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432 \u044f \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u0441\u0435\u043b \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f. \u0412\u044b\u044f\u0441\u043d\u0438\u043b\u043e\u0441\u044c, \u0447\u0442\u043e \u043a\u043e\u0434 \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u0441 \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u043e\u0439 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0430\u0440\u0443 \u0440\u0430\u0437 \u0441\u043f\u0443\u0441\u0442\u0438\u0442\u044c\u0441\u044f \u0432 XML \u0438 \u043d\u0430\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0433\u0440\u0430\u0431\u043b\u0435\u0439. \u0412\u0441\u0435 \u044d\u0442\u043e \u044f \u0441\u043e\u0431\u0440\u0430\u043b \u0432 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0431\u0440\u0430\u0442\u044c \u0432 \u043b\u044e\u0431\u043e\u0439 \u0441\u0432\u043e\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432: \u043e\u0442\u0447\u0435\u0442\u044b, \u043a\u0443\u0440\u0441\u043e\u0432\u044b\u0435, \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e.\u0412\u043e\u0442 \u043a\u0430\u043a \u0431\u044b\u043b\u043e:\u0421\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0441\u0442\u0430\u0440\u043e\u0433\u043e \u043e\u0442\u0447\u0435\u0442\u0430, \u043a\u043e\u0434 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u043e\u0439\u0410 \u0432\u043e\u0442 \u043a\u0430\u043a \u0441\u0442\u0430\u043b\u043e:\u0414\u0432\u0430 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0430, \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0442\u0435\u043a\u0441\u0442\u043e\u043c: Python \u0438 C++\u041e\u0434\u043d\u043e\u0433\u0440\u0443\u043f\u043f\u043d\u0438\u043a\u0438 \u0438 \u043f\u0440\u0435\u043f\u043e\u0434\u0430\u0432\u0430\u0442\u0435\u043b\u0438, \u043c\u044f\u0433\u043a\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0443\u0434\u0438\u0432\u0438\u043b\u0438\u0441\u044c \u0442\u0430\u043a\u043e\u043c\u0443 \u0437\u0430\u0432\u043e\u0437\u0443: \u043a\u043e\u0434 \u0432 \u043e\u0442\u0447\u0435\u0442\u0430\u0445 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c, \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0431\u0435\u0437 \u043b\u0443\u043f\u044b, \u0430 \u0441\u0430\u043c\u0438 \u0444\u0430\u0439\u043b\u044b \u0437\u0430\u043c\u0435\u0442\u043d\u043e \u043f\u043e\u0445\u0443\u0434\u0435\u043b\u0438.\u0427\u0435\u043c \u043f\u043b\u043e\u0445\u0438 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0430\u0422\u0435\u043a\u0441\u0442\u0421\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u0434\u043d\u0435\u043b\u044c\u0437\u044f\u043c\u043e\u0436\u043d\u043e\u041d\u0430\u0439\u0442\u0438 \u0447\u0435\u0440\u0435\u0437 Ctrl+F\u043d\u0435\u043b\u044c\u0437\u044f\u043c\u043e\u0436\u043d\u043e\u0427\u0435\u0442\u043a\u043e\u0441\u0442\u044c \u043f\u0440\u0438 \u043f\u0435\u0447\u0430\u0442\u0438 \u0438 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f\u0432\u0441\u0435\u0433\u0434\u0430 \u0447\u0435\u0442\u043a\u043e\u041f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u0448\u0440\u0438\u0444\u0442 \u0438\u043b\u0438 \u0440\u0430\u0437\u043c\u0435\u0440 \u0432 Word\u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0435\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0447\u0435\u0440\u0435\u0437 \u0441\u0442\u0438\u043b\u044c, \u0437\u0430 \u0441\u0435\u043a\u0443\u043d\u0434\u0443\u0418 \u0435\u0449\u0435 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0441 \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c. \u0414\u043b\u044f \u0447\u0435\u0441\u0442\u043d\u043e\u0433\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u044f \u0432\u0437\u044f\u043b 30 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u043e\u0432 \u043f\u043e 14 \u0441\u0442\u0440\u043e\u043a \u0438 \u0441\u043e\u0431\u0440\u0430\u043b \u0438\u0437 \u043d\u0438\u0445 \u0434\u0432\u0430 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430: \u0432 \u043f\u0435\u0440\u0432\u043e\u043c \u043a\u043e\u0434 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u0430\u043d \u0447\u0435\u0440\u0435\u0437 Pillow (JetBrains Mono, 64 px, \u043a\u0430\u043a \u0432 \u0441\u0442\u0430\u0440\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438), \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u043c \u0432\u0441\u0442\u0430\u0432\u043b\u0435\u043d \u0442\u0435\u043a\u0441\u0442\u043e\u043c.\u0421\u043f\u043e\u0441\u043e\u0431\u0412\u0440\u0435\u043c\u044f \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438\u0420\u0430\u0437\u043c\u0435\u0440 .docx\u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 (Pillow)4,1 \u0441130 \u041a\u0411\u0422\u0435\u043a\u0441\u0442 (python-docx + Pygments)0,6 \u044139 \u041a\u0411\u041f\u0443\u0441\u0442\u043e\u0439 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u0441\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435 \u0432\u0435\u0441\u0438\u0442 \u043e\u043a\u043e\u043b\u043e 36 \u041a\u0411, \u0442\u0430\u043a \u0447\u0442\u043e 30 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0445 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u043e\u0432 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e\u0442 \u043a \u043d\u0435\u043c\u0443 \u0432\u0441\u0435\u0433\u043e \u043f\u0430\u0440\u0443 \u043a\u0438\u043b\u043e\u0431\u0430\u0439\u0442.\u041f\u043e\u0447\u0435\u043c\u0443 \u0431\u044b \u043d\u0435 LaTeX \u0438\u043b\u0438 pandoc? \u0418\u0445 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u043a \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0442\u043e\u0436\u0435 \u0441\u043e\u0432\u0435\u0442\u043e\u0432\u0430\u043b\u0438, \u0438 \u044d\u0442\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b. \u041d\u043e \u043a\u0430\u0444\u0435\u0434\u0440\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e .docx \u043f\u043e \u0441\u0432\u043e\u0435\u043c\u0443 \u0448\u0430\u0431\u043b\u043e\u043d\u0443, \u0430 \u043f\u043e\u043f\u0430\u0441\u0442\u044c \u0432 \u0447\u0443\u0436\u043e\u0439 \u0448\u0430\u0431\u043b\u043e\u043d \u0438\u0437 pandoc \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0447\u0435\u043c \u0434\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0442\u043e \u0441\u0442\u0440\u043e\u043a.\u0428\u0430\u0433 1. \u0421\u0442\u0438\u043b\u044c \u0434\u043b\u044f \u043a\u043e\u0434\u0430\u041f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0430 \u0438\u0437 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0435\u0432: \u0432 Word \u0434\u043b\u044f \u043a\u043e\u0434\u0430 \u0437\u0430\u0432\u043e\u0434\u044f\u0442 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u0442\u0438\u043b\u044c, \u043a\u0430\u043a \u0438 \u0434\u043b\u044f \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432. \u0422\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0438 \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e, \u0430 \u0448\u0440\u0438\u0444\u0442 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435.from docx.enum.style import WD_STYLE_TYPEfrom docx.shared import PtCODE_STYLE = &#171;Code&#187;def ensure_code_style(doc, font=&#187;Courier New&#187;, size=10):    if CODE_STYLE in [s.name for s in doc.styles]:        return    style = doc.styles.add_style(CODE_STYLE, WD_STYLE_TYPE.PARAGRAPH)    style.base_style = doc.styles[&#171;Normal&#187;]    style.font.size = Pt(size)    style.font.no_proof = True  # \u0431\u0435\u0437 \u043a\u0440\u0430\u0441\u043d\u044b\u0445 \u0432\u043e\u043b\u043d\u0438\u0441\u0442\u044b\u0445 \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u043d\u0438\u0439    _set_all_fonts(style.element.get_or_add_rPr(), font)    pf = style.paragraph_format    pf.first_line_indent = Pt(0)  # \u0432 \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u0445 \u043f\u043e \u0413\u041e\u0421\u0422\u0443 \u043e\u0431\u044b\u0447\u043d\u043e \u0435\u0441\u0442\u044c \u043a\u0440\u0430\u0441\u043d\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430    pf.left_indent = Pt(0)    pf.line_spacing = 1.0         # \u0430 \u0435\u0449\u0435 \u043f\u043e\u043b\u0443\u0442\u043e\u0440\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b    pf.space_before = Pt(0)    pf.space_after = Pt(0)\u0421\u0442\u0440\u043e\u0447\u043a\u0430 \u0441 no_proof \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043e\u0442\u043a\u0440\u043e\u0435\u0448\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u0431\u0435\u0437 \u043d\u0435\u0435. Word \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0440\u0435\u0436\u0438\u043c \u0441\u0442\u0440\u043e\u0433\u043e\u0439 \u0443\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u0438\u0446\u044b \u0440\u0443\u0441\u0441\u043a\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430: def \u2013 \u043e\u0448\u0438\u0431\u043a\u0430, popleft \u2013 \u043e\u0448\u0438\u0431\u043a\u0430, elif \u2013 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u043e \u0447\u0442\u043e. \u0427\u0435\u0440\u0435\u0437 \u043f\u0430\u0440\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446 \u043b\u0438\u0441\u0442\u0438\u043d\u0433 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 \u0441\u043e\u0447\u0438\u043d\u0435\u043d\u0438\u0435 \u0434\u0432\u043e\u0435\u0447\u043d\u0438\u043a\u0430, \u0447\u0435\u043c \u043d\u0430 \u043a\u043e\u0434. no_proof \u2013 \u044d\u0442\u043e \u0433\u0430\u043b\u043e\u0447\u043a\u0430 \u00ab\u041d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043f\u0440\u0430\u0432\u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u00bb, \u0438 \u0441\u0442\u043e\u0438\u0442 \u043e\u043d\u0430 \u0441\u0440\u0430\u0437\u0443 \u043d\u0430 \u0432\u0435\u0441\u044c \u0441\u0442\u0438\u043b\u044c.\u0421\u043e \u0448\u0440\u0438\u0444\u0442\u043e\u043c \u043f\u043e\u0434\u0432\u043e\u0445 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0440\u043e\u0434\u0430. \u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c style.font.name = &#171;Courier New&#187;, python-docx \u0432\u044b\u0441\u0442\u0430\u0432\u0438\u0442 \u0448\u0440\u0438\u0444\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043b\u0430\u0442\u0438\u043d\u0438\u0446\u044b (\u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b w:ascii \u0438 w:hAnsi). \u0414\u043b\u044f \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d\u043e\u0432 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432 Word \u0432\u043e\u0437\u044c\u043c\u0435\u0442 \u0448\u0440\u0438\u0444\u0442 \u0438\u0437 \u0431\u0430\u0437\u043e\u0432\u043e\u0433\u043e \u0441\u0442\u0438\u043b\u044f \u2013 \u0438 \u0432 \u043e\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u043c\u043e\u0433\u0443\u0442 \u0432\u0441\u0442\u0440\u0435\u0442\u0438\u0442\u044c\u0441\u044f \u0434\u0432\u0430 \u0448\u0440\u0438\u0444\u0442\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u0434\u0430\u0435\u043c \u0432\u0441\u0435 \u0447\u0435\u0442\u044b\u0440\u0435 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u0430:from docx.oxml.ns import qndef _set_all_fonts(rpr, name):    rfonts = rpr.get_or_add_rFonts()    for attr in (&#171;w:ascii&#187;, &#171;w:hAnsi&#187;, &#171;w:cs&#187;, &#171;w:eastAsia&#187;):        rfonts.set(qn(attr), name)\u041f\u043e\u0447\u0435\u043c\u0443 Courier New, \u0430 \u043d\u0435 JetBrains Mono, \u043a\u0430\u043a \u0431\u044b\u043b\u043e \u043d\u0430 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0430\u0445? \u0415\u0433\u043e \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0442\u044c: \u043e\u043d \u0435\u0441\u0442\u044c \u0432 Windows \u0438 macOS, \u0438 \u0443 \u043f\u0440\u0435\u043f\u043e\u0434\u0430\u0432\u0430\u0442\u0435\u043b\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u043e\u0442\u043a\u0440\u043e\u0435\u0442\u0441\u044f \u0442\u0430\u043a \u0436\u0435, \u043a\u0430\u043a \u0443 \u043c\u0435\u043d\u044f.\u0428\u0430\u0433 2. \u0420\u0430\u043c\u043a\u0430 \u0438 \u0437\u0430\u043b\u0438\u0432\u043a\u0430\u0427\u0442\u043e\u0431\u044b \u043b\u0438\u0441\u0442\u0438\u043d\u0433 \u0447\u0438\u0442\u0430\u043b\u0441\u044f \u043a\u0430\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0431\u043b\u043e\u043a, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u0442\u0438\u043b\u044e \u0441\u0432\u0435\u0442\u043b\u0443\u044e \u0437\u0430\u043b\u0438\u0432\u043a\u0443 \u0438 \u0442\u043e\u043d\u043a\u0443\u044e \u0440\u0430\u043c\u043a\u0443. \u0413\u043e\u0442\u043e\u0432\u043e\u0433\u043e API \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 python-docx \u043d\u0435\u0442, \u0442\u0430\u043a \u0447\u0442\u043e \u043b\u0435\u0437\u0435\u043c \u0432 XML:from docx.oxml import OxmlElementdef _add_box(ppr, fill=&#187;F6F8FA&#187;, border=&#187;D0D7DE&#187;):    pbdr = OxmlElement(&#171;w:pBdr&#187;)    for side in (&#171;top&#187;, &#171;left&#187;, &#171;bottom&#187;, &#171;right&#187;):        el = OxmlElement(f&#187;w:{side}&#187;)        el.set(qn(&#171;w:val&#187;), &#171;single&#187;)        el.set(qn(&#171;w:sz&#187;), &#171;4&#187;)      # \u0432 \u0432\u043e\u0441\u044c\u043c\u044b\u0445 \u0434\u043e\u043b\u044f\u0445 \u043f\u0443\u043d\u043a\u0442\u0430: 4 = 0,5 pt        el.set(qn(&#171;w:space&#187;), &#171;4&#187;)        el.set(qn(&#171;w:color&#187;), border)        pbdr.append(el)    ppr.insert_element_before(pbdr, &#171;w:shd&#187;, *_PPR_TAIL)    shd = OxmlElement(&#171;w:shd&#187;)    shd.set(qn(&#171;w:val&#187;), &#171;clear&#187;)    shd.set(qn(&#171;w:color&#187;), &#171;auto&#187;)    shd.set(qn(&#171;w:fill&#187;), fill)    ppr.insert_element_before(shd, *_PPR_TAIL)\u0421\u0430\u043c\u043e\u0435 \u043a\u043e\u0432\u0430\u0440\u043d\u043e\u0435 \u0437\u0434\u0435\u0441\u044c \u2013 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432. \u0412\u043d\u0443\u0442\u0440\u0438 &lt;w:pPr&gt; \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0435 \u0442\u0435\u0433\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0434\u0442\u0438 \u0441\u0442\u0440\u043e\u0433\u043e \u0432 \u043f\u043e\u0440\u044f\u0434\u043a\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0434\u0430\u0435\u0442 \u0441\u0445\u0435\u043c\u0430 OOXML. \u0415\u0441\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e ppr.append(shd), \u0437\u0430\u043b\u0438\u0432\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0441\u043b\u0435 &lt;w:spacing&gt;. LibreOffice \u0442\u0430\u043a\u043e\u0435 \u043c\u043e\u043b\u0447\u0430 \u043f\u0440\u043e\u0433\u043b\u043e\u0442\u0438\u0442, \u0430 Word \u043c\u043e\u0436\u0435\u0442 \u043e\u0442\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e \u00ab\u043d\u0435\u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435\u00bb. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c \u0447\u0435\u0440\u0435\u0437 insert_element_before \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0442\u0435\u0433\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043e\u0431\u044f\u0437\u0430\u043d\u044b \u0438\u0434\u0442\u0438 \u043f\u043e\u0441\u043b\u0435 \u043d\u0430\u0448\u0435\u0433\u043e:_PPR_TAIL = (    &#171;w:tabs&#187;, &#171;w:suppressAutoHyphens&#187;, &#171;w:kinsoku&#187;, &#171;w:wordWrap&#187;,    &#171;w:overflowPunct&#187;, &#171;w:topLinePunct&#187;, &#171;w:autoSpaceDE&#187;, &#171;w:autoSpaceDN&#187;,    &#171;w:bidi&#187;, &#171;w:adjustRightInd&#187;, &#171;w:snapToGrid&#187;, &#171;w:spacing&#187;, &#171;w:ind&#187;,    &#171;w:contextualSpacing&#187;, &#171;w:mirrorIndents&#187;, &#171;w:suppressOverlap&#187;, &#171;w:jc&#187;,    &#171;w:textDirection&#187;, &#171;w:textAlignment&#187;, &#171;w:textboxTightWrap&#187;,    &#171;w:outlineLvl&#187;, &#171;w:divId&#187;, &#171;w:cnfStyle&#187;, &#171;w:rPr&#187;, &#171;w:sectPr&#187;, &#171;w:pPrChange&#187;,)\u0421\u043f\u0438\u0441\u043e\u043a \u044f \u043f\u043e\u0434\u0441\u043c\u043e\u0442\u0440\u0435\u043b \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u0445 \u0441\u0430\u043c\u043e\u0439 python-docx, \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 CT_PPr: \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0445\u0440\u0430\u043d\u0438\u0442 \u0435\u0433\u043e \u0440\u043e\u0432\u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u0446\u0435\u043b\u0438.\u0428\u0430\u0433 3. \u041f\u043e\u0434\u0441\u0432\u0435\u0442\u043a\u0430: \u0438\u0437 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0432\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u044b\u0410\u0431\u0437\u0430\u0446 \u0432 Word \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u0432 \u2013 runs, \u0438 \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u0432\u043e\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435. Pygments \u0440\u0435\u0436\u0435\u0442 \u043a\u043e\u0434 \u043d\u0430 \u0442\u043e\u043a\u0435\u043d\u044b \u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442 \u0446\u0432\u0435\u0442, \u0436\u0438\u0440\u043d\u043e\u0441\u0442\u044c \u0438 \u043a\u0443\u0440\u0441\u0438\u0432. \u041e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0432\u0440\u0430\u0442\u0438\u0442\u044c \u043e\u0434\u043d\u043e \u0432 \u0434\u0440\u0443\u0433\u043e\u0435:from pygments import lexfrom pygments.lexers import get_lexer_by_namefrom pygments.styles import get_style_by_namedef _runs(code, language, style_name):    style = get_style_by_name(style_name)    chunks = []    lexer = get_lexer_by_name(language, ensurenl=False)    for token_type, value in lex(code, lexer):        s = style.style_for_token(token_type)        fmt = (s[&#171;color&#187;], s[&#171;bold&#187;], s[&#171;italic&#187;])        if chunks and (chunks[-1][1] == fmt or value.isspace()):            chunks[-1][0] += value  # \u0441\u043a\u043b\u0435\u0438\u0432\u0430\u0435\u043c \u0441 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u043c \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u043c        else:            chunks.append([value, fmt])    return chunks\u041f\u0435\u0440\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0434\u0435\u043b\u0430\u043b\u0430 \u043f\u043e \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0443 \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0442\u043e\u043a\u0435\u043d, \u0438 \u044d\u0442\u043e \u0440\u0430\u0441\u0442\u043e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e: Pygments \u0434\u0440\u043e\u0431\u0438\u0442 \u043a\u043e\u0434 \u043e\u0447\u0435\u043d\u044c \u043c\u0435\u043b\u043a\u043e, \u043a\u0430\u0436\u0434\u044b\u0439 \u043f\u0440\u043e\u0431\u0435\u043b \u0438 \u043a\u0430\u0436\u0434\u0430\u044f \u0437\u0430\u043f\u044f\u0442\u0430\u044f \u2013 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0442\u043e\u043a\u0435\u043d. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u044b \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u0441\u0442\u0438\u043b\u0435\u043c \u0441\u043a\u043b\u0435\u0438\u0432\u0430\u044e\u0442\u0441\u044f, \u0430 \u043f\u0440\u043e\u0431\u0435\u043b\u044b (\u0438\u043c \u0446\u0432\u0435\u0442 \u043d\u0435 \u0432\u0430\u0436\u0435\u043d) \u043f\u0440\u0438\u043b\u0438\u043f\u0430\u044e\u0442 \u043a \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c\u0443 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u0443. \u0414\u043b\u044f \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0430 \u0441 \u043f\u043e\u0438\u0441\u043a\u043e\u043c \u0432 \u0448\u0438\u0440\u0438\u043d\u0443 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f 57 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u0432 \u0432\u043c\u0435\u0441\u0442\u043e 147, \u0434\u043b\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u043d\u0430 C++ \u2013 39 \u0432\u043c\u0435\u0441\u0442\u043e 103. \u041c\u0435\u043d\u044c\u0448\u0435 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442\u043e\u0432 \u2013 \u043c\u0435\u043d\u044c\u0448\u0435 XML \u0432 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0435.ensurenl=False \u2013 \u043c\u0435\u043b\u043e\u0447\u044c, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u043d\u0430\u0448\u0435\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0432\u043d\u0438\u0437\u0443 \u043a\u0430\u0436\u0434\u043e\u0439 \u0440\u0430\u043c\u043a\u0438. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e Pygments \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0432 \u043a\u043e\u043d\u0435\u0446 \u043a\u043e\u0434\u0430 \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0441\u0442\u0440\u043e\u043a\u0438, \u044d\u0442\u0430 \u043e\u043f\u0446\u0438\u044f \u0435\u0433\u043e \u043e\u0442\u043a\u043b\u044e\u0447\u0430\u0435\u0442.\u0421\u0430\u043c\u0430 \u0432\u0441\u0442\u0430\u0432\u043a\u0430:from docx.shared import RGBColordef add_code(doc, code, language=&#187;python&#187;, style_name=&#187;friendly&#187;):    ensure_code_style(doc)    p = doc.add_paragraph(style=CODE_STYLE)    for text, (color, bold, italic) in _runs(code.strip(&#171;\\n&#187;), language, style_name):        run = p.add_run(text)        if color:            run.font.color.rgb = RGBColor.from_string(color)        run.bold = bold        run.italic = italic    return p\u0412\u0435\u0441\u044c \u043b\u0438\u0441\u0442\u0438\u043d\u0433 \u2013 \u043e\u0434\u0438\u043d \u0430\u0431\u0437\u0430\u0446. add_run \u0441\u0430\u043c \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \\n \u0432 \u0440\u0430\u0437\u0440\u044b\u0432 \u0441\u0442\u0440\u043e\u043a\u0438 &lt;w:br\/&gt;, \u0430 \\t \u2013 \u0432 \u0442\u0430\u0431\u0443\u043b\u044f\u0446\u0438\u044e \u0438 \u0441\u0442\u0430\u0432\u0438\u0442 xml:space=&#187;preserve&#187;, \u0442\u0430\u043a \u0447\u0442\u043e \u043e\u0442\u0441\u0442\u0443\u043f\u044b \u0432 Python \u043d\u0435 \u0442\u0435\u0440\u044f\u044e\u0442\u0441\u044f. \u0415\u0441\u043b\u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e \u0430\u0431\u0437\u0430\u0446\u0443 \u043d\u0430 \u043a\u0430\u0436\u0434\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u043a\u043e\u0434\u0430, \u0440\u0430\u043c\u043a\u0430 \u043d\u0430\u0440\u0438\u0441\u0443\u0435\u0442\u0441\u044f \u0432\u043e\u043a\u0440\u0443\u0433 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u0430 \u043c\u0435\u0436\u0434\u0443 \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438 \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b \u0438\u0437 \u0448\u0430\u0431\u043b\u043e\u043d\u0430.\u0428\u0430\u0433 4. \u041f\u043e\u0434\u043f\u0438\u0441\u044c \u0441 \u0430\u0432\u0442\u043e\u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u0435\u0439\u041d\u043e\u043c\u0435\u0440 \u0432 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u043c\u043e\u0436\u043d\u043e \u0432\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u043a\u0441\u0442\u043e\u043c: \u00ab\u041b\u0438\u0441\u0442\u0438\u043d\u0433 3\u00bb. \u041d\u043e \u0441\u0442\u043e\u0438\u0442 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043b\u0438\u0441\u0442\u0438\u043d\u0433 \u0432 \u0441\u0435\u0440\u0435\u0434\u0438\u043d\u0443 \u2013 \u0438 \u043d\u0443\u043c\u0435\u0440\u0430\u0446\u0438\u044f \u043f\u043e\u0435\u0434\u0435\u0442. \u0412 Word \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u0435 SEQ, \u0442\u043e \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e \u0432\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043f\u0443\u043d\u043a\u0442 \u00ab\u0421\u0441\u044b\u043b\u043a\u0438 \u2192 \u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u00bb. \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0435\u0433\u043e \u0440\u0443\u043a\u0430\u043c\u0438:def _add_field(paragraph, instr, cached):    def fld(kind):        r = paragraph.add_run()        el = OxmlElement(&#171;w:fldChar&#187;)        el.set(qn(&#171;w:fldCharType&#187;), kind)        r._r.append(el)    fld(&#171;begin&#187;)    r = paragraph.add_run()    instr_el = OxmlElement(&#171;w:instrText&#187;)    instr_el.set(qn(&#171;xml:space&#187;), &#171;preserve&#187;)    instr_el.text = f&#187; {instr} &#187;    r._r.append(instr_el)    fld(&#171;separate&#187;)    paragraph.add_run(cached)  # \u0442\u043e, \u0447\u0442\u043e \u0432\u0438\u0434\u043d\u043e \u0434\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439    fld(&#171;end&#187;)def add_listing(doc, code, title, number, language=&#187;python&#187;):    caption = doc.add_paragraph(&#171;\u041b\u0438\u0441\u0442\u0438\u043d\u0433 &#171;)    _add_field(caption, &#171;SEQ \u041b\u0438\u0441\u0442\u0438\u043d\u0433 \\\\* ARABIC&#187;, str(number))    caption.add_run(f&#187; \u2013 {title}&#187;)    caption.paragraph_format.keep_with_next = True    add_code(doc, code, language)\u041f\u043e\u043b\u0435 \u0443\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u043a\u0430\u043a \u0431\u0443\u0442\u0435\u0440\u0431\u0440\u043e\u0434 \u0438\u0437 \u0442\u0440\u0435\u0445 fldChar: \u043d\u0430\u0447\u0430\u043b\u043e, \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c, \u043a\u043e\u043d\u0435\u0446. \u041c\u0435\u0436\u0434\u0443 \u043d\u0430\u0447\u0430\u043b\u043e\u043c \u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0435\u043c \u043b\u0435\u0436\u0438\u0442 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f, \u043c\u0435\u0436\u0434\u0443 \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u0435\u043c \u0438 \u043a\u043e\u043d\u0446\u043e\u043c \u2013 \u0437\u0430\u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u0415\u0433\u043e \u043c\u044b \u0441\u0440\u0430\u0437\u0443 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c \u043d\u043e\u043c\u0435\u0440\u043e\u043c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0438 \u0431\u0435\u0437 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u0435\u0439. \u0410 \u0435\u0441\u043b\u0438 \u043f\u043e\u0442\u043e\u043c \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043b\u0438\u0441\u0442\u0438\u043d\u0433\u0438 \u0432\u0440\u0443\u0447\u043d\u0443\u044e, \u0445\u0432\u0430\u0442\u0438\u0442 Ctrl+A \u0438 F9 \u2013 Word \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u043d\u043e\u043c\u0435\u0440\u0430 \u0441\u0430\u043c.keep_with_next \u043d\u0443\u0436\u0435\u043d, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0434\u043f\u0438\u0441\u044c \u043d\u0435 \u043e\u0441\u0442\u0430\u043b\u0430\u0441\u044c \u0441\u0438\u0440\u043e\u0442\u043e\u0439 \u0432\u043d\u0438\u0437\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b, \u043f\u043e\u043a\u0430 \u043a\u043e\u0434 \u0443\u0435\u0445\u0430\u043b \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e.\u041a\u0430\u043a \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044ffrom pathlib import Pathfrom docx import Documentfrom docx_code import add_listingdoc = Document(&#171;template.docx&#187;)  # \u0432\u0430\u0448 \u0448\u0430\u0431\u043b\u043e\u043d \u043f\u043e \u0413\u041e\u0421\u0422\u0443add_listing(doc, Path(&#171;bfs.py&#187;).read_text(encoding=&#187;utf-8&#8243;), &#171;\u041f\u043e\u0438\u0441\u043a \u0432 \u0448\u0438\u0440\u0438\u043d\u0443&#187;, 1)add_listing(doc, Path(&#171;main.cpp&#187;).read_text(encoding=&#187;utf-8&#8243;), &#171;\u0427\u0442\u0435\u043d\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430&#187;, 2,&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-497478","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/497478","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=497478"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/497478\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=497478"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=497478"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=497478"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}