Package: rootmd
RootMD 🩺 👩🏼‍⚕️Scientific reports/literate programming tool for CERN ROOT and c++. RootMD is a markdown (and other format) processor for mark up with ROOT-flavored c++ code. RootMD can execute c++ code and inject the output (from stdout, stderr) and link or embed image outputs. Provides a format for producing code + result for better documentation / notes. This is by design not a jupyter notebook, e.g. not a REPL-like environment. If you like Jupyter notebooks then use that :).Installationpython-mpipinstallrootmdthe you can use it with:python -m rootmd <args>Featuresexecute c++ code blocks via ROOT REPLcapture stdout, stderr and inject into outputembed (base64) or link to any image files producedoutput to HTML, Markdown (or obsidian flavored markdown), or as a presentation (via Marp)execute html, css, javascript code blocks (for html output) to customize outputwatch files for changes and rerun (good for iterative workflows)usageusage:rootmd[-h][--outputOUTPUT][--format{html,md,obsidian,json,terminal}][--embed][--asset-dirASSET_DIR][--verbosityVERBOSITY][--watchWATCH][--runRUN][--clean][--no-exec]input

ConvertMarkdownwithinlinec++codetoROOToutput.

positionalarguments:inputinputMarkdownfiletoexecuteandconvert

optionalarguments:-h,--helpshowthishelpmessageandexit--outputOUTPUToutputfilenamedefault<input>.<ext>where<ext>isdeterminedbythechosenformat,defaulthtml--format{html,md,obsidian,json,terminal}outputformat--embedembedimagesasbase64--asset-dirASSET_DIRspecifyassetoutputdirectory,pathsareNOTEre-writtentosupportunlessusingobsidianformat--verbosityVERBOSITYspecifylogverbosity--watchWATCHwatchafileordirectoryforchanges--runRUNcommandtorunafterprocessingafile.Thefilenamecanbesubstitutedintothecommandstringwith{{file}}.Example:--run="echo {{file}}"--cleancleanartifacts,caution-shouldonlyusewithembedorassetcopyto<asset-dir>--no-execDonotexecuteanycodeblocks,justprocessfile(usefulforviewingandtestingconversion)TODOmake it a python package (so that it can be installed via pip)Look into poetrystart versioningsupport output verbosity levels& make output usefulAdd comment for input block identification upon processingadd watch functionality for reprocessing a file on changeAdd some additional featuresHandle watch of multiple files, and how output filename should be namedAdd terminal output using rich pretty output packageconsider iterm image support?See hereBasically, markdown output on the terminal : using richAdd prismjs for inline codetest some failure modes when root code has errors leading to hangadd mathjax to html output for inline mathematics"import" source files into output? So that you can write code in separate file but sow it in the output?add as a block optionsupport for other "languages", e.g. shellsupport for ROOTJS in HTML outputembed histogram as JSON object in HTMLclean assets in embed mode or other output pathdownload + embed external JS for fully contained, offline ready single file HTML outputLoad HTML / CSS defaults from a file in the packageBetter style HTML output (input / output cells more like Jupyter)Consider adding JS for collapsing headings, output blocks etc.add format option to output a ROOT macro with markdown and output converted to commentsintegrate usage of RNUplot for graphical output!implement an auto-draw so that you dont have to "Print(...)" every blockblock option: run code block as a "macro"You can already use .L, .xmove ROOT executor into member not superclassauto-draw dont do it for cells without any drawing!PDF supportBetter PDF embed (link to file) (for Firefox especially) using canvas :https://stackoverflow.com/questions/2104608/hiding-the-toolbars-surrounding-an-embedded-pdfEmbed PDF base64 in object tagFeature wish listCache blocks of code for faster rerunserver for "sharing" of documents, from command line - use secret linksTechnique for RAW output?i.e. write out HTML Table or markupinline code replacement, e.g. "We ranTString::Format("%d",tree->GetEntries())events."Improve ROOT?Apply some default style optionsKnown issueswatch isnt working, especially when input not givensomething is surely brokenROOT REPL issuesROOT REPL struggles with multi-line code:function definitions with "{" on next line does not work since it doesn't understandvoidhello(){// this works}voidworld(){// this DOES NOT work}Code Block Optionsstdoutorout: Defaulttrue.  Set tofalseto hide stdout block. Set to  to write output to the given file.stderrorerr: Defaulttrue. Set tofalseto hide stderr block. Set to  to write output to the given file.silentorquiet: Defaultfalse. Set totrueto hide both stderr and stdoutHTML only.image: css class to use for produced images.raw: output raw result fromstdoutas htmlDependenciesRootMD itself is a pure python package which uses:mistletoe: python markdown parser and processorrich: Rich for pretty terminal outputpyyaml : for parsing yaml front matterDependencies for HTML outputprismjsfor syntax highlighting in HTML outputmathjaxfor rendering mathematicsROOT: installed on system and available on PATHExample : seeexample_in.mdandexample.mdThis is a simple example of markdown processed by RootMD.
You can include any c++ code that ROOT can handle. For instance (using ROOT6)
this part of the file was processed withrootmdexample_in.md-fmd-oexample.mdcout<<"Hello from ROOT (stdout)"<<endl;cerr<<"Hello from ROOT (stderr)"<<endl;# Block [0]HellofromROOT(stdout)HellofromROOT(stderr)TH1*h1=newTH1F("hGaus",";x;counts",100,-5,5);h1->FillRandom("gaus",10000);h1->Draw("pe");h1->Draw("same hist");gPad->Print("h1.svg");# Block [1]Infoin<TCanvas::MakeDefCanvas>:createddefaultTCanvaswithnamec1
Infoin<TCanvas::Print>:SVGfileh1.svghasbeencreatedChangelogv0.6Fix broken options in MdRenderv0.6Add control of output blocks to MdRenderer, update READMEv0.5.9Add additional executor catchCatch "_sigtramp"Catch "(no debug info)"v0.5.8Allow log level to be set from command line arguments.Adds parameter "--log" or "--logLevelv0.5.7Add additional catch conditions on the ROOT executor to try to prevent hanging on code errorsCatch "Root >"Catch "root [N]"Catch "*** Break *** segmentation violation"