Skip to content

Commit ca7e9c4

Browse files
committed
- Unordered lists: - will be translated to bullets (•)
as before, `+` and `*` will be translated to `▪` - Support 'md' extension (or any other for that matter) for testfiles
1 parent e003d91 commit ca7e9c4

30 files changed

Lines changed: 133 additions & 140 deletions

mdtopdf_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ func testit(inputf string, gohighlight bool, t *testing.T) {
3131
inputd := "./testdata/"
3232
input := path.Join(inputd, inputf)
3333

34-
tracerfile := path.Join(inputd, strings.TrimSuffix(path.Base(input), ".text"))
34+
tracerfile := path.Join(inputd, strings.TrimSuffix(path.Base(input), path.Ext(input)))
3535
tracerfile += ".log"
3636

37-
pdffile := path.Join(inputd, strings.TrimSuffix(path.Base(input), ".text"))
37+
pdffile := path.Join(inputd, strings.TrimSuffix(path.Base(input), path.Ext(input)))
3838
pdffile += ".pdf"
3939

4040
content, err := os.ReadFile(input)
@@ -98,7 +98,7 @@ func TestInlineLinks(t *testing.T) {
9898
}
9999

100100
func TestLists(t *testing.T) {
101-
testit("Ordered and unordered lists.text", false, t)
101+
testit("Ordered and unordered lists.md", false, t)
102102
}
103103

104104
func TestStringEmph(t *testing.T) {

nodeProcessing.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,18 @@ func (r *PdfRenderer) processItem(node ast.ListItem, entering bool) {
241241
r.cs.push(x)
242242
if r.cs.peek().listkind == unordered {
243243
tr := r.Pdf.UnicodeTranslatorFromDescriptor("")
244-
r.Pdf.CellFormat(3*r.em, r.Normal.Size+r.Normal.Spacing,
245-
tr("•"),
244+
bulletChar := tr("•")
245+
currFontSize, _ := r.Pdf.GetFontSize()
246+
if node.BulletChar != 45 { // if the bullet char is not '-'
247+
bulletChar = tr("▪")
248+
r.Pdf.SetFont("", "", 25)
249+
}
250+
r.Pdf.CellFormat(4*r.em, r.Normal.Size + r.Normal.Spacing,
251+
bulletChar,
246252
"", 0, "RB", false, 0, "")
253+
r.Pdf.SetFont("", "", currFontSize)
247254
} else if r.cs.peek().listkind == ordered {
248-
r.Pdf.CellFormat(3*r.em, r.Normal.Size+r.Normal.Spacing,
255+
r.Pdf.CellFormat(4*r.em, r.Normal.Size+r.Normal.Spacing,
249256
fmt.Sprintf("%v.", r.cs.peek().itemNumber),
250257
"", 0, "RB", false, 0, "")
251258
}
0 Bytes
Binary file not shown.

testdata/Auto links.pdf

16 Bytes
Binary file not shown.

testdata/Backslash escapes.pdf

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

testdata/Code Blocks.pdf

0 Bytes
Binary file not shown.

testdata/Code Spans.pdf

0 Bytes
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)