Skip to content

WolframInstitute/MarkdownToNotebook

Repository files navigation

MarkdownToNotebook

MarkdownToNotebook[source] converts a literate-markdown document (a file path, an http(s) URL, or a raw string) into a Wolfram notebook, choosing the layout from a Template frontmatter key. The goal is that the markdown can express almost everything the Documentation Tools palette and the definition-notebook docked toolbars provide, so authors never hand-edit notebook cell styles.

One source format produces:

  • Symbol / Guide / TechNote documentation pages (the authoring notebooks DocumentationBuild turns into reference/guide/tutorial pages);
  • FunctionResource / Paclet definition notebooks (the official templates, with their docked Deploy / Submit / Check toolbar, publishable as-is);
  • Default plain styled notebooks.

Frontmatter drives metadata; ## sections and fenced ```wl cells become the content; example cells are evaluated and cached. A #| file: path cell inlines a .wl file or URL.

The function is deployed publicly in the Wolfram Cloud, so you can use it without installing anything:

ResourceFunction["https://www.wolframcloud.com/obj/nikm/DeployedResources/Function/MarkdownToNotebook"]["doc.md"]

Note: official publication to the Wolfram Function Repository is pending review. Until then, use the public cloud link above (or the local MarkdownToNotebook.wl).

Layout

Applications

End-to-end markdown-authored Wolfram artifacts built with MarkdownToNotebook:

  • examples/AccessibleColors - a complete paclet (submodule), authored entirely in markdown and published as Wolfram/AccessibleColors: a guide, four symbol pages, a tutorial, and the Paclet Repository definition.
  • examples/IntroToQuantumComputing - a two-chapter book using the new Template: Chapter (Wolfram Book Tools styles): exercises with solutions, vocabulary tables, Q&A, solved examples, theorem/proof blocks, tech notes, summary, and references. Generates a Contents.nb (using the WolframBookTools paclet's own inline TOC stylesheet and cell shape) plus a Master.nb that concatenates the chapters into one book-form notebook (mirroring WBTCreateCorrespondingPrintDirectory). Published to the cloud at:
  • Other markdown -> notebook samples under examples/ (AdaLovelace, BlochSphereGates, PiIsMostlyRandom, PrimeSpiralPoints, QuantumWalk, ReverseAddSequence, WallpaperGroups) - each a single notebook rendered with the Default / Essay templates.

Quick start

Get["MarkdownToNotebook.wl"];
MarkdownToNotebook["path/to/doc.md"]              (* returns the Notebook expression *)
MarkdownToNotebook["path/to/doc.md", "doc.nb"]   (* also writes doc.nb, returns the file *)

See docs/README.md for the full conventions, and GUIDE.md for the Wolfram Language coding style the .wl and .wls sources follow.

Implementation notes

Parsing is pure Wolfram, kept in the ## Definition cells: there is no paclet directory and no native (C/Rust) extension. If inline-markdown fidelity ever needs a real CommonMark parser, swap only the inline layer (comrak via LibraryLink, or a pandoc shell-out); the block parser and the evaluate/cache engine are unaffected. Example outputs are evaluated once and cached as PersistentObjects keyed by a cumulative content hash of the example cells.

The official, submittable FunctionResource definition notebook is the one CreateNotebook["FunctionResource"] (front end) or ResourceFunction["CreateResourceNotebook"]["Function"] (kernel) opens. Its template is FunctionResource/Kernel/Templates/FunctionResourceDefinition.nb; the Deploy / Submit toolbar lives in docked cells (TemplateBox[{}, "MainGridTemplate"]) of FunctionResourceDefinitionStyles.nb, driven by the DefinitionNotebookClient paclet. The converter fills that template directly, so publishing stays headless.

About

Convert literate markdown into Wolfram notebooks: documentation pages, resource definition notebooks, or plain notebooks, from a Template frontmatter key

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors