pdtmpl

A light weight pre-processor for Pandoc. Target use case is JSON object documents rendered via Pandoc templates.

https://github.com/rsdoiel/pdtmpl

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.2%) to scientific vocabulary
Last synced: 6 months ago · JSON representation ·

Repository

A light weight pre-processor for Pandoc. Target use case is JSON object documents rendered via Pandoc templates.

Basic Info
Statistics
  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created over 3 years ago · Last pushed over 1 year ago
Metadata Files
Readme License Citation Codemeta

README.md

Project Status: Concept – Minimal or no implementation has been done yet, or the repository is only intended to be a limited example, demo, or proof-of-concept.

pdtmpl

A light weight pre-processor for Pandoc. Target use case is JSON object documents rendered via Pandoc templates. Target use case is Markdown document with embedded "form" YAML elements.

This is a proof-of-concept Go package which makes it easy to extend your Go application to incorporate Pandoc template processing. It includes the Go package and an example command line tool (cli).

cli

The command line implementation is a proof of concept Pandoc pre-processor in Go. An example usage would be to process example.json JSON document using a Pandoc template called example.tpml.

~~~shell pdtmpl tmpl example.tmpl < example.json > example.html ~~~

Render a Markdown file with an embedded YAML block describing a webform via Pandoc.

~~~shell pdtmpl webform < document.md | pandoc -f Markdown -t html5 -s ~~~

The Markdown file "document.md" would have a simple web form described via YAML. This oleviates the need to embed HTML. Here's an example of embedding a "search" form in a "document.md"

~~~markdown

A search page ...

This is followed by my form.


form: id: search action: /search method: POST elements: - id: search type: search placeholdertext: enter a search string here - id: submit name: submit type: submit

value: Search

Other text could follow the YAML block.

~~~

When pltmpl webform processes this turns the form object into HTML markup. form describes the outer HTML form element who's attributes also map (e.g. aciton, method). Additionally the form as an "elements" attribute which is a list of HTML elements that are children of the form element. The YAML notations provides a cleaner expression of the webform by avoiding the HTML markdown but clear maps from the HTML markup.

Go package

Here's some simple use examples of the three functions supplied in the pdtmpl package.

Given a JSON Object document as a slice of bytes render formated output based on the Pandoc template example.tmpl

~~~go src, err := ioutil.ReadFile("example.json") if err != nil { // ... handle error } // options passed to Pandoc opt := []string{} src, err = pdtmpl.Apply(src, "example.tmpl", opt) if err != nil { // ... handle error } fmt.Fprintf(os.Stdout, "%s", src) ~~~

Using an io.Reader to retrieve the JSON content, process with the example.tmpl template and write standard output

~~~go f, err := Open("example.json") if err != nil { // ... handle error } defer f.Close() // options passed to Pandoc opt := []string{} src, err := pdtmpl.ReadAll(f, "example.tmpl", opt) if err != nil { // ... handle error } fmt.Fprintf(os.Stdout, "%s", src) ~~~

Using an io.Reader and io.Writer to read JSON source from standard input and write the processed pandoc templated standard output.

~~~go // options passed to Pandoc opt := []string{} err := pdtmpl.ApplyIO(os.Stdin, os.Stdout, "example.tmpl", opt) if err != nil { // ... handle error } ~~~

Requirements

  • Pandoc 2.18 or better
  • Go 1.22 or better to compile from source
  • GNU Make (optional) to automated compilation
  • Git or other Git client to retrieve this repository

Installation

  1. Clone https://github.com/rsdoiel/pdtmpl to your local machine
  2. Change directory into the git repository (i.e. pdtmpl
  3. Compile using make
  4. Install using make install

~~~shell git clone https://github.com/rsdoiel/pdtmpl cd pdtmpl make make install ~~~

NOTE: This recipe assumes' you are familar with setting up a Go development environment (e.g. You've set GOPATH environment appropriately). See the go website for details about setting up and compiler programs.

License

AGPL version 3 or later

Owner

  • Name: R. S. Doiel
  • Login: rsdoiel
  • Kind: user
  • Location: California
  • Company: California Institute of Technology

I am a human. Once upon a time I wrote music and prose. I write software.

Citation (CITATION.cff)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
type: software
title: "pdtmpl"
abstract: "A light weight pre-processor for Pandoc. Target use case is
JSON object documents rendered via Pandoc templates."
authors:
  - family-names: Doiel
    given-names: R. S.
    orcid: "https://orcid.org/0000-0003-0900-6903"



repository-code: "https://github.com/rsdoiel/pdtmpl"
version: 0.0.2
license-url: "https://spdx.org/licenses/AGPL-3.0-or-later"

CodeMeta (codemeta.json)

{
  "@context": "https://doi.org/10.5063/schema/codemeta-2.0",
  "@type": "SoftwareSourceCode",
  "license": "https://spdx.org/licenses/AGPL-3.0-or-later",
  "codeRepository": "https://github.com/rsdoiel/pdtmpl",
  "dateCreated": "2022-07-08",
  "dateModified": "2024-05-20",
  "issueTracker": "https://github.com/rsdoiel/pdtmpl/issues",
  "name": "pdtmpl",
  "version": "0.0.2",
  "description": "A light weight pre-processor for Pandoc. Target use case is JSON object documents rendered via Pandoc templates.",
  "releaseNotes": "updated license to AGPL v3 later",
  "applicationCategory": "web publishing",
  "programmingLanguage": [
    "Go"
  ],
  "operatingSystem": [
    "Linux",
    "Windows 11",
    "macOS"
  ],
  "softwareRequirements": [
    "Pandoc 2.18 or better",
    "Go 1.22 or better"
  ],
  "author": [
    {
      "@type": "Person",
      "@id": "https://orcid.org/0000-0003-0900-6903",
      "givenName": "R. S.",
      "familyName": "Doiel",
      "email": "rsdoiel@gmail.com"
    }
  ]
}

GitHub Events

Total
  • Push event: 2
Last Year
  • Push event: 2

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads: unknown
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 2
proxy.golang.org: github.com/rsdoiel/pdtmpl

pdtmpl.go is a preprocessor package for Pandoc. The driving use case is passing JSON or YAML documents to Pandoc and applying a Pandoc template. @Author R. S. Doiel, <rsdoiel@gmail.com> copyright 2022 R. S. Doiel All rights reserved. License under the 3-Clause BSD License See https://opensource.org/licenses/BSD-3-Clause

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 7.0%
Average: 8.2%
Dependent repos count: 9.3%
Last synced: 6 months ago

Dependencies

go.mod go
  • gopkg.in/yaml.v3 v3.0.1
go.sum go
  • gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405
  • gopkg.in/yaml.v3 v3.0.1