markdown.go 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941
  1. package styles
  2. import (
  3. "github.com/charmbracelet/glamour/ansi"
  4. "github.com/charmbracelet/lipgloss"
  5. )
  6. const defaultMargin = 1
  7. // Helper functions for style pointers
  8. func boolPtr(b bool) *bool { return &b }
  9. func stringPtr(s string) *string { return &s }
  10. func uintPtr(u uint) *uint { return &u }
  11. // CatppuccinMarkdownStyle is the Catppuccin Mocha style for Glamour markdown rendering.
  12. func CatppuccinMarkdownStyle() ansi.StyleConfig {
  13. isDark := lipgloss.HasDarkBackground()
  14. if isDark {
  15. return catppuccinDark
  16. }
  17. return catppuccinLight
  18. }
  19. var catppuccinDark = ansi.StyleConfig{
  20. Document: ansi.StyleBlock{
  21. StylePrimitive: ansi.StylePrimitive{
  22. BlockPrefix: "\n",
  23. BlockSuffix: "",
  24. Color: stringPtr(dark.Text().Hex),
  25. },
  26. Margin: uintPtr(defaultMargin),
  27. },
  28. BlockQuote: ansi.StyleBlock{
  29. StylePrimitive: ansi.StylePrimitive{
  30. Color: stringPtr(dark.Yellow().Hex),
  31. Italic: boolPtr(true),
  32. Prefix: "┃ ",
  33. },
  34. Indent: uintPtr(1),
  35. IndentToken: stringPtr(BaseStyle.Render(" ")),
  36. },
  37. List: ansi.StyleList{
  38. LevelIndent: defaultMargin,
  39. StyleBlock: ansi.StyleBlock{
  40. IndentToken: stringPtr(BaseStyle.Render(" ")),
  41. StylePrimitive: ansi.StylePrimitive{
  42. Color: stringPtr(dark.Text().Hex),
  43. },
  44. },
  45. },
  46. Heading: ansi.StyleBlock{
  47. StylePrimitive: ansi.StylePrimitive{
  48. BlockSuffix: "\n",
  49. Color: stringPtr(dark.Mauve().Hex),
  50. Bold: boolPtr(true),
  51. },
  52. },
  53. H1: ansi.StyleBlock{
  54. StylePrimitive: ansi.StylePrimitive{
  55. Prefix: "# ",
  56. Color: stringPtr(dark.Lavender().Hex),
  57. Bold: boolPtr(true),
  58. BlockPrefix: "\n",
  59. },
  60. },
  61. H2: ansi.StyleBlock{
  62. StylePrimitive: ansi.StylePrimitive{
  63. Prefix: "## ",
  64. Color: stringPtr(dark.Mauve().Hex),
  65. Bold: boolPtr(true),
  66. },
  67. },
  68. H3: ansi.StyleBlock{
  69. StylePrimitive: ansi.StylePrimitive{
  70. Prefix: "### ",
  71. Color: stringPtr(dark.Pink().Hex),
  72. Bold: boolPtr(true),
  73. },
  74. },
  75. H4: ansi.StyleBlock{
  76. StylePrimitive: ansi.StylePrimitive{
  77. Prefix: "#### ",
  78. Color: stringPtr(dark.Flamingo().Hex),
  79. Bold: boolPtr(true),
  80. },
  81. },
  82. H5: ansi.StyleBlock{
  83. StylePrimitive: ansi.StylePrimitive{
  84. Prefix: "##### ",
  85. Color: stringPtr(dark.Rosewater().Hex),
  86. Bold: boolPtr(true),
  87. },
  88. },
  89. H6: ansi.StyleBlock{
  90. StylePrimitive: ansi.StylePrimitive{
  91. Prefix: "###### ",
  92. Color: stringPtr(dark.Rosewater().Hex),
  93. Bold: boolPtr(true),
  94. },
  95. },
  96. Strikethrough: ansi.StylePrimitive{
  97. CrossedOut: boolPtr(true),
  98. Color: stringPtr(dark.Overlay1().Hex),
  99. },
  100. Emph: ansi.StylePrimitive{
  101. Color: stringPtr(dark.Yellow().Hex),
  102. Italic: boolPtr(true),
  103. },
  104. Strong: ansi.StylePrimitive{
  105. Bold: boolPtr(true),
  106. Color: stringPtr(dark.Peach().Hex),
  107. },
  108. HorizontalRule: ansi.StylePrimitive{
  109. Color: stringPtr(dark.Overlay0().Hex),
  110. Format: "\n─────────────────────────────────────────\n",
  111. },
  112. Item: ansi.StylePrimitive{
  113. BlockPrefix: "• ",
  114. Color: stringPtr(dark.Blue().Hex),
  115. },
  116. Enumeration: ansi.StylePrimitive{
  117. BlockPrefix: ". ",
  118. Color: stringPtr(dark.Sky().Hex),
  119. },
  120. Task: ansi.StyleTask{
  121. StylePrimitive: ansi.StylePrimitive{},
  122. Ticked: "[✓] ",
  123. Unticked: "[ ] ",
  124. },
  125. Link: ansi.StylePrimitive{
  126. Color: stringPtr(dark.Sky().Hex),
  127. Underline: boolPtr(true),
  128. },
  129. LinkText: ansi.StylePrimitive{
  130. Color: stringPtr(dark.Pink().Hex),
  131. Bold: boolPtr(true),
  132. },
  133. Image: ansi.StylePrimitive{
  134. Color: stringPtr(dark.Sapphire().Hex),
  135. Underline: boolPtr(true),
  136. Format: "🖼 {{.text}}",
  137. },
  138. ImageText: ansi.StylePrimitive{
  139. Color: stringPtr(dark.Pink().Hex),
  140. Format: "{{.text}}",
  141. },
  142. Code: ansi.StyleBlock{
  143. StylePrimitive: ansi.StylePrimitive{
  144. Color: stringPtr(dark.Green().Hex),
  145. Prefix: "",
  146. Suffix: "",
  147. },
  148. },
  149. CodeBlock: ansi.StyleCodeBlock{
  150. StyleBlock: ansi.StyleBlock{
  151. StylePrimitive: ansi.StylePrimitive{
  152. Prefix: " ",
  153. Color: stringPtr(dark.Text().Hex),
  154. },
  155. Margin: uintPtr(defaultMargin),
  156. },
  157. Chroma: &ansi.Chroma{
  158. Text: ansi.StylePrimitive{
  159. Color: stringPtr(dark.Text().Hex),
  160. },
  161. Error: ansi.StylePrimitive{
  162. Color: stringPtr(dark.Text().Hex),
  163. },
  164. Comment: ansi.StylePrimitive{
  165. Color: stringPtr(dark.Overlay1().Hex),
  166. },
  167. CommentPreproc: ansi.StylePrimitive{
  168. Color: stringPtr(dark.Pink().Hex),
  169. },
  170. Keyword: ansi.StylePrimitive{
  171. Color: stringPtr(dark.Pink().Hex),
  172. },
  173. KeywordReserved: ansi.StylePrimitive{
  174. Color: stringPtr(dark.Pink().Hex),
  175. },
  176. KeywordNamespace: ansi.StylePrimitive{
  177. Color: stringPtr(dark.Pink().Hex),
  178. },
  179. KeywordType: ansi.StylePrimitive{
  180. Color: stringPtr(dark.Sky().Hex),
  181. },
  182. Operator: ansi.StylePrimitive{
  183. Color: stringPtr(dark.Pink().Hex),
  184. },
  185. Punctuation: ansi.StylePrimitive{
  186. Color: stringPtr(dark.Text().Hex),
  187. },
  188. Name: ansi.StylePrimitive{
  189. Color: stringPtr(dark.Sky().Hex),
  190. },
  191. NameBuiltin: ansi.StylePrimitive{
  192. Color: stringPtr(dark.Sky().Hex),
  193. },
  194. NameTag: ansi.StylePrimitive{
  195. Color: stringPtr(dark.Pink().Hex),
  196. },
  197. NameAttribute: ansi.StylePrimitive{
  198. Color: stringPtr(dark.Green().Hex),
  199. },
  200. NameClass: ansi.StylePrimitive{
  201. Color: stringPtr(dark.Sky().Hex),
  202. },
  203. NameConstant: ansi.StylePrimitive{
  204. Color: stringPtr(dark.Mauve().Hex),
  205. },
  206. NameDecorator: ansi.StylePrimitive{
  207. Color: stringPtr(dark.Green().Hex),
  208. },
  209. NameFunction: ansi.StylePrimitive{
  210. Color: stringPtr(dark.Green().Hex),
  211. },
  212. LiteralNumber: ansi.StylePrimitive{
  213. Color: stringPtr(dark.Teal().Hex),
  214. },
  215. LiteralString: ansi.StylePrimitive{
  216. Color: stringPtr(dark.Yellow().Hex),
  217. },
  218. LiteralStringEscape: ansi.StylePrimitive{
  219. Color: stringPtr(dark.Pink().Hex),
  220. },
  221. GenericDeleted: ansi.StylePrimitive{
  222. Color: stringPtr(dark.Red().Hex),
  223. },
  224. GenericEmph: ansi.StylePrimitive{
  225. Color: stringPtr(dark.Yellow().Hex),
  226. Italic: boolPtr(true),
  227. },
  228. GenericInserted: ansi.StylePrimitive{
  229. Color: stringPtr(dark.Green().Hex),
  230. },
  231. GenericStrong: ansi.StylePrimitive{
  232. Color: stringPtr(dark.Peach().Hex),
  233. Bold: boolPtr(true),
  234. },
  235. GenericSubheading: ansi.StylePrimitive{
  236. Color: stringPtr(dark.Mauve().Hex),
  237. },
  238. },
  239. },
  240. Table: ansi.StyleTable{
  241. StyleBlock: ansi.StyleBlock{
  242. StylePrimitive: ansi.StylePrimitive{
  243. BlockPrefix: "\n",
  244. BlockSuffix: "\n",
  245. },
  246. },
  247. CenterSeparator: stringPtr("┼"),
  248. ColumnSeparator: stringPtr("│"),
  249. RowSeparator: stringPtr("─"),
  250. },
  251. DefinitionDescription: ansi.StylePrimitive{
  252. BlockPrefix: "\n ❯ ",
  253. Color: stringPtr(dark.Sapphire().Hex),
  254. },
  255. }
  256. var catppuccinLight = ansi.StyleConfig{
  257. Document: ansi.StyleBlock{
  258. StylePrimitive: ansi.StylePrimitive{
  259. BlockPrefix: "\n",
  260. BlockSuffix: "\n",
  261. Color: stringPtr(light.Text().Hex),
  262. },
  263. Margin: uintPtr(defaultMargin),
  264. },
  265. BlockQuote: ansi.StyleBlock{
  266. StylePrimitive: ansi.StylePrimitive{
  267. Color: stringPtr(light.Yellow().Hex),
  268. Italic: boolPtr(true),
  269. Prefix: "┃ ",
  270. },
  271. Indent: uintPtr(1),
  272. Margin: uintPtr(defaultMargin),
  273. },
  274. List: ansi.StyleList{
  275. LevelIndent: defaultMargin,
  276. StyleBlock: ansi.StyleBlock{
  277. StylePrimitive: ansi.StylePrimitive{
  278. Color: stringPtr(light.Text().Hex),
  279. },
  280. },
  281. },
  282. Heading: ansi.StyleBlock{
  283. StylePrimitive: ansi.StylePrimitive{
  284. BlockSuffix: "\n",
  285. Color: stringPtr(light.Mauve().Hex),
  286. Bold: boolPtr(true),
  287. },
  288. },
  289. H1: ansi.StyleBlock{
  290. StylePrimitive: ansi.StylePrimitive{
  291. Prefix: "# ",
  292. Color: stringPtr(light.Lavender().Hex),
  293. Bold: boolPtr(true),
  294. BlockPrefix: "\n",
  295. },
  296. },
  297. H2: ansi.StyleBlock{
  298. StylePrimitive: ansi.StylePrimitive{
  299. Prefix: "## ",
  300. Color: stringPtr(light.Mauve().Hex),
  301. Bold: boolPtr(true),
  302. },
  303. },
  304. H3: ansi.StyleBlock{
  305. StylePrimitive: ansi.StylePrimitive{
  306. Prefix: "### ",
  307. Color: stringPtr(light.Pink().Hex),
  308. Bold: boolPtr(true),
  309. },
  310. },
  311. H4: ansi.StyleBlock{
  312. StylePrimitive: ansi.StylePrimitive{
  313. Prefix: "#### ",
  314. Color: stringPtr(light.Flamingo().Hex),
  315. Bold: boolPtr(true),
  316. },
  317. },
  318. H5: ansi.StyleBlock{
  319. StylePrimitive: ansi.StylePrimitive{
  320. Prefix: "##### ",
  321. Color: stringPtr(light.Rosewater().Hex),
  322. Bold: boolPtr(true),
  323. },
  324. },
  325. H6: ansi.StyleBlock{
  326. StylePrimitive: ansi.StylePrimitive{
  327. Prefix: "###### ",
  328. Color: stringPtr(light.Rosewater().Hex),
  329. Bold: boolPtr(true),
  330. },
  331. },
  332. Strikethrough: ansi.StylePrimitive{
  333. CrossedOut: boolPtr(true),
  334. Color: stringPtr(light.Overlay1().Hex),
  335. },
  336. Emph: ansi.StylePrimitive{
  337. Color: stringPtr(light.Yellow().Hex),
  338. Italic: boolPtr(true),
  339. },
  340. Strong: ansi.StylePrimitive{
  341. Bold: boolPtr(true),
  342. Color: stringPtr(light.Peach().Hex),
  343. },
  344. HorizontalRule: ansi.StylePrimitive{
  345. Color: stringPtr(light.Overlay0().Hex),
  346. Format: "\n─────────────────────────────────────────\n",
  347. },
  348. Item: ansi.StylePrimitive{
  349. BlockPrefix: "• ",
  350. Color: stringPtr(light.Blue().Hex),
  351. },
  352. Enumeration: ansi.StylePrimitive{
  353. BlockPrefix: ". ",
  354. Color: stringPtr(light.Sky().Hex),
  355. },
  356. Task: ansi.StyleTask{
  357. StylePrimitive: ansi.StylePrimitive{},
  358. Ticked: "[✓] ",
  359. Unticked: "[ ] ",
  360. },
  361. Link: ansi.StylePrimitive{
  362. Color: stringPtr(light.Sky().Hex),
  363. Underline: boolPtr(true),
  364. },
  365. LinkText: ansi.StylePrimitive{
  366. Color: stringPtr(light.Pink().Hex),
  367. Bold: boolPtr(true),
  368. },
  369. Image: ansi.StylePrimitive{
  370. Color: stringPtr(light.Sapphire().Hex),
  371. Underline: boolPtr(true),
  372. Format: "🖼 {{.text}}",
  373. },
  374. ImageText: ansi.StylePrimitive{
  375. Color: stringPtr(light.Pink().Hex),
  376. Format: "{{.text}}",
  377. },
  378. Code: ansi.StyleBlock{
  379. StylePrimitive: ansi.StylePrimitive{
  380. Color: stringPtr(light.Green().Hex),
  381. Prefix: " ",
  382. Suffix: " ",
  383. },
  384. },
  385. CodeBlock: ansi.StyleCodeBlock{
  386. StyleBlock: ansi.StyleBlock{
  387. StylePrimitive: ansi.StylePrimitive{
  388. Prefix: " ",
  389. Color: stringPtr(light.Text().Hex),
  390. },
  391. Margin: uintPtr(defaultMargin),
  392. },
  393. Chroma: &ansi.Chroma{
  394. Text: ansi.StylePrimitive{
  395. Color: stringPtr(light.Text().Hex),
  396. },
  397. Error: ansi.StylePrimitive{
  398. Color: stringPtr(light.Text().Hex),
  399. },
  400. Comment: ansi.StylePrimitive{
  401. Color: stringPtr(light.Overlay1().Hex),
  402. },
  403. CommentPreproc: ansi.StylePrimitive{
  404. Color: stringPtr(light.Pink().Hex),
  405. },
  406. Keyword: ansi.StylePrimitive{
  407. Color: stringPtr(light.Pink().Hex),
  408. },
  409. KeywordReserved: ansi.StylePrimitive{
  410. Color: stringPtr(light.Pink().Hex),
  411. },
  412. KeywordNamespace: ansi.StylePrimitive{
  413. Color: stringPtr(light.Pink().Hex),
  414. },
  415. KeywordType: ansi.StylePrimitive{
  416. Color: stringPtr(light.Sky().Hex),
  417. },
  418. Operator: ansi.StylePrimitive{
  419. Color: stringPtr(light.Pink().Hex),
  420. },
  421. Punctuation: ansi.StylePrimitive{
  422. Color: stringPtr(light.Text().Hex),
  423. },
  424. Name: ansi.StylePrimitive{
  425. Color: stringPtr(light.Sky().Hex),
  426. },
  427. NameBuiltin: ansi.StylePrimitive{
  428. Color: stringPtr(light.Sky().Hex),
  429. },
  430. NameTag: ansi.StylePrimitive{
  431. Color: stringPtr(light.Pink().Hex),
  432. },
  433. NameAttribute: ansi.StylePrimitive{
  434. Color: stringPtr(light.Green().Hex),
  435. },
  436. NameClass: ansi.StylePrimitive{
  437. Color: stringPtr(light.Sky().Hex),
  438. },
  439. NameConstant: ansi.StylePrimitive{
  440. Color: stringPtr(light.Mauve().Hex),
  441. },
  442. NameDecorator: ansi.StylePrimitive{
  443. Color: stringPtr(light.Green().Hex),
  444. },
  445. NameFunction: ansi.StylePrimitive{
  446. Color: stringPtr(light.Green().Hex),
  447. },
  448. LiteralNumber: ansi.StylePrimitive{
  449. Color: stringPtr(light.Teal().Hex),
  450. },
  451. LiteralString: ansi.StylePrimitive{
  452. Color: stringPtr(light.Yellow().Hex),
  453. },
  454. LiteralStringEscape: ansi.StylePrimitive{
  455. Color: stringPtr(light.Pink().Hex),
  456. },
  457. GenericDeleted: ansi.StylePrimitive{
  458. Color: stringPtr(light.Red().Hex),
  459. },
  460. GenericEmph: ansi.StylePrimitive{
  461. Color: stringPtr(light.Yellow().Hex),
  462. Italic: boolPtr(true),
  463. },
  464. GenericInserted: ansi.StylePrimitive{
  465. Color: stringPtr(light.Green().Hex),
  466. },
  467. GenericStrong: ansi.StylePrimitive{
  468. Color: stringPtr(light.Peach().Hex),
  469. Bold: boolPtr(true),
  470. },
  471. GenericSubheading: ansi.StylePrimitive{
  472. Color: stringPtr(light.Mauve().Hex),
  473. },
  474. },
  475. },
  476. Table: ansi.StyleTable{
  477. StyleBlock: ansi.StyleBlock{
  478. StylePrimitive: ansi.StylePrimitive{
  479. BlockPrefix: "\n",
  480. BlockSuffix: "\n",
  481. },
  482. },
  483. CenterSeparator: stringPtr("┼"),
  484. ColumnSeparator: stringPtr("│"),
  485. RowSeparator: stringPtr("─"),
  486. },
  487. DefinitionDescription: ansi.StylePrimitive{
  488. BlockPrefix: "\n ❯ ",
  489. Color: stringPtr(light.Sapphire().Hex),
  490. },
  491. }
  492. func MarkdownTheme(focused bool) ansi.StyleConfig {
  493. if !focused {
  494. return ASCIIStyleConfig
  495. } else {
  496. return DraculaStyleConfig
  497. }
  498. }
  499. const (
  500. defaultListIndent = 2
  501. defaultListLevelIndent = 4
  502. )
  503. var ASCIIStyleConfig = ansi.StyleConfig{
  504. Document: ansi.StyleBlock{
  505. StylePrimitive: ansi.StylePrimitive{
  506. BackgroundColor: stringPtr(Background.Dark),
  507. Color: stringPtr(ForgroundDim.Dark),
  508. },
  509. Indent: uintPtr(1),
  510. IndentToken: stringPtr(BaseStyle.Render(" ")),
  511. },
  512. BlockQuote: ansi.StyleBlock{
  513. StylePrimitive: ansi.StylePrimitive{
  514. BackgroundColor: stringPtr(Background.Dark),
  515. },
  516. Indent: uintPtr(1),
  517. IndentToken: stringPtr("| "),
  518. },
  519. Paragraph: ansi.StyleBlock{
  520. StylePrimitive: ansi.StylePrimitive{
  521. BackgroundColor: stringPtr(Background.Dark),
  522. },
  523. },
  524. List: ansi.StyleList{
  525. StyleBlock: ansi.StyleBlock{
  526. IndentToken: stringPtr(BaseStyle.Render(" ")),
  527. StylePrimitive: ansi.StylePrimitive{
  528. BackgroundColor: stringPtr(Background.Dark),
  529. },
  530. },
  531. LevelIndent: defaultListLevelIndent,
  532. },
  533. Heading: ansi.StyleBlock{
  534. StylePrimitive: ansi.StylePrimitive{
  535. BackgroundColor: stringPtr(Background.Dark),
  536. BlockSuffix: "\n",
  537. },
  538. },
  539. H1: ansi.StyleBlock{
  540. StylePrimitive: ansi.StylePrimitive{
  541. BackgroundColor: stringPtr(Background.Dark),
  542. Prefix: "# ",
  543. },
  544. },
  545. H2: ansi.StyleBlock{
  546. StylePrimitive: ansi.StylePrimitive{
  547. BackgroundColor: stringPtr(Background.Dark),
  548. Prefix: "## ",
  549. },
  550. },
  551. H3: ansi.StyleBlock{
  552. StylePrimitive: ansi.StylePrimitive{
  553. BackgroundColor: stringPtr(Background.Dark),
  554. Prefix: "### ",
  555. },
  556. },
  557. H4: ansi.StyleBlock{
  558. StylePrimitive: ansi.StylePrimitive{
  559. BackgroundColor: stringPtr(Background.Dark),
  560. Prefix: "#### ",
  561. },
  562. },
  563. H5: ansi.StyleBlock{
  564. StylePrimitive: ansi.StylePrimitive{
  565. BackgroundColor: stringPtr(Background.Dark),
  566. Prefix: "##### ",
  567. },
  568. },
  569. H6: ansi.StyleBlock{
  570. StylePrimitive: ansi.StylePrimitive{
  571. BackgroundColor: stringPtr(Background.Dark),
  572. Prefix: "###### ",
  573. },
  574. },
  575. Strikethrough: ansi.StylePrimitive{
  576. BackgroundColor: stringPtr(Background.Dark),
  577. BlockPrefix: "~~",
  578. BlockSuffix: "~~",
  579. },
  580. Emph: ansi.StylePrimitive{
  581. BackgroundColor: stringPtr(Background.Dark),
  582. BlockPrefix: "*",
  583. BlockSuffix: "*",
  584. },
  585. Strong: ansi.StylePrimitive{
  586. BackgroundColor: stringPtr(Background.Dark),
  587. BlockPrefix: "**",
  588. BlockSuffix: "**",
  589. },
  590. HorizontalRule: ansi.StylePrimitive{
  591. BackgroundColor: stringPtr(Background.Dark),
  592. Format: "\n--------\n",
  593. },
  594. Item: ansi.StylePrimitive{
  595. BlockPrefix: "• ",
  596. BackgroundColor: stringPtr(Background.Dark),
  597. },
  598. Enumeration: ansi.StylePrimitive{
  599. BlockPrefix: ". ",
  600. BackgroundColor: stringPtr(Background.Dark),
  601. },
  602. Task: ansi.StyleTask{
  603. Ticked: "[x] ",
  604. Unticked: "[ ] ",
  605. StylePrimitive: ansi.StylePrimitive{
  606. BackgroundColor: stringPtr(Background.Dark),
  607. },
  608. },
  609. ImageText: ansi.StylePrimitive{
  610. BackgroundColor: stringPtr(Background.Dark),
  611. Format: "Image: {{.text}} →",
  612. },
  613. Code: ansi.StyleBlock{
  614. StylePrimitive: ansi.StylePrimitive{
  615. BlockPrefix: "`",
  616. BlockSuffix: "`",
  617. BackgroundColor: stringPtr(Background.Dark),
  618. },
  619. },
  620. CodeBlock: ansi.StyleCodeBlock{
  621. StyleBlock: ansi.StyleBlock{
  622. StylePrimitive: ansi.StylePrimitive{
  623. BackgroundColor: stringPtr(Background.Dark),
  624. },
  625. Margin: uintPtr(defaultMargin),
  626. },
  627. },
  628. Table: ansi.StyleTable{
  629. StyleBlock: ansi.StyleBlock{
  630. StylePrimitive: ansi.StylePrimitive{
  631. BackgroundColor: stringPtr(Background.Dark),
  632. },
  633. IndentToken: stringPtr(BaseStyle.Render(" ")),
  634. },
  635. CenterSeparator: stringPtr("|"),
  636. ColumnSeparator: stringPtr("|"),
  637. RowSeparator: stringPtr("-"),
  638. },
  639. DefinitionDescription: ansi.StylePrimitive{
  640. BackgroundColor: stringPtr(Background.Dark),
  641. BlockPrefix: "\n* ",
  642. },
  643. }
  644. var DraculaStyleConfig = ansi.StyleConfig{
  645. Document: ansi.StyleBlock{
  646. StylePrimitive: ansi.StylePrimitive{
  647. Color: stringPtr(Forground.Dark),
  648. BackgroundColor: stringPtr(Background.Dark),
  649. },
  650. Indent: uintPtr(defaultMargin),
  651. IndentToken: stringPtr(BaseStyle.Render(" ")),
  652. },
  653. BlockQuote: ansi.StyleBlock{
  654. StylePrimitive: ansi.StylePrimitive{
  655. Color: stringPtr("#f1fa8c"),
  656. Italic: boolPtr(true),
  657. BackgroundColor: stringPtr(Background.Dark),
  658. },
  659. Indent: uintPtr(defaultMargin),
  660. IndentToken: stringPtr(BaseStyle.Render(" ")),
  661. },
  662. Paragraph: ansi.StyleBlock{
  663. StylePrimitive: ansi.StylePrimitive{
  664. BackgroundColor: stringPtr(Background.Dark),
  665. },
  666. },
  667. List: ansi.StyleList{
  668. LevelIndent: defaultMargin,
  669. StyleBlock: ansi.StyleBlock{
  670. IndentToken: stringPtr(BaseStyle.Render(" ")),
  671. StylePrimitive: ansi.StylePrimitive{
  672. Color: stringPtr(Forground.Dark),
  673. BackgroundColor: stringPtr(Background.Dark),
  674. },
  675. },
  676. },
  677. Heading: ansi.StyleBlock{
  678. StylePrimitive: ansi.StylePrimitive{
  679. BlockSuffix: "\n",
  680. Color: stringPtr(PrimaryColor.Dark),
  681. Bold: boolPtr(true),
  682. BackgroundColor: stringPtr(Background.Dark),
  683. },
  684. },
  685. H1: ansi.StyleBlock{
  686. StylePrimitive: ansi.StylePrimitive{
  687. Prefix: "# ",
  688. BackgroundColor: stringPtr(Background.Dark),
  689. },
  690. },
  691. H2: ansi.StyleBlock{
  692. StylePrimitive: ansi.StylePrimitive{
  693. Prefix: "## ",
  694. BackgroundColor: stringPtr(Background.Dark),
  695. },
  696. },
  697. H3: ansi.StyleBlock{
  698. StylePrimitive: ansi.StylePrimitive{
  699. Prefix: "### ",
  700. BackgroundColor: stringPtr(Background.Dark),
  701. },
  702. },
  703. H4: ansi.StyleBlock{
  704. StylePrimitive: ansi.StylePrimitive{
  705. Prefix: "#### ",
  706. BackgroundColor: stringPtr(Background.Dark),
  707. },
  708. },
  709. H5: ansi.StyleBlock{
  710. StylePrimitive: ansi.StylePrimitive{
  711. Prefix: "##### ",
  712. BackgroundColor: stringPtr(Background.Dark),
  713. },
  714. },
  715. H6: ansi.StyleBlock{
  716. StylePrimitive: ansi.StylePrimitive{
  717. Prefix: "###### ",
  718. BackgroundColor: stringPtr(Background.Dark),
  719. },
  720. },
  721. Strikethrough: ansi.StylePrimitive{
  722. CrossedOut: boolPtr(true),
  723. BackgroundColor: stringPtr(Background.Dark),
  724. },
  725. Emph: ansi.StylePrimitive{
  726. Color: stringPtr("#f1fa8c"),
  727. Italic: boolPtr(true),
  728. BackgroundColor: stringPtr(Background.Dark),
  729. },
  730. Strong: ansi.StylePrimitive{
  731. Bold: boolPtr(true),
  732. Color: stringPtr(Blue.Dark),
  733. BackgroundColor: stringPtr(Background.Dark),
  734. },
  735. HorizontalRule: ansi.StylePrimitive{
  736. Color: stringPtr("#6272A4"),
  737. Format: "\n--------\n",
  738. BackgroundColor: stringPtr(Background.Dark),
  739. },
  740. Item: ansi.StylePrimitive{
  741. BlockPrefix: "• ",
  742. BackgroundColor: stringPtr(Background.Dark),
  743. },
  744. Enumeration: ansi.StylePrimitive{
  745. BlockPrefix: ". ",
  746. Color: stringPtr("#8be9fd"),
  747. BackgroundColor: stringPtr(Background.Dark),
  748. },
  749. Task: ansi.StyleTask{
  750. StylePrimitive: ansi.StylePrimitive{
  751. BackgroundColor: stringPtr(Background.Dark),
  752. },
  753. Ticked: "[✓] ",
  754. Unticked: "[ ] ",
  755. },
  756. Link: ansi.StylePrimitive{
  757. Color: stringPtr("#8be9fd"),
  758. Underline: boolPtr(true),
  759. BackgroundColor: stringPtr(Background.Dark),
  760. },
  761. LinkText: ansi.StylePrimitive{
  762. Color: stringPtr("#ff79c6"),
  763. BackgroundColor: stringPtr(Background.Dark),
  764. },
  765. Image: ansi.StylePrimitive{
  766. Color: stringPtr("#8be9fd"),
  767. Underline: boolPtr(true),
  768. BackgroundColor: stringPtr(Background.Dark),
  769. },
  770. ImageText: ansi.StylePrimitive{
  771. Color: stringPtr("#ff79c6"),
  772. Format: "Image: {{.text}} →",
  773. BackgroundColor: stringPtr(Background.Dark),
  774. },
  775. Code: ansi.StyleBlock{
  776. StylePrimitive: ansi.StylePrimitive{
  777. Color: stringPtr("#50fa7b"),
  778. BackgroundColor: stringPtr(Background.Dark),
  779. },
  780. },
  781. Text: ansi.StylePrimitive{
  782. BackgroundColor: stringPtr(Background.Dark),
  783. },
  784. DefinitionList: ansi.StyleBlock{},
  785. CodeBlock: ansi.StyleCodeBlock{
  786. StyleBlock: ansi.StyleBlock{
  787. StylePrimitive: ansi.StylePrimitive{
  788. Color: stringPtr(Blue.Dark),
  789. BackgroundColor: stringPtr(Background.Dark),
  790. },
  791. Margin: uintPtr(defaultMargin),
  792. },
  793. Chroma: &ansi.Chroma{
  794. NameOther: ansi.StylePrimitive{
  795. BackgroundColor: stringPtr(Background.Dark),
  796. },
  797. Literal: ansi.StylePrimitive{
  798. BackgroundColor: stringPtr(Background.Dark),
  799. },
  800. NameException: ansi.StylePrimitive{
  801. BackgroundColor: stringPtr(Background.Dark),
  802. },
  803. LiteralDate: ansi.StylePrimitive{
  804. BackgroundColor: stringPtr(Background.Dark),
  805. },
  806. Text: ansi.StylePrimitive{
  807. Color: stringPtr(Forground.Dark),
  808. BackgroundColor: stringPtr(Background.Dark),
  809. },
  810. Error: ansi.StylePrimitive{
  811. Color: stringPtr("#f8f8f2"),
  812. BackgroundColor: stringPtr("#ff5555"),
  813. },
  814. Comment: ansi.StylePrimitive{
  815. Color: stringPtr("#6272A4"),
  816. BackgroundColor: stringPtr(Background.Dark),
  817. },
  818. CommentPreproc: ansi.StylePrimitive{
  819. Color: stringPtr("#ff79c6"),
  820. BackgroundColor: stringPtr(Background.Dark),
  821. },
  822. Keyword: ansi.StylePrimitive{
  823. Color: stringPtr("#ff79c6"),
  824. BackgroundColor: stringPtr(Background.Dark),
  825. },
  826. KeywordReserved: ansi.StylePrimitive{
  827. Color: stringPtr("#ff79c6"),
  828. BackgroundColor: stringPtr(Background.Dark),
  829. },
  830. KeywordNamespace: ansi.StylePrimitive{
  831. Color: stringPtr("#ff79c6"),
  832. BackgroundColor: stringPtr(Background.Dark),
  833. },
  834. KeywordType: ansi.StylePrimitive{
  835. Color: stringPtr("#8be9fd"),
  836. BackgroundColor: stringPtr(Background.Dark),
  837. },
  838. Operator: ansi.StylePrimitive{
  839. Color: stringPtr("#ff79c6"),
  840. BackgroundColor: stringPtr(Background.Dark),
  841. },
  842. Punctuation: ansi.StylePrimitive{
  843. Color: stringPtr(Forground.Dark),
  844. BackgroundColor: stringPtr(Background.Dark),
  845. },
  846. Name: ansi.StylePrimitive{
  847. Color: stringPtr("#8be9fd"),
  848. BackgroundColor: stringPtr(Background.Dark),
  849. },
  850. NameBuiltin: ansi.StylePrimitive{
  851. Color: stringPtr("#8be9fd"),
  852. BackgroundColor: stringPtr(Background.Dark),
  853. },
  854. NameTag: ansi.StylePrimitive{
  855. Color: stringPtr("#ff79c6"),
  856. BackgroundColor: stringPtr(Background.Dark),
  857. },
  858. NameAttribute: ansi.StylePrimitive{
  859. Color: stringPtr("#50fa7b"),
  860. BackgroundColor: stringPtr(Background.Dark),
  861. },
  862. NameClass: ansi.StylePrimitive{
  863. Color: stringPtr("#8be9fd"),
  864. BackgroundColor: stringPtr(Background.Dark),
  865. },
  866. NameConstant: ansi.StylePrimitive{
  867. Color: stringPtr("#bd93f9"),
  868. BackgroundColor: stringPtr(Background.Dark),
  869. },
  870. NameDecorator: ansi.StylePrimitive{
  871. Color: stringPtr("#50fa7b"),
  872. BackgroundColor: stringPtr(Background.Dark),
  873. },
  874. NameFunction: ansi.StylePrimitive{
  875. Color: stringPtr("#50fa7b"),
  876. BackgroundColor: stringPtr(Background.Dark),
  877. },
  878. LiteralNumber: ansi.StylePrimitive{
  879. Color: stringPtr("#6EEFC0"),
  880. BackgroundColor: stringPtr(Background.Dark),
  881. },
  882. LiteralString: ansi.StylePrimitive{
  883. Color: stringPtr("#f1fa8c"),
  884. BackgroundColor: stringPtr(Background.Dark),
  885. },
  886. LiteralStringEscape: ansi.StylePrimitive{
  887. Color: stringPtr("#ff79c6"),
  888. BackgroundColor: stringPtr(Background.Dark),
  889. },
  890. GenericDeleted: ansi.StylePrimitive{
  891. Color: stringPtr("#ff5555"),
  892. BackgroundColor: stringPtr(Background.Dark),
  893. },
  894. GenericEmph: ansi.StylePrimitive{
  895. Color: stringPtr("#f1fa8c"),
  896. Italic: boolPtr(true),
  897. BackgroundColor: stringPtr(Background.Dark),
  898. },
  899. GenericInserted: ansi.StylePrimitive{
  900. Color: stringPtr("#50fa7b"),
  901. BackgroundColor: stringPtr(Background.Dark),
  902. },
  903. GenericStrong: ansi.StylePrimitive{
  904. Color: stringPtr("#ffb86c"),
  905. Bold: boolPtr(true),
  906. BackgroundColor: stringPtr(Background.Dark),
  907. },
  908. GenericSubheading: ansi.StylePrimitive{
  909. Color: stringPtr("#bd93f9"),
  910. BackgroundColor: stringPtr(Background.Dark),
  911. },
  912. Background: ansi.StylePrimitive{
  913. BackgroundColor: stringPtr(Background.Dark),
  914. },
  915. },
  916. },
  917. Table: ansi.StyleTable{
  918. StyleBlock: ansi.StyleBlock{
  919. StylePrimitive: ansi.StylePrimitive{
  920. BackgroundColor: stringPtr(Background.Dark),
  921. },
  922. IndentToken: stringPtr(BaseStyle.Render(" ")),
  923. },
  924. },
  925. DefinitionDescription: ansi.StylePrimitive{
  926. BlockPrefix: "\n* ",
  927. BackgroundColor: stringPtr(Background.Dark),
  928. },
  929. }