Ask HN: Tool to convert JavaScript code comments into Markdown?
I would like a tool which takes code in a javascript project and generates markdown where the comments are taken as direct markdown and the code is wrapped in triple backticks. This would allow me to make a blog post from a javascript project without maintaining two separate files and updating the code in both.
For example if I have this in a javascript file:
/*
# Tutorial Title
Welcome to the codebase tutorial.
## Add Function
This function is used to add numbers. `1+2=3` is an example of some backquoted text.
*/
function add(a,b) {
return a + b;
}
/*
## Subtract Function
This function is used to subtract! ***Use at your own risk***
*/
function subtract(a,b) {
return a - b;
}
I would like the resulting markdown to be: # Tutorial Title
Welcome to the codebase tutorial.
## Add Function
This function is used to add numbers. `1+2=3` is an example of some backquoted text.
```
function add(a,b) {
return a + b;
}
```
## Subtract Function
This function is used to subtract! ***Use at your own risk***
```
function subtract(a,b) {
return a - b;
}
```
Does anyone know of a tool which will do this?
2 comments
[ 3.1 ms ] story [ 14.2 ms ] thread