Skip to content

Consider allowing Nodes with a "fragment" type. #558

@ioquatix

Description

@ioquatix

I'm interested in manipulating markdown ASTs.

It's sometimes problematic to extract a fragment, e.g.

header = Markly.parse("### Hello `World`").first_child
fragment = header.extract_children # Move all children to a node of type `custom`
fragment.to_markdown # => "Hello `World`\n\n"

I'm having trouble with the output formatting.

Ideally, the fragment would just be the raw children, e.g.

fragment.to_markdown # => "Hello `World`"

This would make it a little easier to mash up the AST with different types of outputs.

I suppose the issue is the formatting of custom type nodes, but I'm not sure if there is a problem to change this.

In other words, either (1) we could change the output to be "inline" or add an inline "fragment" node type which does minimal formatting. Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions