Comment by Aachen

Comment by Aachen 2 days ago

39 replies

Please don't turn nice formats into a format that's similar to screenshots of text. Pandoc has an option to pack all images and styles needed to render the page into one html file:

    pandoc --self-contained input.html -o output.html
crazygringo 2 days ago

Or, please do?

I use PDF's so I can send them to my iPad to read offline, highlight them, annotate them, and then send them back to my filesystem with highlights and annotations intact.

I sure can't do that with any "nice formats" like HTML or TXT or EPUB or MOBI.

  • nine_k 2 days ago

    PDF is literally digital paper. HTML has logical structure, it can adapt to different displays, etc.

    Sometimes you want one, sometimes, the other.

    • ratelimitsteve 2 days ago

      >Sometimes you want one, sometimes, the other.

      This is the part that the top commenter missed. Instead they decided that one format is "nice" and the other, by implication, isn't. I find PDFs a lot easier to keep organized en masse, I like that I can use them on any of my devices and it's easy for me to use them when I'm doing in-depth reading such as an ebook. Doubly so because my ereader also does text to speech and syncs across devices so I can read on my tablet while I'm on the exercise bike and then switch to listening to the same book on my phone with minimal seams and without losing my place. It is, in a word, nice.

      • Aachen a day ago

        None of that sounds related to the format?

        - A text to speech engine should work better with the original html structure where it sees bold tags, headings, and full sentences ra-

        ther than broken-off ones

        - Keeping PDFs organised, how would that differ from keeping any other filetype organised? I don't understand what difference you, "by implication", attribute to a file ending in .html or .pdf for being able to handle them en masse. If anything, searching across them will be vastly easier for software (self-written or third-party) and more reliable because it's all plain text

        - Text and audio rendering syncing, I have no experience with but that doesn't sound like it ought to fundamentally work for a display format and not for the source text format. Of course, the software has to have support for this format (and otherwise it's trivial to pdfify a html but vice versa is nearly impossible)

    • Aachen a day ago

      When do want the digital paper when you can have the more flexible one?

      • jerjerjer a day ago

        When I want it to be displayed in the exact same way everywhere.

      • crazygringo a day ago

        Did you not read my reply to your root comment? I already answered this for you.

        Each one has things the other can't do. Neither is universally more flexible.

  • mr_mitm 2 days ago

    You could, though. What you are describing are features of an editor, not a file format. I can imagine a browser addon performing the same tasks.

    • circuit10 2 days ago

      But in this case the flexibility of HTML is a negative because any layout shift would mess up the positions of the annotations, so fixing the layout (and making sure it’s non-interactive) is helpful here

    • whenc 2 days ago

      PDF annotations sit within the file.

      • mr_mitm 2 days ago

        I know, even though that depends on the editor. Okular for example places them in an extra file, last I checked. That's not unique to PDFs. HTML files are modifiable. There is nothing preventing an editor to put annotations in it as well.

    • [removed] 2 days ago
      [deleted]
jasode a day ago

Fyi... the preferred new syntax since 2022 is:

  --embed-resources --standalone.
https://github.com/rstudio/rmarkdown/issues/2382

https://pandoc.org/MANUAL.html#:~:text=Deprecated%20synonym%...

  • Aachen a day ago

    I noticed when trying it out for this comment, but then looked around when it was introduced and it seems recent (as in, an LTS distribution won't have it). Someone on stackoverflow said they get "unknown option --embed-resources". The old option will work for everyone and is also simpler, one instead of two parameters. People whose client supports the new option will see the upgrade suggestion when they run this. In the end I saw mainly downsides to mentioning the new rather than the old way

agedclock 2 days ago

Pandoc would be my preferred tool. It is excellent at converting between other formats as well.

kelnos 2 days ago

> Please don't turn nice formats into a format that's similar to screenshots of text

Converting HTML to PDF shouldn't result in an image wrapped in a PDF. Text will be preserved as text in the final PDF. (Unless the converter is garbage, of course.)

  • Aachen a day ago

    If you've ever copied text out of a PDF, you'll know it's not the original text anymore. Besides ligatures, you get broken sentences with extra hyphens inserted in wrong places (that were word/line breaks in the PDF-rendered version), if it'll properly let you select more than a few words at all. It works like "put these couple words at position x,y" and not (html's) semantic "here comes a heading" tag that helps people accessibly read your text, and if you're not suffering from any impairment or mobile devices with narrower screens than this particular render was designed for, it also lets you work with the document more easily. It's like you remove all HTML and keep only the CSS: all definitions of what's a section, sentence, emphasis, or caption are gone

    I didn't mean literally an image, hence saying image-like. You get similar limitations to when using OCR, which seems very image-like to me

layer8 2 days ago

HTML+CSS+media files isn’t a nice format, and much less portable through time and space than PDF.

  • Aachen a day ago

    Not sure if I'm misreading your comment, but it's not plural files with all those formats separately

    That's what the "self contained" option does: turn it into one nice file. Makes no difference if you copy example.pdf or example.html when both contain all images and styles (except one of them also contains the original semantic text)

moralestapia 2 days ago

Please don't police what other people do.

  • Aachen a day ago

    If I were police, I could still not enforce that this is what they run until it's law. They're free to choose this option if they like the merits

TylerE 2 days ago

Being (not so easily) edited is often a feature, not a bug.

  • craftkiller 2 days ago

    If that is your goal, you should be cryptographically signing your documents with your PGP key. That way you actually have assurance the document has not been modified rather than just hoping someone hasn't modified the document. Additionally, PGP can sign anything so you are open to use whatever format you want.

  • Aachen a day ago

    May I recommend .html in that case? You can embed scripts that control who can run it, having it fetch a decryption token from a server or require a decryption password with a safe password hashing algorithm of your choice

    It's much more versatile than PDF and, if the algorithm decides the user is allowed to read the document, then the user gets to make use of all of the document's options like a better search function (PDF can't find words that are bro-

    ken across lines because that information of what's a word is gone, transformed into coordinates of what characters need to go where). It's also much more readable on different screen sizes, as the user can resize the window to whatever is comfortable on a 27" screen, or fits on their pocket e-reader. You can even draw it on a canvas if you want to prevent people from extracting the decrypted strings (though it's evil, you have that option). There's only benefits!

    PDF is the lazy way to half-ass a read-only document while screwing, ahem, making anyone using a mobile phone zoom, pan, and squint. Thankfully, phones are falling out of fash— wait, scratch that, I just heard text reflow is more relevant than ever as phone use continues to soar

  • ryandrake 2 days ago

    Is this really that much of a motivation in 2025? Maybe in 2000 you could publish a PDF with the assurance that only the people who paid for Acrobat would be able to edit it, but today, there are a lot of accessible ways to edit PDFs, I don't think I'd choose PDF if I for whatever reason wanted to limit others from editing.

  • guywithahat 2 days ago

    I was thinking this too, PDF's exist so people don't mess with the document. That said, it's still a clever feature, and pandoc can convert html into a pdf as well with a conversion engine. That said, I suspect it'll fail on anything sufficiently complex

    pandoc input.html -o output.pdf --pdf-engine=<your engine>