2011-06-12 7 views
3

일부 Markdown 형식의 텍스트를 구문 분석하기 위해 Maruku (Ruby)를 사용하고 있습니다.Maruku가 두 번째 코드 블록을 잘못 구문 분석합니까?

This is a normal line 
# pretend this line is empty 
    printf("First line of code is OK"); 
    printf("Second line of code (or any line thereafter) appears indented by an extra level, which is incorrect!"); 

그래서 4 개 공간 (또는 탭)에 의해 내 MD 파일에 들여 쓰기 한 코드 (내 첫 번째 줄, 것처럼 렌더링 : 같은 같은 code의 블록을 포맷 할 때 나는 문제가 . 나는 그러나, 코드 내 두 번째 줄은 (공간의 정확히 같은 번호로 들여 쓰기)을 HTML이 생성 될 때 추가 4 공백으로 들여 쓰기 끝낸다 기대

출력은 다음과 같습니다.

This is a normal line 
<pre><code>printf("First line of code is OK"); 
     printf("Second line of code (or any line thereafter) appears indented by an extra level, which is incorrect!");</code></pre> 

Gruber의 "Dingus"로 Markdown 입력을 테스트했으며 (즉, 두 블록의 코드 줄이 모두 같은 수준으로 들여 쓰기되어 있습니다) 렌더링됩니다. 그러나 Maruku와 함께, 그것은 침대 다.

또한 RDiscount로 시도했지만 동일한 효과를 얻습니다. 나는 정의 목록이 필요하기 때문에 Maruku를 사용하고 있습니다.

어떻게 SO를 포맷 :

이 그것은 이것이 Maruku 문제지만 HAML 문제가 아니었다 밝혀 법선

printf("First line of code is OK\n"); 
printf("Second line of code (or any line thereafter) appears indented by an extra level, which is incorrect!"); 

답변

7

입니다.

HAML은 공백과 보존에 관해서는 까다 롭습니다. 렌더링 할 때 솔루션에 = preserve @my_html_string을 사용해야했습니다. layout.haml 주어진 예를 들어

:

!!! 5 
%html 
    %body 
     = yield 

%article 
    = preserve @my_html_fragment_with_pre_and_code 

index.haml는 그런 나를 위해 올바르게 렌더링 것이다.

+0

고맙습니다. 나는 Haml에 그것을 좁힐 때까지 원인을 발견하는 것을 시도해 아침을 잃고이 대답을 발견했다. –