{"id":37172535,"url":"https://github.com/gogap/go-pandoc","last_synced_at":"2026-01-14T20:10:36.013Z","repository":{"id":84663631,"uuid":"118426357","full_name":"gogap/go-pandoc","owner":"gogap","description":"Run pandoc as a service","archived":false,"fork":false,"pushed_at":"2020-07-16T06:25:11.000Z","size":28,"stargazers_count":58,"open_issues_count":3,"forks_count":13,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-31T16:03:32.156Z","etag":null,"topics":["docker","pandoc","service"],"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/gogap.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":"2018-01-22T08:11:23.000Z","updated_at":"2024-08-01T05:06:48.000Z","dependencies_parsed_at":"2023-03-12T23:59:39.911Z","dependency_job_id":null,"html_url":"https://github.com/gogap/go-pandoc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gogap/go-pandoc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gogap%2Fgo-pandoc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gogap%2Fgo-pandoc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gogap%2Fgo-pandoc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gogap%2Fgo-pandoc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gogap","download_url":"https://codeload.github.com/gogap/go-pandoc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gogap%2Fgo-pandoc/sbom","scorecard":{"id":433839,"data":{"date":"2025-08-11","repo":{"name":"github.com/gogap/go-pandoc","commit":"7550ed141704d3dabfbed2584a81aa867c82a28c"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.9,"checks":[{"name":"Code-Review","score":1,"reason":"Found 1/9 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: containerImage not pinned by hash: Dockerfile:1: pin your Docker image by updating idocking/pandoc:alpine-2.1.1 to idocking/pandoc:alpine-2.1.1@sha256:519476f151c9b302c1272d1ddad58af17cdb431fd53e10aa7c554bebaf607277","Warn: goCommand not pinned by hash: Dockerfile:4-13","Info:   0 out of   1 containerImage dependencies pinned","Info:   0 out of   1 goCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 3 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T04:06:25.816Z","repository_id":84663631,"created_at":"2025-08-19T04:06:25.816Z","updated_at":"2025-08-19T04:06:25.816Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28434413,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T18:57:19.464Z","status":"ssl_error","status_checked_at":"2026-01-14T18:52:48.501Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["docker","pandoc","service"],"created_at":"2026-01-14T20:10:35.436Z","updated_at":"2026-01-14T20:10:36.004Z","avatar_url":"https://github.com/gogap.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"go-pandoc\n============\n\n# Run as a service\n\n## Run at local\n\n```bash\n\u003e go get github.com/gogap/go-pandoc\n\u003e cd $GOPATH/src/github.com/gogap/go-pandoc\n\u003e go build\n\u003e ./go-pandoc run -c app.conf\n```\n\n## Run at docker\n\n ```bash\n docker pull idocking/go-pandoc:latest\n docker run -it -d -p 8080:8080 idocking/go-pandoc:latest ./go-pandoc run\n ```\n\nor\n\n ```bash\n docker-compose up -d\n ```\n\n\u003e then you could access the 8080 port\n\u003e in osx, you could get the docker ip by command `docker-machine ip`, \n\u003e and the access service by IP:8080\n\n## Config\n\n`app.conf`\n\n```\n{\n\n\tservice {\n\t\tpath = \"/v1\"\n\t\t\n\t\tcors {\n\t\t\tallowed-origins = [\"*\"]\n\t\t}\n\n\t\tgzip-enabled = true\n\n\t\tgraceful {\n\t\t\ttimeout = 10s\n\t\t}\n\n\t\thttp {\n\t\t\taddress = \":8080\"\n\t\t\tenabled = true\n\t\t}\n\n\t\thttps {\n\t\t\taddress = \":443\"\n\t\t\tenabled = false\n\t\t\tcert    = \"\"\n\t\t\tkey     = \"\"\n\t\t}\n\n\t\ttemplates  {\n\t\t\trender-html {\n\t\t\t\ttemplate = \"templates/render_html.tmpl\"\n\t\t\t}\n\n\t\t\tbinary {\n\t\t\t\ttemplate = \"templates/binary.tmpl\"\n\t\t\t}\n\t\t}\n\t}\n\n\tpandoc {\n\n\t\tverbose     = false\n\t\ttrace       = false\n\t\tdump-args   = false\n\t\tignore-args = false\n\n        enable-filter = false\n\t\tenable-lua-filter = false\n\n\t\tsafe-dir = \"/app\"\n\n\t\tfetchers {\n\t\t\thttp {\n\t\t\t\tdriver = http\n\t\t\t\toptions {}\n\t\t\t}\n\n\t\t\tdata {\n\t\t\t\tdriver = data\n\t\t\t\toptions {}\n\t\t\t}\n\t\t}\n\t}\n}\n```\n\nq\n## API\n\n```json\n{\n    \"fetcher\": {\n        \"name\": \"data\",\n        \"params\": {\n            \"data\": \"base64String\"\n        }\n    },\n    \"converter\": {\n        \"from\": \"markdown\",\n        \"to\": \"pdf\",\n        \"standalone\": true,\n        \"variable\": {\n            \"CJKmainfont\": \"Source Han Sans SC\",\n            \"mainfont\": \"Source Han Sans SC\",\n            \"sansfont\": \"Source Han Sans SC\",\n            \"geometry:margin\": \"1cm\",\n            \"subject\": \"gsjbxx\"\n        },\n        \"metadata\":{\n\t    \t\"A\":[\"A\",\"B\",\"C\"],\n\t    \t\"D\":[\"Hello\", \"World\"]\n\t    },\n        \"template\": \"/app/data/docs.template\"\n    },\n    \"template\": \"binary\"\n}\n```\n\n\u003e The font Source Han Sans SC could download from\n\u003e https://github.com/adobe-fonts/source-han-sans/releases/tag/2.000R\n\n\n### Request Args\n\nField|Values|Usage\n:--|:--|:--\nfetcher ||if is nil, converter.uri could not be empty, it will pass to pandoc\nfetcher.name||fetcher name in `app.conf`\nfetcher.params ||different fetcher driver has different options\nconverter||the options for converter\n\n\n### converter\n\nthe converter is the following json struct\n\n\n```json\n{\n  \"from\":\"markdown\",\n  \"to\": \"pdf\",\n  \"pdf_engine\": \"xelatex\"\n   ...\n}\n```\n\n\u003e use `pandoc --help` command to list options\n\n\n### Use curl\n\n```bash\ncurl -X POST \\\n  http://IP:8080/v1/convert \\\n  -H 'accept-encoding: gzip' \\\n  -H 'cache-control: no-cache' \\\n  -H 'content-type: application/json' \\\n  -d '{\n\t\"fetcher\": {\n\t\t\"name\": \"data\",\n\t\t\"params\": {\n\t\t\t\"data\": \"IyMjIEhlbGxvCgo+IEdvLVBhbmRvYw==\"\n\t\t}\n\t},\n\t\"converter\":{\n\t\t\"from\": \"markdown\",\n\t    \"to\" : \"pdf\",\n\t    \"standalone\": true,\n\t    \"variable\":{\n\t    \t\"CJKmainfont\":\"Source Han Sans SC\",\n\t    \t\"mainfont\":\"Source Han Sans SC\",\n\t    \t\"sansfont\": \"Source Han Sans SC\",\n\t    \t\"geometry:margin\":\"1cm\",\n\t    \t\"subject\":\"gsjbxx\"\n\t    },\n\t    \"template\": \"/app/data/docs.template\"\n\t},\n\t\"template\": \"binary\"\n}' --compressed -o test.pdf\n```\n\n\u003e if you enabled gzip, you should add arg `--compressed` to curl\n\n### Template\n\nThe defualt template is \n\n```\n{\"code\":{{.Code}},\"message\":\"{{.Message}}\"{{if .Result}},\"result\":{{.Result|Jsonify}}{{end}}}\n```\n\nresponse example:\n\n\n```json\n{\"code\":0,\"message\":\"\",\"result\":{\"data\":\"bGl.............}}\n```\n\n\nwe could add `template` to render as different response, we have another example template named `render-data`\n\n\n```json\n{\n\t\"converter\":{\n\t\t...\n\t},\n\t\"template\": \"render-html\"\n}\n```\n\nthe response is \n\n```html\n\u003chtml\u003e\n\t\u003cbody\u003e\n\t     \t\u003cimg src=\"data:application/pdf;base64,bGl............\"/\u003e \n \t\u003c/body\u003e\n\u003c/html\u003e\n```\n\nSo, the template will render at brower directly. you could add more your templates\n\n#### Template funcs\n\nFunc|usage\n:--|:--\nbase64Encode|encode value to base64 string\nbase64Decode|decode base64 string to string\njsonify|marshal object\nmd5|string md5 hash\ntoBytes|convert value to []byte\nhtmlEscape|for html safe\nhtmlUnescape|unescape html\n\n#### Template Args\n\n```go\ntype TemplateArgs struct {\n\tFrom string\n\tTo   string\n\tConvertResponse\n\tResponse *RespHelper\n}\n\ntype ConvertResponse struct {\n\tCode    int         `json:\"code\"`\n\tMessage string      `json:\"message\"`\n\tResult  interface{} `json:\"result\"`\n}\n```\n\n#### Internal templates\n\n\u003e at templates dir\n\n\nName|Usage\n:--|:--\n |default template, retrun `code`,`message`, `result`\nrender-html|render data to html\nbinary|you cloud use curl to download directly\n\n##### use render-html\n\n```bash\ncurl -X POST \\\n  http://IP:8080/v1/convert \\\n  -H 'accept-encoding: gzip' \\\n  -H 'cache-control: no-cache' \\\n  -H 'content-type: application/json' \\\n  -d '{\n\t\"converter\":{\n\t\t...\n\t},\n\t\"template\": \"render-html\"\n}' --compressed -o bing.html\n```\n\n\n##### use binary\n\n```bash\ncurl -X POST \\\n  http://IP:8080/v1/convert \\\n  -H 'accept-encoding: gzip' \\\n  -H 'cache-control: no-cache' \\\n  -H 'content-type: application/json' \\\n  -d '{\n\t\"converter\":{\n\t\t...\n\t},\n\t\"template\": \"binary\"\n}' --compressed -o test.pdf\n```\n\n### Fetcher\n\nfetcher is an external source input, sometimes we could not fetch data by url, or the go-pandoc could not access the url because of some auth options\n\n##### Data fetcher\n\nthe request contain data\n\n\n```bash\ncurl -X POST \\\n  http://IP:8080/v1/convert \\\n  -H 'accept-encoding: gzip' \\\n  -H 'cache-control: no-cache' \\\n  -H 'content-type: application/json' \\\n  -d '{\n\t\"fetcher\": {\n\t\t\"name\": \"data\",\n\t\t\"params\": {\n\t\t\t\"data\": \"IyMjIEhlbGxvCgo+IEdvLVBhbmRvYw==\"\n\t\t}\n\t},\n\t\"converter\":{\n\t\t\"from\": \"markdown\",\n\t    \"to\" : \"pdf\",\n\t    \"standalone\": true,\n\t    \"variable\":{\n\t    \t\"CJKmainfont\":\"Source Han Sans SC\",\n\t    \t\"mainfont\":\"Source Han Sans SC\",\n\t    \t\"sansfont\": \"Source Han Sans SC\",\n\t    \t\"geometry:margin\":\"1cm\",\n\t    \t\"subject\":\"gsjbxx\"\n\t    },\n\t    \"template\": \"/app/data/docs.template\"\n\t},\n\t\"template\": \"binary\"\n}' --compressed -o test.pdf\n```\n\n```bash\n\u003e echo IyMjIEhlbGxvCgo+IEdvLVBhbmRvYw== | base64 -D\n\n\n### Hello\n\n\u003e Go-Pandoc\n\n```\n\nparams:\n\n\n```json\n{\n    \"data\":\"base64string\"\n}\n```\n\n\n#### HTTP fetcher\n\nFetch data by http driver\n\n```bash\ncurl -X POST \\\n  http://IP:8080/v1/convert \\\n  -H 'cache-control: no-cache' \\\n  -H 'content-type: application/json' \\\n  -d '{\n\t    \"fetcher\": {\n\t        \"name\": \"http\",\n\t        \"params\": {\n\t            \"url\": \"https://raw.githubusercontent.com/golang/go/master/README.md\"\n\t        }\n\t    },\n\t    \"converter\": {\n\t        \"from\": \"markdown\",\n\t        \"to\": \"pdf\",\n\t        \"standalone\": true,\n\t        \"template\": \"/app/data/docs.template\",\n\t        \"variable\": {\n\t            \"CJKmainfont\": \"Source Han Sans SC\",\n\t            \"mainfont\": \"Source Han Sans SC\",\n\t            \"sansfont\": \"Source Han Sans SC\",\n\t            \"geometry:margin\": \"1cm\",\n\t            \"subject\": \"gsjbxx\"\n\t        }\n\t    },\n\t    \"template\": \"render-html\"\n}' -o golang-readme.html\n```\n\n\u003e if the source contain image urls, it will not display correct, the image resource should be base64 format like:\n\n```markdown\n\n### Title\n\n- content\n\n#### Examle Image: \n![](data:image/png;base64,iVBORw.......)\n\n```\n\n\n\n#### Code your own fetcher\n\nstep 1: Implement the following interface\n\n```go\ntype Fetcher interface {\n\tFetch(FetchParams) ([]byte, error)\n}\n\nfunc NewDataFetcher(conf config.Configuration) (dataFetcher fetcher.Fetcher, err error) {\n\tdataFetcher = \u0026DataFetcher{}\n\treturn\n}\n\n```\n\nstep 2: Reigister your driver\n\n```go\nfunc init() {\n\terr := fetcher.RegisterFetcher(\"data\", NewDataFetcher)\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n}\n```\n\nstep 3: import driver and rebuild\n\n```go\nimport (\n\t_ \"github.com/gogap/go-pandoc/pandoc/fetcher/data\"\n\t_ \"github.com/gogap/go-pandoc/pandoc/fetcher/http\"\n)\n```\n\n\u003e make sure the register name is unique\n\n\n\n# Use this package as libary\n\nJust import `github.com/gogap/go-pandoc/pandoc`\n\n```go\npdoc, err := pandoc.New(conf)\n//...\n//...\nconvData, err := pdoc.Convert(fetcherOpts, convertOpts)\n```\n\n\n## QA\n\n#### How could I pass the `FILE` type args\n\n1. use url `http://` or `https://`\n2. use `file://`, the file should be in `SafeDir`\n3. use `data:image/jpeg;base64,/9j/4AAQSkZJRgABA`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgogap%2Fgo-pandoc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgogap%2Fgo-pandoc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgogap%2Fgo-pandoc/lists"}