khajavi / pandoc

Automatically exported from code.google.com/p/pandoc
GNU General Public License v2.0
0 stars 0 forks source link

Html output is blank when writerStandalone = True #218

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. darcs get http://code.haskell.org
2. cd xmonad
3. sed -i 's/writerHeader/writerIncludeBefore/' util/GenerateManpage.hs
4. runghc util/GenerateManpage.hs

What is the expected output? What do you see instead?
Check man/xmonad.1.html, it is empty.

If you comment out "writerStandalone = True" on line 92, and re-run
GenerateManpage.hs the html output can be displayed correctly in a browser,
but then the doctype and page title are missing.

What version of the product are you using? On what operating system?
pandoc-1.4, linux, ghc-6.12.1

Please provide any additional information below.

Original issue reported on code.google.com by vogt.a...@gmail.com on 16 Feb 2010 at 5:06

GoogleCodeExporter commented 9 years ago
AS of 1.4, pandoc uses a template system for standalone rendering. The default 
template is blank, so you get a blank. You need to set writerTemplate.
The default HTML template can be found in the templates/ subdirectory.
You can also use getDefaultTemplate, but be warned that the API will change 
slightly 
in the next release, so you'll need to change the code again if you use it.

Let me know if this isn't enough information to solve your problem.

Original comment by fiddloso...@gmail.com on 16 Feb 2010 at 5:44

GoogleCodeExporter commented 9 years ago
Thanks for the quick response. It is enough to solve my problem.

I would like for pandoc to fall back to the most appropriate template when
writerTemplate is empty but writerStandalone is True.

If an issue is the inconvenience of compiling in the constants, it can be done
relatively easily as:

> getFile :: FilePath -> ExpQ -- litteral string
> getFile path = do
>    conts <- runIO $ readFile path
>    return $ LitE $ StringL conts

> fallbackTemplate = $(getFile "path/to/template") :: String

Should I send a patch finishing up this idea, or is this not a good idea?

Original comment by vogt.a...@gmail.com on 16 Feb 2010 at 5:28

GoogleCodeExporter commented 9 years ago
Well, I've finally succeeded in getting all the template haskell OUT of pandoc. 
It
isn't so portable -- it kept pandoc from compiling on several architectures 
supported
by debian, for example. So I'd rather not reintroduce it.

I do agree that it would be nice to avoid this "gotcha," but I don't see a 
clean way
to do it w/o using TH.

Perhaps a cleaner setup would replace the writerStandalone flag with a 
writerTemplate
:: Maybe String; if Nothing, a fragment would be generated.  THat would keep 
users
from thinking that setting writerStandalone to True is sufficient.  (But of 
course
this would be a major API change.)

Original comment by fiddloso...@gmail.com on 16 Feb 2010 at 6:00