Closed theramiyer closed 5 years ago
I think you are supposed to name the document so that it ends with .poly.pm
(e.g., foo.poly.pm
). Not sure what will happen if you have just poly.pm
.
I believe you need (provide (all-defined-out))
in the submodule setup
. Otherwise, the tex
rendering won't work (how did you get tex
rendering working?!?)
You have not shown us the content of template.tex.p
. One potential solution to your problem is to change this file.
Is there a way I can conditionally use
decode-paragraphs
only for HTML output?
Yes: use this root
(require racket/function)
(define (root . elements)
(txexpr 'root empty
(decode-elements
elements
#:txexpr-elements-proc
(if (eq? (current-poly-target) 'tex)
identity
decode-paragraphs)
#:string-proc
(compose1 smart-quotes smart-dashes))))
Is there a way I can conditionally use decode-paragraphs only for HTML output?
@sorawee is correct that you can do this, but I doubt you want to — detect-paragraphs
does other tidying too, plus you want consistent results between formats (that is, you want a guarantee that paragraph breaks all fall in the same places, which is only possible if they're detected by the same processing steps)
I’m no LaTeX expert but I think you’d want to find a way to convert the p
tags to blank lines in your LaTeX rendering template (that is, the last possible moment, and then you get the convenience of handling everything as X-expressions up till then)
Yup, I think that changing template.tex.p
is a cleaner solution as well.
I'm sorry, I didn't post the contents of template.tex.p
. I was so caught up in thinking paragraph-decode was interfering, I did not think about my TeX template. Yes, changing this makes more sense, now that it's pointed out. Thank you! Here are the contents.
◊(local-require racket/list)
◊(apply string-append (filter string? (flatten doc)))
And I think I inadvertently removed (provide (all-defined-out))
from the submodule setup. Fixed that.
Actually, there's another solution similar to "conditionally use decode-paragraphs
only for HTML output", but behave much better: change your root
to:
(define (the-paragraph-wrapper xs) (txexpr 'p '() (append xs (list "\n\n"))))
(define (root . elements)
(txexpr 'root empty
(decode-elements
elements
#:txexpr-elements-proc
(if (eq? (current-poly-target) 'tex)
(λ (elements) (decode-paragraphs elements the-paragraph-wrapper))
decode-paragraphs)
#:string-proc
(compose1 smart-quotes smart-dashes))))
with this, decode-paragraphs
is always called, but will also add extras \n\n
for tex documents.
That worked, thank you!
Sorry about the delay in response; no Internet for the last two days. 😄
Hi, everyone. This is my third day with Pollen. Perhaps I'm jumping the gun before learning to use Racket, but I fear hitting writer's block by the time I learn the language. I want to start using Pollen, though, and I fully intend to learn it.
Meanwhile, I want my book output in rudimentary HTML (for Kindle) plus LaTeX. I have created the LaTeX template, and Kindle is not sophisticated enough for layouts; a basic CSS would do (Amazon would rather I submit plain HTML).
Here is a sample of how I'm writing my
poly.pm
files:Here is my
pollen.rkt
This renders the HTML as (which is fantastic):
But renders my LaTeX as:
One way of handling this would be to use
◊p{"TOM!"}◊p{No answer.}
, and omitdecode-paragraphs
, but that is going to make writing worse for me.Is there a way I can conditionally use
decode-paragraphs
only for HTML output? I terribly messed up the syntax in my attempts. How do I write this condition? LaTeX handles---
and...
, but renders'word'
as’word’
; LaTeX uses`word'
for quotes. It accepts‘word’
, though; doesn't interfere withsmart-quotes
.The bigger goal is to know how to use Pollen to process basic HTML and basic LaTeX without having to resort to Markdown, but get all of the capabilities of Markdown (with a parser like Kramdown), ... to …; --- to —, 'word' to ‘word’, etc.