Skip to content

Commit

Permalink
Merge pull request #50 from jessp01/disable-MathAJax-gomarkdown-ext
Browse files Browse the repository at this point in the history
See #49
  • Loading branch information
jessp01 authored Nov 2, 2023
2 parents a8d805b + 4bdd5ab commit 8f4b731
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 6 additions & 3 deletions mdtopdf.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"fmt"
"io"
"os"
"reflect"

"strings"

"github.com/go-pdf/fpdf"
Expand Down Expand Up @@ -338,7 +338,8 @@ func (r *PdfRenderer) Run(content []byte) error {
s = []byte(r.unicodeTranslator(string(s)))
}

exts := parser.CommonExtensions // parser.OrderedListStart | parser.NoEmptyLineBeforeBlock
// exts := parser.CommonExtensions // parser.OrderedListStart | parser.NoEmptyLineBeforeBlock
exts := parser.NoIntraEmphasis | parser.Tables | parser.FencedCode | parser.Autolink | parser.Strikethrough | parser.SpaceHeadings | parser.HeadingIDs | parser.BackslashLineBreak | parser.DefinitionLists
p := parser.NewWithExtensions(exts)
doc := markdown.Parse(s, p)
_ = markdown.Render(doc, r)
Expand Down Expand Up @@ -450,8 +451,10 @@ func (r *PdfRenderer) RenderNode(w io.Writer, node ast.Node, entering bool) ast.
r.processTableRow(node, entering)
case *ast.TableCell:
r.processTableCell(*node, entering)
/*case *ast.Math:
r.processMath(node)*/
default:
panic("Unknown node type " + reflect.TypeOf(node).Name())
fmt.Printf("Unknown node type: %T. Skipping\n", node)
}
return ast.GoToNext
}
Expand Down
7 changes: 7 additions & 0 deletions nodeProcessing.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ func (r *PdfRenderer) processText(node *ast.Text) {
}
}

// This is a stub implementation. For now, the MathAjax extension is disabled.
func (r *PdfRenderer) processMath(node *ast.Math) {
currentStyle := r.cs.peek().textStyle
s := string(node.Literal)
r.write(currentStyle, s)
}

func (r *PdfRenderer) outputUnhighlightedCodeBlock(codeBlock string) {
r.cr() // start on next line!
r.setStyler(r.Backtick)
Expand Down

0 comments on commit 8f4b731

Please sign in to comment.