danielmiessler / fabric

fabric is an open-source framework for augmenting humans using AI. It provides a modular framework for solving specific problems using a crowdsourced set of AI prompts that can be used anywhere.
https://danielmiessler.com/p/fabric-origin-story
MIT License
25.52k stars 2.71k forks source link

[Bug]: write_latex pattern outputs 3 back ticks + latex at the beginning and 3 back ticks at the ending of document #1107

Open questr-hub opened 2 weeks ago

questr-hub commented 2 weeks ago

What happened?

I ran the the following command with the intention of using Fabric to write_latex from a Markdown document and then pipe that into the to_pdf command to generate a PDF.

cat article.md | fabric --pattern write_latex | to_pdf

Unfortunately, the LaTeX file that it creates has leading and trailing characters that the LaTeX engine called by to_pdf chokes on:

First line of document: ```latex Last line of document: ```

Version check

Relevant log output

$ cat article.tex | to_pdf
Error running pdflatex: exit status 1
pdflatex output:
This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022/Debian) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(/tmp/latex_1317854834/input.tex
LaTeX2e <2022-11-01> patch level 1
L3 programming layer <2023-01-16>

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.1 `
     ``latex
Missing character: There is no ` in font nullfont!
Missing character: There is no ` in font nullfont!
Missing character: There is no ` in font nullfont!
Missing character: There is no l in font nullfont!
Missing character: There is no a in font nullfont!
Missing character: There is no t in font nullfont!
Missing character: There is no e in font nullfont!
Missing character: There is no x in font nullfont!

Relevant screenshots (optional)

Screenshot 2024-11-03 1 44 31 PM

questr-hub commented 2 weeks ago

I can address the issue by adding a sed command as follows but I'm curious why Fabric's pattern for write_latex is adding the extra lines, particularly since it instructs the API as folo

Clean with sed cat article.md | fabric --pattern write_latex | sed '1d;$d' > article.tex

From system.md for write_latex pattern:

And, I added the following as well:

arminzaugg commented 2 weeks ago

Hi @questr-hub I can confirm I have the same issue. Thank you for the workaround tip.