Skip to content
This repository was archived by the owner on Jan 5, 2025. It is now read-only.

Commit

Permalink
Fix detection of lists indented by 2 or 3 spaces. Fixes #30
Browse files Browse the repository at this point in the history
  • Loading branch information
bhollis committed Feb 18, 2013
1 parent 9d19671 commit edcae2d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 25 deletions.
7 changes: 2 additions & 5 deletions lib/maruku/input/mdline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,8 @@ def line_md_type
return :header3 if self =~ /^(#)+\s*\S+/
# at least three asterisks/hyphens/underscores on a line, and only whitespace
return :hrule if self =~ /^(\s*[\*\-_]\s*){3,}$/
# Something is wrong with how we parse lists! :-(
#return :ulist if self =~ /^[ ]{0,3}([\*\-\+])\s+.*\w+/
#return :olist if self =~ /^[ ]{0,3}\d+\..*\w+/
return :ulist if self =~ /^[ ]{0,1}([\*\-\+])\s+.*/
return :olist if self =~ /^[ ]{0,1}\d+\.\s+.*/
return :ulist if self =~ /^[ ]{0,3}([\*\-\+])\s+.*/
return :olist if self =~ /^[ ]{0,3}\d+\.\s+.*/
return :quote if self =~ /^>/
return :metadata if self =~ /^@/
return :ald if self =~ AttributeDefinitionList
Expand Down
9 changes: 7 additions & 2 deletions spec/block_docs/issue30.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
PENDING - List markers typically start at the left margin, but may be indented by up to three spaces. https://github.com/bhollis/maruku/issues/30
List markers typically start at the left margin, but may be indented by up to three spaces. https://github.com/bhollis/maruku/issues/30
*** Parameters: ***
{}
*** Markdown input: ***
Expand All @@ -10,7 +10,12 @@ And this:

* still a list
*** Output of inspect ***
md_el(:document, [])
md_el(:document, [
md_par("This is a list:"),
md_el(:ul, md_el(:li_span, "a list", {:want_my_paragraph=>false})),
md_par("And this:"),
md_el(:ul, md_el(:li_span, "still a list", {:want_my_paragraph=>false}))
])
*** Output of to_html ***
<p>This is a list:</p>

Expand Down
50 changes: 32 additions & 18 deletions spec/block_docs/misc_sw.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,22 +214,16 @@ md_el(:document,[
"."
])
],{:want_my_paragraph=>false},[]),
md_el(:li,[
md_par([
md_em(["C++ libraries"]),
": * ",
md_link(["QT"],"qt"),
" for GUIs. * ",
md_link(["GSL"],"gsl"),
" for math. * ",
md_link(["Magick++"],"magick"),
" for manipulating images. * ",
md_link(["Cairo"],"cairo"),
" for creating PDFs. * ",
md_link(["Boost"],"boost"),
" for just about everything else."
])
],{:want_my_paragraph=>false},[])
md_li([
md_par([md_em("C++ libraries"), ":"]),
md_el(:ul, [
md_el(:li_span, [md_link("QT", "qt"), " for GUIs."], {:want_my_paragraph=>false}),
md_el(:li_span, [md_link("GSL", "gsl"), " for math."], {:want_my_paragraph=>false}),
md_el(:li_span, [md_link("Magick++", "magick"), " for manipulating images."], {:want_my_paragraph=>false}),
md_el(:li_span, [md_link("Cairo", "cairo"), " for creating PDFs."], {:want_my_paragraph=>false}),
md_el(:li_span, [md_link("Boost", "boost"), " for just about everything else."], {:want_my_paragraph=>false})
])
], true)
],{},[]),
md_el(:header,["Research"],{:level=>3},[]),
md_el(:ul,[
Expand Down Expand Up @@ -381,7 +375,19 @@ Type "help", "copyright", "credits" or "license" for more information.
</li>

<li>
<p><em>C++ libraries</em>: * <a href="http://www.trolltech.no/">QT</a> for GUIs. * <a href="http://www.gnu.org/software/gsl/">GSL</a> for math. * <a href="http://www.imagemagick.org/Magick++/">Magick++</a> for manipulating images. * <a href="http://cairographics.org/">Cairo</a> for creating PDFs. * <a href="http://www.boost.org/">Boost</a> for just about everything else.</p>
<p><em>C++ libraries</em>:</p>

<ul>
<li><a href="http://www.trolltech.no/">QT</a> for GUIs.</li>

<li><a href="http://www.gnu.org/software/gsl/">GSL</a> for math.</li>

<li><a href="http://www.imagemagick.org/Magick++/">Magick++</a> for manipulating images.</li>

<li><a href="http://cairographics.org/">Cairo</a> for creating PDFs.</li>

<li><a href="http://www.boost.org/">Boost</a> for just about everything else.</li>
</ul>
</li>
</ul>

Expand Down Expand Up @@ -450,8 +456,16 @@ Type "help", "copyright", "credits" or "license" for more information.
\item \emph{Mark-up language}: HTML is so 2001, why don't you take at look at \href{http://en.wikipedia.org/wiki/Markdown}{Markdown}? \href{data/misc_markdown.png}{Look at the source of this page}.


\item \emph{C++ libraries}: * \href{http://www.trolltech.no/}{QT} for GUIs. * \href{http://www.gnu.org/software/gsl/}{GSL} for math. * \href{http://www.imagemagick.org/Magick++/}{Magick++} for manipulating images. * \href{http://cairographics.org/}{Cairo} for creating PDFs. * \href{http://www.boost.org/}{Boost} for just about everything else.
\item \emph{C++ libraries}:

\begin{itemize}%
\item \href{http://www.trolltech.no/}{QT} for GUIs.
\item \href{http://www.gnu.org/software/gsl/}{GSL} for math.
\item \href{http://www.imagemagick.org/Magick++/}{Magick++} for manipulating images.
\item \href{http://cairographics.org/}{Cairo} for creating PDFs.
\item \href{http://www.boost.org/}{Boost} for just about everything else.

\end{itemize}


\end{itemize}
Expand Down

4 comments on commit edcae2d

@distler
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this commit completely break nested lists?

* First
  * Sub1
  * Sub 2
* Second

@bhollis
Copy link
Owner Author

@bhollis bhollis commented on edcae2d Feb 18, 2013 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@distler
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you try it and verify that it broke?

Duh. Of course I did.

So much for (non-"Pending") test coverage.

@bhollis
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, don't worry about it. There's a pending test for it, and pending tests are the "to do" list. I'll fix this along with all the rest of the list parsing.

Please sign in to comment.