jgm / pandoc

Universal markup converter
https://pandoc.org
Other
33.21k stars 3.3k forks source link

typst: `width` and `height` do not convert unitless numbers to inches #9945

Open cscheid opened 3 days ago

cscheid commented 3 days ago

Explain the problem.

The typst writer doesn't automatically convert unitless dimensions to inches, but Typst doesn't like unitless dimensions. This behavior is inconsistent with (eg) the latex writer:

$ pandoc -f markdown -t typst
![](./foo.png){width=640 height=480}
^D
#box(image("./foo.png", height: 480, width: 640))
$ pandoc -f markdown -t latex
![](./foo.png){width=640 height=480}
^D
\includegraphics[width=6.66667in,height=5in]{./foo.png}

Pandoc version?

I used 3.2 and didn't see anything relevant on the 3.2.1 changelog (still compiling 3.2.1 locally...):

$ pandoc --version
pandoc 3.2
Features: +server +lua
Scripting engine: Lua 5.4
User data directory: /Users/cscheid/.local/share/pandoc
Copyright (C) 2006-2024 John MacFarlane. Web: https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.
cscheid commented 3 days ago

I'd work on a PR, but apparently I can't get Pandoc to compile right now:

$ git pull origin main && cabal update && cabal build pandoc-cli
From github.com:jgm/pandoc
 * branch                main       -> FETCH_HEAD
Already up to date.
Downloading the latest package list from hackage.haskell.org
Package list of hackage.haskell.org is up to date.
The index-state is set to 2024-07-03T19:51:11Z.
Build profile: -w ghc-9.4.8 -O1
In order, the following will be built (use -v for more details):
 - pandoc-3.2.1 (lib) (first run)
 - pandoc-server-0.1.0.6 (lib) (first run)
 - pandoc-lua-engine-0.3 (lib) (first run)
 - pandoc-cli-3.2.1 (exe:pandoc) (first run)
Preprocessing library for pandoc-3.2.1..
Building library for pandoc-3.2.1..
[198 of 215] Compiling Text.Pandoc.Readers.TWiki

src/Text/Pandoc/Readers/TWiki.hs:19:40: error:
    Module ‘Data.Char’ does not export ‘isUpperCase’
   |
19 | import Data.Char (isAlphaNum, isDigit, isUpperCase, isLowerCase, isLetter)
   |                                        ^^^^^^^^^^^

src/Text/Pandoc/Readers/TWiki.hs:19:53: error:
    Module ‘Data.Char’ does not export ‘isLowerCase’
   |
19 | import Data.Char (isAlphaNum, isDigit, isUpperCase, isLowerCase, isLetter)
   |                                                     ^^^^^^^^^^^
Error: cabal: Failed to build pandoc-3.2.1 (which is required by exe:pandoc
from pandoc-cli-3.2.1).