Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
github.com/divan/mdtopdf
This package depends on two other packages:
gofpdf
packace to generate the PDFBoth of the above are documented at Go Docs [http://godocs.org].
The tests included here are from the BlackFriday package. See the "testdata" folder. The tests create PDF files and thus while the tests may complete without errors, visual inspection of the created PDF is the only way to determine if the tests really pass!
The tests create log files that trace the BlackFriday parser callbacks. This is a valuable debug tool showing each callback and data provided in each while the AST is presented.
2019-09-23: It appears that the BlackFriday project is no longer active.
There is a fork gomarkdown/markdown
that I may be able to move to
in the future if needed.
The supported elements of markdown are:
How to use of non-Latin fonts/languages is documented in a section below.
It is common for Markdown to include HTML. HTML is treated as a "code block". There is no attempt to convert raw HTML to PDF.
Github-flavored Markdown permits strikethough using tildes. This is not supported at present by gofpdf
as a font style.
The markdown link title, which would show when converted to HTML as hover-over text, is not supported. The generated PDF will show the actual URL that will be used if clicked, but this is a function of the PDF viewer.
Currently all levels of unordered lists use a dash for the bullet. This is a planned fix; see here.
Definition lists are not supported (not sure that markdown supports them -- I need to research this)
The following text features may be tweaked: font, size, spacing, styile, fill color, and text color. These are exported and available via the Styler
struct. Note that fill color only works if the text is ouput using CellFormat(). This is the case for: tables, codeblocks, and backticked text.
Tables are supported, but no attempt is made to ensure fit. You can, however, change the font size and spacing to make it smaller. See example.
To install the package, run the usual go get
:
go get github.com/mandolyte/mdtopdf
In the cmd
folder is an example using the package. It demonstrates
a number of features. The test PDF was created with this command:
go run convert.go -i test.md -o test.pdf
In order to use a non-Latin language there are a number things that must be done. The PDF generator must be configured with:
The above are all requirements of the PDF generator (see dependencies above). I don't know of a straightforward way to determine what the PDF generator needs. I was able to play with a little code to discover what is needed. In addition, the PDF generator testing code has some hints. My code to play with the PDF generator is at mandolyte/samples/gofpdf
.
In addition, this package's Styler
must be used to set the font to match that is configured with the PDF generator.
A complete working example may be found for Russian in the cmd
folder nameed
russian.go
.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.