Coder Social home page Coder Social logo

nielsvaneck / render-md-mermaid Goto Github PK

View Code? Open in Web Editor NEW
17.0 17.0 16.0 740 KB

GitHub Action & Utility for rendering Mermaid-JS diagrams in Markdown files for display on GitHub

License: Apache License 2.0

Makefile 17.31% Shell 77.49% Dockerfile 5.21%

render-md-mermaid's Introduction

Hi there ๐Ÿ‘‹

render-md-mermaid's People

Contributors

danielloader avatar fty4 avatar lemmah avatar nielsvaneck avatar quidryan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

render-md-mermaid's Issues

error: env: can't execute 'bash': No such file or directory

On my first workflow run, I got this error:

env: can't execute 'bash': No such file or directory

...probably because something could have changed in the mermaid-js latest docker image that this project uses as base image.
I was able to resolve it by installing bash and perl in my fork.

How to setup on tree structure defaults working directory?

My repository structure is like below:

  • parent
    • .github/workflows\render-md-mermaid.yml
    • child1 <--- just for this specific child1 folder
      • images
        • child1_child
          • README.md <---
        • README.md <---
    • child2
      - README.md
    • ...
    • README.md
...
on: 
  push:
    paths:
      - child1/**
jobs:
  render-md-mermaid:
    runs-on: ubuntu-latest
    defaults:
      run:
         working-directory: ./child1 # not working

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Render images for every Mermaid diagram in all Markdown files (*.md) in the repo
        uses: nielsvaneck/render-md-mermaid@v1

      - name: Commit rendered png and svg files
        uses: stefanzweifel/git-auto-commit-action@v4
        with:
          repository: ./child1/images
          commit_message: automatically rendered mermaid diagrams

Is there a solution to have a specific working directory with args?
I tried to clone your git repository and change shell find script in 'render-md-mermaid.mk'.
The action works successful but didn't create png and svg.

Timestamp used in svg

Files will be updated by the workflow even if there is no change on the mermaid diagram.

Problem here is the unix timestamp is included in the SVG style tag:

- <style>#mermaid-1672838800238
+ <style>#mermaid-1672838865273

This will result in changed SVG files even if there is no actual change.
A commit should then not be triggered.

One approach would be to use sed and the #mermaid- name could be unified and replaced?

    if [[ "$image_file" =~ ^.*\.svg$ ]]; then
        sed -i.bak -e 's/<br>/<br\/>/g' $image_file
+       sed -i -e 's/mermaid-[0-9]*/mermaid/g' $image_file
    fi

I guess the mermaid-cli does not have the option:

$ ./node_modules/.bin/mmdc -h
Usage: mmdc [options]

Options:
  -V, --version                                   output the version number
  -t, --theme [theme]                             Theme of the chart (choices: "default", "forest", "dark", "neutral", default: "default")
  -w, --width [width]                             Width of the page (default: 800)
  -H, --height [height]                           Height of the page (default: 600)
  -i, --input <input>                             Input mermaid file. Files ending in .md will be treated as Markdown and all charts (e.g. ```mermaid (...)```) will be extracted and generated. Required.
  -o, --output [output]                           Output file. It should be either md, svg, png or pdf. Optional. Default: input + ".svg"
  -e, --outputFormat [format]                     Output format for the generated image. (choices: "svg", "png", "pdf", default: Loaded from the output file extension)
  -b, --backgroundColor [backgroundColor]         Background color for pngs/svgs (not pdfs). Example: transparent, red, '#F0F0F0'. (default: "white")
  -c, --configFile [configFile]                   JSON configuration file for mermaid.
  -C, --cssFile [cssFile]                         CSS file for the page.
  -s, --scale [scale]                             Puppeteer scale factor (default: 1)
  -f, --pdfFit [pdfFit]                           Scale PDF to fit chart
  -q, --quiet                                     Suppress log output
  -p --puppeteerConfigFile [puppeteerConfigFile]  JSON configuration file for puppeteer.
  -h, --help                                      display help for command

.

.

bash is not present in v2

Is this maintained? v2 doesn't really work, as bash is not present and whole thing crashes. Any hope for an update?

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.