MARKMIN line break

278 views
Skip to first unread message

Dirk Krause

unread,
Nov 29, 2012, 11:04:56 AM11/29/12
to web...@googlegroups.com
Hi,

sorry if this was answered elsewhere but I couldn't find it:
I found no consistent answer how to add single line breaks ('<br />') as opposed to paragraphs ('<p>') into MARKMIN.

This is what I found so far:
(1) the 'purest' Markdown doesn't allow line breaks at all (found in stackoverflow)
(2) there is a common practice to add two or more spaces at the end of the line to inject a <br /> (see http://goo.gl/iEGU).
(3) then there is github flavored markdown (http://github.github.com/github-flavored-markdown/ ) which simply adds this to the renderer.

Obviously the MARKMIN renderer doesn't support (3). From some forum posts I thought it would support (2) but it doesn't (I checked on version 2.0.9).

What is the best practice to achieve single line breaks?

Thanks,
  Dirk


villas

unread,
Nov 29, 2012, 12:13:54 PM11/29/12
to web...@googlegroups.com
Use this:

[[NEWLINE]]

Dirk Krause

unread,
Nov 29, 2012, 2:52:24 PM11/29/12
to web...@googlegroups.com
ok, thank you.

I am only wondering why there is a special tag '[[NEWLINE]] when there is already a one-to-one token for it - the single page break itself.
This can be parsed with
re.sub(r'([^\n])\n([^\n])', r'\1[[NEWLINE]]\n\2', s)
(full example here: http://pythonfiddle.com/replace-single-line-break )

Where would I put this regular expression best to avoid the newline tag for the editor?

Thanks again.

Massimo Di Pierro

unread,
Nov 29, 2012, 3:27:19 PM11/29/12
to web...@googlegroups.com
The idea was to insert explicit newlines inside tags like H1, H2, etc.

Dirk Krause

unread,
Nov 29, 2012, 4:27:12 PM11/29/12
to web...@googlegroups.com
I see, and thank you. Now we already have a database full of text without the 'newline' tag and I have two options:
(1) traverse through the database and applying foresaid regex to all text fields or
(2) hack the regex somewhere into the code.

I just tried (2) and it seems to be working; I applied this:
{{=MARKMIN(re.sub(r'([^\n])\n([^\n])', r'\1[[NEWLINE]]\n\2', theText))}}
and it seems to be working.

So that's ok now, but when I do a CSV export it's not in so I my guess is I need to change the MARKMIN renderer itself, right?

Massimo Di Pierro

unread,
Nov 29, 2012, 4:51:45 PM11/29/12
to web...@googlegroups.com
Why do you want the newline at all? If you have \n\n in your text, it will be used to brak <p>...</p>. You can just add space after </p> with css.

Dirk Krause

unread,
Nov 29, 2012, 4:58:18 PM11/29/12
to web...@googlegroups.com
I learned from my editor that there is a huge difference between a paragraph and a line break. This also documented on a different thread here - people writing texts need both.

apps in tables

unread,
Dec 2, 2012, 3:43:22 AM12/2/12
to web...@googlegroups.com

I am trying these:

<td class="span8">{{=(row.body1)+  \n\n              +(row.body2)}}</td>

<td class="span8">{{=(row.body1)+ ' \n\n '            +(row.body2)}}</td>

<td class="span8">{{=(row.body1)+ [[NEWLINE]]  +(row.body2)}}</td>

<td class="span8">{{=(row.body1)+ '[[NEWLINE]]' +(row.body2)}}</td>

and they are not working.

What am i missing?

Regards,

Ashraf
Message has been deleted

Massimo Di Pierro

unread,
Dec 2, 2012, 4:45:50 AM12/2/12
to web...@googlegroups.com
You are missing that you need to generate html <br/> and {{=anything}} always escape anything.

You want:

<td class="span8">{{=(row.body1)}}<br/>{{=(row.body2)}}</td> 

or

<td class="span8">{{=CAT(row.body1,BR(),row.body2)}}</td>

or

<td class="span8">{{=CAT(row.body1,XML('<br/>'),row.body2)}}</td>

or 

<td class="span8">{{=XML(row.body1+'<br/>'+row.body2, sanitize=True)}}</td>

The latter is not quite the same as the others as it allows some HTML in the row.body1/2.

apps in tables

unread,
Dec 2, 2012, 9:51:49 AM12/2/12
to web...@googlegroups.com
Thank you...

Andrew W

unread,
Dec 6, 2012, 6:42:48 PM12/6/12
to web...@googlegroups.com
I assume you are no longer talking about markmin.   I didn't think you could use {{  }}  in markmin.

Correct ?
Reply all
Reply to author
Forward
0 new messages