0

"file_put_contents and a new line help" is close but does not help with my issue.

A user fills in a textarea, which is then sent to a php page for processing.

<form id="slidetext" method="POST" action="create-process.php">
<textarea cols="100" rows="20" id="text" name="text"></textarea>
<input type="submit" id="submit" name="submit">
</form>

The user's input is then used to create a new markdown file on the server.

$text = $_POST['text'];
$file = "files/example.md";
file_put_contents($file, $text);

This works and appears to create a file that adheres to the rules for data separation within the reveal.js framework:

<div class="reveal">
        <div class="slides">
            <section data-markdown="files/example.md"  
                data-separator="^\n\n\n"  
                data-vertical="^\n\n"  
                data-notes="^Note:"  
                data-charset="iso-8859-15">
            </section>      
        </div>
</div>

Despite the example.md file looking like it has new line breaks in the right places, it does not display properly.

If I write the same file manually it does however display as expected. Any help appreciated.

Community
  • 1
  • 1
Russell
  • 655
  • 2
  • 9
  • 21

1 Answers1

0

\r\n (Windows linebreaks) instead of \n (Unix linebreaks) might fix this.

mb21
  • 34,845
  • 8
  • 116
  • 142