Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Notextile strips line breaks #109

Closed
dewyatt opened this issue Aug 24, 2013 · 1 comment
Closed

Notextile strips line breaks #109

dewyatt opened this issue Aug 24, 2013 · 1 comment

Comments

@dewyatt
Copy link

dewyatt commented Aug 24, 2013

http://forum.textpattern.com/viewtopic.php?pid=274764

Example:

notextile..
1

2
3

Should preserve the empty line but does not.

@gocom
Copy link
Member

gocom commented Aug 24, 2013

This seems to affect all blocks; code blocks and what not. Textile replaces all instances of newlines with hard-coded number;

  • In Parser::cleanWhiteSpace() every CRLF and CR are truncated down to one LF...
  • ...any left over empty lines (lines containing only whitespace, e.g. tabs, LF\t) are replaces with LF
  • Then three or more LFs are truncated to down to two.

The output alterations start there. Output can never contain more than two LFs, but that doesn't really matter, since the parser itself doesn't output the whitespace it was given:

  • Parser::blocks() splits given text to blocks by every instance of two LFs; the cleaning makes sure the document contains nothing, but LFLF and LF. There are no whitespace lines left at this point.
  • It then goes over the blocks, formats them.
  • Blocks are joined by two LFs, and lines in those blocks with some number.

For instance for bc its one, but there are inline code tags which kinda result in correct formatting; well, up to one empty line (the correct formatting itself is side-affect). In pre. and notexile. where there are no line wrappers, the resulting markup contains no empty lines.

I was trying to fix this by simply joining lines correctly, but looking at the issue closer, this may really need a bigger rewrite. The newline and whitespace cleaning at least needs to go. It can replace CRLF and CR with single LF, but nothing more. Anything else results in noticeable alterations.

The block parser should be changed to preg_split and the match stored and passed down to block formatters. The hard-coded join value removed, and each block is joined by what it was split with. Same for lines.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants