Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nasa-gcn/afm
Command-line tool to render Astro Flavored Markdown documents to JSON abstract syntax trees or HTML
https://github.com/nasa-gcn/afm
astronomy cli hast markdown mdast unist
Last synced: about 2 months ago
JSON representation
Command-line tool to render Astro Flavored Markdown documents to JSON abstract syntax trees or HTML
- Host: GitHub
- URL: https://github.com/nasa-gcn/afm
- Owner: nasa-gcn
- License: other
- Created: 2024-05-14T14:08:21.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-11-11T20:27:59.000Z (about 2 months ago)
- Last Synced: 2024-11-11T21:29:26.484Z (about 2 months ago)
- Topics: astronomy, cli, hast, markdown, mdast, unist
- Language: JavaScript
- Homepage:
- Size: 337 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[![NPM Version](https://img.shields.io/npm/v/%40nasa-gcn%2Fafm)](https://www.npmjs.com/package/@nasa-gcn/afm)
# Astro Flavored Markdown
This is a command-line tool to render Astro Flavored Markdown documents to JSON abstract syntax trees or HTML. Astro Flavored Markdown is a dialect of [Markdown](https://www.markdownguide.org) for rapid astronomy communications. Astro Flavored Markdown detects and enriches dates, times, sky coordinates, and bibliographic references in text.
This command-line interface is a thin wrapper around [remark-rehype-astro](https://www.npmjs.com/package/@nasa-gcn/remark-rehype-astro), the reference implementation of Astro Flavored Markdown as a plugin for the [Unified](https://unifiedjs.com) parser ecosystem.
## Usage
```
Usage: afm [options] [input]Render Astro Flavored Markdown as a JSON syntax tree or as HTML
Arguments:
input input file [default: stdin]Options:
--html output is in HTML [default: output is in JSON]
-o, --output output file [default: stdout]
-h, --help display help for command
```## Example
Place the following text into a file called example.md:
```
# ExampleHere is a table:
| Transient | Classification |
| --------- | -------------- |
| AT2017gfo | kilonova |
```To render as a JSON syntax tree:
```
$ npx @nasa-gcn/afm example.md
{
"type": "root",
"children": [
{
"type": "heading",
"depth": 1,
"children": [
{
"type": "text",
"value": "Example"
}
]
},
{
"type": "paragraph",
"children": [
{
"type": "text",
"value": "Here is a table:"
}
]
},
{
"type": "table",
"align": [
null,
null
],
"children": [
{
"type": "tableRow",
"children": [
{
"type": "tableCell",
"children": [
{
"type": "text",
"value": "Transient"
}
]
},
{
"type": "tableCell",
"children": [
{
"type": "text",
"value": "Classification"
}
]
}
]
},
{
"type": "tableRow",
"children": [
{
"type": "tableCell",
"children": [
{
"type": "text",
"value": "AT2017gfo",
"data": {
"class": "tns",
"value": "2017gfo"
}
}
]
},
{
"type": "tableCell",
"children": [
{
"type": "text",
"value": "kilonova"
}
]
}
]
}
]
}
]
}
```To render as HTML:
```
$ npx @nasa-gcn/afm --html example.mdExample
Here is a table:
Transient
Classification
AT2017gfo
kilonova
```