Page 1 of 1

How to line break/return with <br/> in LC

Posted: Tue Feb 09, 2021 1:59 pm
by glenn9
I've put together a simple utility in LC which will export a tsv file so that it can then be imported into a flashcard application.

So far so good, I learnt yesterday evening how to successfully export a tsv from LC (with much sense of achievement as I put the GUI and code together in less than an hour!) and I was then able to successfully import the resulting file into the flashcard app... however, it only imports as long as there is only a single line of text, ie no line breaks or returns.

It seems that the flashcard app requires any line breaks to be identified with the '<br/>' code as below.

'Creating Line Breaks in Imported Decks: Anywhere that you would like to have a line break occur in the resulting deck, include this text '<br/>' in your CSV/TSV file'


I therefore tried to accommodate this with:

Code: Select all

on returninfield
   put "<br/>" & return after field 1
   -- omitting the '& return' doesn't help either!
end returninfield
However, the flashcard app says the resulting text is invalid and refuses to import it.

Not sure whether this is a LC issue in terms of the code that it uses for line breaks/returns or whether its the flashcard app's issue.

Superficially I'm thinking that it doesn't seem to like the code that LC is using for line break/return and was assuming that if I can replace the code that LC uses for line breaks/returns with <br/> then it will import!?

I was therefore wondering if it is therefore possible to replace the code LC is using for a line break/return with a <br/> instead?

Grateful for any thoughts/advice,

Regards,

Glenn

Re: How to line break/return with <br/> in LC

Posted: Tue Feb 09, 2021 2:10 pm
by Thierry
glenn9 wrote: I was therefore wondering if it is therefore possible to replace the code
LC is using for a line break/return with a <br/> instead?
Hi Glenn,

This one is straightforward:

Code: Select all

replace cr with "<br/>" in variableWithYourText
Otherwise, I have no idea if this will resolve your main issue...

HTH,

Thierry

Re: How to line break/return with <br/> in LC

Posted: Tue Feb 09, 2021 2:24 pm
by glenn9
Hi Thierry,

This has worked perfectly, thank you so much. Especially that I now understand after looking at your code why mine wasn't working!

Kind regards,

Glenn

Re: How to line break/return with <br/> in LC

Posted: Tue Feb 09, 2021 2:55 pm
by dunbarx
So was it the case that even when you explicitly wrote "<br/>" instead of return, you may have still had some returns in your text?

Thierry's offering is guaranteed to eliminate those, of course, but I am just wondering...

Craig

Re: How to line break/return with <br/> in LC

Posted: Tue Feb 09, 2021 4:05 pm
by glenn9
I think so Craig, I guess I didn't have insight that I was inadvertently adding a 'CR' code (by pressing the 'return' key whilst I was in the field) each time I added the '<br/>' code initially!!

Regards,

Glenn

Re: How to line break/return with <br/> in LC

Posted: Tue Feb 09, 2021 4:26 pm
by Klaus
Hi Glenn,
I was therefore wondering if it is therefore possible to replace the code LC is using for a line break/return with a <br/> instead?
since we are dealing with LC, most of the time the first thought is the correct one and we can translate it almost 1:1 into LC!
See Thierrys script! :-)


Best

Klaus

Re: How to line break/return with <br/> in LC

Posted: Tue Feb 09, 2021 5:37 pm
by dunbarx
What Klaus really meant was "since we are dealing with LC, the answer is YES"

Craig

Re: How to line break/return with <br/> in LC

Posted: Tue Feb 09, 2021 5:47 pm
by Klaus
Oh, did I? :-D