2016-11-25 2 views
0

parsedown 및 codeigniter를 사용하고 있습니다. 내 텍스트 영역에 몇 가지 빈 줄을 추가 한 경우 미리보기에 표시되지 않습니다. 이 이미지 주에 나타낸 바와 같이 그것은 단지 미리보기 상자에서 한 \nparsedown 및 codeigniter를 사용하여 미리보기에 빈 줄 바꿈이 표시되지 않습니다.

을 추가 당신이 텍스트 영역 인 셋톱 박스에서 볼 수 있듯이 미리보기 이미지

enter image description here

에서 하단 박스입니다. 마지막 줄 바로 앞에 큰 간격이 있습니다. 미리보기에는 표시되지 않습니까? 나는 시도하고 BR 또는 nlbr 개행을 교체 할 경우 그것은 parsedown에 들여 쓰기 코드에 영향을 미친다

질문 CodeIgniter의를 사용하고 내가이 (가)의 동일한 액수가 표시됩니다 컨트롤러에서 에코 때 확인 할 수있는 방법 parsedown 윤곽.

스크립트

<script type="text/javascript"> 
$(document).ready(function() { 
    $('#editor').on('paste cut mouseup mousedown mouseout keydown keyup', function(){ 
     var postData = { 
      'html' : $('#editor').val(), 
     }; 
     $.ajax({ 
      type: "POST", 
      url: "<?php echo base_url('example/preview');?>", 
      data: postData, 
      dataType: 'json', 
      success: function(json){ 
       $('#output').html(json['output']); 
      } 
     }); 
    }); 
}); 
</script> 

컨트롤러

당신은 빈 줄을 만들 더블 브레이크 태그를 사용할 필요가
<?php 

class Example extends CI_Controller { 

public function __construct() { 
    parent::__construct(); 
    $this->load->library('parsedown'); 
} 

public function index() 
{ 
    $this->load->view('example_view'); 
} 

public function preview() { 
    $data['success'] = false; 
    $data['output'] = ''; 

    if ($this->input->post('html')) { 
     $data['success'] = true; 
     // Using br or nlbr effect the code indents so can not use it. 
     $data['output'] = str_replace('\n', '<br/>', $this->parsedown->text($this->input->post('html'))); 
    } 

    echo json_encode($data); 
} 

답변

0

.

Something on this line 
<br><br> 
This line has a blank line above it. 

즉 둘 이상의 빈 줄에 필요한 무엇을 작업 할 수 있습니다.

http://parsedown.org/demo에서 게임을 테스트 해보십시오.

+0

텍스트 상자에 각 줄마다
을 넣고 싶지는 않습니다. PHP에서 끝내기를 원합니다. 또한 str_replace에서
을 시도했지만 파서 드가 작동하지 않습니다. – user4419336

+0

음, 파서 다운으로 보내면 두 가지 모두 \ n 또는 \ r \ n- 테스트로 번역하고 nl2br()과 마찬가지로
을 추가하십시오. – TimBrownlaw

+0

예전 태그 등을 가질 때 방해가되면 다른 것을 찾아야합니다. – user4419336