on-munseo-local 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MANIFEST.json +453 -214
- package/NOTICE.md +22 -0
- package/README.md +129 -44
- package/licenses/OnFonts-Baekmuk-COPYRIGHT.txt +23 -0
- package/licenses/OnFonts-OFL.txt +103 -0
- package/licenses/canvaskit/README.md +30 -0
- package/licenses/canvaskit/brotli-LICENSE +19 -0
- package/licenses/canvaskit/emscripten-LICENSE +102 -0
- package/licenses/canvaskit/emscripten-compiler-rt-LICENSE.TXT +311 -0
- package/licenses/canvaskit/emscripten-libcxx-LICENSE.TXT +311 -0
- package/licenses/canvaskit/emscripten-libcxxabi-LICENSE.TXT +311 -0
- package/licenses/canvaskit/emscripten-musl-COPYRIGHT +193 -0
- package/licenses/canvaskit/freetype-FTL.TXT +169 -0
- package/licenses/canvaskit/freetype-LICENSE.TXT +47 -0
- package/licenses/canvaskit/harfbuzz-COPYING +42 -0
- package/licenses/canvaskit/icu-LICENSE +568 -0
- package/licenses/canvaskit/libjpeg-turbo-LICENSE.md +135 -0
- package/licenses/canvaskit/libjpeg-turbo-README.ijg +260 -0
- package/licenses/canvaskit/libpng-LICENSE +134 -0
- package/licenses/canvaskit/libwebp-COPYING +30 -0
- package/licenses/canvaskit/libwebp-PATENTS +23 -0
- package/licenses/canvaskit/wuffs-LICENSE +202 -0
- package/licenses/canvaskit/zlib-LICENSE +19 -0
- package/licenses/canvaskit-BSD-3-Clause.txt +29 -0
- package/local/build.json +3 -3
- package/local/canvaskit/canvaskit.cjs +265 -0
- package/local/canvaskit/canvaskit.wasm +0 -0
- package/local/ck2d.js +2 -0
- package/local/config.js +1 -1
- package/local/fonts/OnBatang-Main.woff2 +0 -0
- package/local/fonts/OnBatangChe-Main.woff2 +0 -0
- package/local/fonts/OnDotum-Main.woff2 +0 -0
- package/local/fonts/OnDotumChe-Main.woff2 +0 -0
- package/local/fonts/OnGothic-Main.woff2 +0 -0
- package/local/fonts/OnGulim-Main.woff2 +0 -0
- package/local/fonts/OnGulimChe-Main.woff2 +0 -0
- package/local/fonts/OnHangyeolBatang-Main.woff2 +0 -0
- package/local/fonts/OnHangyeolBatangBold-Main.woff2 +0 -0
- package/local/fonts/OnHangyeolDotum-Main.woff2 +0 -0
- package/local/fonts/OnHangyeolDotumBold-Main.woff2 +0 -0
- package/local/fonts/OnHeadline-Ext.woff2 +0 -0
- package/local/fonts/OnHeadline-Hanja.woff2 +0 -0
- package/local/fonts/OnHeadline-Main.woff2 +0 -0
- package/local/fonts/OnJungGothic-Main.woff2 +0 -0
- package/local/fonts/OnJungGothic2-Main.woff2 +0 -0
- package/local/fonts/OnJungMyeongjo-Main.woff2 +0 -0
- package/local/fonts/OnKyunGothic-Main.woff2 +0 -0
- package/local/fonts/OnKyunGothic2-Main.woff2 +0 -0
- package/local/fonts/OnKyunMyeongjo-Main.woff2 +0 -0
- package/local/fonts/OnKyunMyeongjo2-Main.woff2 +0 -0
- package/local/fonts/OnMyeongjo-Ext.woff2 +0 -0
- package/local/fonts/OnMyeongjo-Hanja.woff2 +0 -0
- package/local/fonts/OnMyeongjo-Main.woff2 +0 -0
- package/local/fonts/OnSaeMyeongjo2-Main.woff2 +0 -0
- package/local/fonts/OnSinMyeongjo-Main.woff2 +0 -0
- package/local/fonts/OnTtogothic-Ext.woff2 +0 -0
- package/local/fonts/OnTtogothic-Hanja.woff2 +0 -0
- package/local/fonts/OnTtogothic-Main.woff2 +0 -0
- package/local/fonts/OnTtogothicBold-Main.woff2 +0 -0
- package/local/fonts/fonts.json +1 -0
- package/local/imgsized.js +2 -0
- package/local/main.js +1 -1
- package/local/pagefonts.js +2 -0
- package/local/setup.js +1 -1
- package/package.json +3 -2
- package/public/js/gongcheck.js +1 -1
- package/public/js/plain_rules.js +1 -1
- package/public/js/spellcheck.js +1 -1
- package/server/calcwork_worker.js +1 -1
- package/server/offwork_worker.js +1 -1
- package/server/onform.js +1 -1
- package/server/onsvc/core_local.js +1 -1
- package/server/onsvc/router.js +1 -1
- package/server/onsvc/svgdraw.js +2 -0
- package/server/onsvc/worker.js +1 -1
- package/server/ontext.js +1 -1
- package/server/ontext_hwp.js +1 -1
- package/server/ontext_table.js +1 -1
- package/server/ontext_tools.js +1 -1
- package/server/ontext_zip.js +1 -1
- package/server/onwrite.js +1 -1
- package/server/onwrite_gov.js +1 -1
- package/server/onwrite_numcheck.js +1 -1
- package/server/onwrite_review.js +1 -1
- package/server/pdfmd.js +1 -1
- package/server/zipcap.js +1 -1
- package/trial/server/checks.js +1 -1
- package/trial/server/mcp_extra.js +1 -1
- package/trial/server/mcp_more.js +1 -1
- package/trial/web/app/gallery/g01.hwpx +0 -0
- package/trial/web/app/gallery/g02.hwpx +0 -0
- package/trial/web/app/gallery/g03.hwpx +0 -0
- package/trial/web/app/gallery/g04.hwpx +0 -0
- package/trial/web/app/gallery/g05.hwpx +0 -0
- package/trial/web/app/gallery/g06.hwpx +0 -0
- package/trial/web/app/gallery/g07.hwpx +0 -0
- package/trial/web/app/gallery/g08.hwpx +0 -0
- package/trial/web/app/gallery/g09.hwpx +0 -0
- package/trial/web/app/gallery/g10.hwpx +0 -0
- package/trial/web/app/gallery/g11.hwpx +0 -0
- package/trial/web/app/gallery/g12.hwpx +0 -0
- package/trial/web/app/gallery/g13.hwpx +0 -0
- package/trial/web/app/gallery/g14.hwpx +0 -0
- package/trial/web/app/gallery/g15.hwpx +0 -0
- package/trial/web/app/gallery/g16.hwpx +0 -0
- package/trial/web/app/gallery/g17.hwpx +0 -0
- package/trial/web/app/gallery/g18.hwpx +0 -0
- package/trial/web/app/gallery/g19.hwpx +0 -0
- package/trial/web/app/gallery/g20.hwpx +0 -0
- package/trial/web/app/gallery/g21.hwpx +0 -0
- package/trial/web/app/gallery/g22.hwpx +0 -0
- package/trial/web/app/gallery/g23.hwpx +0 -0
- package/trial/web/app/gallery/g24.hwpx +0 -0
- package/trial/web/app/gallery/g25.hwpx +0 -0
- package/trial/web/app/gallery/g26.hwpx +0 -0
- package/trial/web/app/gallery/g27.hwpx +0 -0
- package/trial/web/app/gallery/g28.hwpx +0 -0
- package/trial/web/app/gallery/g29.hwpx +0 -0
- package/trial/web/app/gallery/g30.hwpx +0 -0
- package/trial/web/app/gallery/g31.hwpx +0 -0
- package/trial/web/app/gallery/g32.hwpx +0 -0
- package/trial/web/app/gallery/g33.hwpx +0 -0
- package/trial/web/app/gallery/g34.hwpx +0 -0
- package/trial/web/app/gallery/g35.hwpx +0 -0
- package/trial/web/app/gallery/g36.hwpx +0 -0
- package/trial/web/app/gallery/g37.hwpx +0 -0
- package/trial/web/app/gallery/g38.hwpx +0 -0
- package/trial/web/app/gallery/g39.hwpx +0 -0
- package/trial/web/app/gallery/g40.hwpx +0 -0
- package/trial/web/app/gallery/g41.hwpx +0 -0
- package/trial/web/app/gallery/g42.hwpx +0 -0
- package/trial/web/app/gallery/g43.hwpx +0 -0
- package/trial/web/app/gallery/g44.hwpx +0 -0
- package/trial/web/app/gallery/g45.hwpx +0 -0
- package/trial/web/app/gallery/g46.hwpx +0 -0
- package/trial/web/app/gallery/g47.hwpx +0 -0
- package/trial/web/app/gallery/g48.hwpx +0 -0
- package/trial/web/app/gallery/g49.hwpx +0 -0
- package/trial/web/app/gallery/g50.hwpx +0 -0
- package/trial/web/app/gallery/g51.hwpx +0 -0
- package/trial/web/app/gallery/g52.hwpx +0 -0
- package/trial/web/app/gallery/g53.hwpx +0 -0
- package/trial/web/app/gallery/g54.hwpx +0 -0
- package/trial/web/app/gallery/g55.hwpx +0 -0
- package/trial/web/app/gallery/g56.hwpx +0 -0
- package/trial/web/app/gallery/g57.hwpx +0 -0
- package/trial/web/app/gallery/g58.hwpx +0 -0
- package/trial/web/app/gallery/g59.hwpx +0 -0
- package/trial/web/app/gallery/g60.hwpx +0 -0
- package/trial/web/app/gallery/g61.hwpx +0 -0
- package/trial/web/app/gallery/g62.hwpx +0 -0
- package/trial/web/app/gallery/g63.hwpx +0 -0
- package/trial/web/app/gallery/g64.hwpx +0 -0
- package/trial/web/app/gallery/g65.hwpx +0 -0
- package/trial/web/app/gallery/g66.hwpx +0 -0
- package/trial/web/app/js/refdoc.js +1 -1
package/server/onwrite_gov.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! On 문서 내 PC 판 · on-munseo — 엔진·코드의 무단 복제·배포·재사용·역공학 금지(이용약관 제5조). 오픈소스 부품은 각 라이선스를 따름 */
|
|
2
|
-
import{GOV_ORGS as t}from"./onwrite_gov_orgs.js";export const GOV_FACES=["휴먼명조","HY헤드라인M","맑은 고딕","한양중고딕"];export const GF={body:2,head:3,note:4,table:4,caption:5};const e="#203A7B",s={size:{body:15,sq:15,ci:15,dash:15,dot:14,star:12,ref:12,table:11,caption:13,unit:10,chapter:17,sec:16,title:22,cover:28,sub:15},ls:160,indent:{"□":0,"○":3,"-":6.5,"·":9.5,"*":8,"※":3,"1.":0,"가.":3.5,"1)":7,"가)":10.5,"(1)":14,"(가)":17.5,"①":21},gap:{"□":10,"○":6,"-":3,"·":0,"*":0,"※":3,"1.":6,"가.":3,"1)":2,"가)":1,"(1)":0,"(가)":0,"①":0},chapter:{numFill:e,numColor:"#FFFFFF",line:e,newPage:!1},table:{headFill:"#F2F2F2",outer:"0.4 mm",inner:"0.12 mm",firstColBold:!0},margins:{top:15,bottom:10,left:20,right:20,header:10,footer:10},cover:!1,toc:!1,label:e},n={size:{dot:12,star:13},dotNote:{sp:-5,ra:100},fill:!0,secBox:!0,subHead:!0,circle:"○",circleScale:.8,margins:{top:10,bottom:10,left:15,right:15,header:8,footer:8},gap:{"□":6,"○":4,"-":2}},o=(t,e)=>{const s={...t};for(const[n,o]of Object.entries(e||{}))s[n]=o&&"object"==typeof o&&!Array.isArray(o)&&t[n]&&"object"==typeof t[n]?{...t[n],...o}:o;return s};export const GOV_STYLES={report:o(o(s,n),{name:"report",label:"보고서"}),plan:o(o(s,n),{name:"plan",label:"계획서",cover:!0,toc:!0}),result:o(o(s,n),{name:"result",label:"결과보고서",cover:!0,toc:!0}),press:o(s,{name:"press",label:"보도자료",tailNote:!0,table:{headFill:"#DFE6F7"},size:{dash:14,title:20}}),gongmun:o(s,{name:"gongmun",label:"기안문",size:{body:15,title:20},gap:{"1.":4,"가.":2}}),notice:o(s,{name:"notice",label:"공고문",size:{title:21},gap:{"1.":9,"가.":3}})};const i={"공고문":"notice","공고":"notice",notice:"notice","보고서":"report","계획서":"plan","사업계획서":"plan","결과보고서":"result","보도자료":"press","기안문":"gongmun","공문":"gongmun",report:"report",plan:"plan",result:"result",press:"press",gongmun:"gongmun",draft:"gongmun"},r={press:"press",notice:"notice"},c=t=>String(t??"").replace(/\s+/g,""),l=(e,s)=>{const n=t[r[e]];if(!n||!s)return null;const o=c(s),i=Object.keys(n).find((t=>c(t)===o));return i?{name:i,...n[i]}:null},p=new Map;export function govStyle(t,e){const s=i[String(t||"").trim()];if(!s)return null;const n=l(s,e);if(!n)return GOV_STYLES[s];const r=s+"|"+n.name;if(!p.has(r)){const{docs:t,name:e,...i}=n;p.set(r,o(GOV_STYLES[s],i))}return p.get(r)}export function govRule(t,e){const s=i[String(t||"").trim()];if(!s||!e)return null;const n=l(s,e);return n?{ministry:n.name,docs:n.docs,from:"우리 공개 문서 통계"}:{ministry:null,note:r[s]?`「${e}」는 통계가 부족해 공통 꼴로 만들었어요.`:"보고서·계획서·결과보고서·기안문은 기관별 통계가 아직 없어 공통 꼴로 만들었어요."}}const a=/\*\*[^*\n]+\*\*/;export function govForm(t,e){if(!i[String(e||"").trim()])return[];const s=String(t||"").replace(/\r\n?/g,"\n").split("\n");let n=!1,o=!1,r=0,c=0;for(let t=0;t<s.length;t++){const e=s[t];0!==t||"---"!==e.trim()?n?"---"===e.trim()&&(n=!1):/^\s*```/.test(e)?o=!o:o||(/^\s*[□■○ㅇ◦\-·]\s+/.test(e)&&r++,a.test(e)&&c++):n=!0}return r>=8&&!c?[{rule:"굵은 글 없음",hint:"핵심 수치·용어·기한·결론 문구는 **굵게** 써서 훑어 읽을 때 눈에 들어오게 하세요."}]:[]}export const govOrgList=e=>{const s=i[String(e||"").trim()],n=s&&t[r[s]];return n?Object.entries(n).map((([t,e])=>({org:t,docs:e.docs}))):[]};export const GOV_STYLE_LIST=Object.values(GOV_STYLES).map((t=>({id:t.name,label:t.label})));export function symKind(t){return t?"□■◇◆▶▷►▸➢➤☞".includes(t)?"□":"○●◎◦".includes(t)?"○":"-"===t||"–"===t?"-":"·ㆍ∙•".includes(t)?"·":"*"===t||"+"===t?"*":"※"===t?"※":/^\d+\.$/.test(t)?"1.":/^[가-하]\.$/.test(t)?"가.":/^\d+\)$/.test(t)?"1)":/^[가-하]\)$/.test(t)?"가)":/^\(\d+\)$/.test(t)?"(1)":/^\([가-하]\)$/.test(t)?"(가)":/^[①-⑳]$/.test(t)?"①":null:null}export const sqHeading=t=>{const e=String(t).replace(/\*\*/g,"").trim();return e.length<=30&&!/(다|요|함|음|임|됨|짐|있음|없음)\.?$/.test(e)&&!/[.。]$/.test(e)};export const sqLine=t=>{const e=String(t).replace(/\*\*/g,"").trim();return!(!sqHeading(e)&&(e.length>60||!/^[^::]{1,12}[::]/.test(e)||/(다|요|함|음|임|됨|짐|있음|없음)\.?$/.test(e)||/[^\d\s][.。]$/.test(e)||16===(t=>{const e=(t||"").charCodeAt(0)-44032;return e>=0&&e<11172?e%28:-1})(e.slice(-1))&&!/\d\s*\S$/.test(e)))};export const labelOf=t=>/^\(([^()]{1,10})\)\s*/.exec(String(t));export const isCaption=t=>/^\s*<\s*[^<>]{1,80}\s*>\s*$/.test(t)||/^\s*\[\s*(?:표|그림)\s*[\d-]*\s*\][^\n]{0,80}$/.test(t);export const isUnit=t=>/^\s*\(\s*단위\s*[::][^)]{1,40}\)\s*$/.test(t);export const isTotalRow=t=>/^\s*(합\s*계|총\s*계|소\s*계|계|합)\s*$/.test(String(t));export const ROMAN=["Ⅰ","Ⅱ","Ⅲ","Ⅳ","Ⅴ","Ⅵ","Ⅶ","Ⅷ","Ⅸ","Ⅹ","Ⅺ","Ⅻ"];const u=t=>String(t).replace(/\s+/g," ").trim().slice(0,60);function h(t){let e;return(e=/^[□■◆◇▣]\s*(.+)$/.exec(t))||(e=/^(?:\d{1,2}[.)]|[①-⑳])\s*(.+)$/.exec(t))?[0,e[1]]:(e=/^[○●◦◯]\s*(.+)$/.exec(t))||(e=/^[가-힣][.)]\s+(.+)$/.exec(t))?[1,e[1]]:(e=/^[-–—·•*※]\s*(.+)$/.exec(t))?[2,e[1]]:[null,t]}export function parseDiagram(t){let e=[],s="",n=null;for(const o of String(t||"").split(/\r?\n/)){const t=o.replace(/\t/g," "),i=t.trim();if(!i)continue;const r=/^(?:제목\s*[::]\s*(.+)|[【〈<]\s*([^】〉>]+?)\s*[】〉>])$/.exec(i);if(/^\[\s*[^\]]+?\s*\]$/.test(i))continue;if(r&&!s&&!e.length){s=u(r[1]||r[2]);continue}if(/\s(?:>|→|⇒|->)\s/.test(i)){const t=i.split(/\s+(?:>|→|⇒|->)\s+/).map(u).filter(Boolean);if(t.length>1&&!n&&!e.length){n=t;continue}}const c=h(i);e.push({ind:t.length-t.trimStart().length,lv:c[0],t:u(c[1])})}if(n&&!e.length)return{title:s,items:n.slice(0,8).map((t=>({t:t,kids:[]}))),chain:!0};const o=e.some((t=>t.ind>0)),i=t=>o?t.ind:null==t.lv?0:t.lv,r=[...new Set(e.map(i))].sort(((t,e)=>t-e)),c=[];let l=null,p=null;for(const t of e){const e=r.indexOf(i(t)),s={t:t.t,kids:[]};0!==e&&l?1!==e&&p?p.kids.length<8&&p.kids.push(s):l.kids.length<8&&(l.kids.push(s),p=s):c.length<8?(c.push(s),l=s,p=null):l=null}return{title:s,items:c}}export const diagramKind=t=>t.chain||t.items.every((t=>!t.kids.length))?"flow":1===t.items.length?"tree":"stack";export const isDiagramFence=t=>/^(체계도|모식도|추진체계|흐름도|diagram)(?=\s|$)/i.test(String(t||"").trim());export const diagramMode=(t,e)=>/(?:^|\s)(도형|shape)(?=\s|$)/i.test(String(t||""))?"shape":/(?:^|\s)(표|table)(?=\s|$)/i.test(String(t||""))?"table":e;export const NAVY_COLOR=e;export const numLike=t=>/^[△▲▽▼↑↓]?\s*[-+±]?\s*\d[\d,]*(?:\.\d+)?\s*(?:%p?|배|[가-힣]{1,3}|[a-zA-Z㎞㎡㎏]{1,3})?(?:\s*\([^()]{1,14}\))?$/.test(String(t).trim())||/^\(\s*[-+]?[\d,.]+\s*%?\s*\)$/.test(String(t).trim());export const dashLike=t=>/^[-–—-·]?$/.test(String(t).trim());export function pageLayout(t){const e=String(t||""),s=+((/<svg[^>]*\sheight="([\d.]+)"/.exec(e)||[])[1]||0),n=t=>t.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&"),o=[],i=new Map;for(const t of e.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/g))for(const e of t[1].matchAll(/\.([A-Za-z_][\w-]*)\s*\{[^}]*?font-size:\s*([\d.]+)/g))i.set(e[1],+e[2]);const r=t=>{const e=/font-size="([\d.]+)"/.exec(t);if(e)return+e[1];const s=i.size&&/\sclass="([^"]+)"/.exec(" "+t);return s&&i.get(s[1])||10};for(const t of e.matchAll(/<text\s([^>]*)>([^<]*)<\/text>/g)){const e=+(/\sy="([\d.-]+)"/.exec(" "+t[1])||[])[1],s=r(t[1]);if(Number.isFinite(e)){const i=+(/\sx="([\d.-]+)"/.exec(" "+t[1])||[])[1],r=n(t[2]);let c=0;for(const t of r)c+=t.codePointAt(0)>=4352||/[□○◦※·]/.test(t)?1:/\s|\d/.test(t)?.5:/[.,:;'!|()\[\]]/.test(t)?.3:.55;o.push({y:e,f:s,c:r,xe:Number.isFinite(i)?i+c*s:NaN})}}o.sort(((t,e)=>t.y-e.y));const c=[];let l=null;for(const t of o)l&&Math.abs(t.y-l.y)<=Math.max(1.5,.35*t.f)?(l.t+=t.c,!(t.xe>l.xe)&&l.xe>=0||(l.xe=t.xe)):(l={y:t.y,t:t.c,xe:t.xe,f:t.f},c.push(l));const p=[];for(const t of e.matchAll(/<image\s([^>]*)>/g)){const e=+((/\sy="([\d.-]+)"/.exec(" "+t[1])||[])[1]||0),s=+((/height="([\d.]+)"/.exec(t[1])||[])[1]||0);s>20&&p.push([e,s])}const a=/<clipPath id="body-clip[^"]*"><rect\b[^>]*\sy="([\d.]+)"[^>]*\sheight="([\d.]+)"/.exec(e),u=a?Math.round(10*(+a[1]+ +a[2]))/10:0,h=/<clipPath id="body-clip[^"]*"><rect\b[^>]*\sx="([\d.]+)"[^>]*\swidth="([\d.]+)"/.exec(e),m=h?Math.round(10*(+h[1]+ +h[2]))/10:0;return{t:o.map((t=>t.c)).join(""),H:s,B:u,Rx:m,lines:c.map((t=>[Math.round(10*t.y)/10,t.t,Number.isFinite(t.xe)?Math.round(10*t.xe)/10:null,t.f])),imgs:p}}export const NOT_IN_SOURCE="〔원문에 없는 숫자〕";const m=/^\[\s*(표|그래프|차트|체계도|모식도|추진\s*체계도?|흐름도|사례|참고)\s*([^\]]*)\]\s*(.*)$/,f=/^\s+(?=(?:[□■◆◇○●◦\-–·ㆍ*※▸◈]|\d{1,2}[.)]|[가-하][.)]|\(\d{1,2}\)|\([가-하]\)|[①-⑳])\s)/;export function composeToMarkdown(t,e={}){let s=String(t||"").replace(/\r\n?/g,"\n"),n=0;s=s.split("〔원문에 없는 숫자〕").map(((t,e,s)=>e<s.length-1?(n++,t.replace(/[ \t]+$/,"")):t)).join("");const o=s.split("\n"),i=[];let r=0,c=!1;if("---"===o[0]){const t=o.indexOf("---",1);t>0&&(i.push(...o.slice(0,t+1)),r=t+1)}const l=t=>t.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map((t=>t.trim())),p=t=>{const e=/\(\s*단위\s*[::]\s*([^)]+)\)/.exec(t);return e?e[1].trim():""},a=t=>{const e=Math.max(...t.map((t=>t.length))),s=t=>t.concat(new Array(e-t.length).fill("")).map((t=>t.replace(/\|/g,"/")));return["| "+s(t[0]).join(" | ")+" |","|"+new Array(e).fill("---").join("|")+"|",...t.slice(1).map((t=>"| "+s(t).join(" | ")+" |"))]},u=()=>{i.length&&""!==i[i.length-1]&&i.push("")};let h=!1;for(;r<o.length;r++){const t=o[r],e=t.trim();if(/^(```|~~~)/.test(e)){c=!c,i.push(t);continue}if(c){i.push(t);continue}let s;if(!h&&(s=/^제목\s*[::]\s*(.+)$/.exec(e))){i.push("# "+s[1].trim(),""),h=!0;continue}if(e&&(h=!0),s=m.exec(e)){const e=s[1].replace(/\s/g,""),n=s[2].trim(),c=s[3].trim(),h=c.replace(/\(\s*단위\s*[::][^)]*\)/,"").trim(),f=p(c)||p(n),d=[];let x=r+1;if("참고"!==e)for(;x<o.length;x++){const t=o[x].trim();if(!t||m.test(t)||/^[□■]\s/.test(t)||/^#{1,6}\s/.test(t))break;if(!("표"!==e&&"그래프"!==e&&"차트"!==e||(g=t,g.includes("|")&&l(g).length>=2)))break;d.push(t)}if(r=x-1,"표"===e){if(d.length<2){i.push(t,...d);continue}u(),h&&i.push(`< ${h} >`),f&&i.push(`(단위: ${f})`),u(),i.push(...a(d.map(l)),"");continue}if("그래프"===e||"차트"===e){const e=d.map(l);if(e.length<2){i.push(t,...d);continue}const s=/\(([^)]{1,12})\)\s*$/.exec(e[0][0]||""),o=f||(s?s[1]:""),r=/원|파이/.test(n)?"원":/꺾은선|선/.test(n)?"꺾은선":"막대";u(),i.push("```그래프 "+r+" "+(h||"그래프"),...o?[`(단위: ${o})`]:[],...a(e),"```","");continue}if("사례"===e){u(),i.push("> ### "+(h||"사례"));for(const t of d){const e=/^[▸▶►·-]\s*(.+)$/.exec(t);i.push(e?"> ○ "+e[1]:"> **"+t.replace(/\*\*/g,"")+"**")}i.push("");continue}if("참고"===e){u(),i.push("\x3c!-- 쪽나눔 --\x3e","","### 참고 "+(h||"")),i.push("");continue}const $=[];if(d.some((t=>/^[□■○●◦\-–·]\s/.test(t)||/\s(?:→|->|⇒)\s/.test(t))))$.push(...d);else{let t=!1;for(const e of d){if(/^\[[^\]]+\]$/.test(e))continue;const s=e.split(/\s+\|\s+|\s*|\s*/).map((t=>t.trim())).filter(Boolean),n=t=>{const e=/^(.+?)\s*[::]\s+(.+)$/.exec(t)||/^(.+?)\s+[::]\s*(.+)$/.exec(t);return e?[e[1].trim(),e[2].trim()]:[t,""]};if(1!==s.length&&t)for(const t of s){const[e,s]=n(t);$.push(" ○ "+e),s&&$.push(" - "+s)}else for(const e of(s.length,s)){const[o,i]=n(e);1===s.length?($.push("□ "+o),i&&$.push(" ○ "+i),t=!0):($.push("□ "+o),i&&$.push(" ○ "+i))}}}u(),i.push("```체계도 "+(h||"체계도"),...$,"```","");continue}if(s=/^【\s*([①-⑳].+?)\s*】$/.exec(e)){u(),i.push("#### "+s[1],"");continue}if(s=/^【\s*(.+?)\s*】$/.exec(e)){u(),i.push("### "+s[1],"");continue}if(/^[◆◈◇]\s/.test(e)){u(),i.push("> "+e,"");continue}if(s=/^([ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ])\s*[.)]\s*(.+)$/.exec(e)){u(),i.push("## "+s[1]+". "+s[2],"");continue}const n=t.replace(f,"");n!==t||/^(?:[□■○●◦※▸◈]|\d{1,2}[.)]|[가-하][.)])\s/.test(n.trim())?(u(),i.push(n.trim(),"")):i.push(t)}var g;let d=i.join("\n").replace(/\n{3,}/g,"\n\n");if(e.toc&&!/^##\s/m.test(d)){let t=!1;const e=d.split("\n"),s=e.map((e=>/^(```|~~~)/.test(e)?(t=!t,!1):!t&&/^□\s/.test(e)&&sqHeading(e.slice(1))));s.filter(Boolean).length>=2&&(d=e.map(((t,e)=>s[e]?"## "+t.slice(1).trim():t)).join("\n"))}return{text:d,unsourced:n}}export function templateFrame(t){const e=String(t||"").replace(/\r\n?/g,"\n").split("\n"),s=[];let n=0;if("---"===e[0]){const t=e.indexOf("---",1);t>0&&(n=t+1)}const o=t=>`〈${t}〉`,i=/^(현황|원인|격차|문제|문제점|개선|내용|일정|기간|지역|장소|일시|대상|방법|대상·방법|결과|계획|평가|보완|의견|목적|근거|예산|비용|성과|운영|문의|참석|기대\s?효과|추진\s?경과|향후\s?계획|조치|요청|협조|기한|제출|배경|필요성|주요\s?내용|검토|참고)$/,r=(t,e)=>{const s=/^(\([^()]{1,10}\)\s*)/.exec(t)||/^([^::]{1,14}[::]\s*)/.exec(t);let n=s?s[1]:"";const r=/^\(([^()]+)\)/.exec(n);return r&&!i.test(r[1].trim())&&(n="("+o("말머리")+") "),n+o(e)},c=t=>t.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map((t=>t.trim()));let l=null,p=null;for(;n<e.length;n++){const t=e[n].trim();if(!t){s.push("");continue}let i;if(/^#\s/.test(t))s.push("# "+o("문서 제목"));else if(i=/^(#{2,3})\s+(.+)$/.exec(t)){const t=i[2],e=/^((?:[ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ]|\d{1,2})\s*[.)]?)\s*(.*)$/.exec(t);s.push(i[1]+" "+("##"===i[1]?t:(e?e[1]+" ":"")+o("소제목")))}else if(i=/^```\s*(그래프|차트|체계도|모식도|추진체계|흐름도)\s*(\S*)\s*(.*)$/.exec(t)){const t=[];let r=n+1;for(;r<e.length&&!/^```/.test(e[r].trim());r++)t.push(e[r]);if(n=r,"그래프"===i[1]||"차트"===i[1]){const e=t.map((t=>/\(\s*단위\s*[::]\s*([^)]+)\)/.exec(t))).find(Boolean),n=t.filter((t=>t.includes("|")&&!/^[\s|:-]+$/.test(t))).map(c);s.push(`[그래프 ${i[2]||"막대"}] ${o("그래프 제목")}${e?` (단위: ${e[1].trim()})`:""}`,n[0]?n[0].join(" | "):"항목 | 값",n[0]?n[0].map(((t,e)=>o(e?"숫자":"항목"))).join(" | "):o("항목")+" | "+o("숫자"),"")}else if(t.some((t=>/\s(?:→|->|⇒)\s/.test(t)))){const e=Math.max(3,Math.min(6,(t.find((t=>/→|->|⇒/.test(t)))||"").split(/→|->|⇒/).length));s.push(`[체계도] ${o("체계도 제목")}`,Array.from({length:e},((t,e)=>o(`단계 ${e+1}`))).join(" → "),"")}else{s.push(`[체계도] ${o("체계도 제목")}`);for(const e of t){const t=/^(\s*)([□■○●◦\-–·])\s/.exec(e);t&&s.push(t[1]+t[2]+" "+o("□"===t[2]||"■"===t[2]?"맨 위 기관·단계":"○"===t[2]||"●"===t[2]?"기관·단계":"역할"))}s.push("")}}else if(isCaption(t))l=t;else if(isUnit(t))p=t;else if(/^\|/.test(t)){const t=[];let i=n;for(;i<e.length&&/^\|/.test(e[i].trim());i++)/^[\s|:-]+$/.test(e[i])||t.push(c(e[i]));n=i-1;const r=t[0]||[],a=t.slice(1).some((t=>t.some((t=>/^[■●▬]+$/.test(t))))),u=t.slice(1).find((t=>isTotalRow(t[0])));s.push(`[표] ${o("표 제목")}${p?" "+p.trim():""}`,r.join(" | "));const h=r.map(((t,e)=>e?a?e%2?"■":"":o("내용"):o(a?"과제":"구분")));s.push(h.join(" | "),h.join(" | ")),u&&s.push(r.map(((t,e)=>e?o("합"):u[0])).join(" | ")),s.push(""),l=null,p=null}else if(/^<\/?(table|tr|p)\b/i.test(t))s.push(t.replace(/<td([^>]*)>([^<]+)<\/td>/g,((t,e,s)=>/^[○□\s.·~()년월일총백만원국비지방비/]*$/.test(s)?t:`<td${e}>${o("내용")}</td>`)));else if(/^>/.test(t)){const e=t.replace(/^>\s*/,"");s.push(/^#{1,6}\s/.test(e)?"> ### "+o("상자 제목"):/^[○□\-]/.test(e)?"> "+e[0]+" "+o("핵심 목표·요약"):"> "+o("한 줄 요약"))}else if(/^⇨/.test(t))s.push("⇨ "+o("결론 한 줄"));else if(/^붙임\s/.test(t))s.push("붙임 1. "+o("붙임 문서")+" 1부.");else if(/^<!--/.test(t))s.push(t);else if(i=/^([□■○●◦\-–·*※]|\d{1,2}[.)]|[가-하][.)]|\(\d{1,2}\)|[①-⑳])\s+(.+)$/.exec(t)){const t=i[1],e=i[2].replace(/\*\*/g,""),n="□"===t?sqHeading(e)?"소제목":"핵심 문장":"○"===t?"내용(~함·~임)":"-"===t||"–"===t?"세부 내용":"*"===t?"출처·참고":"※"===t?"유의 사항":/^\d/.test(t)&&sqHeading(e)&&!/[::]/.test(e)?"항목 제목":"내용";s.push(t+" "+("□"===t&&sqHeading(e)?o(n):r(e,n)))}else/^\*\*.+\*\*/.test(t)?s.push(t):s.push(o("문단"))}return s.join("\n").replace(/\n{3,}/g,"\n\n").trim()+"\n"}
|
|
2
|
+
import{GOV_ORGS as t}from"./onwrite_gov_orgs.js";export const GOV_FACES=["휴먼명조","HY헤드라인M","맑은 고딕","한양중고딕"];export const GF={body:2,head:3,note:4,table:4,caption:5};const e="#203A7B",s={size:{body:15,sq:15,ci:15,dash:15,dot:14,star:12,ref:12,table:11,caption:13,unit:10,chapter:17,sec:16,title:22,cover:28,sub:15},ls:160,indent:{"□":0,"○":3,"-":6.5,"·":9.5,"*":8,"※":3,"1.":0,"가.":3.5,"1)":7,"가)":10.5,"(1)":14,"(가)":17.5,"①":21},gap:{"□":10,"○":6,"-":3,"·":0,"*":0,"※":3,"1.":6,"가.":3,"1)":2,"가)":1,"(1)":0,"(가)":0,"①":0},chapter:{numFill:e,numColor:"#FFFFFF",line:e,newPage:!1},table:{headFill:"#F2F2F2",outer:"0.4 mm",inner:"0.12 mm",firstColBold:!0},margins:{top:15,bottom:10,left:20,right:20,header:10,footer:10},cover:!1,toc:!1,label:e},n={size:{dot:12,star:13},dotNote:{sp:-5,ra:100},fill:!0,secBox:!0,subHead:!0,circle:"○",circleScale:.8,margins:{top:10,bottom:10,left:15,right:15,header:8,footer:8},gap:{"□":6,"○":4,"-":2}},o=(t,e)=>{const s={...t};for(const[n,o]of Object.entries(e||{}))s[n]=o&&"object"==typeof o&&!Array.isArray(o)&&t[n]&&"object"==typeof t[n]?{...t[n],...o}:o;return s};export const GOV_STYLES={report:o(o(s,n),{name:"report",label:"보고서"}),plan:o(o(s,n),{name:"plan",label:"계획서",cover:!0,toc:!0}),result:o(o(s,n),{name:"result",label:"결과보고서",cover:!0,toc:!0}),press:o(s,{name:"press",label:"보도자료",tailNote:!0,table:{headFill:"#DFE6F7"},size:{dash:14,title:20}}),gongmun:o(s,{name:"gongmun",label:"기안문",size:{body:15,title:20},gap:{"1.":4,"가.":2}}),notice:o(s,{name:"notice",label:"공고문",size:{title:21},gap:{"1.":9,"가.":3}})};const i={"공고문":"notice","공고":"notice",notice:"notice","보고서":"report","계획서":"plan","사업계획서":"plan","결과보고서":"result","보도자료":"press","기안문":"gongmun","공문":"gongmun",report:"report",plan:"plan",result:"result",press:"press",gongmun:"gongmun",draft:"gongmun"},r={press:"press",notice:"notice"},c=t=>String(t??"").replace(/\s+/g,""),l=(e,s)=>{const n=t[r[e]];if(!n||!s)return null;const o=c(s),i=Object.keys(n).find((t=>c(t)===o));return i?{name:i,...n[i]}:null},p=new Map;export function govStyle(t,e){const s=i[String(t||"").trim()];if(!s)return null;const n=l(s,e);if(!n)return GOV_STYLES[s];const r=s+"|"+n.name;if(!p.has(r)){const{docs:t,name:e,...i}=n;p.set(r,o(GOV_STYLES[s],i))}return p.get(r)}export function govRule(t,e){const s=i[String(t||"").trim()];if(!s||!e)return null;const n=l(s,e);return n?{ministry:n.name,docs:n.docs,from:"우리 공개 문서 통계"}:{ministry:null,note:r[s]?`「${e}」는 통계가 부족해 공통 꼴로 만들었어요.`:"보고서·계획서·결과보고서·기안문은 기관별 통계가 아직 없어 공통 꼴로 만들었어요."}}const a=/\*\*[^*\n]+\*\*/;export function govForm(t,e){if(!i[String(e||"").trim()])return[];const s=String(t||"").replace(/\r\n?/g,"\n").split("\n");let n=!1,o=!1,r=0,c=0;for(let t=0;t<s.length;t++){const e=s[t];0!==t||"---"!==e.trim()?n?"---"===e.trim()&&(n=!1):/^\s*```/.test(e)?o=!o:o||(/^\s*[□■○ㅇ◦\-·]\s+/.test(e)&&r++,a.test(e)&&c++):n=!0}return r>=8&&!c?[{rule:"굵은 글 없음",hint:"핵심 수치·용어·기한·결론 문구는 **굵게** 써서 훑어 읽을 때 눈에 들어오게 하세요."}]:[]}export const govOrgList=e=>{const s=i[String(e||"").trim()],n=s&&t[r[s]];return n?Object.entries(n).map((([t,e])=>({org:t,docs:e.docs}))):[]};export const GOV_STYLE_LIST=Object.values(GOV_STYLES).map((t=>({id:t.name,label:t.label})));export function symKind(t){return t?"□■◇◆▶▷►▸➢➤☞".includes(t)?"□":"○●◎◦".includes(t)?"○":"-"===t||"–"===t?"-":"·ㆍ∙•".includes(t)?"·":"*"===t||"+"===t?"*":"※"===t?"※":/^\d+\.$/.test(t)?"1.":/^[가-하]\.$/.test(t)?"가.":/^\d+\)$/.test(t)?"1)":/^[가-하]\)$/.test(t)?"가)":/^\(\d+\)$/.test(t)?"(1)":/^\([가-하]\)$/.test(t)?"(가)":/^[①-⑳]$/.test(t)?"①":null:null}export const sqHeading=t=>{const e=String(t).replace(/\*\*/g,"").trim();return e.length<=30&&!/(다|요|함|음|임|됨|짐|있음|없음)\.?$/.test(e)&&!/[.。]$/.test(e)};export const sqLine=t=>{const e=String(t).replace(/\*\*/g,"").trim();return!(!sqHeading(e)&&(e.length>60||!/^[^::]{1,12}[::]/.test(e)||/(다|요|함|음|임|됨|짐|있음|없음)\.?$/.test(e)||/[^\d\s][.。]$/.test(e)||16===(t=>{const e=(t||"").charCodeAt(0)-44032;return e>=0&&e<11172?e%28:-1})(e.slice(-1))&&!/\d\s*\S$/.test(e)))};export const labelOf=t=>/^\(([^()]{1,10})\)\s*/.exec(String(t));export const isCaption=t=>/^\s*<\s*[^<>]{1,80}\s*>\s*$/.test(t)||/^\s*\[\s*(?:표|그림)\s*[\d-]*\s*\][^\n]{0,80}$/.test(t);export const isUnit=t=>/^\s*\(\s*단위\s*[::][^)]{1,40}\)\s*$/.test(t);export const isTotalRow=t=>/^\s*(합\s*계|총\s*계|소\s*계|계|합)\s*$/.test(String(t));export const ROMAN=["Ⅰ","Ⅱ","Ⅲ","Ⅳ","Ⅴ","Ⅵ","Ⅶ","Ⅷ","Ⅸ","Ⅹ","Ⅺ","Ⅻ"];const u=t=>String(t).replace(/\s+/g," ").trim().slice(0,60);function h(t){let e;return(e=/^[□■◆◇▣]\s*(.+)$/.exec(t))||(e=/^(?:\d{1,2}[.)]|[①-⑳])\s*(.+)$/.exec(t))?[0,e[1]]:(e=/^[○●◦◯]\s*(.+)$/.exec(t))||(e=/^[가-힣][.)]\s+(.+)$/.exec(t))?[1,e[1]]:(e=/^[-–—·•*※]\s*(.+)$/.exec(t))?[2,e[1]]:[null,t]}export function parseDiagram(t){let e=[],s="",n=null;for(const o of String(t||"").split(/\r?\n/)){const t=o.replace(/\t/g," "),i=t.trim();if(!i)continue;const r=/^(?:제목\s*[::]\s*(.+)|[【〈<]\s*([^】〉>]+?)\s*[】〉>])$/.exec(i);if(/^\[\s*[^\]]+?\s*\]$/.test(i))continue;if(r&&!s&&!e.length){s=u(r[1]||r[2]);continue}if(/\s(?:>|→|⇒|->)\s/.test(i)){const t=i.split(/\s+(?:>|→|⇒|->)\s+/).map(u).filter(Boolean);if(t.length>1&&!n&&!e.length){n=t;continue}}const c=h(i);e.push({ind:t.length-t.trimStart().length,lv:c[0],t:u(c[1])})}if(n&&!e.length)return{title:s,items:n.slice(0,8).map((t=>({t:t,kids:[]}))),chain:!0};const o=e.some((t=>t.ind>0)),i=t=>o?t.ind:null==t.lv?0:t.lv,r=[...new Set(e.map(i))].sort(((t,e)=>t-e)),c=[];let l=null,p=null;for(const t of e){const e=r.indexOf(i(t)),s={t:t.t,kids:[]};0!==e&&l?1!==e&&p?p.kids.length<8&&p.kids.push(s):l.kids.length<8&&(l.kids.push(s),p=s):c.length<8?(c.push(s),l=s,p=null):l=null}return{title:s,items:c}}export const diagramKind=t=>t.chain||t.items.every((t=>!t.kids.length))?"flow":1===t.items.length?"tree":"stack";export const isDiagramFence=t=>/^(체계도|모식도|추진체계|흐름도|diagram)(?=\s|$)/i.test(String(t||"").trim());export const diagramMode=(t,e)=>/(?:^|\s)(도형|shape)(?=\s|$)/i.test(String(t||""))?"shape":/(?:^|\s)(표|table)(?=\s|$)/i.test(String(t||""))?"table":e;export const NAVY_COLOR=e;export const numLike=t=>/^[△▲▽▼↑↓]?\s*[-+±]?\s*\d[\d,]*(?:\.\d+)?\s*(?:%p?|배|[가-힣]{1,3}|[a-zA-Z㎞㎡㎏]{1,3})?(?:\s*\([^()]{1,14}\))?$/.test(String(t).trim())||/^\(\s*[-+]?[\d,.]+\s*%?\s*\)$/.test(String(t).trim());export const dashLike=t=>/^[-–—-·]?$/.test(String(t).trim());export function pageLayout(t){const e=String(t||""),s=+((/<svg[^>]*\sheight="([\d.]+)"/.exec(e)||[])[1]||0),n=t=>t.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&"),o=[],i=new Map;for(const t of e.matchAll(/<style\b[^>]*>([\s\S]*?)<\/style>/g))for(const e of t[1].matchAll(/\.([A-Za-z_][\w-]*)\s*\{[^}]*?font-size:\s*([\d.]+)/g))i.set(e[1],+e[2]);const r=t=>{const e=/font-size="([\d.]+)"/.exec(t);if(e)return+e[1];const s=i.size&&/\sclass="([^"]+)"/.exec(" "+t);return s&&i.get(s[1])||10};for(const t of e.matchAll(/<text\s([^>]*)>([^<]*)<\/text>/g)){const e=/\stransform="translate\(([\d.-]+)[ ,]+([\d.-]+)\)(?:\s*scale\(([\d.]+))?/.exec(" "+t[1]),s=e?+e[2]:+(/\sy="([\d.-]+)"/.exec(" "+t[1])||[])[1],i=r(t[1]);if(Number.isFinite(s)){const r=e?+e[1]:+(/\sx="([\d.-]+)"/.exec(" "+t[1])||[])[1],c=n(t[2]),l=e&&e[3]&&+e[3]||1;let p=0;for(const t of c)p+=t.codePointAt(0)>=4352||/[□○◦※·]/.test(t)?1:/\s|\d/.test(t)?.5:/[.,:;'!|()\[\]]/.test(t)?.3:.55;p*=l,o.push({y:s,f:i,c:c,xe:Number.isFinite(r)?r+p*i:NaN,x:r,w:p*i})}}o.sort(((t,e)=>t.y-e.y));const c=[];let l=null;for(const t of o)l&&Math.abs(t.y-l.y)<=Math.max(1.5,.35*t.f)?(l.t+=t.c,l.gl.push(t),!(t.xe>l.xe)&&l.xe>=0||(l.xe=t.xe),!(t.x<l.xs)&&l.xs>=0||(l.xs=t.x)):(l={y:t.y,t:t.c,xe:t.xe,f:t.f,xs:t.x,gl:[t]},c.push(l));for(const t of c){const e=t.gl.filter((t=>Number.isFinite(t.x))).sort(((t,e)=>t.x-e.x));let s=0,n=0;for(let o=1;o<e.length;o++){const i=(e[o].x-(e[o-1].x+e[o-1].w))/(e[o].f||t.f||10);i>.2&&(s+=i,n++)}t.gap=n?Math.round(s/n*1e3)/1e3:null}const p=[];for(const t of e.matchAll(/<image\s([^>]*)>/g)){const e=+((/\sy="([\d.-]+)"/.exec(" "+t[1])||[])[1]||0),s=+((/height="([\d.]+)"/.exec(t[1])||[])[1]||0);s>20&&p.push([e,s])}const a=/<clipPath id="body-clip[^"]*"><rect\b[^>]*\sy="([\d.]+)"[^>]*\sheight="([\d.]+)"/.exec(e),u=a?Math.round(10*(+a[1]+ +a[2]))/10:0,h=/<clipPath id="body-clip[^"]*"><rect\b[^>]*\sx="([\d.]+)"[^>]*\swidth="([\d.]+)"/.exec(e),f=h?Math.round(10*(+h[1]+ +h[2]))/10:0;return{t:o.map((t=>t.c)).join(""),H:s,B:u,Rx:f,lines:c.map((t=>[Math.round(10*t.y)/10,t.t,Number.isFinite(t.xe)?Math.round(10*t.xe)/10:null,t.f,Number.isFinite(t.xs)?Math.round(10*t.xs)/10:null,t.gap])),imgs:p}}export const NOT_IN_SOURCE="〔원문에 없는 숫자〕";const f=/^\[\s*(표|그래프|차트|체계도|모식도|추진\s*체계도?|흐름도|사례|참고)\s*([^\]]*)\]\s*(.*)$/,g=/^\s+(?=(?:[□■◆◇○●◦\-–·ㆍ*※▸◈]|\d{1,2}[.)]|[가-하][.)]|\(\d{1,2}\)|\([가-하]\)|[①-⑳])\s)/;export function composeToMarkdown(t,e={}){let s=String(t||"").replace(/\r\n?/g,"\n"),n=0;s=s.split("〔원문에 없는 숫자〕").map(((t,e,s)=>e<s.length-1?(n++,t.replace(/[ \t]+$/,"")):t)).join("");const o=s.split("\n"),i=[];let r=0,c=!1;if("---"===o[0]){const t=o.indexOf("---",1);t>0&&(i.push(...o.slice(0,t+1)),r=t+1)}const l=t=>t.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map((t=>t.trim())),p=t=>{const e=/\(\s*단위\s*[::]\s*([^)]+)\)/.exec(t);return e?e[1].trim():""},a=t=>{const e=Math.max(...t.map((t=>t.length))),s=t=>t.concat(new Array(e-t.length).fill("")).map((t=>t.replace(/\|/g,"/")));return["| "+s(t[0]).join(" | ")+" |","|"+new Array(e).fill("---").join("|")+"|",...t.slice(1).map((t=>"| "+s(t).join(" | ")+" |"))]},u=()=>{i.length&&""!==i[i.length-1]&&i.push("")};let h=!1;for(;r<o.length;r++){const t=o[r],e=t.trim();if(/^(```|~~~)/.test(e)){c=!c,i.push(t);continue}if(c){i.push(t);continue}let s;if(!h&&(s=/^제목\s*[::]\s*(.+)$/.exec(e))){i.push("# "+s[1].trim(),""),h=!0;continue}if(e&&(h=!0),s=f.exec(e)){const e=s[1].replace(/\s/g,""),n=s[2].trim(),c=s[3].trim(),h=c.replace(/\(\s*단위\s*[::][^)]*\)/,"").trim(),g=p(c)||p(n),d=[];let x=r+1;if("참고"!==e)for(;x<o.length;x++){const t=o[x].trim();if(!t||f.test(t)||/^[□■]\s/.test(t)||/^#{1,6}\s/.test(t))break;if(!("표"!==e&&"그래프"!==e&&"차트"!==e||(m=t,m.includes("|")&&l(m).length>=2)))break;d.push(t)}if(r=x-1,"표"===e){if(d.length<2){i.push(t,...d);continue}u(),h&&i.push(`< ${h} >`),g&&i.push(`(단위: ${g})`),u(),i.push(...a(d.map(l)),"");continue}if("그래프"===e||"차트"===e){const e=d.map(l);if(e.length<2){i.push(t,...d);continue}const s=/\(([^)]{1,12})\)\s*$/.exec(e[0][0]||""),o=g||(s?s[1]:""),r=/원|파이/.test(n)?"원":/꺾은선|선/.test(n)?"꺾은선":"막대";u(),i.push("```그래프 "+r+" "+(h||"그래프"),...o?[`(단위: ${o})`]:[],...a(e),"```","");continue}if("사례"===e){u(),i.push("> ### "+(h||"사례"));for(const t of d){const e=/^[▸▶►·-]\s*(.+)$/.exec(t);i.push(e?"> ○ "+e[1]:"> **"+t.replace(/\*\*/g,"")+"**")}i.push("");continue}if("참고"===e){u(),i.push("\x3c!-- 쪽나눔 --\x3e","","### 참고 "+(h||"")),i.push("");continue}const $=[];if(d.some((t=>/^[□■○●◦\-–·]\s/.test(t)||/\s(?:→|->|⇒)\s/.test(t))))$.push(...d);else{let t=!1;for(const e of d){if(/^\[[^\]]+\]$/.test(e))continue;const s=e.split(/\s+\|\s+|\s*|\s*/).map((t=>t.trim())).filter(Boolean),n=t=>{const e=/^(.+?)\s*[::]\s+(.+)$/.exec(t)||/^(.+?)\s+[::]\s*(.+)$/.exec(t);return e?[e[1].trim(),e[2].trim()]:[t,""]};if(1!==s.length&&t)for(const t of s){const[e,s]=n(t);$.push(" ○ "+e),s&&$.push(" - "+s)}else for(const e of(s.length,s)){const[o,i]=n(e);1===s.length?($.push("□ "+o),i&&$.push(" ○ "+i),t=!0):($.push("□ "+o),i&&$.push(" ○ "+i))}}}u(),i.push("```체계도 "+(h||"체계도"),...$,"```","");continue}if(s=/^【\s*([①-⑳].+?)\s*】$/.exec(e)){u(),i.push("#### "+s[1],"");continue}if(s=/^【\s*(.+?)\s*】$/.exec(e)){u(),i.push("### "+s[1],"");continue}if(/^[◆◈◇]\s/.test(e)){u(),i.push("> "+e,"");continue}if(s=/^([ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ])\s*[.)]\s*(.+)$/.exec(e)){u(),i.push("## "+s[1]+". "+s[2],"");continue}const n=t.replace(g,"");n!==t||/^(?:[□■○●◦※▸◈]|\d{1,2}[.)]|[가-하][.)])\s/.test(n.trim())?(u(),i.push(n.trim(),"")):i.push(t)}var m;let d=i.join("\n").replace(/\n{3,}/g,"\n\n");if(e.toc&&!/^##\s/m.test(d)){let t=!1;const e=d.split("\n"),s=e.map((e=>/^(```|~~~)/.test(e)?(t=!t,!1):!t&&/^□\s/.test(e)&&sqHeading(e.slice(1))));s.filter(Boolean).length>=2&&(d=e.map(((t,e)=>s[e]?"## "+t.slice(1).trim():t)).join("\n"))}return{text:d,unsourced:n}}export function templateFrame(t){const e=String(t||"").replace(/\r\n?/g,"\n").split("\n"),s=[];let n=0;if("---"===e[0]){const t=e.indexOf("---",1);t>0&&(n=t+1)}const o=t=>`〈${t}〉`,i=/^(현황|원인|격차|문제|문제점|개선|내용|일정|기간|지역|장소|일시|대상|방법|대상·방법|결과|계획|평가|보완|의견|목적|근거|예산|비용|성과|운영|문의|참석|기대\s?효과|추진\s?경과|향후\s?계획|조치|요청|협조|기한|제출|배경|필요성|주요\s?내용|검토|참고)$/,r=(t,e)=>{const s=/^(\([^()]{1,10}\)\s*)/.exec(t)||/^([^::]{1,14}[::]\s*)/.exec(t);let n=s?s[1]:"";const r=/^\(([^()]+)\)/.exec(n);return r&&!i.test(r[1].trim())&&(n="("+o("말머리")+") "),n+o(e)},c=t=>t.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map((t=>t.trim()));let l=null,p=null;for(;n<e.length;n++){const t=e[n].trim();if(!t){s.push("");continue}let i;if(/^#\s/.test(t))s.push("# "+o("문서 제목"));else if(i=/^(#{2,3})\s+(.+)$/.exec(t)){const t=i[2],e=/^((?:[ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ]|\d{1,2})\s*[.)]?)\s*(.*)$/.exec(t);s.push(i[1]+" "+("##"===i[1]?t:(e?e[1]+" ":"")+o("소제목")))}else if(i=/^```\s*(그래프|차트|체계도|모식도|추진체계|흐름도)\s*(\S*)\s*(.*)$/.exec(t)){const t=[];let r=n+1;for(;r<e.length&&!/^```/.test(e[r].trim());r++)t.push(e[r]);if(n=r,"그래프"===i[1]||"차트"===i[1]){const e=t.map((t=>/\(\s*단위\s*[::]\s*([^)]+)\)/.exec(t))).find(Boolean),n=t.filter((t=>t.includes("|")&&!/^[\s|:-]+$/.test(t))).map(c);s.push(`[그래프 ${i[2]||"막대"}] ${o("그래프 제목")}${e?` (단위: ${e[1].trim()})`:""}`,n[0]?n[0].join(" | "):"항목 | 값",n[0]?n[0].map(((t,e)=>o(e?"숫자":"항목"))).join(" | "):o("항목")+" | "+o("숫자"),"")}else if(t.some((t=>/\s(?:→|->|⇒)\s/.test(t)))){const e=Math.max(3,Math.min(6,(t.find((t=>/→|->|⇒/.test(t)))||"").split(/→|->|⇒/).length));s.push(`[체계도] ${o("체계도 제목")}`,Array.from({length:e},((t,e)=>o(`단계 ${e+1}`))).join(" → "),"")}else{s.push(`[체계도] ${o("체계도 제목")}`);for(const e of t){const t=/^(\s*)([□■○●◦\-–·])\s/.exec(e);t&&s.push(t[1]+t[2]+" "+o("□"===t[2]||"■"===t[2]?"맨 위 기관·단계":"○"===t[2]||"●"===t[2]?"기관·단계":"역할"))}s.push("")}}else if(isCaption(t))l=t;else if(isUnit(t))p=t;else if(/^\|/.test(t)){const t=[];let i=n;for(;i<e.length&&/^\|/.test(e[i].trim());i++)/^[\s|:-]+$/.test(e[i])||t.push(c(e[i]));n=i-1;const r=t[0]||[],a=t.slice(1).some((t=>t.some((t=>/^[■●▬]+$/.test(t))))),u=t.slice(1).find((t=>isTotalRow(t[0])));s.push(`[표] ${o("표 제목")}${p?" "+p.trim():""}`,r.join(" | "));const h=r.map(((t,e)=>e?a?e%2?"■":"":o("내용"):o(a?"과제":"구분")));s.push(h.join(" | "),h.join(" | ")),u&&s.push(r.map(((t,e)=>e?o("합"):u[0])).join(" | ")),s.push(""),l=null,p=null}else if(/^<\/?(table|tr|p)\b/i.test(t))s.push(t.replace(/<td([^>]*)>([^<]+)<\/td>/g,((t,e,s)=>/^[○□\s.·~()년월일총백만원국비지방비/]*$/.test(s)?t:`<td${e}>${o("내용")}</td>`)));else if(/^>/.test(t)){const e=t.replace(/^>\s*/,"");s.push(/^#{1,6}\s/.test(e)?"> ### "+o("상자 제목"):/^[○□\-]/.test(e)?"> "+e[0]+" "+o("핵심 목표·요약"):"> "+o("한 줄 요약"))}else if(/^⇨/.test(t))s.push("⇨ "+o("결론 한 줄"));else if(/^붙임\s/.test(t))s.push("붙임 1. "+o("붙임 문서")+" 1부.");else if(/^<!--/.test(t))s.push(t);else if(i=/^([□■○●◦\-–·*※]|\d{1,2}[.)]|[가-하][.)]|\(\d{1,2}\)|[①-⑳])\s+(.+)$/.exec(t)){const t=i[1],e=i[2].replace(/\*\*/g,""),n="□"===t?sqHeading(e)?"소제목":"핵심 문장":"○"===t?"내용(~함·~임)":"-"===t||"–"===t?"세부 내용":"*"===t?"출처·참고":"※"===t?"유의 사항":/^\d/.test(t)&&sqHeading(e)&&!/[::]/.test(e)?"항목 제목":"내용";s.push(t+" "+("□"===t&&sqHeading(e)?o(n):r(e,n)))}else/^\*\*.+\*\*/.test(t)?s.push(t):s.push(o("문단"))}return s.join("\n").replace(/\n{3,}/g,"\n\n").trim()+"\n"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! On 문서 내 PC 판 · on-munseo — 엔진·코드의 무단 복제·배포·재사용·역공학 금지(이용약관 제5조). 오픈소스 부품은 각 라이선스를 따름 */
|
|
2
|
-
import"../public/js/spellcheck.js";import{parseMarkdown as t,segsText as s}from"./onwrite.js";import{composeToMarkdown as n}from"./onwrite_gov.js";const
|
|
2
|
+
import"../public/js/spellcheck.js";import{parseMarkdown as t,segsText as s}from"./onwrite.js";import{composeToMarkdown as n}from"./onwrite_gov.js";const o=(t,s=60)=>(t=String(t).replace(/\s+/g," ").trim()).length>s?t.slice(0,s-1)+"…":t;export function textChecks(t,s){const n=String(t||"").replace(/\*\*/g,""),c=globalThis.EbSpell,e=[];if(!c)return e;const i={};for(const t of c.shiftHits(n,i))e.push({kind:"셈",at:o(t.m0,50),why:t.why,want:t.want});for(const t of c.calc([n],i))e.push({kind:"셈",at:o(n.slice(Math.max(0,t.off-30),t.off+t.len),50),why:t.why,want:t.to});const r=(i.셈||0)+(i.산출||0);return s&&r&&(s.셈=(s.셈||0)+r),e}export function numberChecks(c,{limit:e=20,stat:i=null}={}){let r,l=String(c||"");if(/^\s*\[(?:표|그래프)/m.test(l))try{l=n(l,{}).text}catch{}try{r=t(l).blocks}catch{return[]}const f=[],a=globalThis.EbSpell;let h=0,p="";for(const t of r){if(f.length>=e)break;if("tbl"===t.t){if(h++,i&&(i.표=(i.표||0)+1),!a||"function"!=typeof a.sums)continue;const n=t.tb.cells.map(((t,n)=>({cell:n,row:t.r,col:t.c,rs:t.rs,cs:t.cs,t:t.content.map((t=>t.tbl?"":s(t.segs))).join(" ").trim()})));let c=[];try{c=a.sums(n)||[]}catch{c=[]}const e=p||`${h}번째 표`;for(const t of c)f.push({kind:"표",at:o(`「${e}」 ${t.from}`,50),why:o(t.why,160),want:t.to||null});p="";continue}if("cap"===t.t){p=s(t.segs).replace(/^\s*[<〈]\s*|\s*[>〉]\s*$/g,"").trim();continue}const n="li"===t.t||"p"===t.t||"h"===t.t?t.src:"";if(!n)continue;const c=/^\s*[<〈]\s*(.+?)\s*[>〉]\s*$/.exec(String(n).split("\n")[0]);if(c&&!/[<>]/.test(c[1])){p=c[1];continue}const r=String(n).replace(/<[^>]{0,200}>/g,"");for(const t of r.split("\n"))f.push(...textChecks(t,i))}return f.slice(0,e)}
|
package/server/onwrite_review.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! On 문서 내 PC 판 · on-munseo — 엔진·코드의 무단 복제·배포·재사용·역공학 금지(이용약관 제5조). 오픈소스 부품은 각 라이선스를 따름 */
|
|
2
|
-
import{calc as e}from"./calcwork.js";const t=["맞춤법·띄어쓰기","날짜·요일","금액","목록 합계"],s={"보고서":"보고서","계획서":"계획서","결과보고서":"결과보고서","보도자료":"보도자료","기안문":"기안문","공고문":"공고문"},n=new Set(["보고서","계획서","결과보고서"]);export async function reviewMdWork(e){const s=await import("./onwrite_numcheck.js"),n=await import("../trial/server/checks.js"),l={},o=s.numberChecks(String(e??""),{stat:l});let r=[];try{const s=n.checkParas(n.parasOf(String(e??"")),{limit:20});for(const e of t)for(const t of s.items&&s.items[e]||[])r.push({kind:e,from:t.from,to:t.to,why:t.why})}catch{r=[]}return{numbers:o,stat:l,spell:r.slice(0,20)}}export async function reviewWritten(t,l,o,r={}){let
|
|
2
|
+
import{calc as e}from"./calcwork.js";const t=["맞춤법·띄어쓰기","날짜·요일","금액","목록 합계"],s={"보고서":"보고서","계획서":"계획서","결과보고서":"결과보고서","보도자료":"보도자료","기안문":"기안문","공고문":"공고문"},n=new Set(["보고서","계획서","결과보고서"]);export async function reviewMdWork(e){const s=await import("./onwrite_numcheck.js"),n=await import("../trial/server/checks.js"),l={},o=s.numberChecks(String(e??""),{stat:l});let r=[];try{const s=n.checkParas(n.parasOf(String(e??"")),{limit:20});for(const e of t)for(const t of s.items&&s.items[e]||[])r.push({kind:e,from:t.from,to:t.to,why:t.why})}catch{r=[]}return{numbers:o,stat:l,spell:r.slice(0,20)}}export async function reviewWritten(t,l,o,r={}){let i=null;try{i=await e("reviewMd",[t])}catch{i=null}const h=[],c=s[o]||"한글 문서",a=l&&l.pages;h.push(`${n.has(o)?"응급의료 기본계획(보건복지부) 꼴 ":""}${c}${a?` ${a}쪽`:""}으로 만들었어요.`);const p=[],d=r&&r.tidy;if(d&&d.total>0&&d.n){const e=[d.n.tilde?`물결표 띄어쓰기 ${d.n.tilde}곳`:"",d.n.colon?`쌍점 띄어쓰기 ${d.n.colon}곳`:"",d.n.date?`날짜 꼴 ${d.n.date}곳`:""].filter(Boolean).join("·");e&&p.push(`원고의 ${e}을 행정업무운영 편람대로 맞췄어요${d.examples&&d.examples[0]?`(「${String(d.examples[0]).slice(0,40)}」)`:""}`)}l&&l.condensed&&p.push(`끝 쪽에 ${l.condensed.lines}줄만 넘어가 문서 전체 줄 간격을 ${l.condensed.ls}%로 좁혀 ${l.condensed.from}쪽을 ${l.condensed.to}쪽으로 맞췄어요`);const u=l&&l.shortFix||{},$=Math.max(0,(l&&l.spaced||0)-(u.liftC||0)),f=Math.max(0,(l&&l.tight||0)-(u.liftT||0));if(($||f)&&p.push(`줄 끝이 빠듯하거나 마지막 줄에 몇 글자만 남던 문단은 그 문단만 ${[$?`낱말 사이 빈칸(${$}곳)`:"",f?`글자 사이(${f}곳)`:""].filter(Boolean).join("·")}을 조금 좁혀 맞췄어요`),l&&l.shortFix&&(l.shortFix.lifted||l.shortFix.pushed)){const e=l.shortFix,t=`${e.narrowed?"글자 사이·글자 폭을":"글자 사이를"} 조금 좁혀 윗줄로 올${e.pushed?"리거나":"렸어요"}(${e.lifted}곳${e.narrowed?`, 그 가운데 글자 폭 ${e.narrowed}곳`:""})`;p.push(`마지막 줄이 짧게 남던 문단 ${e.lifted+e.pushed}곳은 글은 그대로 두고 그 문단만 ${e.lifted?t:""}${e.lifted&&e.pushed?" ":""}${e.pushed?`글자 사이를 조금 넓혀 마지막 줄을 채웠어요(${e.pushed}곳)`:""}`)}l&&l.shrunk&&p.push("쪽 아래가 비지 않게 그래프를 남은 자리에 맞춰 줄였어요"),p.length&&h.push("저절로 맞춘 것: "+p.join(" · ")+".");const m=(e=>(String(e||"").match(/○○+/g)||[]).length)(t)+(r.placeholders&&r.placeholders.length||0);if(m&&h.push(`「○○」로 비워 둔 자리가 ${m}곳 있어요 — 보내기 전에 채워 주세요.`),i){const e=i.stat&&i.stat.표||0,t=i.stat&&i.stat.셈||0,s=i.numbers||[];if(s.length)h.push(`셈이 맞지 않아 보이는 곳이 ${s.length}곳 있어요(아래 수치 확인) — 문서는 고치지 않았으니 맞는 값을 확인해 주세요.`);else if(e||t){const s=[e?`표 ${e}개의 합계`:"",t?`글 속 비율·증감 셈 ${t}곳`:""].filter(Boolean).join("와 ");h.push(`${s}${/곳$/.test(s)?"을":"를"} 맞춰 봤고, 어긋난 곳은 없었어요.`)}i.spell&&i.spell.length&&h.push(`맞춤법·날짜·금액에서 확인할 곳이 ${i.spell.length}곳 있어요(아래 맞춤법 확인).`)}return h.push("한글에서 열어 보시고, 고칠 곳을 말씀해 주시거나 고친 파일을 올려 주세요."),{tell_user:h,...i&&i.numbers&&i.numbers.length?{number_check:i.numbers}:{},...i&&i.spell&&i.spell.length?{spell_check:i.spell}:{}}}
|