@seanmozeik/markdown-display 0.3.5 → 0.4.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/README.md +41 -20
- package/dist/abap-9xbv043v.js +2 -0
- package/dist/actionscript-3-ffr5ydrs.js +2 -0
- package/dist/ada-jk2gn0pn.js +2 -0
- package/dist/andromeeda-24gktw4d.js +2 -0
- package/dist/angular-html-xg28445y.js +2 -0
- package/dist/angular-ts-1xq6mw7g.js +2 -0
- package/dist/apache-4b3b0eyy.js +2 -0
- package/dist/apex-a3awgdsm.js +2 -0
- package/dist/apl-f630k1vx.js +2 -0
- package/dist/applescript-qreypzb3.js +2 -0
- package/dist/ara-a0ghw0xy.js +2 -0
- package/dist/asciidoc-17amrzcg.js +2 -0
- package/dist/asm-1ybpdpc6.js +2 -0
- package/dist/astro-2vzy1qg5.js +2 -0
- package/dist/aurora-x-pb2h8m75.js +2 -0
- package/dist/awk-4g14sdfr.js +2 -0
- package/dist/ayu-dark-a6e49das.js +2 -0
- package/dist/ayu-light-ac787hyf.js +2 -0
- package/dist/ayu-mirage-zjtmb0bg.js +2 -0
- package/dist/ballerina-fd1yzyy8.js +2 -0
- package/dist/banner-ng06wc8g.js +12 -0
- package/dist/bat-x024z34k.js +2 -0
- package/dist/beancount-4aa1ce0k.js +2 -0
- package/dist/berry-1157ed3y.js +2 -0
- package/dist/bibtex-s0jadepe.js +2 -0
- package/dist/bicep-gx08m1nz.js +2 -0
- package/dist/bird2-3g0vanh0.js +2 -0
- package/dist/blade-22gzdntq.js +2 -0
- package/dist/bsl-r8cmv6pz.js +2 -0
- package/dist/c-g33d1744.js +2 -0
- package/dist/c3-02s6n09a.js +2 -0
- package/dist/cadence-b5x3mzqg.js +2 -0
- package/dist/cairo-4v5k49bw.js +2 -0
- package/dist/catppuccin-frappe-zze8rp4c.js +2 -0
- package/dist/catppuccin-latte-ebmyxk6e.js +2 -0
- package/dist/catppuccin-macchiato-8m9avkeq.js +2 -0
- package/dist/catppuccin-mocha-caq0gmr7.js +2 -0
- package/dist/clarity-x08cc58e.js +2 -0
- package/dist/cli-0y1zeg7v.js +3 -0
- package/dist/cli-1hj5h9f9.js +3 -0
- package/dist/cli-2h1yfjdw.js +3 -0
- package/dist/cli-30n24kzz.js +3 -0
- package/dist/cli-3fzyv189.js +3 -0
- package/dist/cli-3wvgjq8z.js +3 -0
- package/dist/cli-3z230jhh.js +3 -0
- package/dist/cli-48yac15g.js +3 -0
- package/dist/cli-58p99hkc.js +3 -0
- package/dist/cli-5jp9npt1.js +3 -0
- package/dist/cli-5v8q61ce.js +3 -0
- package/dist/cli-6jzqb50s.js +3 -0
- package/dist/cli-79y9hz07.js +3 -0
- package/dist/cli-81dmk4ts.js +3 -0
- package/dist/cli-81w52zkt.js +3 -0
- package/dist/cli-8nneg522.js +3 -0
- package/dist/cli-8qe0pqv6.js +3 -0
- package/dist/cli-a8250sbe.js +3 -0
- package/dist/cli-ac5hc1dt.js +3 -0
- package/dist/cli-app-6kzbj8e4.js +411 -0
- package/dist/cli-ayvxq7qa.js +3 -0
- package/dist/cli-banpa4vr.js +7 -0
- package/dist/cli-bt5bw9b4.js +3 -0
- package/dist/cli-c0mb9wq6.js +3 -0
- package/dist/cli-dg73jpjs.js +3 -0
- package/dist/cli-e21h859y.js +3 -0
- package/dist/cli-g0wwxff6.js +3 -0
- package/dist/cli-gtjpq1mb.js +3 -0
- package/dist/cli-ha8pqpt8.js +3 -0
- package/dist/cli-hsvv3jzh.js +3 -0
- package/dist/cli-hxsnf2x8.js +3 -0
- package/dist/cli-jewjtf3e.js +3 -0
- package/dist/cli-jkvh6m6e.js +3 -0
- package/dist/cli-jqdxtesj.js +3 -0
- package/dist/cli-k2dtsfh9.js +3 -0
- package/dist/cli-m8zynty7.js +3 -0
- package/dist/cli-n5czz7gz.js +3 -0
- package/dist/cli-r2h3ee8w.js +3 -0
- package/dist/cli-rkqs0vcv.js +3 -0
- package/dist/cli-ss2qwkcc.js +3 -0
- package/dist/cli-tse5g5yz.js +3 -0
- package/dist/cli-v04mbmxe.js +3 -0
- package/dist/cli-v37wd532.js +3 -0
- package/dist/cli-vbncttvd.js +3 -0
- package/dist/cli-vt93z537.js +3 -0
- package/dist/cli-w37ddf7r.js +3 -0
- package/dist/cli-yjt0k8jp.js +3 -0
- package/dist/cli-yxfvsvk9.js +3 -0
- package/dist/clojure-vzmv55wf.js +2 -0
- package/dist/cmake-7y22bc67.js +2 -0
- package/dist/cobol-kdnhdmjz.js +2 -0
- package/dist/codeowners-x6m7bhdc.js +2 -0
- package/dist/codeql-6rz9fzqw.js +2 -0
- package/dist/coffee-hdfzr8ps.js +2 -0
- package/dist/common-lisp-zmr06g7n.js +2 -0
- package/dist/coq-r8j5c36h.js +2 -0
- package/dist/cpp-cnh8n6p9.js +2 -0
- package/dist/crystal-mrgdvpq4.js +2 -0
- package/dist/csharp-q48m96qr.js +2 -0
- package/dist/css-bd0hqx8d.js +2 -0
- package/dist/csv-4m85ky3s.js +2 -0
- package/dist/cue-tkch0b5s.js +2 -0
- package/dist/cypher-9v66whj2.js +2 -0
- package/dist/d-h7frep7v.js +2 -0
- package/dist/dark-plus-3mz49csr.js +2 -0
- package/dist/dart-0ts3fbr7.js +2 -0
- package/dist/dax-epx6f5sr.js +2 -0
- package/dist/desktop-ga56hzcd.js +2 -0
- package/dist/diff-nj0camxe.js +2 -0
- package/dist/docker-ck9z05s1.js +2 -0
- package/dist/dotenv-n24rx33c.js +2 -0
- package/dist/dracula-rt7zm8kp.js +2 -0
- package/dist/dracula-soft-ny1w766n.js +2 -0
- package/dist/dream-maker-5bdhk1xw.js +2 -0
- package/dist/edge-nes62z5q.js +2 -0
- package/dist/elixir-t2dacwg4.js +2 -0
- package/dist/elm-efkwc9kb.js +2 -0
- package/dist/emacs-lisp-aeyrqndc.js +2 -0
- package/dist/erb-1jnjam5w.js +2 -0
- package/dist/erlang-q2nxsk7t.js +2 -0
- package/dist/everforest-dark-q5afr5gg.js +2 -0
- package/dist/everforest-light-gwf12vcx.js +2 -0
- package/dist/fennel-qcrnckrq.js +2 -0
- package/dist/fish-fybdeyvp.js +2 -0
- package/dist/fluent-71z72985.js +2 -0
- package/dist/fortran-fixed-form-1gqb01bw.js +2 -0
- package/dist/fortran-free-form-kxkmegqs.js +2 -0
- package/dist/fsharp-cgvxcgsx.js +2 -0
- package/dist/gdresource-46k5gmzt.js +2 -0
- package/dist/gdscript-68kq1xvg.js +2 -0
- package/dist/gdshader-b3674jka.js +2 -0
- package/dist/genie-jyymh6js.js +2 -0
- package/dist/gherkin-7e2sjv5d.js +2 -0
- package/dist/git-commit-9wk0r5sb.js +2 -0
- package/dist/git-rebase-prhzk4j5.js +2 -0
- package/dist/github-dark-default-0vxh5df6.js +2 -0
- package/dist/github-dark-dimmed-mrkg0dkj.js +2 -0
- package/dist/github-dark-high-contrast-dfjvzvs1.js +2 -0
- package/dist/github-dark-vmmv282e.js +2 -0
- package/dist/github-light-79sz9hnx.js +2 -0
- package/dist/github-light-default-1jr038w7.js +2 -0
- package/dist/github-light-high-contrast-r2s26c8v.js +2 -0
- package/dist/gleam-0915n1m3.js +2 -0
- package/dist/glimmer-js-k7czmdfm.js +2 -0
- package/dist/glimmer-ts-194ejtg4.js +2 -0
- package/dist/glsl-dj78d5j4.js +2 -0
- package/dist/gn-1hvwh71v.js +2 -0
- package/dist/gnuplot-3hmy4dt7.js +2 -0
- package/dist/go-33wfsnyk.js +2 -0
- package/dist/graphql-0aac9yec.js +2 -0
- package/dist/groovy-ja0xcaxz.js +2 -0
- package/dist/gruvbox-dark-hard-5s80mtba.js +2 -0
- package/dist/gruvbox-dark-medium-n4khhzte.js +2 -0
- package/dist/gruvbox-dark-soft-e71n00ep.js +2 -0
- package/dist/gruvbox-light-hard-pbvye0e8.js +2 -0
- package/dist/gruvbox-light-medium-ta1n6jez.js +2 -0
- package/dist/gruvbox-light-soft-ymh9etvc.js +2 -0
- package/dist/hack-wbm9q4mm.js +2 -0
- package/dist/haml-gx26k3n5.js +2 -0
- package/dist/handlebars-x15bnv4j.js +2 -0
- package/dist/haskell-gphr2mx4.js +2 -0
- package/dist/haxe-jjqygeb7.js +2 -0
- package/dist/hcl-cr0bx0fz.js +2 -0
- package/dist/hjson-f1xxjn7x.js +2 -0
- package/dist/hlsl-dx0egzxe.js +2 -0
- package/dist/horizon-bright-4xdqr7cd.js +2 -0
- package/dist/horizon-ztsnzjdn.js +2 -0
- package/dist/houston-61g9eh8r.js +2 -0
- package/dist/html-derivative-hvxv75a7.js +2 -0
- package/dist/html-wqddzypw.js +2 -0
- package/dist/http-kh76rh1s.js +2 -0
- package/dist/hurl-4c8qps7w.js +2 -0
- package/dist/hxml-3bkn4jp8.js +2 -0
- package/dist/hy-fxpg7aaw.js +2 -0
- package/dist/imba-q8na79n7.js +2 -0
- package/dist/index-pdw64t43.js +15 -0
- package/dist/ini-s6y2n2r0.js +2 -0
- package/dist/java-bcf5924q.js +2 -0
- package/dist/javascript-qmy7d5mk.js +2 -0
- package/dist/jinja-y1162pxj.js +2 -0
- package/dist/jison-444dx63z.js +2 -0
- package/dist/json-gwwdj89t.js +2 -0
- package/dist/json5-3100ynmc.js +2 -0
- package/dist/jsonc-v2rnz0h1.js +2 -0
- package/dist/jsonl-axvqz7sn.js +2 -0
- package/dist/jsonnet-zfn0ptb5.js +2 -0
- package/dist/jssm-gej4xq4j.js +2 -0
- package/dist/jsx-zc0j90dq.js +2 -0
- package/dist/julia-as91r849.js +2 -0
- package/dist/just-zmsqbkqy.js +2 -0
- package/dist/kanagawa-dragon-d76szdr9.js +2 -0
- package/dist/kanagawa-lotus-wd9eezwr.js +2 -0
- package/dist/kanagawa-wave-acc5532t.js +2 -0
- package/dist/kdl-0nd9fhgr.js +2 -0
- package/dist/kotlin-v71xk1rn.js +2 -0
- package/dist/kusto-9mpsj4vk.js +2 -0
- package/dist/laserwave-db8954kv.js +2 -0
- package/dist/latex-xs0c2nvw.js +2 -0
- package/dist/lean-vdhz6cqv.js +2 -0
- package/dist/less-312pw0ev.js +2 -0
- package/dist/light-plus-aq99ra4y.js +2 -0
- package/dist/liquid-dmnzg3ty.js +2 -0
- package/dist/llvm-t6bzgxkv.js +2 -0
- package/dist/log-ssjyybt8.js +2 -0
- package/dist/logo-qb8mz41r.js +2 -0
- package/dist/lua-kk3ewrfz.js +2 -0
- package/dist/luau-1332gd7k.js +2 -0
- package/dist/make-ym3y5he3.js +2 -0
- package/dist/markdown-yakp348x.js +2 -0
- package/dist/marko-t2xabqrz.js +2 -0
- package/dist/material-theme-darker-vyfbvm1v.js +2 -0
- package/dist/material-theme-e94sgaj2.js +2 -0
- package/dist/material-theme-lighter-12stms50.js +2 -0
- package/dist/material-theme-ocean-vbjhpav2.js +2 -0
- package/dist/material-theme-palenight-zvsby2j7.js +2 -0
- package/dist/matlab-7z9bsz8e.js +2 -0
- package/dist/md.js +4 -0
- package/dist/mdc-fnzmnxrv.js +2 -0
- package/dist/mdx-txks2jee.js +2 -0
- package/dist/mermaid-2geg9v5h.js +2 -0
- package/dist/min-dark-p6btg8dq.js +2 -0
- package/dist/min-light-v3br1wzp.js +2 -0
- package/dist/mipsasm-npsfhz7p.js +2 -0
- package/dist/mojo-53s8q8kz.js +2 -0
- package/dist/monokai-j1kkm1ja.js +2 -0
- package/dist/moonbit-gcr903w0.js +2 -0
- package/dist/move-4vm43y7r.js +2 -0
- package/dist/narrat-4dfafp1n.js +2 -0
- package/dist/nextflow-gen0wthn.js +2 -0
- package/dist/nextflow-groovy-rntv4ct1.js +2 -0
- package/dist/nginx-md97v71f.js +2 -0
- package/dist/night-owl-bgdmn1df.js +2 -0
- package/dist/night-owl-light-jka34m0q.js +2 -0
- package/dist/nim-fngvzh2t.js +2 -0
- package/dist/nix-x4emth0n.js +2 -0
- package/dist/nord-xscwecj8.js +2 -0
- package/dist/nushell-tjxswzet.js +2 -0
- package/dist/objective-c-nk9a9yrs.js +2 -0
- package/dist/objective-cpp-p6sapemd.js +2 -0
- package/dist/ocaml-bcy7sgka.js +2 -0
- package/dist/odin-5vrv5d1s.js +2 -0
- package/dist/one-dark-pro-r96tb03e.js +2 -0
- package/dist/one-light-bfcdemmg.js +2 -0
- package/dist/openscad-w36wsg83.js +2 -0
- package/dist/pascal-zje13224.js +2 -0
- package/dist/perl-jb96y2dw.js +2 -0
- package/dist/php-66y7zdam.js +2 -0
- package/dist/pkl-j08f73a2.js +2 -0
- package/dist/plastic-d95k0yjm.js +2 -0
- package/dist/plsql-a5tqv6r5.js +2 -0
- package/dist/po-z4zztbvf.js +2 -0
- package/dist/poimandres-ft3p00vk.js +2 -0
- package/dist/polar-45ka4fdw.js +2 -0
- package/dist/postcss-ak75ftnf.js +2 -0
- package/dist/powerquery-j6z2e9xw.js +2 -0
- package/dist/powershell-ca63wk2e.js +2 -0
- package/dist/prisma-b2y4avdt.js +2 -0
- package/dist/prolog-wktkj1zv.js +2 -0
- package/dist/proto-5pd1z1zv.js +2 -0
- package/dist/pug-80k5jz6p.js +2 -0
- package/dist/puppet-66683nhq.js +2 -0
- package/dist/purescript-cmqqet79.js +2 -0
- package/dist/python-jabyzx3d.js +2 -0
- package/dist/qml-d92cbtkt.js +2 -0
- package/dist/qmldir-za85z5zc.js +2 -0
- package/dist/qss-gh7cf1zk.js +2 -0
- package/dist/r-s39xqqt9.js +2 -0
- package/dist/racket-gbjk3es0.js +2 -0
- package/dist/raku-zqwbnxmq.js +2 -0
- package/dist/razor-zg3bck80.js +2 -0
- package/dist/red-k6970d1d.js +2 -0
- package/dist/reg-gserh519.js +2 -0
- package/dist/regexp-a95pq17y.js +2 -0
- package/dist/rel-gaefrfhc.js +2 -0
- package/dist/riscv-cszphkwv.js +2 -0
- package/dist/ron-yf5x21c5.js +2 -0
- package/dist/rose-pine-1zbcjg1b.js +2 -0
- package/dist/rose-pine-dawn-tmsqdesr.js +2 -0
- package/dist/rose-pine-moon-cmwgg41b.js +2 -0
- package/dist/rosmsg-8j5zf8wv.js +2 -0
- package/dist/rst-7trgmfaq.js +2 -0
- package/dist/ruby-2svq4615.js +2 -0
- package/dist/rust-q5spk848.js +2 -0
- package/dist/sas-qhcyyrbt.js +2 -0
- package/dist/sass-qwyex0n3.js +2 -0
- package/dist/scala-jmhd870s.js +2 -0
- package/dist/scheme-5dvkrg0d.js +2 -0
- package/dist/scss-7v9m0m7d.js +2 -0
- package/dist/sdbl-93kewz9d.js +2 -0
- package/dist/shaderlab-97e0480d.js +2 -0
- package/dist/shellscript-6mxk36va.js +2 -0
- package/dist/shellsession-c7mva2xt.js +2 -0
- package/dist/slack-dark-y62znhvd.js +2 -0
- package/dist/slack-ochin-esm65n7t.js +2 -0
- package/dist/smalltalk-fkw0jz97.js +2 -0
- package/dist/snazzy-light-gdz5rv1k.js +2 -0
- package/dist/solarized-dark-zgcy8wm4.js +2 -0
- package/dist/solarized-light-66pg8xzk.js +2 -0
- package/dist/solidity-q5d4ht8n.js +2 -0
- package/dist/soy-hhhx5cj0.js +2 -0
- package/dist/sparql-hm2pqpge.js +2 -0
- package/dist/splunk-w5h843nw.js +2 -0
- package/dist/sql-pas3x5ke.js +2 -0
- package/dist/ssh-config-n2kt2cym.js +2 -0
- package/dist/stata-9j4p5d8c.js +2 -0
- package/dist/stylus-9s01c3kp.js +2 -0
- package/dist/surrealql-gxntasn8.js +2 -0
- package/dist/svelte-nvgnrg0t.js +2 -0
- package/dist/swift-j07yna4k.js +2 -0
- package/dist/synthwave-84-d7yw2bf0.js +2 -0
- package/dist/system-verilog-30bs377q.js +2 -0
- package/dist/systemd-4252hbv8.js +2 -0
- package/dist/talonscript-qbxwesm0.js +2 -0
- package/dist/tasl-m18yj07w.js +2 -0
- package/dist/tcl-qfvbg90f.js +2 -0
- package/dist/templ-msv3jzfx.js +2 -0
- package/dist/terraform-w6q6kyy0.js +2 -0
- package/dist/tex-1h8385qh.js +2 -0
- package/dist/tokyo-night-11kv01fx.js +2 -0
- package/dist/toml-02rkjp4b.js +2 -0
- package/dist/ts-tags-zmwja4z5.js +2 -0
- package/dist/tsv-t7svepav.js +2 -0
- package/dist/tsx-5ck84m8p.js +2 -0
- package/dist/turtle-synzazfp.js +2 -0
- package/dist/twig-41166c5j.js +2 -0
- package/dist/typescript-cqey3bjn.js +2 -0
- package/dist/typespec-ddd8ynv9.js +2 -0
- package/dist/typst-ex558216.js +2 -0
- package/dist/v-1bn5h0en.js +2 -0
- package/dist/vala-078a3s0x.js +2 -0
- package/dist/vb-5sq26hr3.js +2 -0
- package/dist/verilog-ekh48e1e.js +2 -0
- package/dist/vesper-j18bqpbg.js +2 -0
- package/dist/vhdl-fhjza3xz.js +2 -0
- package/dist/viml-9jfzgmge.js +2 -0
- package/dist/vitesse-black-3b8qwvte.js +2 -0
- package/dist/vitesse-dark-bsvtvg1h.js +2 -0
- package/dist/vitesse-light-egp8j39z.js +2 -0
- package/dist/vue-6yd2mg34.js +2 -0
- package/dist/vue-html-y5mtwexa.js +2 -0
- package/dist/vue-vine-732a4732.js +2 -0
- package/dist/vyper-h4fr87vt.js +2 -0
- package/dist/wasm-c0hbsbpk.js +2 -0
- package/dist/wasm-xe5dxyky.js +2 -0
- package/dist/wenyan-pf79c6ns.js +2 -0
- package/dist/wgsl-20v05k5y.js +2 -0
- package/dist/wikitext-6vf691aw.js +2 -0
- package/dist/wit-gp0gbqxw.js +2 -0
- package/dist/wolfram-y1r4y7zp.js +2 -0
- package/dist/xml-9fqvyqnc.js +2 -0
- package/dist/xsl-xpzpqrmc.js +2 -0
- package/dist/yaml-885sffq4.js +2 -0
- package/dist/zenscript-0k3ar154.js +2 -0
- package/dist/zig-h5gys7p5.js +2 -0
- package/package.json +51 -23
- package/src/app/cli-info.ts +90 -0
- package/src/app/errors.ts +19 -0
- package/src/app/file-not-found-error.ts +6 -0
- package/src/app/format-error.ts +35 -0
- package/src/app/invalid-theme-error.ts +6 -0
- package/src/app/pager-error.ts +5 -0
- package/src/app/run-md.ts +197 -0
- package/src/app/stdin-read-error.ts +5 -0
- package/src/cli/options.ts +20 -0
- package/src/cli-app.ts +113 -0
- package/src/cli.ts +64 -0
- package/src/config/errors.ts +6 -0
- package/src/config/index.ts +183 -0
- package/src/config/read-error.ts +6 -0
- package/src/constants.ts +2 -0
- package/src/index.ts +51 -0
- package/src/lib/ansi.ts +24 -0
- package/src/lib/config.ts +2 -0
- package/src/lib/default-config.toml +25 -0
- package/src/lib/elements/blockquote.ts +34 -0
- package/src/lib/elements/code.ts +326 -0
- package/src/lib/elements/heading.ts +39 -0
- package/src/lib/elements/link.ts +33 -0
- package/src/lib/elements/list.ts +89 -0
- package/src/lib/elements/table.ts +65 -0
- package/src/lib/elements/text.ts +237 -0
- package/src/lib/languages.ts +123 -0
- package/src/lib/layout.ts +67 -0
- package/src/lib/pager.ts +121 -0
- package/src/lib/parser.ts +299 -0
- package/src/lib/render-code-blocks.ts +25 -0
- package/src/lib/render.ts +37 -0
- package/src/lib/shiki.ts +197 -0
- package/src/lib/width.ts +21 -0
- package/src/paths.ts +14 -0
- package/src/ui/banner.ts +23 -0
- package/src/ui/picker.ts +120 -0
- package/src/ui/themes/ansi.ts +161 -0
- package/src/ui/themes/color-support.ts +106 -0
- package/src/ui/themes/generated.ts +748 -0
- package/src/ui/themes/index.ts +58 -0
- package/src/ui/themes/overrides.ts +83 -0
- package/src/ui/themes/semantic.ts +125 -0
- package/src/ui/themes/types.ts +67 -0
- package/dist/index.js +0 -194
package/src/cli.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
|
|
3
|
+
const hasArg = (name: string): boolean => process.argv.includes(name);
|
|
4
|
+
|
|
5
|
+
const wantsRaw = (): boolean => hasArg('--raw') || hasArg('-r');
|
|
6
|
+
|
|
7
|
+
const isFlagValue = (args: readonly string[], index: number): boolean => {
|
|
8
|
+
const previous = args[index - 1];
|
|
9
|
+
return previous === '--theme' || previous === '-t' || previous === '--width' || previous === '-w';
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const rawInputFiles = (): string[] =>
|
|
13
|
+
process.argv.slice(2).filter((arg, index, args) => {
|
|
14
|
+
if (arg === '--raw' || arg === '-r') {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
if (arg.startsWith('-')) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
return !isFlagValue(args, index);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const runRaw = async (): Promise<void> => {
|
|
24
|
+
const files = rawInputFiles();
|
|
25
|
+
const chunks: string[] = [];
|
|
26
|
+
|
|
27
|
+
if (files.length === 0) {
|
|
28
|
+
chunks.push(await Bun.stdin.text());
|
|
29
|
+
} else {
|
|
30
|
+
chunks.push(...(await Promise.all(files.map((path) => Bun.file(path).text()))));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
console.log(chunks.join('\n'));
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const runCli = async (): Promise<void> => {
|
|
37
|
+
if (wantsRaw()) {
|
|
38
|
+
await runRaw();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const { runCliApp } = await import('./cli-app');
|
|
43
|
+
runCliApp();
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const formatBootstrapError = (error: unknown): string => {
|
|
47
|
+
if (error instanceof Error) {
|
|
48
|
+
return error.message;
|
|
49
|
+
}
|
|
50
|
+
return String(error);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const isMain = (): boolean => {
|
|
54
|
+
return import.meta.filename === Bun.main;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
if (isMain()) {
|
|
58
|
+
await runCli().catch((error: unknown) => {
|
|
59
|
+
console.error(formatBootstrapError(error));
|
|
60
|
+
process.exitCode = 1;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { runCli };
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { Effect } from 'effect';
|
|
2
|
+
|
|
3
|
+
import defaultToml from '../lib/default-config.toml';
|
|
4
|
+
import { configTomlPath } from '../paths';
|
|
5
|
+
import { ConfigParseError } from './errors';
|
|
6
|
+
import { ConfigReadError } from './read-error';
|
|
7
|
+
|
|
8
|
+
interface MdConfig {
|
|
9
|
+
theme: string;
|
|
10
|
+
width: 'auto' | number;
|
|
11
|
+
truecolor: 'auto' | boolean;
|
|
12
|
+
nerd_fonts: 'auto' | boolean;
|
|
13
|
+
display: { padding: boolean; maxWidth: number };
|
|
14
|
+
code: { wrap: boolean; continuation: string };
|
|
15
|
+
text: { hyphenation: boolean; locale: string };
|
|
16
|
+
links: { osc8: 'auto' | boolean; show_urls: boolean };
|
|
17
|
+
pager: { command: string; args: string[] };
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const isPlainRecord = (value: unknown): value is Record<string, unknown> =>
|
|
21
|
+
typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
22
|
+
|
|
23
|
+
const baseConfigRecord = isPlainRecord(defaultToml) ? defaultToml : {};
|
|
24
|
+
|
|
25
|
+
const deepMerge = (
|
|
26
|
+
target: Record<string, unknown>,
|
|
27
|
+
source: Record<string, unknown>,
|
|
28
|
+
): Record<string, unknown> => {
|
|
29
|
+
const result = { ...target };
|
|
30
|
+
for (const key of Object.keys(source)) {
|
|
31
|
+
const sourceVal = source[key];
|
|
32
|
+
const targetVal = target[key];
|
|
33
|
+
if (isPlainRecord(sourceVal) && isPlainRecord(targetVal)) {
|
|
34
|
+
result[key] = deepMerge(targetVal, sourceVal);
|
|
35
|
+
} else if (sourceVal !== undefined) {
|
|
36
|
+
result[key] = sourceVal;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const parseTomlConfig = Effect.fn('config.parse-toml')(function* parseTomlConfigGen(
|
|
43
|
+
text: string,
|
|
44
|
+
path: string,
|
|
45
|
+
) {
|
|
46
|
+
const parsed = yield* Effect.try({
|
|
47
|
+
catch: (cause) => new ConfigParseError({ cause, path }),
|
|
48
|
+
try: () => Bun.TOML.parse(text),
|
|
49
|
+
});
|
|
50
|
+
if (!isPlainRecord(parsed)) {
|
|
51
|
+
return yield* new ConfigParseError({ cause: `${path} must be a TOML table`, path });
|
|
52
|
+
}
|
|
53
|
+
return parsed;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const readBoolean = (value: unknown, fallback: boolean): boolean =>
|
|
57
|
+
typeof value === 'boolean' ? value : fallback;
|
|
58
|
+
|
|
59
|
+
const readString = (value: unknown, fallback: string): string =>
|
|
60
|
+
typeof value === 'string' ? value : fallback;
|
|
61
|
+
|
|
62
|
+
const readWidth = (value: unknown, fallback: MdConfig['width']): MdConfig['width'] =>
|
|
63
|
+
value === 'auto' || typeof value === 'number' ? value : fallback;
|
|
64
|
+
|
|
65
|
+
const isTriState = (value: unknown): value is 'auto' | boolean =>
|
|
66
|
+
value === 'auto' || typeof value === 'boolean';
|
|
67
|
+
|
|
68
|
+
const readTriState = (value: unknown, fallback: 'auto' | boolean): 'auto' | boolean =>
|
|
69
|
+
isTriState(value) ? value : fallback;
|
|
70
|
+
|
|
71
|
+
const readNumber = (value: unknown, fallback: number): number =>
|
|
72
|
+
typeof value === 'number' ? value : fallback;
|
|
73
|
+
|
|
74
|
+
const readStringList = (value: unknown, fallback: string[]): string[] =>
|
|
75
|
+
Array.isArray(value)
|
|
76
|
+
? value.filter((entry): entry is string => typeof entry === 'string')
|
|
77
|
+
: fallback;
|
|
78
|
+
|
|
79
|
+
const recordField = (
|
|
80
|
+
merged: Record<string, unknown>,
|
|
81
|
+
base: Record<string, unknown>,
|
|
82
|
+
key: string,
|
|
83
|
+
): Record<string, unknown> => {
|
|
84
|
+
if (isPlainRecord(merged[key])) {
|
|
85
|
+
return merged[key];
|
|
86
|
+
}
|
|
87
|
+
if (isPlainRecord(base[key])) {
|
|
88
|
+
return base[key];
|
|
89
|
+
}
|
|
90
|
+
return {};
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const readMaxWidth = (merged: Record<string, unknown>, base: Record<string, unknown>): number => {
|
|
94
|
+
const mergedDisplay = recordField(merged, base, 'display');
|
|
95
|
+
const baseDisplay = isPlainRecord(base['display']) ? base['display'] : {};
|
|
96
|
+
return readNumber(mergedDisplay['maxWidth'], readNumber(baseDisplay['maxWidth'], 0));
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const buildMdConfig = (merged: Record<string, unknown>): MdConfig => {
|
|
100
|
+
const base = baseConfigRecord;
|
|
101
|
+
const mergedCode = recordField(merged, base, 'code');
|
|
102
|
+
const baseCode = recordField(base, base, 'code');
|
|
103
|
+
const mergedDisplay = recordField(merged, base, 'display');
|
|
104
|
+
const baseDisplay = recordField(base, base, 'display');
|
|
105
|
+
const mergedLinks = recordField(merged, base, 'links');
|
|
106
|
+
const baseLinks = recordField(base, base, 'links');
|
|
107
|
+
const mergedPager = recordField(merged, base, 'pager');
|
|
108
|
+
const basePager = recordField(base, base, 'pager');
|
|
109
|
+
const mergedText = recordField(merged, base, 'text');
|
|
110
|
+
const baseText = recordField(base, base, 'text');
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
code: {
|
|
114
|
+
continuation: readString(
|
|
115
|
+
mergedCode['continuation'],
|
|
116
|
+
readString(baseCode['continuation'], '→'),
|
|
117
|
+
),
|
|
118
|
+
wrap: readBoolean(mergedCode['wrap'], readBoolean(baseCode['wrap'], true)),
|
|
119
|
+
},
|
|
120
|
+
display: {
|
|
121
|
+
maxWidth: readMaxWidth(merged, base),
|
|
122
|
+
padding: readBoolean(mergedDisplay['padding'], readBoolean(baseDisplay['padding'], true)),
|
|
123
|
+
},
|
|
124
|
+
links: {
|
|
125
|
+
osc8: readTriState(mergedLinks['osc8'], readTriState(baseLinks['osc8'], 'auto')),
|
|
126
|
+
show_urls: readBoolean(mergedLinks['show_urls'], readBoolean(baseLinks['show_urls'], false)),
|
|
127
|
+
},
|
|
128
|
+
nerd_fonts: readTriState(merged['nerd_fonts'], readTriState(base['nerd_fonts'], 'auto')),
|
|
129
|
+
pager: {
|
|
130
|
+
args: readStringList(mergedPager['args'], readStringList(basePager['args'], [])),
|
|
131
|
+
command: readString(mergedPager['command'], readString(basePager['command'], 'less')),
|
|
132
|
+
},
|
|
133
|
+
text: {
|
|
134
|
+
hyphenation: readBoolean(
|
|
135
|
+
mergedText['hyphenation'],
|
|
136
|
+
readBoolean(baseText['hyphenation'], true),
|
|
137
|
+
),
|
|
138
|
+
locale: readString(mergedText['locale'], readString(baseText['locale'], 'en-us')),
|
|
139
|
+
},
|
|
140
|
+
theme: readString(merged['theme'], readString(base['theme'], 'catppuccin-frappe')),
|
|
141
|
+
truecolor: readTriState(merged['truecolor'], readTriState(base['truecolor'], 'auto')),
|
|
142
|
+
width: readWidth(merged['width'], readWidth(base['width'], 'auto')),
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const normalizeConfig = (raw: Record<string, unknown>): MdConfig =>
|
|
147
|
+
buildMdConfig(deepMerge(baseConfigRecord, raw));
|
|
148
|
+
|
|
149
|
+
const DEFAULT_CONFIG: MdConfig = normalizeConfig({});
|
|
150
|
+
|
|
151
|
+
const loadConfigFile = Effect.fn('config.load-file')(function* loadConfigFileGen(
|
|
152
|
+
configPath: string,
|
|
153
|
+
) {
|
|
154
|
+
const file = Bun.file(configPath);
|
|
155
|
+
const exists = yield* Effect.tryPromise({
|
|
156
|
+
catch: (cause) => new ConfigReadError({ cause, path: configPath }),
|
|
157
|
+
try: () => file.exists(),
|
|
158
|
+
});
|
|
159
|
+
if (!exists) {
|
|
160
|
+
return DEFAULT_CONFIG;
|
|
161
|
+
}
|
|
162
|
+
const text = yield* Effect.tryPromise({
|
|
163
|
+
catch: (cause) => new ConfigReadError({ cause, path: configPath }),
|
|
164
|
+
try: () => file.text(),
|
|
165
|
+
});
|
|
166
|
+
const parsed = yield* parseTomlConfig(text, configPath);
|
|
167
|
+
return normalizeConfig(parsed);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Loads `~/.config/md/config.toml` when present; otherwise defaults.
|
|
172
|
+
*/
|
|
173
|
+
const loadUserConfig = Effect.fn('config.load')(function* loadUserConfig() {
|
|
174
|
+
const path = configTomlPath();
|
|
175
|
+
const config = yield* loadConfigFile(path);
|
|
176
|
+
yield* Effect.annotateCurrentSpan({ path });
|
|
177
|
+
return config;
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
export type { MdConfig };
|
|
181
|
+
export type { ConfigParseError } from './errors';
|
|
182
|
+
export type { ConfigReadError } from './read-error';
|
|
183
|
+
export { DEFAULT_CONFIG, loadConfigFile, loadUserConfig };
|
package/src/constants.ts
ADDED
package/src/index.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { Effect } from 'effect';
|
|
2
|
+
|
|
3
|
+
import { DEFAULT_CONFIG } from './config';
|
|
4
|
+
import type { MarkdownParseError } from './lib/parser';
|
|
5
|
+
import { render } from './lib/render';
|
|
6
|
+
|
|
7
|
+
export { CONFIG_DIR_NAME } from './constants';
|
|
8
|
+
export { configRoot, configTomlPath, expandHome } from './paths';
|
|
9
|
+
export {
|
|
10
|
+
DEFAULT_CONFIG,
|
|
11
|
+
loadConfigFile,
|
|
12
|
+
loadUserConfig,
|
|
13
|
+
type MdConfig,
|
|
14
|
+
type ConfigParseError,
|
|
15
|
+
type ConfigReadError,
|
|
16
|
+
} from './config';
|
|
17
|
+
export type {
|
|
18
|
+
MdAppError,
|
|
19
|
+
FileNotFoundError,
|
|
20
|
+
InvalidThemeError,
|
|
21
|
+
StdinReadError,
|
|
22
|
+
} from './app/errors';
|
|
23
|
+
export { formatMdAppError, isMdAppError } from './app/format-error';
|
|
24
|
+
export { showHelp, showVersion } from './app/cli-info';
|
|
25
|
+
export { runMd, type MdCliOptions } from './app/run-md';
|
|
26
|
+
export { app, program, runnableProgram, runtimeLayer } from './cli-app';
|
|
27
|
+
export { render } from './lib/render';
|
|
28
|
+
export {
|
|
29
|
+
CODE_BLOCK_HIGHLIGHT_CONCURRENCY,
|
|
30
|
+
renderCodeBlocksParallel,
|
|
31
|
+
type CodeBlockRef,
|
|
32
|
+
} from './lib/render-code-blocks';
|
|
33
|
+
export { clearHighlightCache, highlightCode, stripItalicAnsi } from './lib/shiki';
|
|
34
|
+
export type { Config } from './lib/config';
|
|
35
|
+
export type { MarkdownParseError } from './lib/parser';
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Convenience function to render markdown with default configuration.
|
|
39
|
+
* For advanced usage, use the Effect-based `render()` function with custom config.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* import { renderMarkdown } from '@seanmozeik/markdown-display';
|
|
44
|
+
* import { Effect } from 'effect';
|
|
45
|
+
*
|
|
46
|
+
* const program = renderMarkdown('# Hello World');
|
|
47
|
+
* Effect.runSync(program);
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export const renderMarkdown = (markdown: string): Effect.Effect<string, MarkdownParseError> =>
|
|
51
|
+
render(markdown, DEFAULT_CONFIG);
|
package/src/lib/ansi.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Src/lib/ansi.ts
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ANSI / invisible character handling for terminal width and stripping.
|
|
5
|
+
* Broader escape patterns adapted from claudewatch/src/render/measure.ts.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const ESC = '\u001B';
|
|
9
|
+
const BEL = '\u0007';
|
|
10
|
+
const ANSI_PATTERN = new RegExp(
|
|
11
|
+
`${ESC}\\[[0-9;]*m|${ESC}\\].*?${BEL}|${ESC}\\[[\\d;]*[A-Za-z]`,
|
|
12
|
+
'gu',
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const ZERO_WIDTH_PATTERN = /[\u0300-\u036F\u200B\u200C\uFEFF\u202A-\u202E]|\u200D/gu;
|
|
16
|
+
|
|
17
|
+
const SOFT_HYPHEN_REGEX = /\u00AD/gu;
|
|
18
|
+
|
|
19
|
+
export const stripAnsi = (str: string): string => str.replace(ANSI_PATTERN, '');
|
|
20
|
+
|
|
21
|
+
export const stripInvisible = (str: string): string =>
|
|
22
|
+
stripAnsi(str).replace(SOFT_HYPHEN_REGEX, '').replace(ZERO_WIDTH_PATTERN, '');
|
|
23
|
+
|
|
24
|
+
export const visibleLength = (str: string): number => Bun.stringWidth(stripInvisible(str));
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# src/lib/default-config.toml
|
|
2
|
+
theme = "frappe"
|
|
3
|
+
width = "auto"
|
|
4
|
+
truecolor = "auto" # "auto" | true | false
|
|
5
|
+
nerd_fonts = "auto" # "auto" | true | false
|
|
6
|
+
|
|
7
|
+
[display]
|
|
8
|
+
padding = true # responsive padding based on terminal width
|
|
9
|
+
maxWidth = 0 # 0 = full width, 80-120 = constrain & center
|
|
10
|
+
|
|
11
|
+
[code]
|
|
12
|
+
wrap = true
|
|
13
|
+
continuation = "→"
|
|
14
|
+
|
|
15
|
+
[text]
|
|
16
|
+
hyphenation = true
|
|
17
|
+
locale = "en-us"
|
|
18
|
+
|
|
19
|
+
[links]
|
|
20
|
+
osc8 = "auto"
|
|
21
|
+
show_urls = false
|
|
22
|
+
|
|
23
|
+
[pager]
|
|
24
|
+
command = ""
|
|
25
|
+
args = ["-r", "-F", "-K", "-X"]
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Src/lib/elements/blockquote.ts
|
|
2
|
+
import { getMutedColor, getSubtleColor } from '../../ui/themes/semantic';
|
|
3
|
+
import { wrapText } from './text';
|
|
4
|
+
|
|
5
|
+
interface BlockquoteConfig {
|
|
6
|
+
width: number;
|
|
7
|
+
hyphenation?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const NEWLINE_NOT_DOUBLE = /\n(?!\n)/gu;
|
|
11
|
+
const COLLAPSE_SPACES = / +/gu;
|
|
12
|
+
|
|
13
|
+
export const renderBlockquote = (text: string, config?: BlockquoteConfig, depth = 1): string => {
|
|
14
|
+
const prefixRaw = '│ '.repeat(depth);
|
|
15
|
+
const prefix = getSubtleColor()(prefixRaw);
|
|
16
|
+
const prefixWidth = prefixRaw.length;
|
|
17
|
+
const innerWidth =
|
|
18
|
+
config?.width !== undefined && config.width > 0 ? config.width - prefixWidth : 0;
|
|
19
|
+
|
|
20
|
+
const content =
|
|
21
|
+
innerWidth > 0
|
|
22
|
+
? wrapText(
|
|
23
|
+
text.replaceAll(NEWLINE_NOT_DOUBLE, ' ').replaceAll(COLLAPSE_SPACES, ' '),
|
|
24
|
+
innerWidth,
|
|
25
|
+
{ hyphenation: config?.hyphenation ?? true, locale: 'en-us' },
|
|
26
|
+
)
|
|
27
|
+
: text;
|
|
28
|
+
|
|
29
|
+
const mutedColor = getMutedColor();
|
|
30
|
+
return content
|
|
31
|
+
.split('\n')
|
|
32
|
+
.map((line) => `${prefix}${mutedColor(line)}`)
|
|
33
|
+
.join('\n');
|
|
34
|
+
};
|