michelf / php-markdown

Parser for Markdown and Markdown Extra derived from the original Markdown.pl by John Gruber.
http://michelf.ca/projects/php-markdown/
Other
3.43k stars 530 forks source link

[Feature Request] <cite> in <blockquote> #131

Open MightyPork opened 11 years ago

MightyPork commented 11 years ago

You often need to put a cite note into a blockquote.

> Something very smart here,
> other line of the wisdom.

> <cite>&#8213; Some Wise Guy</cite>

Now while this works, it's nowhere as neat and readable as this

> Something very smart here,
> other line of the wisdom.
> -- Some Wise Guy

I am using this to do the trick

"#^>\s*--\s*(.*)$#im" => "\n> <cite>$1</cite>\n",

along with a bit of CSS

blockquote cite {
    display: block;
}

blockquote cite:before {
    content: "\2014 \2009";
}

How about adding a support for the cite note into MarkdownExtra? Simply the last > -- Something will turn into <cite> outside the last paragraph, but still inside the blockquote.

ethantw commented 10 years ago

This is wrong. You shall not put the author's name into <cite>. The semantic element is made to cite the source of the quotes, e.g. the title of a book, a website, or the name of an article, etc.

Below is the example,

<blockquote>
<p>Something very smart here, <br>
other line of the wisdom.</p>

<footer>
— Some Wise Guy, <cite>Some Wise Masterpiece</cite>
</footer>
</blockquote>
gizmecano commented 10 years ago

The use of this element is indeed not so simple (see http://html5doctor.com/blockquote-q-cite/#cite or http://devdocs.io/html/cite). I think that elements <cite> and <q> are probably one of the main limitations of the Markdown language.

gizmecano commented 10 years ago

To add to the confusion about these elements, the specifications seem to have been updated recently, as described in this recent article (http://html5doctor.com/cite-and-blockquote-reloaded/). However, I doubt that this can change anything for this issue...

MightyPork commented 10 years ago

Well, I didn't really expect you conservative guys to change anything, but this last definition pretty much matches my use of the tags, doesn't it? Finally the syntax can be used in a way that makes some sense!

vagari commented 10 years ago

I'm still hoping for some HTML5 in Markdown at some point. Maybe with an option to turn it on. There are a handful, like figure, that would be nice additions. The HTML5doctor examples make use of footer. A List Apart uses figure.

michelf commented 10 years ago

In case someone is interested, I've made a "HTML5 update" wiki page to collect ideas a while ago. https://github.com/michelf/php-markdown/wiki/HTML5-update

The idea of formalizing how to indicate the source of a blockquote is a good idea. I don't feel the source should look as if it was "inside" the blockquote in the Markdown document though. What would you feel about this instead:

> blockquote is a blockquote
> and is a blockquote
[ Some Wise Guy ]

The caption could be allowed above too. I'm not too sure what the HTML markup should be, but this syntax would fit well with the proposed table and figure captions syntax in the HTML5 update wiki document.

MightyPork commented 10 years ago

Considering that the same syntax would be used for captions in general, I think it's a good solution. If it isn't inside the quote, then the -- syntax doesn't make much sense and this has a more general meaning.

vagari commented 10 years ago

Thanks for pointing out that wiki entry. I had no idea it was there. I added a couple points to it. A reference to the Markdown Extra Extended style for figure. And a point about adding a bit more HTML5 to ordered lists.

Perhaps the HTML could be similar to A List Apart's. A blockquote with a paragraph below that includes a class when by itself. And when using a figure, depending on its location, stick it inside the figcaption? (Not sure what to do about cite assuming the whole attribution isn't wrapped in it.)

> It is the unofficial force—the Baker Street irregulars.
[ Sherlock Holmes, <cite>Sign of Four</cite> ]

Becomes...

<blockquote>It is the unofficial force—the Baker Street irregulars.</blockquote>
<p class="quote-citation">Sherlock Holmes, <cite>Sign of Four</cite></p>

With proposed Markdown Extra figure syntax...

!   > It is the unofficial force—the Baker Street irregulars.
    [ Sherlock Holmes, <cite>Sign of Four</cite> ]

Becomes...

<figure>
<blockquote>It is the unofficial force—the Baker Street irregulars.</blockquote>
<figcaption>Sherlock Holmes, <cite>Sign of Four</cite></figcaption>
<figure>

With alternative Markdown Extra Extended syntax for figure... It could be...

=== 
> It is the unofficial force—the Baker Street irregulars.
[ Sherlock Holmes, <cite>Sign of Four</cite> ]
=== 

Or...

=== 
> It is the unofficial force—the Baker Street irregulars.
=== [ Sherlock Holmes, <cite>Sign of Four</cite> ]

And what about keeping things separate? Perhaps being more modular would allow for writers to use variations and not set things in stone.

=== 
> It is the unofficial force—the Baker Street irregulars.
[ Sherlock Holmes, <cite>Sign of Four</cite> ]
=== [ Fig A. An example of a quote. ]

Becomes...

<figure>
<blockquote>It is the unofficial force—the Baker Street irregulars.</blockquote>
<p class="quote-citation">Sherlock Holmes, <cite>Sign of Four</cite></p>
<figcaption>Fig A. An example of a quote.</figcaption>
<figure>

Not sure how you'd do that with the proposed Markdown Extra method. Perhaps?

[ Fig A. An example of a quote. ]
!   > It is the unofficial force—the Baker Street irregulars.
    [ Sherlock Holmes, <cite>Sign of Four</cite> ] 

Just a bit of brainstorming... Sorry for all the ellipses. ;-)

michelf commented 10 years ago

@vagari Actually, what I had in mind is that

> It is the unofficial force—the Baker Street irregulars.
[ Sherlock Holmes, <cite>Sign of Four</cite> ]

would create a caption for the quote. Since there's no standard way to add a caption to a quote in HTML, we can be creative in the output (just like footnotes). It could use <figure> and <figcaption>, it could use a <p> with a class, or it could use a <footer> inside the blockquote.

I'm still on the fence about the syntax. It seems to me that people would write it that way in a natural email conversation (what @MightyPork suggested initially):

> It is the unofficial force—the Baker Street irregulars.
> -- Sherlock Holmes, Sign of Four

It also matches visually how most people will want to style the thing. This syntax also makes a lot of sense with a <footer> inside the blockquote element.

jacktonkin commented 10 years ago

I've implemented the syntax described above for a project I'm working on: If the last line of the block quote begins with -- then it is placed inside <footer> tags. So:

> It is the unofficial force—the Baker Street irregulars.
> -- Sherlock Holmes, Sign of Four

or

> It is the unofficial force—the Baker Street irregulars.
-- Sherlock Holmes, Sign of Four

becomes

<blockquote>
  <p>It is the unofficial force—the Baker Street irregulars.</p>
  <footer>Sherlock Holmes, Sign of Four</footer>
</blockquote>

The contents of the footer are parsed for span-level markdown only.

michelf commented 10 years ago

Here's my reservation with the -- syntax: it looks natural and it already produces a good enough output with the feature not implemented, which means that it's likely already in use (please confirm if you've already seen it). If those people upgrade to a new version that replaces the -- with a <footer>, they'll lose the typographic formatting (the --). Perhaps the produced output should include an em dash in the output, inside the <footer>.

MightyPork commented 10 years ago

I don't fully agree with the idea of adding a real dash in the output. Not everyone will be happy with em dash, some will want a ornamental leaf, arrow, or just make the footer thing italic and gray. If you leave the dash out, everyone can add it with CSS if it's what they want, while the others won't have to invent postprocessors to rid them off the dash.

Perhaps, if you want dash, at least make it optional.

michelf commented 10 years ago

@MightyPork Instead of a simple em dash, the output could be <span class="blockquote-source-prefix">&#x2014;</span>. Making the dash always present in the HTML output has the advantage that it'll still work without the stylesheet, like in a feed reader. If you have a stylesheet you can use display:none and do your own thing.

MightyPork commented 10 years ago

Good idea, if this is going to be added, I'm cool with it :)

taufik-nurrohman commented 9 years ago

:+1: