Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ftn2pdf outputs HTML #1

Closed
stevenjaycohen opened this issue Sep 8, 2023 · 14 comments
Closed

ftn2pdf outputs HTML #1

stevenjaycohen opened this issue Sep 8, 2023 · 14 comments

Comments

@stevenjaycohen
Copy link

The command I ran

ftn2pdf sample.fountain sample.pdf

The sample script

Title:
    Show Title
    Cool Sub-Title
Credit: Written by
Author: Steven Jay Cohen
Contact:
    Steven Jay Cohen
    123 Main Street #24
    Boston, MA 02134
    781-555-1212
    name@domain.com

INT. PHONE CALL - EVENING

# Scene 0: Cold Open

= Maggie is woken up by an automated phone call she does not want.

VOICE RECORDING
Hello, this is an important message from the Chase Visa Department of Collections. We are reaching out to -- Margaret Protagonist -- regarding your Chase Visa account ending in -- 3292.

Maggie sighs.

VOICE RECORDING
Our records indicate that there is an outstanding balance of $89,532 and 47 cents. We understand that financial situations can be challenging, and we're here to help you find a solution to bring your account back into good standing.

Maggie breathes.

VOICE RECORDING
If you would like to hear this information again, please press 1 now. To discuss the available options for resolving this matter with a representative, press 2 now.

Maggie presses 2

VOICE RECORDING
Thank you. Our customer service team is ready to assist you in finding a suitable solution. Please hold for the next available representative.

Hold Music

VOICE RECORDING
Thank you for your patience. A representative will be with you shortly to assist you in setting up a payment plan or discussing other options to help you get back on track with your account.

Hold Music

VOICE RECORDING
We value your business and are committed to helping you find a resolution. We appreciate your attention to this matter and look forward to working with you. Please continue to hold for the next available representative.

Hold Music

CUSTOMER SERVICE
Thank you for choosing Amazon-Chase Visa, my name is Elaine, to whom do I have the pleasure of–?

Maggie disconnects the call, breathes calmly and slowly, and puts down the phone.

> FADE TO OPENING.

INT. THE OFFICE

# SCENE 1

= Everyone still hungover from the office party.

GEORGE
You've got some nerve, showing your face around here today.

MAGGIE
(headache and sarcasm)
Good morning to you too, George.

When trying to open the resulting file, I get this error

image

Here is the file

sample.pdf

Changing the filetype to .html does give proper HTML

  • Debian 12 (stable)
  • PoDoFo v0.9.8+dfsg-3+b1 installed from the Debian Stable repo
@xiota
Copy link
Owner

xiota commented Sep 8, 2023

Probably the PoDoFo version detection is broken. Would you mind building an older commit and letting me know if it works?

@stevenjaycohen
Copy link
Author

stevenjaycohen commented Sep 8, 2023

Suspecting the Build with -O3 flag might be the issue, I wound back to the one before that, and voila! It works!

So 3a07337 is the working build on my system.

Here is the working export:

sample.pdf

Thank you for this! Your solution is the best fit for my workflow.

I am noticing some differences between the formatting output from your tool and the output from afterwriting.

If I were to dive into the CSS and work on adding these, would that be of any help to you?

Just trying to give back. Thanks again!

@stevenjaycohen
Copy link
Author

stevenjaycohen commented Sep 8, 2023

Wow, I just put one of my full scripts through ftn2pdf and it is far superior to afterwriting in a few ways. You are definitely handling how/where to page break in a much better way!

My questions are:

Odds are you have already done a few of these and I just missed them. Hoping I can be of some help on this project, even if it is mostly testing and tweaking CSS.

@stevenjaycohen
Copy link
Author

I am modifying vim-fountain to handle all of the tags that you document.

@xiota
Copy link
Owner

xiota commented Sep 8, 2023

I just pushed an update to modify the build flags. Would you please build 4a93e3b and let me know if it works?

I'm also curious about what OS/distro you're using. Recently, the PoDoFo library was updated (0.10.x) and is now completely incompatible with the version I used (0.9.x). So PDF export will be in a precarious position as distros move to the new library.

I haven't used afterwriting before. From what I can tell, it uses html/javascript. This program/library is pure C++. I just found magicfountain, which might be worth looking into.

Modifying the CSS files won't have any effect on PDF output. They're used only for presentation of the other formats in a web browser. It could help with printing from a web browser or using an HTML to PDF converter. If you know or find a good command-line converter, I'd be interested to know what it is.

PDF output was hand coded/tweaked. That makes the code "messy". I originally tried to duplicate the output from other screenplay programs, but gave up on it because they were all different and I couldn't figure out the exact pagebreak rules they were using.

It's been a while since I looked at the code, but I will try to answer your questions:

@stevenjaycohen
Copy link
Author

4a93e3b fails with the following:

$ make
g++  -O3 -DENABLE_EXPORT_PDF -I .  -c -o ftn2xml.o ftn2xml.cc
ftn2xml.cc: In function ‘int main(int, char**)’:
ftn2xml.cc:54:15: error: ‘ftn2pdf’ is not a member of ‘Fountain’; did you mean ‘ftn2fdx’?
   54 |     Fountain::ftn2pdf(argv[2], input);
      |               ^~~~~~~
      |               ftn2fdx
make: *** [<builtin>: ftn2xml.o] Error 1

Commenting out CPPFLAGS makes it compile properly

CPPFLAGS = -O3 -DENABLE_EXPORT_PDF -I .

I am using Debian 12 Stable. So, it is likely 2 years before I will get PoDoFo v0.10.x :)

