Giter Club home page Giter Club logo

markdown's Introduction

โš ๏ธ This repository contains prototype PDF templating tools for easily using Markdown as source-of-truth for TCG docs. They are currently experimental and not official, final, nor approved.

How to use this for your document (GitHub)

Create a private repository based on the example template repository, or set up the GitHub action in any repository using the instructions below.

Document metadata

Write normal Markdown, with a YAML document metadata block at the top, containing the relevant metadata.

---
title: "Document Title"
version: 0.1
revision: 1
date: 2022/09/17
type: SPECIFICATION
status: DRAFT
...

status can be any string, but if it is DRAFT then the tool will render a watermark on the PDF.

status: DRAFT

You can specify either the bluetop or greentop (default) cover backgrounds with the following optional YAML metadata field:

template: bluetop

or

template: greentop

Separators and page breaks

Horizontal separators are transformed by the workflow into page breaks for readability in both GitHub and PDF views.

---

Tables of contents, figures, and tables

Provide a table of contents, list of figures, and list of tables anywhere (usually, after the disclaimers, change history, and document-style remarks) in the document with:

---

\tableofcontents

\listoffigures

\listoftables

---

Tables

Tables in Markdown look like the following:

| **Revision** | **Date**   | **Description** |
| ------------ | ---------- | --------------- |
| 0.1/1        | 2022/09/17 | Initial draft   |
Revision Date Description
0.1/1 2022/09/17 Initial draft

Informative text blocks

TCG makes use of a gray box for "informative text." To write informative text in your Markdown source, use the block-quote syntax:

> Informative text goes here!
>
> It can be multiple paragraphs, if you wish.

It will look like this in the GitHub markdown view:

Informative text goes here!

It can be multiple paragraphs, if you wish.

The tool will insert the "Start of informative text" / "End of informative text" delimiters into the informative text blocks automatically.

Diagrams

You can include diagrams using Mermaid syntax:

```mermaid {caption="Sequence Diagram A"}
sequenceDiagram
Host->>TPM: TPM2_Startup
loop Measurements
    Host->>TPM: TPM2_PCR_Extend
end
Host->>TPM: TPM2_Quote
TPM->>Host: <quoted PCRs>
```

The code above generates a diagram that looks like this:

sequenceDiagram
Host->>TPM: TPM2_Startup
loop Measurements
    Host->>TPM: TPM2_PCR_Extend
end
Host->>TPM: TPM2_Quote
TPM->>Host: <quoted PCRs>
Loading

In the example above, "Sequence Diagram A" is the name shown in the figure caption and table of figures. To exclude the caption and table-of-figures entry, leave out the caption on the first line, i.e. just:

```mermaid

Mermaid supports the following types of diagrams:

  • Sequence diagrams (as above)
  • Flow charts
  • Gantt charts
  • UML class diagrams
  • Git branch graphs
  • And more

Images

You can also include images if you check them into the root of the repository. Note: GitHub and Pandoc disagree somewhat on the paths to images, so the safest path to success is to keep the Markdown source and image files all together in the root of the repository.

![Image B](computer.jpg)

produces:

Image B

In the example above, "Image B" is the name shown in the figure caption and table of figures. To exclude the caption and table-of-figures entry, leave the caption blank (i.e., ![](computer.jpg))

See the samples in the root directory for more examples.

Here is an example of a GitHub Action configuration that renders a Markdown file to PDF, attaches it to the workflow, and checks it into the repo (if not a pull request):

Setting up the GitHub action

name: Render

on:
  push:
    branches:
      - main
  pull_request:
  workflow_dispatch:

jobs:
  render:
    runs-on: ubuntu-latest
    container:
      image: ghcr.io/trustedcomputinggroup/pandoc:0.3.0
    name: Render PDF
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Render
        uses: trustedcomputinggroup/[email protected]
        with:
          input-md: main.md
          output-pdf: spec.pdf

      - name: Upload samples
        uses: actions/upload-artifact@master
        with:
          name: spec.pdf
          path: spec.pdf

      - name: Check in latest render
        uses: stefanzweifel/git-auto-commit-action@v4
        with:
          commit_message: Generate latest PDF
          file_pattern: spec.pdf
        if: github.event_name != 'pull_request'

How to use this for your document (Local)

Either clone the repository and install Pandoc and its dependencies, or

docker pull ghcr.io/trustedcomputinggroup/markdown:latest

When running Pandoc (either directly or using docker run), you'll have to pass all the arguments that the action does.

How to contribute to this template

Send a PR! A GitHub Action in this repo will automatically run the tools with all your changes on top. You can find the rendered samples under "action validation" in the "checks" tab of your PR: image

markdown's People

Contributors

chrisfenner avatar

Stargazers

 avatar Marcel Maatkamp avatar

Watchers

 avatar Dennis Mattoon avatar

markdown's Issues

informative text blocks

Is it supposed to look like:

**start of informative comment**
my informative comment
**end of informatrive comment**

image

Footer is slightly misaligned

For some reason, the copyright TCG line is about a pixel or so higher than the rest of the footer material. Drives me a little nuts.

image

Feature requests

I can think of a few basic obvious features we need to support:

  • Ensure that embedding images is easy and provide an example
  • Support diagrams using e.g. mermaid
  • Support (and provide an example) images + diagrams as figures (with a list-of-figures)
  • Make the tables nicer (it's the most old-school LaTeX looking part of this template)

References don't render nicely

This markdown:

# References

[1] Trusted Computing Group, "DICE Protection Environment," 2023. [Online].
    Available: https://trustedcomputinggroup.org.

[2] Trusted Computing Group, "DICE Certificate Profiles," 2020. [Online].
    Available: https://trustedcomputinggroup.org.

[3] Internet Engineering Task Force, "Cryptographic Message Syntax (CMS)," 2009. [Online].
    Avilable: https://www.ietf.org/rfc/rfc5652.txt

[4] Internet Engineering Task Force, "PKCS #10: Certification Request Syntax Specification Version 1.7," 2000. [Online].
    Avilable: https://www.ietf.org/rfc/rfc2986.txt

Renders like this:

Screenshot 2023-03-23 at 5 21 04 PM

A couple issues:

  • Spacing is a bit tight. I'm not sure if there's a good way to artificially add more spacing
  • The margin wrapping doesn't seem to be working correctly. See how the link doesn't wrap in reference 3, but the wrapping does work in reference 4

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.