Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve heading sizing #27

Merged
merged 2 commits into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion internal/renderer/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,16 @@ func (r *renderer) getMarkdownStop(n ast.Node) int {
return 0
}

return curr.Lines().At(l - 1).Start
stop := curr.Lines().At(l - 1).Start

// add back markdown heading levels
if curr.Kind() == ast.KindHeading {
heading := curr.(*ast.Heading)
// simple math to add back ## incl trailing space
stop = stop - 1 - heading.Level
}

return stop
}

// AddOptions has no effect
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"document":[{"markdown":"# Tortuga API\n\nThe API built for [Tortuga Prototype](https://www.notion.so/statefulhq/Tortuga-Prototype-c406dd5fa1ad452dba15560a6cead5f9).\n\n\u003e **Warning!** All code snippets below assume you're in the **`./api`** directory.\n\n## Start\n\nFirst 😇, install dev dependencies:"},{"attributes":{"name":"install"},"content":"brew bundle\n","description":"First 😇, install dev dependencies:","language":"sh","lines":["brew bundle"]},{"markdown":"Deploy site to Vercel"},{"content":"https://vercel.com/stateful/stateful-com\n","description":"Deploy site to Vercel","language":"Vercel","lines":["https://vercel.com/stateful/stateful-com"]},{"markdown":"Next run dependencies:"},{"attributes":{"name":"docker-compose"},"content":"$ docker compose up -d\n","description":"Next run dependencies:","language":"sh","lines":["docker compose up -d"]},{"markdown":"Then you should be able to successfully run:"},{"attributes":{"name":"run"},"content":"$ echo \"Running\"\n$ go run ./cmd/api/main.go\n2022/05/10 12:18:18 starting to listen on: :8080\n","description":"Then you should be able to successfully run:","language":"sh","lines":["echo \"Running\"","go run ./cmd/api/main.go"]},{"markdown":"Development\n\n\u003e Currently, VS Code and Go extension require opening `./api` as a project root directory to work properly.\n\u003e You can use Workspaces to open the project root directory and `./api` as a second folder.\n\nTry using [watchexec](https://github.com/watchexec/watchexec) to autoreload."},{"attributes":{"name":"watch"},"content":"watchexec -r -e go -- go run ./cmd/api/main.go\n","description":"Try using [watchexec](https://github.com/watchexec/watchexec) to autoreload.","language":"sh","lines":["watchexec -r -e go -- go run ./cmd/api/main.go"]},{"markdown":"Deployment\n\nDeployments are managed with Terraform. Go to [infra](../infra) to learn how to run it.\n\n[infra](../infra) automatically discovers if source files of the api changed. If so, it triggers a Docker image build and updates a Cloud Run service.\n\n## Database\n\nIt uses PostgreSQL.\n\n### Migrations\n\n[Atlas CLI](https://atlasgo.io/cli/getting-started/setting-up) is used to manage database migrations in a declarative way.\n\nMigrations are run automatically by the API server process.\n\nIn a case you want to run them manually and re-use Postgres from Docker Compose:"},{"attributes":{"name":"migrate"},"content":"$ atlas schema apply -u \"postgres://postgres:postgres@localhost:15432/tortuga?sslmode=disable\" -f atlas.hcl\n","description":"In a case you want to run them manually and re-use Postgres from Docker Compose:","language":"sh","lines":["atlas schema apply -u \"postgres://postgres:postgres@localhost:15432/tortuga?sslmode=disable\" -f atlas.hcl"]},{"markdown":"API\n\n\u003e Each insert accepts also `user_id` which is nullable for now.\n\u003e All endpoints implement also `GET` method to return all collected results so far starting from the most recent.\n\n### Tasks\n\nInserting task execution metadata:"},{"attributes":{"name":"post-task"},"content":"$ curl -XPOST -H \"Content-Type: application/json\" localhost:8080/tasks/ -d '{\"duration\": \"10s\", \"exit_code\": 0, \"name\": \"Run task\", \"runbook_name\": \"RB 1\", \"runbook_run_id\": \"6e975f1b-0c0f-4765-b24a-2aa87b901c06\", \"start_time\": \"2022-05-05T04:12:43Z\", \"command\": \"/bin/sh\", \"args\": \"echo hello\", \"feedback\": \"this is cool!\", \"extra\": \"{\\\"hello\\\": \\\"world\\\"}\"}'\n{\"id\":\"6e975f1b-0c0f-4765-b24a-2aa87b901c06\"}\n","description":"Inserting task execution metadata:","language":"sh","lines":["curl -XPOST -H \"Content-Type: application/json\" localhost:8080/tasks/ -d '{\"duration\": \"10s\", \"exit_code\": 0, \"name\": \"Run task\", \"runbook_name\": \"RB 1\", \"runbook_run_id\": \"6e975f1b-0c0f-4765-b24a-2aa87b901c06\", \"start_time\": \"2022-05-05T04:12:43Z\", \"command\": \"/bin/sh\", \"args\": \"echo hello\", \"feedback\": \"this is cool!\", \"extra\": \"{\\\"hello\\\": \\\"world\\\"}\"}'"]},{"markdown":"A task can be patched:"},{"attributes":{"name":"patch-task"},"content":"$ curl -X PATCH -H \"Content-Type: application/json\" localhost:8080/tasks/6e975f1b-0c0f-4765-b24a-2aa87b901c06/ -d '{\"duration\": \"15s\", \"exit_code\": 1}'\n{\"id\":\"6e975f1b-0c0f-4765-b24a-2aa87b901c06\"}\n","description":"A task can be patched:","language":"sh","lines":["curl -X PATCH -H \"Content-Type: application/json\" localhost:8080/tasks/6e975f1b-0c0f-4765-b24a-2aa87b901c06/ -d '{\"duration\": \"15s\", \"exit_code\": 1}'"]},{"markdown":"Feedback\n\nInserting feedback can optionally take a `task_id`:"},{"attributes":{"name":"post-feedback"},"content":"$ curl -XPOST -H \"Content-Type: application/json\" localhost:8080/feedback/ -d '{\"message\": \"My feedback!\", \"task_id\": \"6e975f1b-0c0f-4765-b24a-2aa87b901c06\"}'\n{\"id\":\"a02b6b5f-46c4-40ff-8160-ff7d55b8ca6f\"}\n","description":"Inserting feedback can optionally take a `task_id`:","language":"sh","lines":["curl -XPOST -H \"Content-Type: application/json\" localhost:8080/feedback/ -d '{\"message\": \"My feedback!\", \"task_id\": \"6e975f1b-0c0f-4765-b24a-2aa87b901c06\"}'"]},{"markdown":"Feedback can be patched:"},{"attributes":{"name":"patch-feedback"},"content":"$ curl -X PATCH -H \"Content-Type: application/json\" localhost:8080/feedback/a02b6b5f-46c4-40ff-8160-ff7d55b8ca6f/ -d '{\"message\": \"Modified!\"}'\n{\"id\":\"a02b6b5f-46c4-40ff-8160-ff7d55b8ca6f\"}\n","description":"Feedback can be patched:","language":"sh","lines":["curl -X PATCH -H \"Content-Type: application/json\" localhost:8080/feedback/a02b6b5f-46c4-40ff-8160-ff7d55b8ca6f/ -d '{\"message\": \"Modified!\"}'"]},{"markdown":"Editor configs\n\nInserting editor configs:"},{"attributes":{"name":"post-editor-config"},"content":"$ curl -XPOST -H \"Content-Type: application/json\" localhost:8080/editor-configs/ -d '{\"data\": \"{\\\"files.autoSave\\\": \\\"afterDelay\\\"}\"}'\n{\"id\":\"4c7d6fb5-eb53-44f7-8883-80f276af65a1\"}\n","description":"Inserting editor configs:","language":"sh","lines":["curl -XPOST -H \"Content-Type: application/json\" localhost:8080/editor-configs/ -d '{\"data\": \"{\\\"files.autoSave\\\": \\\"afterDelay\\\"}\"}'"]}]}
{"document":[{"markdown":"# Tortuga API\n\nThe API built for [Tortuga Prototype](https://www.notion.so/statefulhq/Tortuga-Prototype-c406dd5fa1ad452dba15560a6cead5f9).\n\n\u003e **Warning!** All code snippets below assume you're in the **`./api`** directory.\n\n## Start\n\nFirst 😇, install dev dependencies:"},{"attributes":{"name":"install"},"content":"brew bundle\n","description":"First 😇, install dev dependencies:","language":"sh","lines":["brew bundle"]},{"markdown":"Deploy site to Vercel"},{"content":"https://vercel.com/stateful/stateful-com\n","description":"Deploy site to Vercel","language":"Vercel","lines":["https://vercel.com/stateful/stateful-com"]},{"markdown":"Next run dependencies:"},{"attributes":{"name":"docker-compose"},"content":"$ docker compose up -d\n","description":"Next run dependencies:","language":"sh","lines":["docker compose up -d"]},{"markdown":"Then you should be able to successfully run:"},{"attributes":{"name":"run"},"content":"$ echo \"Running\"\n$ go run ./cmd/api/main.go\n2022/05/10 12:18:18 starting to listen on: :8080\n","description":"Then you should be able to successfully run:","language":"sh","lines":["echo \"Running\"","go run ./cmd/api/main.go"]},{"markdown":"## Development\n\n\u003e Currently, VS Code and Go extension require opening `./api` as a project root directory to work properly.\n\u003e You can use Workspaces to open the project root directory and `./api` as a second folder.\n\nTry using [watchexec](https://github.com/watchexec/watchexec) to autoreload."},{"attributes":{"name":"watch"},"content":"watchexec -r -e go -- go run ./cmd/api/main.go\n","description":"Try using [watchexec](https://github.com/watchexec/watchexec) to autoreload.","language":"sh","lines":["watchexec -r -e go -- go run ./cmd/api/main.go"]},{"markdown":"## Deployment\n\nDeployments are managed with Terraform. Go to [infra](../infra) to learn how to run it.\n\n[infra](../infra) automatically discovers if source files of the api changed. If so, it triggers a Docker image build and updates a Cloud Run service.\n\n## Database\n\nIt uses PostgreSQL.\n\n### Migrations\n\n[Atlas CLI](https://atlasgo.io/cli/getting-started/setting-up) is used to manage database migrations in a declarative way.\n\nMigrations are run automatically by the API server process.\n\nIn a case you want to run them manually and re-use Postgres from Docker Compose:"},{"attributes":{"name":"migrate"},"content":"$ atlas schema apply -u \"postgres://postgres:postgres@localhost:15432/tortuga?sslmode=disable\" -f atlas.hcl\n","description":"In a case you want to run them manually and re-use Postgres from Docker Compose:","language":"sh","lines":["atlas schema apply -u \"postgres://postgres:postgres@localhost:15432/tortuga?sslmode=disable\" -f atlas.hcl"]},{"markdown":"## API\n\n\u003e Each insert accepts also `user_id` which is nullable for now.\n\u003e All endpoints implement also `GET` method to return all collected results so far starting from the most recent.\n\n### Tasks\n\nInserting task execution metadata:"},{"attributes":{"name":"post-task"},"content":"$ curl -XPOST -H \"Content-Type: application/json\" localhost:8080/tasks/ -d '{\"duration\": \"10s\", \"exit_code\": 0, \"name\": \"Run task\", \"runbook_name\": \"RB 1\", \"runbook_run_id\": \"6e975f1b-0c0f-4765-b24a-2aa87b901c06\", \"start_time\": \"2022-05-05T04:12:43Z\", \"command\": \"/bin/sh\", \"args\": \"echo hello\", \"feedback\": \"this is cool!\", \"extra\": \"{\\\"hello\\\": \\\"world\\\"}\"}'\n{\"id\":\"6e975f1b-0c0f-4765-b24a-2aa87b901c06\"}\n","description":"Inserting task execution metadata:","language":"sh","lines":["curl -XPOST -H \"Content-Type: application/json\" localhost:8080/tasks/ -d '{\"duration\": \"10s\", \"exit_code\": 0, \"name\": \"Run task\", \"runbook_name\": \"RB 1\", \"runbook_run_id\": \"6e975f1b-0c0f-4765-b24a-2aa87b901c06\", \"start_time\": \"2022-05-05T04:12:43Z\", \"command\": \"/bin/sh\", \"args\": \"echo hello\", \"feedback\": \"this is cool!\", \"extra\": \"{\\\"hello\\\": \\\"world\\\"}\"}'"]},{"markdown":"A task can be patched:"},{"attributes":{"name":"patch-task"},"content":"$ curl -X PATCH -H \"Content-Type: application/json\" localhost:8080/tasks/6e975f1b-0c0f-4765-b24a-2aa87b901c06/ -d '{\"duration\": \"15s\", \"exit_code\": 1}'\n{\"id\":\"6e975f1b-0c0f-4765-b24a-2aa87b901c06\"}\n","description":"A task can be patched:","language":"sh","lines":["curl -X PATCH -H \"Content-Type: application/json\" localhost:8080/tasks/6e975f1b-0c0f-4765-b24a-2aa87b901c06/ -d '{\"duration\": \"15s\", \"exit_code\": 1}'"]},{"markdown":"### Feedback\n\nInserting feedback can optionally take a `task_id`:"},{"attributes":{"name":"post-feedback"},"content":"$ curl -XPOST -H \"Content-Type: application/json\" localhost:8080/feedback/ -d '{\"message\": \"My feedback!\", \"task_id\": \"6e975f1b-0c0f-4765-b24a-2aa87b901c06\"}'\n{\"id\":\"a02b6b5f-46c4-40ff-8160-ff7d55b8ca6f\"}\n","description":"Inserting feedback can optionally take a `task_id`:","language":"sh","lines":["curl -XPOST -H \"Content-Type: application/json\" localhost:8080/feedback/ -d '{\"message\": \"My feedback!\", \"task_id\": \"6e975f1b-0c0f-4765-b24a-2aa87b901c06\"}'"]},{"markdown":"Feedback can be patched:"},{"attributes":{"name":"patch-feedback"},"content":"$ curl -X PATCH -H \"Content-Type: application/json\" localhost:8080/feedback/a02b6b5f-46c4-40ff-8160-ff7d55b8ca6f/ -d '{\"message\": \"Modified!\"}'\n{\"id\":\"a02b6b5f-46c4-40ff-8160-ff7d55b8ca6f\"}\n","description":"Feedback can be patched:","language":"sh","lines":["curl -X PATCH -H \"Content-Type: application/json\" localhost:8080/feedback/a02b6b5f-46c4-40ff-8160-ff7d55b8ca6f/ -d '{\"message\": \"Modified!\"}'"]},{"markdown":"### Editor configs\n\nInserting editor configs:"},{"attributes":{"name":"post-editor-config"},"content":"$ curl -XPOST -H \"Content-Type: application/json\" localhost:8080/editor-configs/ -d '{\"data\": \"{\\\"files.autoSave\\\": \\\"afterDelay\\\"}\"}'\n{\"id\":\"4c7d6fb5-eb53-44f7-8883-80f276af65a1\"}\n","description":"Inserting editor configs:","language":"sh","lines":["curl -XPOST -H \"Content-Type: application/json\" localhost:8080/editor-configs/ -d '{\"data\": \"{\\\"files.autoSave\\\": \\\"afterDelay\\\"}\"}'"]}]}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"document":[{"markdown":"To deploy to production, run:"},{"content":"deployctl deploy --project=runme main.ts\n","description":"To deploy to production, run:","language":"sh","lines":["deployctl deploy --project=runme main.ts"]},{"markdown":"\u003cp align=\"center\"\u003e\u003csmall\u003eCopyright 2022 © \u003ca href=\"http://stateful.com/\"\u003eStateful\u003c/a\u003e – Apache 2.0 License\u003c/small\u003e\u003c/p\u003e"}]}