I'll check magicfountain, but honestly, your code fits my workflow well. Beyond updating vim-fountain to match everything that you have added here, I also added this to my vimrc

"eXport Fountain (PDF)
map <silent><leader>xf <esc>:!ftn2pdf % %:r.pdf<cr>:!open %:r.pdf<cr>

I had wrongly guessed that the CSS affected the output because I deal with html-based PDF generation so often. Before your code, afterwriting had the most professional looking output for my purpose. I have it installed on a github repo as an Action that uses its npm. So, when I push a fountain file, it generates the PDF.

To be clear, yours is better. Honestly, the more advanced page break handling is really impressive.

I had put a Draft date: in my fountain file, and your code skipped it gracefully. So, kudos there. It's honestly not needed. Just missing for completeness.

Your CONT/MORE position makes sense. Like I said, your page breaks make it less needed.

If there were a LibreOffice (ODT) output, I'd love to have the Sections and Synopses there. that would let me make some formatting tweaks and then use its PDF exporter. I wonder if it is possible to use the XML output that way?

Implementing a PDF flag to include comments would be a nice enhancement.

I am including a sample file here that I fed to afterwriting. That way you can see how it is handling those little extras.

test.fountain.txt

test.pdf

@xiota
Copy link
Owner

xiota commented Sep 9, 2023

Could you try building c1bf18e ? (Will have to use git pull -f. Also, don't forget make clean.)

My distro (Arch) switched to PoDoFo 0.10.x, and I hadn't been able to build this with PDF support. I figured it out a moment ago, but it breaks building on Debian.

I am using Debian 12 Stable. So, it is likely 2 years before I will get PoDoFo v0.10.x :)

The pro and con of Debian.

To be clear, yours is better. Honestly, the more advanced page break handling is really impressive.

I appreciate the compliment. How did you find this program, and what prompted your search? Did you try screenplain? It's written in Python and outputs html/css. (Not trying to push you to other programs. Wondering about what you tried and what you thought.)

Implementing a PDF flag to include comments would be a nice enhancement.

The programs' functionality are really bare because they were written as tests/demos. I mainly wrote this to generate real-time previews for a Geany plugin.

I don't mind fixing bugs and possibly making minor adjustments, but would prefer to avoid major overhauls. A lot of things are difficult to change. It's basically processing XML without a proper XML parser.

LibreOffice ... XML ...

You can convert with ftn2html. Then add in the head section:

<link href="fountain-html.css" rel="stylesheet" type="text/css" />

It doesn't seem to work with LibreOffice, but does with Firefox. You'll have to fix the font size in the css file. It's set to 8pt instead of 12pt because that's what my Geany plugin uses for previews.

The html output of section headers and synopses is incorrect. I'll take a look at it after this issue is resolved.

@stevenjaycohen
Copy link
Author

It looks like c1bf18e fixes it! 🥳

test.pdf

| I figured it out a moment ago

Fantastic! Good to hear!

| The pro and con of Debian.

Indeed 🙂

| How did you find this program, and what prompted your search?

I had been searching a lot. I am pretty sure that searching fountain parser was the first link I came upon.

| Did you try screenplain?

I did. The afterwriting workflow (using git push/pull to generate the PDFs) was nicer from within Vim, and afterwriting's output was just nicer.

| Wondering about what you tried and what you thought.

My goal was to continue to write in Vim, using fountain.vim for syntax highlighting (I forked that to add everything that you documented). And, in the ideal world, I just wanted to issue a command to generate a PDF. So, adding a github Action with afterwriting was easy (and almost perfect) It does have a few odd bugs here and there. So I kept looking around.

Other things I tried incude (in no particular order):

For sake of completeness, I also found this for Google Docs:

For dedicated apps, I like:

I was also planning on asking the WaveMaker developer if he'd support Fountain.

| LibreOffice ... XML ...

I am going to mess around with it and see what I can do, maybe pipe your output to Pandoc and have it generate the ODT file. I may be able to hand pandoc an ODT template file based upon your tags.

@stevenjaycohen
Copy link
Author

Keeping you in the loop: kblin/vim-fountain#2

@stevenjaycohen
Copy link
Author

So, I spoke too soon. When converting 6 scripts, 1 converts perfectly, 1 loses the title page, and the rest show up as empty PDFs. I have tried both HEAD and the commit before the compile note.

@xiota
Copy link
Owner

xiota commented Nov 29, 2023

Sorry I somehow missed your last message. Do you have copies of the problem scripts stored somewhere so I can look at them?

I would also like to revise the title page according to "The Hollywood Standard". Don't know when I'll get around to it though.

@chariegg
Copy link

Sorry I somehow missed your last message. Do you have copies of the problem scripts stored somewhere so I can look at them?

I would also like to revise the title page according to "The Hollywood Standard". Don't know when I'll get around to it though.

I find the current title page it generates looks exactly the same as any other hollywood script. What more standard could it be? Unless I'm mistaken.

@xiota
Copy link
Owner

xiota commented Nov 30, 2023

"The Hollywood Standard" is a book I learned about after I had already written this program. The difference is probably a missing or extra space here or there. Title pages probably have some variation anyway, but if I get around to it, would be nice to follow some well-known reference.

@xiota
Copy link
Owner

xiota commented Apr 8, 2024

It looks like c1bf18e fixes it! 🥳

Closing this issue because it was resolved by updating compiler flags. If there are problems buried in comments or new ones, feel free to open a new issue.

For pdf export with podofo 0.10.x, use the main branch (versions numbered 0.1.x). For podofo 0.9.x, use the v0.0.x branch.

@xiota xiota closed this as completed Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants