Coder Social home page Coder Social logo

gettalong / kramdown Goto Github PK

View Code? Open in Web Editor NEW
1.7K 1.7K 264.0 3.38 MB

kramdown is a fast, pure Ruby Markdown superset converter, using a strict syntax definition and supporting several common extensions.

Home Page: http://kramdown.gettalong.org

License: Other

Ruby 81.58% Shell 0.67% HTML 17.27% Roff 0.48%
html kramdown markdown pdf ruby

kramdown's People

Contributors

284km avatar adwylie avatar alext avatar amarandon avatar antoineco avatar ashmaroli avatar benarmston avatar boblail avatar boutil avatar brandur avatar cabo avatar ccorn avatar chrisjefferson avatar gettalong avatar gioele avatar glebm avatar hperl avatar jhund avatar kejadlen avatar kivikakk avatar le0pard avatar lilith avatar maxmeyer avatar mojavelinux avatar parkr avatar plexus avatar powerpak avatar tmthrgd avatar tsl0922 avatar unibr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kramdown's Issues

Render Hooks

I've been using Kramdown for some time and love the extended syntax. However, the code blocks seem to be handled by CodeRay by default, but I heavily prefer the better supported Pygments.rb library (previously Albino) since it has much better syntax support (and CodeRay is on its way to abandonment I believe).

