Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

format svg option disappears text #66

Open
fdq09eca opened this issue Apr 28, 2021 · 6 comments
Open

format svg option disappears text #66

fdq09eca opened this issue Apr 28, 2021 · 6 comments

Comments

@fdq09eca
Copy link

fdq09eca commented Apr 28, 2021

```{.mermaid width=300 format=svg}
graph TD
   a((3, 1)) --> b 
   a((3, 1)) --> d 
   b((3, 2)) --> c 
   b((3, 2)) --> e 
   d((2, 1)) --> g
   c((3, 3)) --> f[2, 3]
   g((1, 1)) --> h 
   e((2, 2))
   h((1, 2)) --> i[1, 3] 
```

the above code snippet produces the following when I turn it into .pdf with the following pandoc cmd:

pandoc 2018-19-v1.md --pdf-engine=pdflatex -o 2018-19v1.pdf --filter mermaid-filter

image

the following mermaid produces the diagram normally with the same pandoc cmd

```mermaid
graph TD
   a((3, 1)) --> b %% 1
   a((3, 1)) --> d %% 1
   b((3, 2)) --> c %% visit b 1st then d becoz b cost < d cost
   b((3, 2)) --> e 
   d((2, 1)) --> g
   c((3, 3)) --> f[2, 3]
   g((1, 1)) --> h %% visit g 1st then e: becoz g_x < e_x
   e((2, 2))
   h((1, 2)) --> i[1, 3] %% visit i 1st then f becoz h_x < f_x
```

image

@john-d-murphy
Copy link

john-d-murphy commented Sep 26, 2021

I see the same issue when using the svg option for any graph that requires text.

@mesaquen
Copy link

@fdq09eca For now, as a workaround you can use format=pdf. It did the trick for me.

@26huitailang
Copy link

gitGraph the same problem with format=svg

@Menchen
Copy link

Menchen commented Dec 16, 2021

@fdq09eca For now, as a workaround you can use format=pdf. It did the trick for me.

I just tried format=pdf and got error with --pdf-engine=xelatex, I got it working by patching the filter manually and I think it's might help someone else.

Error producing PDF.
! Unable to load picture or PDF file '/private/var/folders/79/y1_gqzxx47g93kdrt
1lryp740000gn/T/tmp.z11Cdyupv8/tex2pdf.-6291c7ad0e584f21/928567e026eb8398e14a84
84a8c4677a81bf400c.png'.
<to be read again>
                   }
l.894 ...67e026eb8398e14a8484a8c4677a81bf400c.png}

It seems that patching the filter it works by passing the pdf path directy(Start at line 83):

    if (options.loc == 'inline') {
        if (options.format === 'svg') {
            var data = fs.readFileSync(savePath, 'utf8')
            newPath = "data:image/svg+xml;base64," + new Buffer(data).toString('base64');
        } else if(options.format === 'pdf'){
            newPath = savePath;
        }
        else  {
            var data = fs.readFileSync(savePath)
            newPath = 'data:image/png;base64,' + new Buffer(data).toString('base64');
        }

@andreilgeorgescu
Copy link

@fdq09eca For now, as a workaround you can use format=pdf. It did the trick for me.

Thanks! This worked for me, but only after changing it from the default inline location to a folder by adding loc=figures.

@leg7
Copy link

leg7 commented May 23, 2024

Format pdf works for me. Maybe this should be the default format since png can't scale anyways?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants