Skip to content

andy840119/JupyterSharpParser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

6410c09 · Feb 23, 2019

History

66 Commits
Dec 13, 2018
Dec 15, 2018
Feb 23, 2019
Nov 17, 2018
Nov 17, 2018
Dec 13, 2018
Dec 13, 2018
Dec 13, 2018
Dec 15, 2018

Repository files navigation

JupyterSharpParser

Build status CodeFactor NuGet NuGet NuGet

Jupyter parser written in C#

Samlpe :

var jupyterText = "[Text in jupyer document]";
JupyterDocument document = Jupyter.Parse(jupyterText);

//You can do anything in this document such as add cell
document.Cells.Add(new CodeCell
{
    ExecutionCount = 10,
    Source = new List<string>{"print(3 * 2)"}
});

Convert To Json :

// Output
var writer = new StringWriter();

// Create a HTML Renderer and setup it with the pipeline
var renderer = new JsonRenderer(writer);

// Renders Jupyter Document to Json (to the writer)
renderer.Render(document);

// Gets the rendered string
var result = writer.ToString();

Convert To Html :

// Output
var writer = new StringWriter();

// Create a HTML Renderer and setup it with the pipeline
var renderer = new HtmlRenderer(writer);

// Renders Jupyter Document to Json (to the writer)
renderer.Render(document);

// Gets the rendered string
var result = writer.ToString();

Convert To Pdf :

//Note : Due to Select.HtmlToPdf.NetCore, PDF limited to most 5 page,
//       And cannot work on other platform such as mac and linux.

// Output
using(var stream = new FileStream("fileName"))
{
    // Create a HTML Renderer and setup it with the pipeline
    var renderer = new PdfRenderer(stream);

    // Renders Jupyter Document to Json (to the writer)
    renderer.Render(document);  
}