View Single Post
Old 04-28-2011, 07:23 AM   #1
kiwidude
Calibre Plugins Developer
kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.kiwidude ought to be getting tired of karma fortunes by now.
 
Posts: 4,731
Karma: 2197770
Join Date: Oct 2010
Location: Australia
Device: Kindle Oasis
Using composite_formatter.safe_format with multiline text?

I'm moving an email conversation to here.

I am enhancing the Generate Cover plugin to support template driven expressions from a text input field. I thought it would be nice if I changed the input to be a multiline QTextEdit, thereby allowing the user to do multiline expressions like:

Genre: {tags}\n
Published: {pubdate}

However the problem I have is that composite_formatter.safe_format() strips newline characters out. Now if I substitute in something else like <br/> it will work, but then it will blow up if you try to use a multiline complex {} expression.

Any suggestions? I need something that template formatter won't strip out that I can split on afterwards, but that won't cause multi-line formulas to blow up...

Or do we just tell users not to do multi-line formulas?
kiwidude is offline   Reply With Quote