New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extra empty lines not showing up in preview using parsedown and codeigniter #450
Comments
Yes. The second image is correct but also not using code format. |
He's not talking about code blocks @aidantwoods, he wants something similar to @wolfgang1983: Markdown works with paragraphs, not with line breaks. You'll have to explicitly tell Parsedown to create a "empty" paragraph. There are many ways to accomplish this, here are some examples: paragraph 1
<br />
paragraph 2 paragraph 1
paragraph 2 The following is the most syntactically correct, but depending on your website's stylesheet it may not be visible: paragraph 1
<p></p>
paragraph 2 |
@PhrozenByte I tried using nl2br but when it does it effect the code indent. Codeigniter
|
You are not supposed to use |
Issue #448 (comment) may help RE inserting lines within normal text, if you really can't use HTML to do it. Also, for the literal '—' character inside |
cc @erusev shall I make a PR with something similar to the diff linked to in the above comment? (similar: can probably implement a bit cleaner). I guess this is a feature that a few people would find useful (even though it will break a few commonmark tests if enabled). |
Is this about code blocks or not? I'm confused :/ Parsedown has an option called |
@erusev I think it's about regular text (though I guess the code blocks is a separate issue). I think |
Have updated question/issue with image |
As said, this is expected behavior, it's consistent to both the original Markdown description and the CommonMark specs. @wolfgang1983, you'll either have to extend Parsedown (see wiki) or use one of the workarounds described in #450 (comment). |
With |
@erusev: I always thought that This is a longer text with
a custom line break gets This is a longer text with Normally Parsedown (and most other Markdown parsers; this btw complies to both the original Markdown description and the CommonMark specs) would parse this to (i.e. no line break) This is a longer text with a custom line break This doesn't affect multiple empty lines, those are still parsed as two paragraphs (and not three). So This is a longer text with
three empty lines gets This is a longer text with three empty lines with both GitHub flawored Markdown and Parsedown, no matter @wolfgang1983 in contrast is trying to achieve something like this with the previous example: This is a longer text with three empty lines |
Right, I believe you are correct, |
@erusev is it worth adding in another built in setter for literal line breaks (similar (but possibly cleaner than) this patch I threw together #448 (comment))? Given this issue (and the one opened in the linked comment) are both requesting the same functionality I'd guess it might be a useful addon for at least a few people. Also, since |
@aidantwoods: Just my 2 cents: Sure, why not (with another option like your suggested paragraph 1
paragraph 2 should result in the HTML <p>paragraph 1</p>
<p></p>
<p>paragraph 2</p> when this new option |
@aidantwoods on my code a where would place it I did a test tun but nothing happened. |
@aidantwoods This seems like a feature that should rather be built is an extension, I appreciate the offer, though. |
@erusev Alright, no worries 👍 @wolfgang1983 I've created a seperate branch with Branch: https://github.com/aidantwoods/parsedown/tree/patch-6 Diff: aidantwoods@fd681ee#diff-ed0d3da57330712681e64f838087ea47 |
@aidantwoods will give it ago. I like this parsedown.php my fav so far. |
@aidantwoods works fine now thanks |
@aidantwoods I have just started testing it getting code from database with new lines ->setLiteralBreaks(true) but getting it from database now throws error. Was working fine with jquery preview but now have to get from db but throws error when enable ->setLiteralBreaks(true)
|
@wolfgang1983 Have you got some test data you could give me that replicates the issue so I can track it down? |
@aidantwoods I use codeigniter I have put the parsedown.php in my libraries folder here is my controller I have loaded the library in the __construct are and on the get_form is where I use ->text() http://pastebin.com/raw/HaQ3eBR9 I just seems $Parsedown->setLiteralBreaks(true); if I have text and then code under it will throw error. Message: Uninitialized string offset: 0 |
@wolfgang1983 have you got any of the actual text that caused the error? (i.e. something that would be returned by |
@aidantwoods I tried it just like this way it does not seem which is similar to text I would get from database but sill produces error I just put \n\n for new lines same as me pressing enter for new line in text area as testing but still error when set this to $Parsedown->setLiteralBreaks(true);
And throws same error.
|
@wolfgang1983 Just updated the branch (diff: aidantwoods@539f152) Moved the code that creates text on a blank line to before the continuable/completable checks are made (which rely on the first char in the line). By the way, because setLiteralBreaks essentially just removes the ability for a blank line to interrupt a paragraph – you won't be able to start an unmarked code block (i.e. from your example |
@aidantwoods Hi again, I Know this is closed but small bug in your add on https://github.com/aidantwoods/parsedown When I have enabled setLiteralBreaks(true) for some reason it add br to every line it should only be for the extra spaces I create. Because now it effects the code indents and removes pre tags for code |
Is this happening with the markerless code block? (I.e. Text that is indented >= 4 times to become code?) |
@aidantwoods when I have my code intended 4 spaces and have setLiteralBreaks(true) in preview as showing in image for some reason removes pre and code tags. What I would of liked is only when I click enter on a line does it add newline only for that line i use $Parsedown->text() |
Yeah, that's expected behaviour really – as said in #450 (comment). You'd need to use Per commonmark spec: an unmarked code block cannot interrupt a paragraph (but a line containing only whitespace can). (An unmarked code block is one that is indented, and contains no (non-whitespace) 'markers' to delimit the code).
You can use a marked code block to enclose code, the only other solution would be to have |
Thanks once again |
Hi, @aidantwoods I have noticed a small issue with the code you gave me with lists the if press enter after the last list number or bulleted one it should clear it but for some reason when ever I start a new line after the last list item it still thinks its in list. How to solve this |
Seems this is an issue with Parsedown (rather than this particular extension).
1. list item
2. list item
```
code
``` as 1. list item
2. list item
```
code
``` Parsedown parses the former (correctly) as <ol>
<li>list item</li>
<li>list item</li>
</ol>
<pre><code>code</code></pre> But fails when parsing the latter by neglecting to honour list content indentation rules specified in commonmark, and so the following is produced for the latter: <ol>
<li>list item</li>
<li>list item
<pre><code>code</code></pre></li>
</ol> The correct result for a commonmark compliant parser for the latter markdown text can be found here: http://spec.commonmark.org/dingus/?text=1.%20list%20item%0A2.%20list%20item%0A%60%60%60%0Acode%0A%60%60%60 and is as follows: <ol>
<li>list item</li>
<li>list item</li>
</ol>
<pre><code>code
</code></pre> Probably the best thing to do is open another issue with Parsedown about code blocks not being able to interrupt a list block based on indentation. Once Parsedown can do this then you'll be able to start a new code block after a list with |
Previewing parsedown not displaying correct newlines in preview
With
<br/>
manually entered texarea I do not want to have to enter<br/>
all the time if need to have extra linesQuestion: How can I get it to show correct lines amount of lines that are in the textarea to preview?
Controller How I load the parsedown.php
if I replace
\n
with<br>
it will effect the code indents I have tried nl2br() alsoScript
it's one of the best markdowns this is the only thing I can that need to fix.
The text was updated successfully, but these errors were encountered: