neroist / nimitheme

Make nimib look beautiful with nimitheme
https://neroist.github.io/nimitheme/
MIT License
10 stars 0 forks source link

refactor to protect from nimib code changes? #2

Closed pietroppeter closed 1 year ago

pietroppeter commented 1 year ago

something you might want to consider while working on this would be to add a template with some basic fields (even static ones) to make sure that when we change code nimib side (e.g. context at some point will be replaced with data) you do not have to change it everywhere (which in your case is not really a big deal, a search and replace should work fine). A bit like you do for highlight: https://github.com/neroist/nimitheme/blob/1bca8ffc647084c164167ead03a7ca11a3dcfa25/src/nimitheme/highlight_js.nim#L4

something like this (I guess you might have other options somewhere; warning: have not tested it).

template useStyle(stylesheet: static string, useDarkMode: static bool = false, useDefault: static bool = true, customStyle: static string = "") =
  when useDefault:
    doc.useDefault
  when useDarkMode:
    doc.darkMode
  doc.context["stylesheet"] = stylesheet
  when customStyle.len > 0:
    doc.context["nb_style"] = doc.context["nb_style"].vString & '\n' & customStyle
neroist commented 1 year ago

This sounds great! I made a PR to use this here: #5