{"id":13446277,"url":"https://github.com/campoy/embedmd","last_synced_at":"2025-10-06T12:44:02.030Z","repository":{"id":9452824,"uuid":"62099451","full_name":"campoy/embedmd","owner":"campoy","description":"embedmd: embed code into markdown and keep everything in sync","archived":false,"fork":false,"pushed_at":"2024-03-19T15:21:09.000Z","size":11736,"stargazers_count":778,"open_issues_count":13,"forks_count":65,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-04-12T02:57:32.293Z","etag":null,"topics":["golang","markdown","utility"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/campoy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-06-28T01:16:46.000Z","updated_at":"2025-03-14T01:14:54.000Z","dependencies_parsed_at":"2024-06-18T12:26:45.795Z","dependency_job_id":null,"html_url":"https://github.com/campoy/embedmd","commit_stats":{"total_commits":56,"total_committers":11,"mean_commits":5.090909090909091,"dds":0.4107142857142857,"last_synced_commit":"97c13d6e41602fc6e397eb51c45f38069371a969"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/campoy%2Fembedmd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/campoy%2Fembedmd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/campoy%2Fembedmd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/campoy%2Fembedmd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/campoy","download_url":"https://codeload.github.com/campoy/embedmd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254170059,"owners_count":22026219,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","markdown","utility"],"created_at":"2024-07-31T05:00:50.335Z","updated_at":"2025-10-06T12:43:56.997Z","avatar_url":"https://github.com/campoy.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/campoy/embedmd.svg)](https://travis-ci.org/campoy/embedmd) [![Go Report Card](https://goreportcard.com/badge/github.com/campoy/embedmd)](https://goreportcard.com/report/github.com/campoy/embedmd)\n\n\n# embedmd\n\nAre you tired of copy pasting your code into your `README.md` file, just to\nforget about it later on and have unsynced copies? Or even worse, code\nthat does not even compile?\n\nThen `embedmd` is for you!\n\n`embedmd` embeds files or fractions of files into Markdown files. It does\nso by searching `embedmd` commands, which are a subset of the Markdown\nsyntax for comments. This means they are invisible when Markdown is\nrendered, so they can be kept in the file as pointers to the origin of\nthe embedded text.\n\nThe command receives a list of Markdown files. If no list is given, the command\nreads from the standard input.\n\nThe format of an `embedmd` command is:\n\n```Markdown\n[embedmd]:# (pathOrURL language /start regexp/ /end regexp/)\n```\n\nThe embedded code will be extracted from the file at `pathOrURL`,\nwhich can either be a relative path to a file in the local file\nsystem (using always forward slashes as directory separator) or\na URL starting with `http://` or `https://`.\nIf the `pathOrURL` is a URL the tool will fetch the content in that URL.\nThe embedded content starts at the first line that matches `/start regexp/`\nand finishes at the first line matching `/end regexp/`.\n\nOmitting the the second regular expression will embed only the piece of text\nthat matches `/regexp/`:\n\n```Markdown\n[embedmd]:# (pathOrURL language /regexp/)\n```\n\nTo embed the whole line matching a regular expression you can use:\n\n```Markdown\n[embedmd]:# (pathOrURL language /.*regexp.*/)\n```\n\nTo embed from a point to the end you should use:\n\n```Markdown\n[embedmd]:# (pathOrURL language /start regexp/ $)\n```\n\nTo embed a whole file, omit both regular expressions:\n\n```Markdown\n[embedmd]:# (pathOrURL language)\n```\n\nYou can omit the language in any of the previous commands, and the extension\nof the file will be used for the snippet syntax highlighting.\n\nThis works when the file extensions matches the name of the language (like Go\nfiles, since `.go` matches `go`). However, this will fail with other files like\n`.md` whose language name is `markdown`.\n\n```Markdown\n[embedmd]:# (file.ext)\n```\n\n## Installation\n\n\u003e You can install Go by following [these instructions](https://golang.org/doc/install).\n\n`embedmd` is written in Go, so if you have Go installed you can install it with\n`go get`:\n\n```\ngo get github.com/campoy/embedmd\n```\n\nThis will download the code, compile it, and leave an `embedmd` binary\nin `$GOPATH/bin`.\n\nEventually, and if there's enough interest, I will provide binaries for\nevery OS and architecture out there ... _eventually_.\n\n## Usage:\n\nGiven the two files in [sample](sample):\n\n*hello.go:*\n\n[embedmd]:# (sample/hello.go)\n```go\n// Copyright 2016 Google Inc. All rights reserved.\n// Use of this source code is governed by the Apache 2.0\n// license that can be found in the LICENSE file.\n\npackage main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n)\n\nfunc main() {\n\tfmt.Println(\"Hello, there, it is\", time.Now())\n}\n```\n\n*docs.md:*\n\n[embedmd]:# (sample/docs.md Markdown /./ /embedmd.*time.*/)\n```Markdown\n# A hello world in Go\n\nGo is very simple, here you can see a whole \"hello, world\" program.\n\n[embedmd]:# (hello.go)\n\nWe can try to embed a file from a directory.\n\n[embedmd]:# (test/hello.go /func main/ $)\n\nYou always start with a `package` statement like:\n\n[embedmd]:# (hello.go /package.*/)\n\nFollowed by an `import` statement:\n\n[embedmd]:# (hello.go /import/ /\\)/)\n\nYou can also see how to get the current time:\n\n[embedmd]:# (hello.go /time\\.[^)]*\\)/)\n```\n\n# Flags\n\n* `-w`: Executing `embedmd -w docs.md` will modify `docs.md`\nand add the corresponding code snippets, as shown in\n[sample/result.md](sample/result.md).\n\n* `-d`: Executing `embedmd -d docs.md` will display the difference\nbetween the contents of `docs.md` and the output of\n`embedmd docs.md`.\n\n### Disclaimer\n\nThis is not an official Google product (experimental or otherwise), it is just\ncode that happens to be owned by Google.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcampoy%2Fembedmd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcampoy%2Fembedmd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcampoy%2Fembedmd/lists"}