Skip to content

Add concrete syntax details #36

@CupOfTea696

Description

@CupOfTea696

Add concrete syntax details

It would be nice to have concrete syntax information on certain nodes, for example, which bullet type was used for a list item.

Problem

When using a markdown parser to modify markdown and write it back to a file, it would be nice to re-use the same style as the original markdown content. Currently, there is no way to get this information to either use inside a compiler or to set the compiler options.

Expected behaviour

Syntax details included in tree Nodes. Below an example for emphasis

Interface

interface Emphasis <: Parent {
  type: "emphasis"
  character: string?
  children: [TransparentContent]
}

Markdown:

*alpha* _bravo_

Yields:

{
  type: 'paragraph',
  children: [
    {
      type: 'emphasis',
      character: '*',
      children: [{type: 'text', value: 'alpha'}]
    },
    {type: 'text', value: ' '},
    {
      type: 'emphasis',
      character: '_',
      children: [{type: 'text', value: 'bravo'}]
    }
  ]
}

When recompiling the above tree back to Markdown, it would render back to *alpha* _bravo_ rather than *alpha* *bravo*, unless the compiler is explicitly set to use a certain character for emphasis.

Alternatives

This could be implemented without any compiler modifications by having a utility that detects the used syntax and sets the compiler's options accordingly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🙅 no/wontfixThis is not (enough of) an issue for this project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions