More Maruku #to_markdown fixes.

Is there any point to this?
What version of Markdown are
we targetting, anyway?
This commit is contained in:
Jacques Distler 2011-08-21 13:41:20 -05:00
parent f463a3b1c8
commit 477bd91567
14 changed files with 69 additions and 51 deletions

View file

@ -28,7 +28,7 @@ class String
# " andrea censi " => [" andrea ", "censi "] # " andrea censi " => [" andrea ", "censi "]
def mysplit def mysplit
res = split.map{|x| x+" "} res = split.map{|x| x+" "}
if self[0] == 32 if self[0] == ' '
res[0] = " " + res[0] res[0] = " " + res[0]
end end
res res
@ -59,7 +59,7 @@ module MaRuKu; module Out; module Markdown
end end
def to_md_code(context) def to_md_code(context)
@raw_code.split("\n").collect { |line| " " + line}.join("\n") + "\n" @raw_code.split("\n").collect { |line| " " + line}.join("\n") + "\n\n"
end end
def to_md_quote(context) def to_md_quote(context)
@ -68,7 +68,7 @@ module MaRuKu; module Out; module Markdown
end end
def to_md_hrule(context) def to_md_hrule(context)
"* * *" "* * *\n"
end end
def to_md_emphasis(context) def to_md_emphasis(context)
@ -101,7 +101,7 @@ module MaRuKu; module Out; module Markdown
end end
def to_md_im_link(context) def to_md_im_link(context)
"[#{children_to_md(context)}](#{@url}#{" #{@title}" if @title})" "[#{children_to_md(context)}](#{@url}#{" \"#{@title}\"" if @title})"
end end
def to_md_link(context) def to_md_link(context)
@ -109,14 +109,14 @@ module MaRuKu; module Out; module Markdown
end end
def to_md_im_image(context) def to_md_im_image(context)
"![#{children_to_md(context)}](#{@url}#{" #{@title}" if @title})" "![#{children_to_md(context)}](#{@url}#{" \"#{@title}\"" if @title})"
end end
def to_md_image(context) def to_md_image(context)
"![#{children_to_md(context)}][#{@ref_id}]" "![#{children_to_md(context)}][#{@ref_id}]"
end end
def to_md_ref_definition(context) def to_md_ref_definition(context)
"[#{@ref_id}] #{@url}#{" #{@title}" if @title}" "[#{@ref_id}] #{@url}#{" \"#{@title}\"" if @title}"
end end
def to_md_li_span(context) def to_md_li_span(context)

View file

@ -40,12 +40,12 @@ The HTML specification is maintained by the W3C.
Operation Tigra Genesis is going well. Operation Tigra Genesis is going well.
*** Output of to_md *** *** Output of to_md ***
The HTMLspecification is maintained by The HTML specification is maintained by
the W3C. the W3C.
*[HTML]: Hyper Text Markup Language *[HTML]: Hyper Text Markup Language
*[W3C]: World Wide Web Consortium *[W3C]: World Wide Web Consortium
Operation Tigra Genesisis going well. Operation Tigra Genesis is going well.
*[Tigra Genesis]: *[Tigra Genesis]:
*** Output of to_s *** *** Output of to_s ***

View file