Is there already a good API hook/class to inherit from (similar to RedCarpet's renderer base class) so that I can use Pygments to render my code block whenever one is processed? I could hack around in a fork to use Pygments instead, but it would be nicer if this could be done with a simple render class or method overwrite.

Have a blessed day!
~ Jonathan Martin

Table alignment with no header

Currently trying to get cell alignment working without headers and

|       |      |      |
|:-----:|:----:|:----:|
| this  | does | work |
{:.table}

but

|:-----:|:----:|:---:|
| this  | does | not |
{:.table}

No or invalid attributes found in IAL/ALD content – for simple {::comment}

$ ruby --version && gem --version && bundle --version
ruby 2.0.0p0 (2013-02-24) [i386-mingw32]
2.0.3
Bundler version 1.3.4
$ gem list --local kr

*** LOCAL GEMS ***

kramdown (1.0.1)

test.md

{::comment}
abcdefghijklmnopqrstuvwxyz 0123456789                                                     
{:/comment}

# TEST

Executing kramdown results in:

$ kramdown test.md   > test.html
Warning: No or invalid attributes found in IAL/ALD content:

Repeated footnotes

From the documentation,

The footnote name has to be unique in the whole kramdown document. Therefore you can’t link to the same footnote definition twice.

I am curious why this is the case? It would seem to me that just like links with identifiers, repeating an identifier means you want the same footnote reference to appear linking to the same footnote. Repeating footnotes is not uncommon in prose, particularly when the footnotes are formatted as endnotes or utilized as citations.

I realize this is something that PHP Markdown Extra and pandoc don't currently handle any better. The former prohibits it, like kramdown, while the latter creates two footnotes with the same content if a footnote is repeated. But it would seem that the intent here is clear: a user repeating [^7] later in a document probably didn't mean that they wanted that literal text, they almost certainly wanted a repeated footnote. As for pandoc's behavior, repeating footnotes in HTML output (where they appear as endnotes) seems silly, but I guess it could make sense for LaTeX or a paginated output, in which case it would be better left up to the discretion of the typesetting software or macros.

Unique IDs for footnote list items

I've noticed that Kramdown implements footnotes by creating list html tags with IDs like this:

<li id="fn:1">

But this causes trouble if you have multiple blog posts on the same page (for instance, the index page of a blog). You end up with several list tags with the same ID and the footnotes in each blog post just end up pointing to the footnotes in the top article on the page.

Given that Markdown footnote syntax allows the creation of footnotes with arbitrary text like this:

[^myCrazyFootnoteName]: The War of 1812 actually took place in 1811.

It'd be awesome if Kramdown used that text as the ID rather than the generic fn:1, fn:2, etc.

Or is there already an option for this in Kramdown and I'm a big dummy? Thanks.

ALDs and IALs – why so restrictive?

When working on kramdown documents, [Jade](similar to [Slim]) documents and CSS simultaneously, I have found myself getting used to not putting space(s) between ids and classes:

article#main.blog-post.text-content
    h1 My awesome blog post …
.blog-post.is-active {
    color: black;
}

which caused me to write such kramdown:

Some text in a paragraph with a [link](#note){:.text-link.ref}
and an **important notice**{:#note.frag.highlight}

Since the parser happily ignores my errors, it took some time before I understood what was going on, and I could correct it:

Some text in a paragraph with a [link](#note){:.text-link .ref}
and an **important notice**{:#note .frag .highlight}

I feel that a big thing of markdown is that it isn't very restrictive (although sometimes not restrictive enough—luckily kramdown has already addressed that ;): Ending #:s in headings can be 0–n, there can be any number of = and - for h1 and h2, *, + and - are allowed as list markers and many things can be indented up to three spaces. Why must the ALDs and IALs be so restrictive? I find both kramdown examples above to be about equally readable—in fact, I even find the former to be more readable when reading the content, since I find it easier to skip the IALs if they are just one "chunk". It also saves me from mentioned problem.

I propose:

  • The spaces to be optional between ids/classes and ids/classes
  • Anything invalid to generate warnings

Or at least only the latter item.

Bad matching of inline math delimiters with line breaks in between

For example:

$$1$$ A $$2$$

$$1
$$ A $$2$$

generates:

<p><script type="math/tex">1</script> A <script
type="math/tex">2</script></p>

<p>$$1
<script type="math/tex"> A </script>2$$</p>

Notice that in the first case 1 and 2 are correctly recognized as math, but in the second case the line break makes
the closing $$ of 1 match the opening $$ of 2.

Maybe this is intended to work that way but I couldn't find any precise assertion regarding this in the documentation.
Besides, the behavior wreaks havoc with editors that insert line breaks when formatting paragraphs, like vim.

NOTE: I've also reported this here http://rubyforge.org/tracker/index.php?func=detail&aid=29801&group_id=7403&atid=28673 .

Wrap Kramdown tables in a div

I think it would be convenient to wrap kramdown-generated tables in a div.

Here's my use case:

I want to have a table with width: 100% and it's contents stretched to fill the full width (so I can't have a display: block on the table). But I also want an overflow: auto on the table, so if the screen is too narrow, the table scrolls horizontally.

The only way to do this is to have a wrapper div with overflow: auto set.

I've currently worked around it by setting parse_block_html: true and adding a <div class="table-wrapper"> into my source markdown; you can see it in action here and the source markdown here.

It would be neat to have this wrapper generated by kramdown, so the source markdown remains uncluttered.

Parse header IDs with colons

Kramdown does not parse valid HTML IDs for the {#} anchor syntax, and differs from PHP Markdown Extra behavior on header IDs:

# Header {#id:with-a-colon}

Parsed by Kramdown as:

<h1 id="header-idwith-a-colon">Header {#id:with-a-colon}</h1>

Expected (and properly parsed by PHP Markdown Extras):

<h1 id="id:with-a-colon">Header</h1>

Also, the HTML spec explicitly states:

ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

Source

Attempt to auto-load unknown input/output formats

When invoking kramdown -o foo and there is no Kramdown::Document#to_foo method, kramdown should attempt to load kramdown/converter/foo and try again. Likewise, this could be done for -i foo and kramdown/parser/foo. This would allow kramdown to automatically leverage other kramdown libraries.

A way to add a custom tag around a section of your kramdown document to exclude it?

For instance, let's say I have kramdown document as follows:

<meta charset="utf-8">
<title>Wikipedia</title>
<meta name="title" content="Wikipedia">
<meta name="description" content="Wikipedia, the free encyclopedia that anyone can edit.">

##Some text
##Some text

I would like to keep "Some text" but remove the title and meta tags. Is there a way to tag that section for removal?

Advanced tables (colspan / rowspan / multi-paragraph)?

Is colspan or rowspan supported?
Is there any way to make a multi-paragraph cell?

Or any ideas as to how we could go about adding it? (cell-level IAL?)

Tables are one of my remaining headaches preventing me from going going full markdown (no html).

Kramdown in place of Redcarpet

I have been using Redcarpet b/c for my application is is important to support GitHub compatibility. However, Redcarpet does not appear to work for JRuby, so I am looking at switching to Kramdown. But I am concerned for lack of "```" style code blocks.

Is this something that could a least be optional for Kramdown?

Also, are there any other features that Kramdown doesn't support that Redcarpet does? I looked for a comparison but did not come across one.

Replace quotation marks with a dedicated HTML tag q

The current syntax provides the smart_quotes option to transform the simplified quotation marks " and ' into typographically correct quote pairs (»«, „“, …). This is a step forward from default markdown, but away from semantic meaning of a quote.

The point is: a quote is a markup like emphasis. We should treat it like such. There is a dedicated HTML tag q for quotes you can design it with CSS whatever your language requires. German would write:

q:before { content: "»" }
q:after {  content: "«" }

What do you thing about introducing that way to parse quotation marks? Maybe as an option?

Code blocks with HTML entity codes are processed wrong

Currently code blocks that contain HTML entity codes are not being displayed correctly.

If my markdown is this:

 1 &lt; 2

It turns it into the following html:

 <pre><code> 1 &amp;lt; 2\n</code></pre>\n

So the & in &lt; is being replaced with its own entity code, which isn't the expected behaviour.

`<strong>` tags are not parsed correctly from HTML

<strong> tags are not parsed correctly if they start or end with a space.

Using the API, the following does not parse:

irb(main):039:0> puts Kramdown::Document.new("<strong>oops </strong>", {input: 'html'}).to_latex

=> nil

<b> behaves correctly:

irb(main):040:0> puts Kramdown::Document.new("<b>oops </b>", {input: 'html'}).to_latex
\emph{oops }
=> nil

The same issue exists with <em> (not working) and <i> (working).

Finding out line number of current token?

Hi.

I'm writing extension for Kramdown (extending Kramdown::Parser::Kramdown) and in my case invalid data should stop execution of parsing. For this I'm using simple exception, but I need to provide info on which line it occured.

The question is: how do I find out which line/column is currently being processed by parser?

Thank you.

Support for HTML5 sections

It would be nice to have a way to generate <section> elements in addition to simple titles and paragraphs.

For example,

# Title

foo

## Section 1

bar

## Section 2

baz

would be converted to

<h1>Title</h1>
<p>foo</p>
<section>
    <h2>Section 1</h2>
    <p>bar</p>
</section>
<section>
    <h2>Section 2</h2>
    <p>baz</p>
</section>

Pure Ruby PDF converter based on prawn

I'm currently investigating how much effort it would take to create a pure Ruby PDF converter based on the prawn PDF library.

Any input, ideas, etc. are appreciated, especially on the following items:

  • Expectations for such a converter
  • How to handle customization of individual element output?
  • Other libraries than prawn that are better suited for this task
  • Is there need for such a converter?

two table parse-block issues, possibly related

% cat test.md
<div>
  <div>
  <div>
  **Test Div**
  </div>
  </div>
</div>


<table>
  <tr>
  <td>
  **Item**
  </td>
  </tr>
</table>


% kramdown --parse-block-html test.md
<div>
  <div>
    <div>
      <p><strong>Test Div</strong></p>
    </div>
  </div>
</div>

<table>
  <tr>
  <td>
  **Item**
  </td>
  </tr>
</table>


% cat test2.md
<table>
  <tr>
    <td markdown="1">**Item**</td>
  </tr>
</table>

% kramdown --parse-block-html test2.md
<table>
  <tr>
    <td>
      <p><strong>Item</strong>&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;</p>
    </td></tr></table>
Warning: Found no end tag for 'td' - auto-closing it
Warning: Found invalidly used HTML closing tag for 'td'
Warning: Found invalidly used HTML closing tag for 'tr'
Warning: Found invalidly used HTML closing tag for 'table'

subscript _ is wrongly converted to <em>

I'am using octopress with kramdown, my equation is as follows:

$P(X)=P\left(X \vert Y_1\right)+ P\left(X \vert Y_2\right)+…+ P\left(X \vert Y_n\right)$

I found it was converted to

$P(X)=P\left(X \vert Y<em>1\right)+ P\left(X \vert Y</em>2\right)+…+ P\left(X \vert Y_n\right)$

the subscript _1 and _2 was wrongly converted to <em> and </em>, which will prevent mathjax to display it.

figure element

I’ve been trying to write lately with kramdown's markdown parser and I’ve come across two problems that seem to unsolvable in the current release.

One is that there seems to be no way to stop kramdown from wrapping image links in

tags. This is often fine but when paired with something like

p + p {
    text-indent: 1em;
}

the results are less than happy, images inherit unwanted text stylings and go all over the shop.

Markdown is smart enough not to add tags to existing block level elements, could the same method be used to allow specifying of stand-alone images?

If this is unfeasible or undesirable, could it be possible to allow it via an option ( say :image_block => true )

The second problem is attempting to use html5's new

and elements. According to can I use it all major browsers now support them and they’re certainly a great help in writing articles with images that need citations or have direct references to text.

Looking through google to see if anyone has attempted it I found https://github.com/michelf/php-markdown/wiki/HTML5-update which seems to have a pretty useful starting point for working out a syntax to use them.

Would either of these problems be something we might be able to do something about?

Styling hardcoded <div> around CodeRay code table

Hi there,

I’m trying to style a CodeRay code table (:coderay_line_numbers set to :table) in such a way that overflowing code is scrolled, i.e. I want to add

overflow-x: scroll

to the element containing the code table. As can bee seen at https://github.com/gettalong/kramdown/blob/master/lib/kramdown/converter/html.rb#L109 this is sadly a hardcoded <div> element without any class or other identifier set, making it unreachable for CSS (unless you put an HTML attribute list after each and every single codeblock you write to include a class). Applying overflow-x: scroll to the table itself doesn’t work, because it’s the table that overflows itself, requiring me to set this on the parent element, which is unreachable without changing kramdown’s code. Here’s an example of the generated HTML (the nonsense code is just to make it overflow):

<div><table class="CodeRay"><tr>
  <td class="line-numbers"><pre><a href="#n1" name="n1">1</a>
<a href="#n2" name="n2">2</a>
<a href="#n3" name="n3">3</a>
<a href="#n4" name="n4">4</a>
<a href="#n5" name="n5">5</a>
</pre></td>
  <td class="code"><pre><span class="comment"># foo.rb</span>
<span class="keyword">def</span> <span class="function">foo</span>
  puts <span class="string"><span class="delimiter">&quot;</span><span class="content">Hi</span><span class="delimiter">&quot;</span></span>
  jkdhg dkjghd kjhdfg kjhdfg  dkjfghdgh dfhgdkghdg dkjdjg(gdg) jsdhfs ksjdfhsjfs kjjjj skdjf
<span class="keyword">end</span>
</pre></td>
</tr></table>
</div>

A workaround is setting :coderay_line_numbers to :inline, but this in turn makes simple select-n-copy by mouse impossible (because the line numbers are now copied, too). Disabling line numbers altogether is not an option for me, as I sometimes have quite long code listings.

Suggestion: Add a new option coderay_div_class or something like that that allows to globally apply a class to the <div> sorrounding a coderay table.

Valete,
Quintus

How to add a new macro?

Hello

I'd like to add some macros for kramdown (something likes \def or \newcommand in LaTeX.) Can I do this in Kramdown?

For example, I have a large set of abbreviations and URI definitions (for reference link). It's nice if I can put all of them some places and use them in another document. Moreover, some things like date will help to print current date information would help a lot.

Thank you.

CLI configuration option documentation?

I'm having trouble finding explicit examples that set any of the options from the command line. I've checked the options manual, and not found any examples there. Is there a way to pass them in with a CLI call?

Clarification So in writing tests that invoke kramdown from the command line, I finally realize that I can "pass in" options by adding them to the input file, for example by prepending the line

"{::options entity_output='symbolic' /}"

to the file being converted. Although that syntax does not match the documented state for the option as passed in from within a Ruby call's Hash arguments (the value is not a symbol).

But that syntax doesn't work on the command line, and I'm writing expectations that specifically look at CLI use cases. What string must be passed in at the command line if an option is to be set without rewriting the input file?

Inconsistent hard line break behavior in GFM (GitHub Flavored Markdown) parser

I was perusing Kramdown's GFM (GitHub Flavored Markdown) parser, and came across one area that was slightly surprising. It seems that it automatically adds hard line breaks to Markdown it parses (see https://github.com/gettalong/kramdown/blob/master/lib/kramdown/parser/gfm.rb#L17-L20):

      def parse
        super
        add_hard_line_breaks(@root)
      end

This is conspicuously different from Redcarpet's default behavior in this area (which I believe is the closest thing to a GFM reference parser as we have), from Kramdown's documented behavior there too (which is only to insert a hard break only on two spaces or two backslashes at the end of a line), and even from GitHub's behavior while editing Markdown documents in-browser (see this Gist for reference):

irb(main):001:0> require "redcarpet"
=> true
irb(main):002:0> str = <<-eos
irb(main):003:0" The result of this piece of Markdown should
irb(main):004:0" be two paragraphs with this being the first
irb(main):005:0" one.
irb(main):006:0"
irb(main):007:0" This is the second.
irb(main):008:0" eos
=> "The result of this piece of Markdown should\nbe two paragraphs with this being the first\none.\n\nThis is the second.\n"
irb(main):009:0> renderer = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new)
=> #<Redcarpet::Markdown:0x007fbaf2be95d8>
irb(main):010:0> renderer.render(str)
=> "<p>The result of this piece of Markdown should\nbe two paragraphs with this being the first\none.</p>\n\n<p>This is the second.</p>\n"
irb(main):012:0> require "kramdown"
=> true
irb(main):013:0> Kramdown::Document.new(str).to_html
=> "<p>The result of this piece of Markdown should\nbe two paragraphs with this being the first\none.</p>\n\n<p>This is the second.</p>\n"
irb(main):014:0> Kramdown::Document.new(str, input: "GFM").to_html
=> "<p>The result of this piece of Markdown should<br />\nbe two paragraphs with this being the first<br />\none.</p>\n\n<p>This is the second.</p>\n"

Is there a reason that it behaves this way? Can I send a pull to change it or put it in an option?

/cc @plexus

String causes Kramdown::Document.new to freeze.

This string (all alphanumeric characters replaced with 'B') causes Kramdown::Document.new to either hang, forever, or take 107,000,000ms to complete.

Running Ruby 2.0.0 and Kramdown 1.0.1 or reference

=> "   \r\n \r\n B\r\n \r\n \r\n \r\n \r\n                           BBBBBBBB. \r\n\r\n\r\n\r\n               BBBB BB BBBBBBBB BBBBB. BBBBBBB BB BBBBB BB BBB BBBB BBBBB BBB BBB BBBB BBB BBBBBBB BBB BBBBBBB. B BBB'B BBBBB BBBB BBB BBBB BBBBBBB BBBB BBBB BBBB BBBBBBBB.\r\n\r\n\r\n                    BBB BBBBB BBBBB BBB BBBB BBBB BBBB, BBB BBBBB BB BBBBB BBB BB BBBBBB BBBB BBB BBBBB BBBB BB. BBBBB BBB BBBBB BBBBB BBB BBBB BB BBBB BBBB BBBBB.\r\n\r\n\r\n                             BBBB BBBBB, BBBBB, BBBBBBBB?\r\n\r\n                       BB BBB BB BBBB BBB BBBB BBB BBBBBB /BBB BB BBBBBBBBB BBBB BBBBBBB BBBBBB BB BBB. \r\n\r\n\r\n                       BBBB BBBBBBBB BBB BBBB BB BBBBB BBB BBBBBB BBBB BBBBB BBBBBB BBBBBBBBB BBBB BB BBBBB......................................................................\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n                  BBBBB B'B BBB BBBBB. BBBB BBBBB BBBBB. ( B BBBBB BBBBBBBBBB BBBBB BBBB'B BBBBB BBBBB. BBB BBBB BBBBB BBBB BBBB. BBBBBBB BBB BB BBBBBBB BBB BBB B BBBB BBBBBBBBBBBB. BBBBB BBBBB.)\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n                 BBBB'B BB\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n.\r\n\r\n            B BBB BBB BBB ? B. B BBB BBBBBB BBBB BBB BBBB. BBBBBBB BB BBBBBBB B BBBB BBBB BBB BBBBBB. \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n             BBBB BB 'BBBB' BBBB BBBBB.\r\n\r\n\r\n                               BBBBBBBB B BBBB BBBBBB BB BBBBBBBB BBB BBBBBBB BBBBBBB BBBBBBB. \r\n\r\n\r\n         B BBBB BB BBBB. BBBBB BBBBBBBB. BBB BB BB. BB BB BBBB BB BBBBBBBBBB. BB BBBBBBBB BB BBBBBBBBB. \r\n\r\n\r\n                         BBBBBBBB BB BBBB. BBBBBBB BBB BBBBB BBBBB BBBBB. B'BB BBBBBBB BB BBBBB BBBBB BBBBBBB BBB BBBBB. BBBB. \r\n\r\n      B BBBBBB BBBB BB BBBB BBB. (BB BBB BBBBB BBBBB...............B)\r\n\r\n\r\n\r\n               BBBB!\r\n\r\n\r\n\r\n             BBBB BB BBB BBBBBBB BBBBBB.           \r\nB\r\n\r\nB\r\n\r\n\r\n\r\n         BBBBB BB/BBB BBBBB!  BBBB BBBB BBBBBBBBBBB 'BBB'B BBBBBB.' \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n              BBBB BBBBBBB BBBB BB BBB BBBBBBBB BB BBBB BBBBBB BBB BBBBBBBBB BBBB. BBBBBBBB BBBBBBB BBBB BBBB BBBB BB BBBB BB BBBB BB BBBB B BBB BB BBBBB BBBBBB.  B BBBB BBBBBBB BB BBBB BBBBB B BBB BBBBBBB BB BBBBB BBBB. BBB BBBBBBB BBBB. B BBB BBBB BBBB B BBBB BBBBBB BBB B BBBBBB BBBBBB. BBB BB BBBBBB BBBBBB BBBBBBBBBB BB...BBBBB BBBB BBBB BB BBBBB. (BBBBBBB BBB BBBBBB BBB'B BBBB BBB BBBBB BBB BB BBBBB BBBBBBBBBBB  BBBBB B BBBB BBBB BBBBB. \r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n    BBBBB BB BB BBBB B'B BBBB BBBBB BBBBB BBB BB BBBBBB/BBB (BBBBB) BBBBBB BB. \r\n                              BBBBBBBB. B BBB BBBB BB BB BBB/BBBBBB BBBBBB BBB BBBB BBBBBBBB BB BB B BBBBBB BBBBBB BBBBB. (BBB/B BBB BBBB BBBB...BBB BBB BBB BBBB BB BB B BBBB BB BBB BB? BBBBBBB B BBB B BBBB BBBBBBBB BBB B BBB BBB BBBBB BBBB BBB BBBB BB B BBBBBBBB BB BBBBB BB BB BBB BBBBB BBB BB BBBBB BBBBBBB B BBB BBBBBBB. BBBBBB (BBBBB) BBBB BBBBB BBBBBBB BBBBB BBBB BBBB BBB. 100 BBBBBB BB BBBBB. BBBB BBB BBB BBBBBB BBB BB. BBB BBBB BB BBB BBBBB! BBB BB BBBBBB BBBBB B BBB'B BBBBBBBBB BBBB BBB BBB. (BBBBBB BBBBBBB BB BBBB BBBBB (BBBBBB BBBBB BBBBB BBBBB.))\r\n\r\n\r\n        BBB B BBBBBBBBBBB BBBB BBB BB BBB. BBBBB BBB BBBBB B BBBB BBBBBB BBBBB BBB. BB BBBBBB BBB BBBB B BBB BB BBBBBBBB BBBBBB BBBB BBB B BBBBBB BBBB BBBBBB BBBBBBB BBBB BBBB BBB BBBBBBBB.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n               BBBBB!!!!!!!\r\n\r\n\r\n             B BBB BBBB BBBBBB BBBB BBBB BBBB B BBB BBBBB BBB BBBBB B BBBB BBBBBBB BB BB BBBB BBBBBBBBB. B BBBB BBBBBB BBBBBBB BBBB BBBB BBB BBBB.\r\n\r\n                                                   BB BB, BB BBBBBB BBBB, (BBBBBB BB BBB BBBB . BBBBB BB BBBB BBBB BB BB BBBB BBBB B BBBB BB BB (BB BBBB BB BBB BBBBBBB BB BBBBBBB. )) BB'BB BBB BBB'B BB BB BBBB BB B BBBB B BBBBB (BB BBBBBB BB BBB B'BB BBBBBBBB BB BBBB BBBB.)\r\n\r\n\r\n      B BBBBB B'BB BBB BB BBBB BBB BBB.\r\n\r\n\r\n       \r\n\r\n"

Missing .gemspec

Hello. I would like to apply some specific fixes to kramdown and use that altered version in my production code. But problem is, that there is no .gemspec file and I just couldn't reference altered sources in Gemfile through :git => '...', i.e. there is no gem specification for that.

Is there any civil way to patch sources and use them along with Gemfile? Or I should fix that directly in .rvm/gems/ruby-2.0.0-p0/... in place?

Help appreciated,
thanks.

Three back ticks with a specific language

I see that

~~~~ ruby
puts 'I am ruby'
~~~~

is supported, what about supporting

```ruby
puts 'I am ruby'
```

? This is used in some other systems so we could make our markdown files more portable.

Thanks!

no parser to handle the specified input format

I've been seeing this Kramdown::Error a lot on Heroku in a Rails app that has threadsafe = true set.

We have markdown that's stored in the database, and rendered in a slim template via a Kramdown::Document. Will try to get more info soon.

Has anyone else seen any issues with thread safety?

no obvious way to turn off smart quote parsing in command line tool

Smart quote parsing in a simple document created a bunch of weird-ass UTF-8 (I assume) entities. I wanted to turn smart quote parsing off, but the only option given is --smart-quotes, and I couldn't figure out how to tell it to leave smart quotes the hell alone.

This drove me back to Markdown.pl.

transliterated-header-ids error

$ ruby --version && kramdown --version && gem list | grep stringex && kramdown --transliterated-header-ids
ruby 2.0.0p247 (2013-06-27) [x64-mingw32]
1.1.0
stringex (2.0.8)
Hello
=====
^Z
c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/stringex-2.0.8/lib/stringex/unidecoder.rb:70:in `<module:Stringex>': uninitialized const
ant Stringex::StringExtensions (NameError)
        from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/stringex-2.0.8/lib/stringex/unidecoder.rb:69:in `<top (required)>'
        from c:/Ruby200-x64/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `require'
        from c:/Ruby200-x64/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `rescue in require'
        from c:/Ruby200-x64/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:35:in `require'
        from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/kramdown-1.1.0/lib/kramdown/utils/unidecoder.rb:24:in `<module:Unidecoder>'

        from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/kramdown-1.1.0/lib/kramdown/utils/unidecoder.rb:16:in `<module:Utils>'
        from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/kramdown-1.1.0/lib/kramdown/utils/unidecoder.rb:13:in `<module:Kramdown>'
        from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/kramdown-1.1.0/lib/kramdown/utils/unidecoder.rb:12:in `<top (required)>'
        from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/kramdown-1.1.0/lib/kramdown/converter/base.rb:156:in `generate_id'
        from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/kramdown-1.1.0/lib/kramdown/converter/html.rb:137:in `convert_header'
        from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/kramdown-1.1.0/lib/kramdown/converter/html.rb:78:in `block in inner'
        from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/kramdown-1.1.0/lib/kramdown/converter/html.rb:77:in `each'
        from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/kramdown-1.1.0/lib/kramdown/converter/html.rb:77:in `inner'
        from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/kramdown-1.1.0/lib/kramdown/converter/html.rb:332:in `convert_root'
        from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/kramdown-1.1.0/lib/kramdown/converter/html.rb:65:in `convert'
        from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/kramdown-1.1.0/lib/kramdown/converter/base.rb:79:in `convert'
        from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/kramdown-1.1.0/lib/kramdown/document.rb:120:in `method_missing'
        from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/kramdown-1.1.0/bin/kramdown:61:in `block in <top (required)>'
        from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/kramdown-1.1.0/bin/kramdown:61:in `each'
        from c:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/kramdown-1.1.0/bin/kramdown:61:in `<top (required)>'
        from c:/Ruby200-x64/bin/kramdown:23:in `load'

Windows 7 x64.

Unicode problem (I guess)

On Windows 7:

$ ruby --version && kramdown --version
ruby 1.9.3p385 (2013-02-06) [i386-mingw32]
0.14.2

$ kramdown
"å
^Z
c:/Ruby193/lib/ruby/gems/1.9.1/gems/kramdown-0.14.2/lib/kramdown/parser/kramdown.rb:213:in `check': incompatible encoding regexp
 match (UTF-8 regexp with CP850 string) (Encoding::CompatibilityError)
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/kramdown-0.14.2/lib/kramdown/parser/kramdown.rb:213:in `block in parse_spans'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/kramdown-0.14.2/lib/kramdown/parser/kramdown.rb:212:in `each'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/kramdown-0.14.2/lib/kramdown/parser/kramdown.rb:212:in `any?'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/kramdown-0.14.2/lib/kramdown/parser/kramdown.rb:212:in `parse_spans'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/kramdown-0.14.2/lib/kramdown/parser/kramdown.rb:165:in `block in update_tree'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/kramdown-0.14.2/lib/kramdown/parser/kramdown.rb:161:in `map!'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/kramdown-0.14.2/lib/kramdown/parser/kramdown.rb:161:in `update_tree'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/kramdown-0.14.2/lib/kramdown/parser/kramdown.rb:179:in `block in update_tree'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/kramdown-0.14.2/lib/kramdown/parser/kramdown.rb:161:in `map!'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/kramdown-0.14.2/lib/kramdown/parser/kramdown.rb:161:in `update_tree'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/kramdown-0.14.2/lib/kramdown/parser/kramdown.rb:103:in `parse'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/kramdown-0.14.2/lib/kramdown/parser/base.rb:78:in `parse'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/kramdown-0.14.2/lib/kramdown/document.rb:119:in `initialize'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/kramdown-0.14.2/bin/kramdown:72:in `new'
        from c:/Ruby193/lib/ruby/gems/1.9.1/gems/kramdown-0.14.2/bin/kramdown:72:in `<top (required)>'
        from c:/Ruby193/bin/kramdown:23:in `load'
        from c:/Ruby193/bin/kramdown:23:in `<

Seem to happen for any input containing either of ', " or -- and a unicode character (such as å, ä, ö, é).

Update the benchmarks

I just ran the benchmarks against Ruby 1.9.3p392 and 2.0.0-p0 on my quad-core / 8Gb / ThinkPad x230 and got faster times than the benchmarks on the website.

$ ruby -Ilib ./benchmark/benchmark.rb 
Running tests on 2013-05-06 under ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-linux]

Test using file mdsyntax.text and 20 runs
Rehearsal ----------------------------------------------------
kramdown 1.0.1     0.840000   0.010000   0.850000 (  0.862268)
Maruku 0.6.1       2.980000   0.040000   3.020000 (  3.054157)
BlueFeather 0.41   3.770000   0.010000   3.780000 (  3.834840)
BlueCloth 2.2.0    0.040000   0.010000   0.050000 (  0.041931)
RDiscount 1.6.8    0.030000   0.000000   0.030000 (  0.025679)
redcarpet 2.2.2    0.000000   0.000000   0.000000 (  0.005483)
------------------------------------------- total: 7.730000sec

                       user     system      total        real
kramdown 1.0.1     0.820000   0.010000   0.830000 (  0.839418)
Maruku 0.6.1       2.960000   0.040000   3.000000 (  3.039902)
BlueFeather 0.41   3.850000   0.020000   3.870000 (  3.895995)
BlueCloth 2.2.0    0.040000   0.000000   0.040000 (  0.042047)
RDiscount 1.6.8    0.020000   0.000000   0.020000 (  0.020884)
redcarpet 2.2.2    0.000000   0.000000   0.000000 (  0.005442)

Test using file mdbasics.text and 20 runs
Rehearsal ----------------------------------------------------
kramdown 1.0.1     0.150000   0.000000   0.150000 (  0.154461)
Maruku 0.6.1       0.730000   0.000000   0.730000 (  0.731644)
BlueFeather 0.41   0.960000   0.000000   0.960000 (  0.963303)
BlueCloth 2.2.0    0.010000   0.000000   0.010000 (  0.011516)
RDiscount 1.6.8    0.000000   0.000000   0.000000 (  0.004375)
redcarpet 2.2.2    0.010000   0.000000   0.010000 (  0.007611)
------------------------------------------- total: 1.860000sec

                       user     system      total        real
kramdown 1.0.1     0.150000   0.000000   0.150000 (  0.154506)
Maruku 0.6.1       0.700000   0.000000   0.700000 (  0.712578)
BlueFeather 0.41   0.960000   0.000000   0.960000 (  0.970353)
BlueCloth 2.2.0    0.010000   0.000000   0.010000 (  0.012758)
RDiscount 1.6.8    0.000000   0.000000   0.000000 (  0.005801)
redcarpet 2.2.2    0.000000   0.000000   0.000000 (  0.001888)

You should rerun the benchmarks and see if Kramdown or Ruby has improved performance wise.

Superscripts and subscripts in Kramdown?

I love the extra power kramdown gives me, so I was surprised not to find any syntax for superscripts and subscripts other than the inelegant <sup> html injection. Are there any particular reasons support isn't built in?

The most natural syntax I've seen uses carets for super and tilde for sub:

October 31^st^
H~2~O

Are there any plans to add this to the kramdown spec/parser?

~ Jonathan Martin

definition list misbehavior?

I've been over the text in https://gist.github.com/4078441 with a fine-toothed comb, and can't find whatever it is triggers the misrecognition of the second definition. No odd characters, and that second definition is unrecognized whether in or out of context.

I was about to suggest it was the parenthesis starting the definition block, but then saw the third one works fine. I can only assume a leaky regex.

Incorrect smart_quote handling around underscore markup

Using kramdown to mark up a digitized book, I've been converting the OCR-generated asterisks to underscores to improve the code's readability.

The :smart_quotes substitution algorithm breaks around text with underscores. For example:

"_Hurrah!_"

'__Absolutely__.'

renders both lines with closing quotes at both ends of the word. Asterisk markup works correctly, as does explicit html markup.

Adding a horizontal line before the footnote content

I'd really like to separate the footnote content with a horizontal line. I've seen that in

# File lib/kramdown/converter/html.rb, line 397
def footnote_content

The footnote content is generated as

"<div class=\"footnotes\">\n#{convert(ol, 2)}</div>\n"

I think it would be better to add a </hr> so that the footnotes are separated from the main content.

Fenced code blocks not being processed by Coderay

The fenced code does not get processed with Coderay in the following example. I'm using the Kramdown gem v0.14.1. Any ideas why?

require 'kramdown'

text = "
~~~ ruby
class Foo
  def bar
    return 'baz'
  end
end
~~~"

puts Kramdown::Document.new(text).to_html

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.