Multi-line code markdown

28 views
Skip to first unread message

Andrew Pike

unread,
Apr 3, 2018, 5:04:22 AM4/3/18
to nvpy
Hi,

Is it possible to have more than one line of code using markdown?  For example, the below works fine:

`
PHPSESSIONPATH="/tmp"
`

But include more than one line.....


`
PHPSESSIONPATH="/tmp"
PHPSESSIONLIFETIME=$(php -i 2>/dev/null | grep -w session.gc_maxlifetime | awk '{print $3}' | head -1);
PHPSESSIONLIFETIMEMINUTE=$( expr $PHPSESSIONLIFETIME / 60 );
`

and although it changes the font, all three lines are outputted as one line...

PHPSESSIONPATH="/tmp" PHPSESSIONLIFETIME=$(php -i 2>/dev/null | grep -w session.gc_maxlifetime | awk '{print $3}' | head -1); PHPSESSIONLIFETIMEMINUTE=$( expr $PHPSESSIONLIFETIME / 60 );

Not ideal.  Is this a bug or am I missing something?

Andrew Pike

unread,
Apr 3, 2018, 11:43:58 AM4/3/18
to nvpy
So to answer my own question - just indent each line in the code block by 4 spaces or 1 tab:

    PHPSESSIONPATH="/tmp"
    PHPSESSIONLIFETIME=$(php -i 2>/dev/null | grep -w session.gc_maxlifetime | awk '{print $3}' | head -1);
    PHPSESSIONLIFETIMEMINUTE=$( expr $PHPSESSIONLIFETIME / 60 );




平野勇輝

unread,
Apr 5, 2018, 6:01:09 PM4/5/18
to nvpy
Thank you for your bug report.
This problem is solves by enable the "fenced_code" extension. Please append those line to your "nvpy.cnf" file.

md_extensions = markdown.extensions.fenced_code


I think default behavior of markdown converter is not intuitive. so I pushed a commit that enable some extensions by default.


2018年4月4日水曜日 0時43分58秒 UTC+9 Andrew Pike:
Reply all
Reply to author
Forward
0 new messages