@ -51,18 +51,15 @@ Paragraph with a.
Paragraph with \emph{emphasis} Paragraph with \emph{emphasis}
*** Output of to_md *** *** Output of to_md ***
## Header with attributes ## {#header1} ## Header with attributes ##
### Header with attributes ### {#header2} ### Header with attributes ###
### Header no attributes ### ### Header no attributes ###
{:warn2}Paragraph with a. Paragraph with a.
{#par1}
Paragraph with *emphasis*{:hello notfound} Paragraph with *emphasis*
{#par2}
{:hello: .chello}
*** Output of to_s *** *** Output of to_s ***
Header with attributesHeader with attributesHeader no attributesParagraph with a.Paragraph with emphasis Header with attributesHeader with attributesHeader no attributesParagraph with a.Paragraph with emphasis

View file

@ -74,17 +74,15 @@ This block is composed of three lines:
This block is composed of 5 This block is composed of 5
one one
four four
This block is composed of 2 This block is composed of 2
two two
*** Output of to_s *** *** Output of to_s ***
This block is composed of three lines:This block is composed of 5This block is composed of 2 This block is composed of three lines:This block is composed of 5This block is composed of 2

View file

@ -63,6 +63,7 @@ This is not code
This is code (4 spaces): This is code (4 spaces):
Code Code
This is not code This is not code
Code Code
@ -70,6 +71,7 @@ This is not code
This is code (1 tab): This is code (1 tab):
Code Code
This is not code This is not code
Code Code

View file

@ -6,15 +6,24 @@ Write a comment abouth the test here.
This is an email address: <andrea@invalid.it> This is an email address: <andrea@invalid.it>
Address: <andrea@invalid.it>
*** Output of inspect *** *** Output of inspect ***
md_el(:document,[ md_el(:document,[
md_par(["This is an email address: ", md_email("andrea@invalid.it")]) md_par(["This is an email address: ", md_email("andrea@invalid.it")]),
md_par(["Address: ", md_email("andrea@invalid.it")])
],{},[]) ],{},[])
*** Output of to_html *** *** Output of to_html ***
<p>This is an email address: <a href="mailto:andrea@invalid.it">&#097;&#110;&#100;&#114;&#101;&#097;&#064;&#105;&#110;&#118;&#097;&#108;&#105;&#100;&#046;&#105;&#116;</a></p> <p>This is an email address: <a href="mailto:andrea@invalid.it">&#097;&#110;&#100;&#114;&#101;&#097;&#064;&#105;&#110;&#118;&#097;&#108;&#105;&#100;&#046;&#105;&#116;</a></p>
<p>Address: <a href="mailto:andrea@invalid.it">&#097;&#110;&#100;&#114;&#101;&#097;&#064;&#105;&#110;&#118;&#097;&#108;&#105;&#100;&#046;&#105;&#116;</a></p>
*** Output of to_latex *** *** Output of to_latex ***
This is an email address: \href{mailto:andrea@invalid.it}{andrea\char64invalid\char46it} This is an email address: \href{mailto:andrea@invalid.it}{andrea\char64invalid\char46it}
Address: \href{mailto:andrea@invalid.it}{andrea\char64invalid\char46it}
*** Output of to_md *** *** Output of to_md ***
This is an email address: <andrea@invalid.it>
*** Output of to_s ***
This is an email address: This is an email address:
<andrea@invalid.it>
Address: <andrea@invalid.it>
*** Output of to_s ***
This is an email address: Address:

View file

@ -19,7 +19,7 @@ The following should not be translated:
&copy; &copy;
It should read just like this: `&copy;`. It should read like this: `&copy;`.
*** Output of inspect *** *** Output of inspect ***
@ -44,7 +44,7 @@ md_el(:document,[
]), ]),
md_par(["The following should not be translated:"]), md_par(["The following should not be translated:"]),
md_el(:code,[],{:raw_code=>"&copy;"},[]), md_el(:code,[],{:raw_code=>"&copy;"},[]),
md_par(["It should read just like this: ", md_code("&copy;"), "."]) md_par(["It should read like this: ", md_code("&copy;"), "."])
],{},[]) ],{},[])
*** Output of to_html *** *** Output of to_html ***
<p>Maruku translates HTML entities to the equivalent in LaTeX:</p> <p>Maruku translates HTML entities to the equivalent in LaTeX:</p>
@ -60,7 +60,7 @@ md_el(:document,[
<pre><code>&amp;copy;</code></pre> <pre><code>&amp;copy;</code></pre>
<p>It should read just like this: <code>&amp;copy;</code>.</p> <p>It should read like this: <code>&amp;copy;</code>.</p>
*** Output of to_latex *** *** Output of to_latex ***
Maruku translates HTML entities to the equivalent in \LaTeX\xspace : Maruku translates HTML entities to the equivalent in \LaTeX\xspace :
@ -79,7 +79,7 @@ Entity-substitution does not happen in code blocks or inline code.
The following should not be translated: The following should not be translated:
\begin{verbatim}&copy;\end{verbatim} \begin{verbatim}&copy;\end{verbatim}
It should read just like this: {\colorbox[rgb]{1.00,0.93,1.00}{\tt \char38copy\char59}}. It should read like this: {\colorbox[rgb]{1.00,0.93,1.00}{\tt \char38copy\char59}}.
*** Output of to_md *** *** Output of to_md ***
Maruku translates HTML entities to the Maruku translates HTML entities to the
equivalent in LaTeX: equivalent in LaTeX:
@ -99,6 +99,6 @@ The following should not be translated:
&copy; &copy;
It should read just like this: `&copy;`. It should read like this: `&copy;`.
*** Output of to_s *** *** Output of to_s ***
Maruku translates HTML entities to the equivalent in LaTeX:EntityResultabEntity-substitution does not happen in code blocks or inline code.The following should not be translated:It should read just like this: . Maruku translates HTML entities to the equivalent in LaTeX:EntityResultabEntity-substitution does not happen in code blocks or inline code.The following should not be translated:It should read like this: .

View file

@ -55,8 +55,9 @@ End of {\colorbox[rgb]{1.00,0.93,1.00}{\tt paragraph~}}
Hello: ! \! \` \{ \} \[ \] \( \) \# \. \! * \* * Hello: ! \! \` \{ \} \[ \] \( \) \# \. \! * \* *
Ora, *emphasis*, **bold**, * <- due asterischi-> * , un underscore-> _ , _emphasis_, Ora, *emphasis*, **bold**, * <- due
incre*dible*e! asterischi-> * , un underscore-> _ ,
*emphasis*, incre*dible*e!
This is ``Code with a special: -> ` <- ``(after) This is ``Code with a special: -> ` <- ``(after)

View file

@ -53,11 +53,11 @@ Then you can create links to different parts of the same document like this:
\hyperlink{header1}{Link back to header 1}, \hyperlink{header2}{Link back to header 2}, \hyperlink{header3}{Link back to header 3} \hyperlink{header1}{Link back to header 1}, \hyperlink{header2}{Link back to header 2}, \hyperlink{header3}{Link back to header 3}
*** Output of to_md *** *** Output of to_md ***
# Header 1 # {#header1} # Header 1 #
## Header 2 ## {#header2} ## Header 2 ##
### Header 3 ### {#header3} ### Header 3 ###
Then you can create links to different Then you can create links to different
parts of the same document like this: parts of the same document like this:

View file

@ -29,9 +29,10 @@ md_el(:document,[
Examples of numeric character references include \copyright{} or \copyright{} for the copyright symbol, $A${} or $A${} for the Greek capital letter alpha, and or for the Arabic letter alef. Examples of numeric character references include \copyright{} or \copyright{} for the copyright symbol, $A${} or $A${} for the Greek capital letter alpha, and or for the Arabic letter alef.
*** Output of to_md *** *** Output of to_md ***
Examples of numeric character Examples of numeric character
references include &169;or &169;for the references include &169; or &169; for
copyright symbol, &913;or &913;for the the copyright symbol, &913; or &913;
Greek capital letter alpha, and &1575; for the Greek capital letter alpha,
or &1575;for the Arabic letter alef. and &1575; or &1575; for the Arabic
letter alef.
*** Output of to_s *** *** Output of to_s ***
Examples of numeric character references include or for the copyright symbol, or for the Greek capital letter alpha, and or for the Arabic letter alef. Examples of numeric character references include or for the copyright symbol, or for the Greek capital letter alpha, and or for the Arabic letter alef.

View file

@ -35,5 +35,10 @@ md_el(:document,[
\vspace{.5em} \hrule \vspace{.5em} \vspace{.5em} \hrule \vspace{.5em}
*** Output of to_md *** *** Output of to_md ***
* * *
* * *
* * *
* * *
* * *
*** Output of to_s *** *** Output of to_s ***

View file

@ -72,15 +72,21 @@ I'{}ll say it one more time: this page does not use
This is double size: This is double size:
*** Output of to_md *** *** Output of to_md ***
This page does not utilize ![Cascading Style Sheets](http://jigsaw.w3.org/css-validator/images/vcss) This page does not utilize
![Cascading Style Sheets](http://jigsaw.w3.org/css-validator/images/vcss)
Please mouseover to see the title: ![Cascading Style Sheets](http://jigsaw.w3.org/css-validator/images/vcss "Title ok!") Please mouseover to see the title:
![Cascading Style Sheets](http://jigsaw.w3.org/css-validator/images/vcss "Title ok!")
Please mouseover to see the title: ![Cascading Style Sheets](http://jigsaw.w3.org/css-validator/images/vcss 'Title ok!') Please mouseover to see the title:
![Cascading Style Sheets](http://jigsaw.w3.org/css-validator/images/vcss "Title ok!")
I'll say it one more time: this page does not use ![Cascading Style Sheets] [css] I'll say it one more time: this
page does not use
![Cascading Style Sheets][css]
This is double size: ![Cascading Style Sheets] [css2] This is double size:
![Cascading Style Sheets][css2]
[css]: http://jigsaw.w3.org/css-validator/images/vcss "Optional title attribute" [css]: http://jigsaw.w3.org/css-validator/images/vcss "Optional title attribute"

View file

@ -33,9 +33,9 @@ md_el(:document,[
\end{itemize} \end{itemize}
*** Output of to_md *** *** Output of to_md ***
- - A
- - ?
- - B
*** Output of to_s *** *** Output of to_s ***
A?B A?B

View file

@ -47,15 +47,14 @@ This is ruby code:
*** Output of to_md *** *** Output of to_md ***
This is ruby code: This is ruby code:
require 'maruku' require 'maruku'
puts Maruku.new($stdin).to_html puts Maruku.new($stdin).to_html
This is ruby code: This is ruby code:
require 'maruku' require 'maruku'
{: lang=ruby html_use_syntax}
puts Maruku.new($stdin).to_html puts Maruku.new($stdin).to_html
*** Output of to_s *** *** Output of to_s ***
This is ruby code:This is ruby code: This is ruby code:This is ruby code: