More Maruku #to_markdown fixes.

Is there any point to this?
What version of Markdown are
we targetting, anyway?
master
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 "]
def mysplit
res = split.map{|x| x+" "}
if self[0] == 32
if self[0] == ' '
res[0] = " " + res[0]
end
res
@ -59,7 +59,7 @@ module MaRuKu; module Out; module Markdown
end
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
def to_md_quote(context)
@ -68,7 +68,7 @@ module MaRuKu; module Out; module Markdown
end
def to_md_hrule(context)
"* * *"
"* * *\n"
end
def to_md_emphasis(context)
@ -101,7 +101,7 @@ module MaRuKu; module Out; module Markdown
end
def to_md_im_link(context)
"[#{children_to_md(context)}](#{@url}#{" #{@title}" if @title})"
"[#{children_to_md(context)}](#{@url}#{" \"#{@title}\"" if @title})"
end
def to_md_link(context)
@ -109,14 +109,14 @@ module MaRuKu; module Out; module Markdown
end
def to_md_im_image(context)
"![#{children_to_md(context)}](#{@url}#{" #{@title}" if @title})"
"![#{children_to_md(context)}](#{@url}#{" \"#{@title}\"" if @title})"
end
def to_md_image(context)
"![#{children_to_md(context)}][#{@ref_id}]"
end
def to_md_ref_definition(context)
"[#{@ref_id}] #{@url}#{" #{@title}" if @title}"
"[#{@ref_id}] #{@url}#{" \"#{@title}\"" if @title}"
end
def to_md_li_span(context)
@ -130,7 +130,7 @@ module MaRuKu; module Out; module Markdown
def to_md_abbr_def(context)
"*[#{self.abbr}]: #{self.text}\n"
end
def to_md_ol(context)
len = (context[:line_length] || DefaultLineLength) - 2
md = ""

View File

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

View File

@ -51,18 +51,15 @@ Paragraph with a.
Paragraph with \emph{emphasis}
*** Output of to_md ***
## Header with attributes ## {#header1}
## Header with attributes ##
### Header with attributes ### {#header2}
### Header with attributes ###
### Header no attributes ###
{:warn2}Paragraph with a.
{#par1}
Paragraph with a.
Paragraph with *emphasis*{:hello notfound}
{#par2}
Paragraph with *emphasis*
{:hello: .chello}
*** Output of to_s ***
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
one
four
This block is composed of 2
two
*** Output of to_s ***
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):
Code
This is not code
Code
@ -70,6 +71,7 @@ This is not code
This is code (1 tab):
Code
This is not code
Code

View File

@ -6,15 +6,24 @@ Write a comment abouth the test here.
This is an email address: <andrea@invalid.it>
Address: <andrea@invalid.it>
*** Output of inspect ***
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 ***
<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 ***
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 ***
This is an email address: <andrea@invalid.it>
*** Output of to_s ***
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;
It should read just like this: `&copy;`.
It should read like this: `&copy;`.
*** Output of inspect ***
@ -44,7 +44,7 @@ md_el(:document,[
]),
md_par(["The following should not be translated:"]),
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 ***
<p>Maruku translates HTML entities to the equivalent in LaTeX:</p>
@ -60,7 +60,7 @@ md_el(:document,[
<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 ***
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:
\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 ***
Maruku translates HTML entities to the
equivalent in LaTeX:
@ -99,6 +99,6 @@ The following should not be translated:
&copy;
It should read just like this: `&copy;`.
It should read like this: `&copy;`.
*** 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: ! \! \` \{ \} \[ \] \( \) \# \. \! * \* *
Ora, *emphasis*, **bold**, * <- due asterischi-> * , un underscore-> _ , _emphasis_,
incre*dible*e!
Ora, *emphasis*, **bold**, * <- due
asterischi-> * , un underscore-> _ ,
*emphasis*, incre*dible*e!
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}
*** 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
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.
*** Output of to_md ***
Examples of numeric character
references include &169;or &169;for the
copyright symbol, &913;or &913;for the
Greek capital letter alpha, and &1575;
or &1575;for the Arabic letter alef.
references include &169; or &169; for
the copyright symbol, &913; or &913;
for the Greek capital letter alpha,
and &1575; or &1575; for the Arabic
letter alef.
*** 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.

View File

@ -35,5 +35,10 @@ md_el(:document,[
\vspace{.5em} \hrule \vspace{.5em}
*** Output of to_md ***
* * *
* * *
* * *
* * *
* * *
*** 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:
*** 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"

View File

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

View File

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