Giter Site home page Giter Site logo

mdtopdf's Issues

Panic when table has an empty heading cell

A table like this:

|       | head2 | head3 |
| ----- | ----- | ----- |
| 1     | 2     | 3     |

causes a panic. As far as I know, it's legal markdown to have an empty heading cell, but not sure. I've never had a problem rendering it in any other way or converting it to PDF with pandoc, vscode extensions, etc.

Table support

Need to review gofpdf examples (if any) of creating tables. BlackFriday provides events for:

  • table
  • table head
  • table body
  • table row
  • table cell

I have not yet tested the BF support for tables... so that should be the first action - make sure it really works.

md2pdf_trace.log by default

I noticed that the tool creates an output trace file by default. This isn't ideal, since the trace contains the contents of the file and leaves it on the system.

Consider using gofpdf

Note that github.com/jung-kurt/gofpdf is no longer being maintained, whereas github.com/go-pdf/fpdf is a drop-in replacement (I have done so on my local copy), that is being actively maintained and has performance enhancements.

Installing latest binary results with binary named "cmd", not "mdtopdf"

@jessp01 - am I doing something wrong? Below is a transcript.

$ echo $GOBIN
/home/cecil/go/bin
$ go install github.com/mandolyte/mdtopdf/cmd@latest
$ mdtopdf -h
-bash: mdtopdf: command not found
$ ls $GOBIN
catcsv      csvq      gomodifytags  impl         reordercsv        staticcheck
cmd         dedupcsv  goplay        pivotcsv     simplehttpserver  transformcsv
comparecsv  diffcsv   gopls         recursecsv   sortcsv
convert     dlv       gotests       recursedata  splitcsv
$ cmd -h
Usage of cmd:
  -author string
        Author; used if -footer is passed
  -font-file string
        path to font file to use
  -font-name string
        Font name ID; e.g 'Helvetica-1251'
  -help
        Show usage message
  -i string
        Input filename or HTTP(s) URL; default is os.Stdin
  -new-page-on-hr
        Interpret HR as a new page; useful for presentations
  -o string
        Output PDF filename; required
  -orientation string
        [portrait | landscape] (default "portrait")
  -page-size string
        [A3 | A4 | A5] (default "A4")
  -s string
        Path to github.com/jessp01/gohighlight/syntax_files
  -theme string
        [light|dark] (default "light")
  -title string
        Presentation title
  -unicode-encoding string
        e.g 'cp1251'
  -with-footer
        Print doc footer (author  title  page number)
$ go install github.com/mandolyte/mdtopdf/cmd/mdtopdf@latest
go: github.com/mandolyte/mdtopdf/cmd/mdtopdf@latest: module github.com/mandolyte/mdtopdf@latest found (v1.5.0), but does not contain package github.com/mandolyte/mdtopdf/cmd/mdtopdf
$ 

could not locate "helveticaBB"

Problem

While working with this library I found an interesting case. If you create this markdown

### **Email:** issuer\_email

and when you try to convert, you will get an error:

➜  go run convert.go -i bad-markdown.md -o result.pdf 
2023/01/20 16:37:07 pdf.OutputFileAndClose() error:Pdf.OutputFileAndClose() error on result.pdf:could not locate "helveticaBB" among embedded core font definition files

Additional info
My understanding, gotopdf missing some fonts for italic headers

Incorrect url in the readme.md

In the Syntax Highlighting section, in the README.md file, the link to gohighlight module is incorrect (https://github.com/mandolyte/mdtopdf/blob/master/github.com/jessp01/gohighlight) which causes a 404.

Truncation of lines in long code blocks

Try converting a markdown document with a wide line in the code block:

This line is really quite long, long and even more long so that the text reaches the edge of the page. More and more and more.

It is expected that either the text is wrapped or the code block font size adjusted to accommodate the width of the line.

Instead, the text goes outside of the edge of the grey code block box and gets truncated.

Thanks and...

This project is awesome, thank you! We gophers are just too awesome!

Would it ever make sense to do a "dark mode" feature or better yet have a pluggable palette of 3-4 colors. :D

Thanks again,
Drew

get the latest version

Hi author, I noticed that the latest version has reached v2.2.4, but when I go get it, I only get v1.5.3, is there any way to use the latest code

Needed changes in light of the creation of v2

Hi @mandolyte ,

Since we're now on v2, some structure changes are required as, when one runs:

go install github.com/mandolyte/mdtopdf/cmd/md2pdf@latest

The received version is v1.5.3, not v2.2.1.

When trying to explicitly install v2.2.1:

$ go install github.com/mandolyte/mdtopdf/cmd/[email protected]

One would get this message:

go: github.com/mandolyte/mdtopdf/cmd/[email protected]: github.com/mandolyte/[email protected]: invalid version: module contains a go.mod file, so module path must match major version ("github.com/mandolyte/mdtopdf/v2")

Please see https://go.dev/blog/v2-go-modules

Happy to help with the restructure if you'd like.

Cheers,

Panic when markdown has dollar signs in it

The following markdown doc causes mdtopdf to panic:

Bob had $20 and but lost $10.

The panic is:

$ ./md2pdf -i  /tmp/foo.md  -o /tmp/out.md.pdf
panic: Unknown node type *ast.Math

goroutine 1 [running]:
github.com/mandolyte/mdtopdf.(*PdfRenderer).RenderNode(0x4000030800?, {0x0?, 0x40001a1b08?}, {0x45ac90?, 0x4000020aa0?}, 0xc0?)
        /home/psanford/projects/thirdparty/mdtopdf/mdtopdf.go:454 +0x5e4
github.com/gomarkdown/markdown.Render.func1({0x45ac90?, 0x4000020aa0?}, 0x80?)
        /home/psanford/.cache/gopath/pkg/mod/github.com/gomarkdown/[email protected]/markdown.go:63 +0x50
github.com/gomarkdown/markdown/ast.NodeVisitorFunc.Visit(0x4000172840?, {0x45ac90?, 0x4000020aa0?}, 0x68?)
        /home/psanford/.cache/gopath/pkg/mod/github.com/gomarkdown/[email protected]/ast/node.go:574 +0x38
github.com/gomarkdown/markdown/ast.Walk({0x45ac90, 0x4000020aa0}, {0x457420, 0x400007b3e0})
        /home/psanford/.cache/gopath/pkg/mod/github.com/gomarkdown/[email protected]/ast/node.go:546 +0x58
github.com/gomarkdown/markdown/ast.Walk({0x45a430, 0x4000172840}, {0x457420, 0x400007b3e0})
        /home/psanford/.cache/gopath/pkg/mod/github.com/gomarkdown/[email protected]/ast/node.go:557 +0x144
github.com/gomarkdown/markdown/ast.Walk({0x45a3e8, 0x40001727e0}, {0x457420, 0x400007b3e0})
        /home/psanford/.cache/gopath/pkg/mod/github.com/gomarkdown/[email protected]/ast/node.go:557 +0x144
github.com/gomarkdown/markdown/ast.WalkFunc(...)
        /home/psanford/.cache/gopath/pkg/mod/github.com/gomarkdown/[email protected]/ast/node.go:580
github.com/gomarkdown/markdown.Render({0x45a3e8, 0x40001727e0}, {0x458c20, 0x40001d0000})
        /home/psanford/.cache/gopath/pkg/mod/github.com/gomarkdown/[email protected]/markdown.go:62 +0xd0
github.com/mandolyte/mdtopdf.(*PdfRenderer).Run(0x40001d0000, {0x400003e200?, 0x242?, 0x40001a1d30?})
        /home/psanford/projects/thirdparty/mdtopdf/mdtopdf.go:344 +0xb4
github.com/mandolyte/mdtopdf.(*PdfRenderer).Process(0x40001d0000, {0x400003e200?, 0x1e?, 0x200?})
        /home/psanford/projects/thirdparty/mdtopdf/mdtopdf.go:318 +0x1b8
main.main()
        /home/psanford/projects/thirdparty/mdtopdf/cmd/md2pdf/md2pdf.go:157 +0x9fc

Seems like the issue is that you have enabled the MathJax extension via parser.CommonExtensions but you don't actually support those AST types.

I'm not trying to use MathJax so it would be nice if there was an option to override the markdown extensions enabled.

Does it support non latin characters?

source
Влюбиться можно в красоту, но полюбить – лишь только душу!

result
ВлюбитÑOEÑ•Ñ• можно в краѕоту, но полюбитÑOE
– лишÑOE толÑOEко душу!

This is how it makes text with non latin characters. A required font is in the project folder and the font name is used in Styler options. How to fix it?

Support for a "book form" PDF

Sorry about the issue title. What I mean specifically is to support multiple markdown files to create one PDF.

This would permit a scenario of writing a book or article with multiple chapters or sections, where each chapter/section is in its own markdown file.

Non-local and non-png images cause conversion error

Use a markdown document that references an image that is either not local or isn't a png. An example is the README.md for this project, which has a godoc image link. Run mktopdf -i <the_markdown_doc> -o test.pdf.

Expected behaviour is that the output doesn't has the image, fine since not all markdown/HTML syntax is supported. A warning might be useful.

Instead, export completely fails with an error indicating that it cannot open the file path and dumps the http URL for the image link.

Chinese encoding problems

I noticed that the chinese pdf example you generated is garbled.

https://github.com/mandolyte/mdtopdf/blob/master/cmd/chinese.pdf

Can you support scaling of images?

Can you support scaling of images in this project? They are coming out at 100% which can be disproportional for the page, in the context of an eBook or white-paper this would be particularly useful.

Idea: themed output

Since markdown has no real styling information and PDF has no real equivalent to after-the-fact styling like CSS it would be interesting if this tool had some theming concept. Out of the box, it would be great to support certain common styles of PDF documents. One example that comes to mind is an academic paper style (e.g. https://arxiv.org/pdf/1801.00013.pdf). Another could be a user guide style that resembles certain common manuals. I think it would also be useful to have some way to add more themes to the tool whether programmatically or declaratively.

List support

The following remains to be done:

  • different bullets for nested items
  • paragraphs within an item is not working correctly (will likely require push/pop stack to manage proper context)
  • loose vs tight is not supported; only "tight" is working at present.

Table rendering issues

Hi. First off great project.

I seem to be having problems rendering tables. Columns with very long lines overlap the table's boundary.

### Some Title Goes Here

| Horizonal Header | Horizonal Value                                                      |
|-------------------------|----------------------------------------------------------------------|
| Period                  | 2023/1                                                                                                  |
| Project          | Project #1                                                                                             |
| Manager       | Very long name goes here without wrapping with ellipses if possible. |
| Access ID     | 1234567890                                                           |

This is what I get, which is not what I need

image

Also is it possible to have horizontal header/value layout?

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.