Parser

Built atop the unified ecosystem, specifically remark, which takes .lit Markdown source and outputs mdast (Markdown Abstract Syntax Tree)

Implementation

Extensions

Frontmatter

Implementation

Sections

Sections are automatically created from the nested structure of Headings.

md
# Headline (root section)
## Subtitle (child section)

They can be collapse/folded (tbd)

md
# >Headline (collapsed)

Implementation

Cells

Currently implemented as part of Sections, see above.

Codeblocks

Implementation

jsmetatostring
const metaToString = lit.parser.utils.metaToString;

const input =
  "js index.jsx !foo #bar baz=qux\\ zig < source.jsx > json output.json #faz !raz";
const meta = lit.parser.utils.parseMeta({ meta: input });
console.log(input);
console.log(meta);
return metaToString(meta);
return lit.parser.utils;

txtUpdated 24.9w ago
js index.jsx !foo #bar baz=qux\ zig < source.jsx > json output.json #faz !raz
{ attrs: { baz: 'qux\\ zig' },
  lang: 'js',
  filename: 'index.jsx',
  directives: [ 'foo' ],
  tags: [ 'bar' ],
  baz: 'qux\\ zig',
  isOutput: false,
  output: 
   { attrs: {},
     lang: 'json',
     filename: 'output.json',
     tags: [ 'faz' ],
     directives: [ 'raz' ],
     isOutput: false,
     output: undefined,
     hasOutput: false,
     hasSource: false,
     source: undefined,
     raw: 'json output.json #faz !raz' },
  hasOutput: true,
  hasSource: true,
  source: 
   { attrs: {},
     lang: 'txt',
     filename: 'source.jsx',
     isOutput: false,
     output: undefined,
     hasOutput: false,
     hasSource: false,
     source: undefined,
     raw: 'txt source.jsx' },
  raw: 'js index.jsx !foo #bar baz=qux\\ zig < source.jsx > json output.json #faz !raz',
  fromSource: 'source.jsx' }
js index.jsx !foo baz=qux\ zig #bar < txt source.jsx > json output.json !raz #faz

Markdown blocks

Implementation

AST to String

  • #TODO refactor save (update src) to operate on AST directly and stringify as below, instead of the cureent ../utils/unist-patch-source implementaction.

    This is complicated by the fact that new cell source can in effect result in previous and next cell semantic/structure changes, hence the patch source implementation

js
const {toMarkdown, ungroupSections}
      = lit.parser.utils
const unGroup = ungroupSections()()
const tree = unGroup(lit.ast)
const md = toMarkdown(tree)
return md