Questions on markdown

19 views
Skip to first unread message

leo

unread,
Jul 4, 2011, 1:06:29 PM7/4/11
to django...@googlegroups.com
I using a textfield to store some information and in admin
input interface i enter like this


Action: check WSMB
Reason: customer check this then got error
Result: finish, result is good, in spec

every single sentence every row, I using markdown to convert
this plain text to html but it did not go as i expected.

the formated text is below,


<p>Action: check WSMB
Reason: customer check this then got error
Result: finish, result is good, in spec</p>

this is not what i expected, i want every single sentence every row,
it misses some html mark.
what should i do?

someone help me.


My function of markdown.

from markdown import markdown

save(self):
self.action_html = markdown(self.action_detail, extensions = [],
safe_mode=True, output_format = 'html4',)

creecode

unread,
Jul 4, 2011, 1:46:49 PM7/4/11
to django...@googlegroups.com, chli...@gmail.com
Hello Liu,

On Monday, July 4, 2011 10:06:29 AM UTC-7, Liu Lin wrote:

If I understand your post correctly you are entering in something like...

Action: check WSMB
Reason: customer check this then got error
Result: finish, result is good, in spec

...in a field of your form.  Upon save you process this field with markdown and you want to store something like...

<p>Action: check WSMB</p>
<p>Reason: customer check this then got error</p>
<p>Result: finish, result is good, in spec</p>
 
I'm no markdown expert but I would say this is a problem of your understanding of how markdown turns it's markup and into html not a problem with Django or the markdown package.

To achieve the results you want I think you would need to enter something like...


Action: check WSMB

Reason: customer check this then got error

Result: finish, result is good, in spec

You need a blank line between each line.

Alternately you could preprocess the input and add the extra lines yourself before processing with markdown..

Toodle-looooooooooooooo...............
creecode

Masklinn

unread,
Jul 4, 2011, 1:59:10 PM7/4/11
to django...@googlegroups.com
On 2011-07-04, at 19:06 , leo wrote:
> I using a textfield to store some information and in admin
> input interface i enter like this
>
>
> Action: check WSMB
> Reason: customer check this then got error
> Result: finish, result is good, in spec
>
> every single sentence every row, I using markdown to convert
> this plain text to html but it did not go as i expected.
>
> the formated text is below,
>
>
> <p>Action: check WSMB
> Reason: customer check this then got error
> Result: finish, result is good, in spec</p>
>
> this is not what i expected, i want every single sentence every row,
> it misses some html mark.
> what should i do?
>
> someone help me.
Well depends. This behavior is as per "spec" for the original markdown dialect: single newlines are ignored (they're basically seen as line wrapping), double newlines create new paragraphs, ending a line with two spaces creates a hard return.

Since you have not specified what you expect your markdown text to become, there is little we can do to help you with.

leo

unread,
Jul 4, 2011, 2:02:48 PM7/4/11
to django...@googlegroups.com
Yes, you totally understood me,actually I copied the text from word and
paste into textfield, it is very inconvenience manually add a blank line
and also as you mentioned,if I put blank line between each line the appearance
is not what i like i like this

 
Action: check WSMB
Reason: customer check this then got error
Result: finish, result is good, in spec

so do you have any suggestion to achieve this goal?

Thank you very much.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/Tjkni_VHXCUJ.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

--
chlin

leo

unread,
Jul 4, 2011, 2:08:03 PM7/4/11
to django...@googlegroups.com, Masklinn
The original text is

Action: check WSMB
Reason: customer check this then got error
Result: finish, result is good, in spec

what i want is

html format

Action: check WSMB<br>
Reason: customer check this then got error<br>
Result: finish, result is good, in spec<br>

--
chlin

Petite Abeille

unread,
Jul 4, 2011, 2:22:13 PM7/4/11
to django...@googlegroups.com

On Jul 4, 2011, at 8:08 PM, leo wrote:

> what i want is

To quote the friendly manual:

"When you do want to insert a <br /> break tag using Markdown, you end a line with two or more spaces, then type return."

http://daringfireball.net/projects/markdown/syntax#p

DrBloodmoney

unread,
Jul 5, 2011, 6:03:30 AM7/5/11
to django...@googlegroups.com

If you're copy/pasting test that's not Markdown, then Markdown will
not magically help you. If you have unformatted text that you want to
turn into html, you're probably going to have to do a little text
pre-processing. Good news: you're using Python and text processing is
easily in python.

Derek

unread,
Jul 5, 2011, 9:23:54 AM7/5/11
to Django users
On Jul 5, 12:03 pm, DrBloodmoney <drbloodmo...@gmail.com> wrote:
> On Mon, Jul 4, 2011 at 2:22 PM, Petite Abeille <petite.abei...@gmail.com> wrote:
>
> > On Jul 4, 2011, at 8:08 PM, leo wrote:
>
> >> what i want is
>
> > To quote the friendly manual:
>
> > "When you do want to insert a <br /> break tag using Markdown, you end a line with two or more spaces, then type return."
>
> >http://daringfireball.net/projects/markdown/syntax#p
>
> If you're copy/pasting test that's not Markdown, then Markdown will
> not magically help you. If you have unformatted text that you want to
> turn into html, you're probably going to have to do a little text
> pre-processing.

Good news: you're using Python and text processing is easy in Python.
Bad news: even if you're using Python, you still have to know how to
use it ;)

bruno desthuilliers

unread,
Jul 5, 2011, 11:04:10 AM7/5/11
to Django users


On Jul 5, 3:23 pm, Derek <gamesb...@gmail.com> wrote:
>
> Good news: you're using Python and text processing is easy in Python.
> Bad news:  even if you're using Python, you still have to know how to
> use it ;)


Good news: you sometimes don't have anything to do - except, of
course, reading the FineManual(tm) and using the appropriate filters:
https://docs.djangoproject.com/en/1.3/ref/templates/builtins/#linebreaks

@OP: unless of course you wanted to use other markup features<g>

leo

unread,
Jul 5, 2011, 11:11:40 AM7/5/11
to django...@googlegroups.com
thank you all good news, with your help, I found a
way to achieve my goal.

on the way to what i want.

--
chlin

Benoit Perdu - TransMékong

unread,
Jul 6, 2011, 5:22:16 AM7/6/11
to django...@googlegroups.com
Leo,

If you want to wrap without the end of a paragraph, you should end your lines with 2 or more spaces then do a single new line.

This is as per the standard Markdown behaviour.

Also, make sure you parse all the text you need parsed in one go, not line by line.

All the best

Benoit
Reply all
Reply to author
Forward
0 new messages