News for hackers. Stuff that matters.
Re:Show HN: htmldocs - Typeset and Generate PDFs with HTML/CSS by cubefox on Wednesday January 17, 2024 @11:45AM (#39030136)
See also native CSS support for paged media:

https://www.w3.org/TR/css-page-3/

When I looked into it several years ago, browser support for some critical features wasn't there yet. Not sure whether this has improved.

In principle, this would be a great alternative to proprietary PDF rendering libraries which require you to design your document completely in (e.g. Java) code, and to the typical LaTeX approach. You really appreciate the elegance of HTML+CSS once you had the misfortune of having to do a simple fucking table in LaTeX.

Re:Show HN: htmldocs - Typeset and Generate PDFs with HTML/CSS by lelanthran on Wednesday January 17, 2024 @12:06PM (#39030413)
I dunno about that.

For simple stuff, sure HTML and CSS is great, but when I want something print-perfect I use LaTeX.

A simple table in LaTeX is no harder than in HTML, assuming the same level of knowledge in the tool.

But then when you throw in a simple requirement like "left margins on even pages and right margins on odd pages need to be larger", HTML becomes hell to work in.

HTML and CSS, even with a media query for print, sucks.

Re:Show HN: htmldocs - Typeset and Generate PDFs with HTML/CSS by kelvinzhang on Wednesday January 17, 2024 @12:22PM (#39030625)
I think in the long term, HTML/CSS will win out once there's better support for CSS Paged Module Level 3, and you'll be able to achieve that requirement with just

    @page :left {
        margin-left: 20mm;
        margin-right: 10mm;
    }
    
    @page :right {
        margin-left: 10mm;
        margin-right: 20mm;
    }

instead of needing to install/import different LaTeX packages. I think for most of my current use-cases level 2 has been sufficient but I can see if I can include Paged.js polyfill support by default so there's more support for customizability on that front.
Re:Show HN: htmldocs - Typeset and Generate PDFs with HTML/CSS by x905 on Wednesday January 17, 2024 @12:49PM (#39030993)
@Page { size: A4; margin: 20mm 10mm 10mm 25mm; } Do my print specifics (hidden-print class etc), everyone can optimize it for his local layout, every browser supports "print to pdf", done.
Re:Show HN: htmldocs - Typeset and Generate PDFs with HTML/CSS by threatofrain on Wednesday January 17, 2024 @12:32PM (#39030778)
In CSS you can directly target even or odd or some other arithmetic sequence.

    :nth-of-type(2n+1)
Re:Show HN: htmldocs - Typeset and Generate PDFs with HTML/CSS by lelanthran on Thursday January 18, 2024 @12:04AM (#39038102)
I'm not an expert in CSS, but I don't know how I can use that to refer to pages.

I mean, I'm not creating pages with `<page>...</page>`.

Re:Show HN: htmldocs - Typeset and Generate PDFs with HTML/CSS by cubefox on Thursday January 18, 2024 @06:07AM (#39040392)
Re:Show HN: htmldocs - Typeset and Generate PDFs with HTML/CSS by philistine on Wednesday January 17, 2024 @01:06PM (#39031228)
TeX at this point has entered computing legend. It has such a long and storied life.

But it’s old. We need something modern, that represents current ways to make documents from code. And that way is CSS. I bet within my lifetime most scientific publications will move to a PDF tool that ingests CSS. We just need to find something open-source and clean that has no missing functionality.

Re:Show HN: htmldocs - Typeset and Generate PDFs with HTML/CSS by replwoacause on Wednesday January 17, 2024 @04:01PM (#39033387)
What about https://typst.app ?
Re:Show HN: htmldocs - Typeset and Generate PDFs with HTML/CSS by philistine on Wednesday January 17, 2024 @09:51PM (#39037003)
Is it open source ?
Re:Show HN: htmldocs - Typeset and Generate PDFs with HTML/CSS by mgt19937 on Wednesday January 17, 2024 @10:05PM (#39037140)
Re:Show HN: htmldocs - Typeset and Generate PDFs with HTML/CSS by kaladin-jasnah on Wednesday January 17, 2024 @10:11PM (#39037195)
I designed some worksheets in Typst and it is the best experience I've had with a typesetting system, hands down. It's not for everything but its defaults are good and very simple.
Re:Show HN: htmldocs - Typeset and Generate PDFs with HTML/CSS by lelanthran on Thursday January 18, 2024 @12:27AM (#39038248)
> But it’s old. We need something modern, that represents current ways to make documents from code.

I'd love something newer than TeX/LaTeX. Something with consistency (is it \$CMD{...}, \begin{$CMD}...\end{$CMD} or \{$CMD ...}?), better error messages, more specific and targeted warnings (most hbox-full warnings can be ignored, but many can't!), support for specifying `-Werror` (like gcc) and other things like that.

> I bet within my lifetime most scientific publications will move to a PDF tool that ingests CSS.

Maybe[1]. CSS and HTML needs a lot more functionality though. They have no page counter, no chapter counter, section counters, etc. No river detection, run detection, orphan detection, etc. No automatic reference manager[2], no automatic referencing of chapters, sections, tables, figures, etc. Missing correct hyphenation breakpoints.

Additionally, some things are there, but in a poor (for typesetting) way - inter-paragraph spacing must be faked (no, `:after` isn't a good way to specify `inter` spacing), no way to prevent what should be an atomic element (say ... an mbox containing a paragraph and an image) being broken across pages, no way to float an element to the next point in the document where it will fit (LaTeX does this by default, and it annoyed me no end when I could not find a way to get HTML documents to stop breaking my pretty short table across a page, and instead just place it on the next page).

Another thing that I think are a poor fit, but others think are superior, are the scripting facilities for creating new commands: doing `\newcommand or \newenvironment` is a lot less friction than doing an entire custom element. It's so little friction, that for an invoice I can simply do `\newcommand{\client}{\textbf\emph{The Client PTY LTD}}` and then use `\client` everywhere in the document.

I'm looking forward to a new LaTeX/TeX that fixes all those things. Maybe CSS+HTML would eventually get them, but many of those things are table stakes for typesetting, and yet they are not even on the horizon (or roadmap) for CSS+HTML.

[1] Could be I'm wrong. Like I said in another response, I'm no expert in CSS or HTML. [1] This can be easily resolved with a custom web component

> And that way is CSS. I bet within my lifetime most scientific publications will move to a PDF tool that ingests CSS. We just need to find something open-source and clean that has no missing functionality.

Re:Show HN: htmldocs - Typeset and Generate PDFs with HTML/CSS by cubefox on Thursday January 18, 2024 @05:49AM (#39040273)
> Could be I'm wrong. Like I said in another response, I'm no expert in CSS or HTML.

Looks like it. I'm pretty sure most of the things you mentioned are either already possible or in the paged media spec / covered by paged.js.

Re:Show HN: htmldocs - Typeset and Generate PDFs with HTML/CSS by chrisfinazzo on Wednesday January 17, 2024 @05:33PM (#39034532)
Once I had the chance to move away from Word, TeX was the first place I went. That said, I eventually tired of the obtuse error messages and felt I was making things more complicated for no real gain.

Even keeping a BasicTex environment working requires effort that HTML does not.

Re:Show HN: htmldocs - Typeset and Generate PDFs with HTML/CSS by lelanthran on Thursday January 18, 2024 @12:07AM (#39038124)
> That said, I eventually tired of the obtuse error messages and felt I was making things more complicated for no real gain.

The error messages are pretty poor.

> Even keeping a BasicTex environment working requires effort that HTML does not.

I've been told, by Mac and Winodws users, that it's a pain.

Personally I've never had to download extra packages/styles directly on Debian. Performing `apt-get install tex-<whatever>` normally installs everything (where `<whatever>` is something I find from a search in synaptic).

Re:Show HN: htmldocs - Typeset and Generate PDFs with HTML/CSS by chrisfinazzo on Thursday January 18, 2024 @10:15AM (#39042672)
I solved the issue by installing manually, but even that is a pain with TeX Live - some of the directory tree needed to be created before BasicTex was aware of the packages I was using.
Re:Show HN: htmldocs - Typeset and Generate PDFs with HTML/CSS by tingletech on Wednesday January 17, 2024 @11:53AM (#39030253)
Support is getting better, there is also a poly fill of sorts https://pagedjs.org