vmg / redcarpet

The safe Markdown parser, reloaded.
MIT License
4.99k stars 526 forks source link

Replace quotation marks with a dedicated HTML tag q #278

Closed doktorbro closed 11 years ago

doktorbro commented 11 years ago

I want to use Redcarpet as markdown engine in Jekyll. As I read in docs the current syntax provides the Smarty Pants option to transform the simplified marks " into typographically correct English marks (“”). This is a little step forward, but the rest of the world uses other quotation marks. How would you make all the non English writers happy? The easiest solution would be the 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 human language requires. German would write:

q:before { content: "»" }
q:after  { content: "«" }
<p>Albert Einstein sagte: <q>Ich glaube nicht an einen Gott.</q>

that renders to

Albert Einstein sagte: »Ich glaube nicht an einen Gott.«

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

I don’t see any difference between handling a pair of asterisks and a pair of quotation marks. If you apply the proven asterisk-to-emphasis-algorithm to the quotation mark, it should work like a charm.

robin850 commented 11 years ago

Hello,

Thanks for your contribution ; we are always glad to improve Redcarpet. This proposal seems reasonable if we provide it through an option (to keep a kind of compatibility "layer").

@mattr- : What do you think?

mattr- commented 11 years ago

This would be an excellent thing to have in redcarpet

On Thu, Jul 18, 2013 at 5:04 AM, Robin Dupret notifications@github.comwrote:

Hello,

Thanks for your contribution ; we are always glad to improve Redcarpet. This proposal seems reasonable if we provide it through an option (to keep a kind of compatibility "layer").

@mattr- https://github.com/mattr- : What do you think?

— Reply to this email directly or view it on GitHubhttps://github.com/vmg/redcarpet/issues/278#issuecomment-21173815 .

aprescott commented 11 years ago

Wouldn't authors of a non-English piece of text already be using characters like « for non-English quotation marks? I can see a potential problem with trying to map English-text " characters to non-English quotation marks.

Also, <q> (+ :before) is CSS generated content, and as such, quotation characters generated for <q> are still unselectable (at least in Chrome). You can see this by pasting

data:text/html;charset=utf8,<p>testing <q>hello</q> testing</p>

into the address bar, selecting all of the rendered text on the page, copying with (Cmd/Ctrl)-C and pasting elsewhere. The quotation marks will be missing, leaving: testing hello testing.

doktorbro commented 11 years ago

Once more: in the world of news and literature the quotation is the most important markup after the heading. Check these two examples for regular writings full of quotations.

  1. News article from 2013: Judge calls satanic killing 'disgusting, hideous and vulgar'
  2. Novel chapter from 1915: _Sherlock Holmes Discourses_

People care the most about what other people say. So if you want to make journalists and writers love markdown, semantically proper quotation marks are the killer feature.

doktorbro commented 11 years ago

@aprescott No, authors of a non-English piece of text use same QWERTY keyboards you do. So typing the " is the easiest way to markup the quote, just like for you as English writer. The right marks are hidden in the second or third layer, so they are invsible to the writer.

The markdown processor don’t have to know about the proper quotations marks, it must just converts "quote" to <q>quote</q>. That’s all. Everything else can be done with CSS.

It’s not always just a mark. In French there must be a non-break space between a mark and the quote. «&nbsp;quote&nbsp;». This is nearly impossible to reach by typing every symbol by hand, but no problem with CSS. Read a deep introduction about the quotation styling by @oli from Information Architects (dudes behind the markdown app iA Writer).

Yes, CSS generated content is not selectable. Headings h2, list items li, and code snippets code lose they markup too if you copy the rendered text and paste it in your text editor. What is the problem with that? A markup is a markup. It’s there to show a different voice, layer, language, listing.

aprescott commented 11 years ago

I would say in a significant number of cases, quotes are much more than a presentational concern and have actual semantic meaning which you would want to preserve, even after you stripped all styling. For example, to show disambiguation between literally spoken text and paraphrased content. From a journalistic perspective, that's important. Consider complex sentences with quotes part of the way through them. Copying such text would require manual editing to insert them again after pasting.

If it's some configurable setting for what " and ' can map to, that's a separate issue, but I think it's important to at least recognise that <q> has shortcomings in modern browsers which should prevent this from becoming the standard way Redcarpet interprets quotes.

And foreign keyboards certainly have mappings for the relevant languages quotation marks, at least in my experience. French journalists are no doubt more than accustomed to writing with « and » in their raw source text.

doktorbro commented 11 years ago

Quotes have semantic meaning, this is what I’m talking about. Like code does. Quote is for showing different person, code is for showing different language. Copying code requires manual editing to insert them again after pasting.

I don’t demand to be that a standard way, give me that option and I’m happy. Who knows, maybe one day as Africa is grown up it turns to default option.

What “shortcomings in modern browsers” do you mean? I use <q> in German and Russian prose since more than one year with no issues in Firefox, Chrome, and Safari. Can you provide an example for shortcomings, please?

And foreign keyboards certainly have mappings for the relevant languages quotation marks, at least in my experience. French journalists are no doubt more than accustomed to writing with « and » in their raw source text.

What language are you talking about? There is no mapping for the " sign on keyboards outside of English area. The " is the ". The relevant languages quotation marks are hidden in the sublayer, if the OS provides them at all.

French journalists type the same wrong quotation marks " as American and German journalists do. It’s a shame how typographically ill-conducted some of the biggest publishers are. Examples for news articles with wrong quotation marks:

  1. French _Le Monde_
  2. German Der Spiegel
  3. English Los Angeles Times

If that professional would use the Redcarpet renderer with my proposed option, they don’t need to change their workflow. Add some CSS rules and the same text by the same journalist shines like in the good old days.

aprescott commented 11 years ago

What “shortcomings in modern browsers” do you mean? I use <q> in German and Russian prose since more than one year with no issues in Firefox, Chrome, and Safari. Can you provide an example for shortcomings, please?

In Chrome, the quotes from <q> will not be copied. You can see this by using

data:text/html;charset=utf8,<p>testing <q>hello</q> testing</p>

in the address bar and trying to copy the page. Firefox used to have this same behaviour, if I remember, but at least in version 22 the quotes are included in the copied text. So perhaps this is a Chrome bug.

doktorbro commented 11 years ago

@aprescott I see your concerns. From my point of view Chrome’s behavior is regular, Firefox is nice. Copying rendered text may be lossy.

W3C says:

Quotation punctuation […] will be inserted into the rendering by the user agent.

We can raise a bug report for Chrome to put quotations marks into the q-copy. I’m sure Chrome devs can be as nice as Firefox devs are.

But don’t forget, markdown is primarily a tool for writing content by hands and reading it. Not copying. So this shortcoming is not critical.