commit 1391315a90d3560777707c4054a09851eabc09e5
parent 41d2b4eac2b1b3ed4058b477ffaaa5cf7569c199
Author: markseu <mark2011@mayberg.se>
Date: Sun, 2 Jun 2013 22:58:52 +0200
Hello responsive web (markdown update)
Diffstat:
4 files changed, 309 insertions(+), 17 deletions(-)
diff --git a/content/1-home/page.txt b/content/1-home/page.txt
@@ -2,6 +2,7 @@
Title: Home
---
Yes, your Yellow installation works!
-You can now [edit this page](@baselocation/wiki/) or use your favorite text editor.
+You can now [edit this page](@baselocation/wiki/) or use your favorite text editor.
+See [Yellow documentation](https://github.com/markseu/yellowcms-extensions/tree/master/documentation) for more.
-Visit [Yellow on Github](https://github.com/markseu/yellowcms).
-\ No newline at end of file
+Have fun making your website.
+\ No newline at end of file
diff --git a/media/styles/default.css b/media/styles/default.css
@@ -1,4 +1,4 @@
-/* Yellow default style 0.1.0 */
+/* Yellow default style 0.1.1 */
html, body, div, span { margin:0; padding:0; border:0; vertical-align:baseline; }
body {
@@ -11,6 +11,7 @@ body {
}
h1, h2, h3, h4, h5, h6 { color:#07d; font-weight:normal; }
hr { height:1px; background:#ddd; border:0; }
+code { font-size:1.1em; }
a, img { border:none; text-decoration:none; }
a { color:#717171; }
a:hover { color:#07d; }
@@ -25,7 +26,11 @@ a:hover { color:#07d; }
.navigation ul { margin:0 -0.3em; padding:0; list-style:none; }
.content a { color:#07d; }
.content a:hover { color:#07d; text-decoration:underline; }
+.content img { max-width:100%; height:auto; }
.footer { margin-top:0.5em; padding-top:0.5em; border-top:1px solid #ddd; }
+.left { float:left; margin:0 1em 0 0; }
+.center { display:block; margin:0 auto; }
+.right { float:right; margin:0 0 0 1em; }
/* Responsive and print */
diff --git a/system/core/core_markdown.php b/system/core/core_markdown.php
@@ -5,7 +5,7 @@
// Markdown parser core plugin
class Yellow_Markdown
{
- const Version = "0.1.2";
+ const Version = "0.1.3";
var $markdown; //markdown parser
var $html; //generated HTML
@@ -49,11 +49,13 @@ class Yellow_MarkdownExtraParser extends MarkdownExtra_Parser
list($width, $height) = $this->yellow->toolbox->detectImageDimensions($this->yellow->config->get("imageDir").$path);
$alt = $matches[2];
$title = $matches[7];
+ $attr = $this->doExtraAttributes("img", $dummy =& $matches[8]);
$result = "<img src=\"".$this->encodeAttribute($src)."\"";
if($width && $height) $result .= " width=\"$width\" height=\"$height\"";
- if(isset($alt)) $result .= " alt=\"".$this->encodeAttribute($alt)."\"";
- if(isset($title)) $result .= " title=\"".$this->encodeAttribute($title)."\"";
+ if(!empty($alt)) $result .= " alt=\"".$this->encodeAttribute($alt)."\"";
+ if(!empty($title)) $result .= " title=\"".$this->encodeAttribute($title)."\"";
+ $result .= $attr;
$result .= $this->empty_element_suffix;
return $this->hashPart($result);
diff --git a/system/core/markdown.php b/system/core/markdown.php
@@ -12,8 +12,8 @@
#
-define( 'MARKDOWN_VERSION', "1.0.1p" ); # Sun 13 Jan 2013
-define( 'MARKDOWNEXTRA_VERSION', "1.2.6" ); # Sun 13 Jan 2013
+define( 'MARKDOWN_VERSION', "1.0.1q" ); # 11 Apr 2013
+define( 'MARKDOWNEXTRA_VERSION', "1.2.7" ); # 11 Apr 2013
#
@@ -79,7 +79,7 @@ Plugin Name: Markdown Extra
Plugin Name: Markdown
Plugin URI: http://michelf.ca/projects/php-markdown/
Description: <a href="http://daringfireball.net/projects/markdown/syntax">Markdown syntax</a> allows you to write using an easy-to-read, easy-to-write plain text format. Based on the original Perl version by <a href="http://daringfireball.net/">John Gruber</a>. <a href="http://michelf.ca/projects/php-markdown/">More...</a>
-Version: 1.2.6
+Version: 1.2.7
Author: Michel Fortin
Author URI: http://michelf.ca/
*/
@@ -295,7 +295,7 @@ class Markdown_Parser {
$this->titles = $this->predef_titles;
$this->html_hashes = array();
- $in_anchor = false;
+ $this->in_anchor = false;
}
function teardown() {
@@ -1816,7 +1816,7 @@ class MarkdownExtra_Parser extends Markdown_Parser {
if (empty($attr)) return "";
# Split on components
- preg_match_all("/[.#][-_:a-zA-Z0-9]+/", $attr, $matches);
+ preg_match_all('/[#.][-_:a-zA-Z0-9]+/', $attr, $matches);
$elements = $matches[0];
# handle classes and ids (only first id taken into account)
@@ -1842,6 +1842,51 @@ class MarkdownExtra_Parser extends Markdown_Parser {
}
+ function stripLinkDefinitions($text) {
+ #
+ # Strips link definitions from text, stores the URLs and titles in
+ # hash references.
+ #
+ $less_than_tab = $this->tab_width - 1;
+
+ # Link defs are in the form: ^[id]: url "optional title"
+ $text = preg_replace_callback('{
+ ^[ ]{0,'.$less_than_tab.'}\[(.+)\][ ]?: # id = $1
+ [ ]*
+ \n? # maybe *one* newline
+ [ ]*
+ (?:
+ <(.+?)> # url = $2
+ |
+ (\S+?) # url = $3
+ )
+ [ ]*
+ \n? # maybe one newline
+ [ ]*
+ (?:
+ (?<=\s) # lookbehind for whitespace
+ ["(]
+ (.*?) # title = $4
+ [")]
+ [ ]*
+ )? # title is optional
+ (?:[ ]* '.$this->id_class_attr_catch_re.' )? # $5 = extra id & class attr
+ (?:\n+|\Z)
+ }xm',
+ array(&$this, '_stripLinkDefinitions_callback'),
+ $text);
+ return $text;
+ }
+ function _stripLinkDefinitions_callback($matches) {
+ $link_id = strtolower($matches[1]);
+ $url = $matches[2] == '' ? $matches[3] : $matches[2];
+ $this->urls[$link_id] = $url;
+ $this->titles[$link_id] =& $matches[4];
+ $this->ref_attr[$link_id] = $this->doExtraAttributes("", $dummy =& $matches[5]);
+ return ''; # String that will replace the block
+ }
+
+
### HTML Block Parser ###
# Tags that are always treated as block tags:
@@ -1968,7 +2013,7 @@ class MarkdownExtra_Parser extends Markdown_Parser {
[ ]{0,'.($indent+3).'}~{3,}
[ ]*
(?:
- [.]?[-_:a-zA-Z0-9]+ # standalone class name
+ \.?[-_:a-zA-Z0-9]+ # standalone class name
|
'.$this->id_class_attr_nocatch_re.' # extra attributes
)?
@@ -2309,6 +2354,244 @@ class MarkdownExtra_Parser extends Markdown_Parser {
}
+ function doAnchors($text) {
+ #
+ # Turn Markdown link shortcuts into XHTML <a> tags.
+ #
+ if ($this->in_anchor) return $text;
+ $this->in_anchor = true;
+
+ #
+ # First, handle reference-style links: [link text] [id]
+ #
+ $text = preg_replace_callback('{
+ ( # wrap whole match in $1
+ \[
+ ('.$this->nested_brackets_re.') # link text = $2
+ \]
+
+ [ ]? # one optional space
+ (?:\n[ ]*)? # one optional newline followed by spaces
+
+ \[
+ (.*?) # id = $3
+ \]
+ )
+ }xs',
+ array(&$this, '_doAnchors_reference_callback'), $text);
+
+ #
+ # Next, inline-style links: [link text](url "optional title")
+ #
+ $text = preg_replace_callback('{
+ ( # wrap whole match in $1
+ \[
+ ('.$this->nested_brackets_re.') # link text = $2
+ \]
+ \( # literal paren
+ [ \n]*
+ (?:
+ <(.+?)> # href = $3
+ |
+ ('.$this->nested_url_parenthesis_re.') # href = $4
+ )
+ [ \n]*
+ ( # $5
+ ([\'"]) # quote char = $6
+ (.*?) # Title = $7
+ \6 # matching quote
+ [ \n]* # ignore any spaces/tabs between closing quote and )
+ )? # title is optional
+ \)
+ (?:[ ]? '.$this->id_class_attr_catch_re.' )? # $8 = id/class attributes
+ )
+ }xs',
+ array(&$this, '_doAnchors_inline_callback'), $text);
+
+ #
+ # Last, handle reference-style shortcuts: [link text]
+ # These must come last in case you've also got [link text][1]
+ # or [link text](/foo)
+ #
+ $text = preg_replace_callback('{
+ ( # wrap whole match in $1
+ \[
+ ([^\[\]]+) # link text = $2; can\'t contain [ or ]
+ \]
+ )
+ }xs',
+ array(&$this, '_doAnchors_reference_callback'), $text);
+
+ $this->in_anchor = false;
+ return $text;
+ }
+ function _doAnchors_reference_callback($matches) {
+ $whole_match = $matches[1];
+ $link_text = $matches[2];
+ $link_id =& $matches[3];
+
+ if ($link_id == "") {
+ # for shortcut links like [this][] or [this].
+ $link_id = $link_text;
+ }
+
+ # lower-case and turn embedded newlines into spaces
+ $link_id = strtolower($link_id);
+ $link_id = preg_replace('{[ ]?\n}', ' ', $link_id);
+
+ if (isset($this->urls[$link_id])) {
+ $url = $this->urls[$link_id];
+ $url = $this->encodeAttribute($url);
+
+ $result = "<a href=\"$url\"";
+ if ( isset( $this->titles[$link_id] ) ) {
+ $title = $this->titles[$link_id];
+ $title = $this->encodeAttribute($title);
+ $result .= " title=\"$title\"";
+ }
+ if (isset($this->ref_attr[$link_id]))
+ $result .= $this->ref_attr[$link_id];
+
+ $link_text = $this->runSpanGamut($link_text);
+ $result .= ">$link_text</a>";
+ $result = $this->hashPart($result);
+ }
+ else {
+ $result = $whole_match;
+ }
+ return $result;
+ }
+ function _doAnchors_inline_callback($matches) {
+ $whole_match = $matches[1];
+ $link_text = $this->runSpanGamut($matches[2]);
+ $url = $matches[3] == '' ? $matches[4] : $matches[3];
+ $title =& $matches[7];
+ $attr = $this->doExtraAttributes("a", $dummy =& $matches[8]);
+
+
+ $url = $this->encodeAttribute($url);
+
+ $result = "<a href=\"$url\"";
+ if (isset($title)) {
+ $title = $this->encodeAttribute($title);
+ $result .= " title=\"$title\"";
+ }
+ $result .= $attr;
+
+ $link_text = $this->runSpanGamut($link_text);
+ $result .= ">$link_text</a>";
+
+ return $this->hashPart($result);
+ }
+
+
+ function doImages($text) {
+ #
+ # Turn Markdown image shortcuts into <img> tags.
+ #
+ #
+ # First, handle reference-style labeled images: ![alt text][id]
+ #
+ $text = preg_replace_callback('{
+ ( # wrap whole match in $1
+ !\[
+ ('.$this->nested_brackets_re.') # alt text = $2
+ \]
+
+ [ ]? # one optional space
+ (?:\n[ ]*)? # one optional newline followed by spaces
+
+ \[
+ (.*?) # id = $3
+ \]
+
+ )
+ }xs',
+ array(&$this, '_doImages_reference_callback'), $text);
+
+ #
+ # Next, handle inline images: 
+ # Don't forget: encode * and _
+ #
+ $text = preg_replace_callback('{
+ ( # wrap whole match in $1
+ !\[
+ ('.$this->nested_brackets_re.') # alt text = $2
+ \]
+ \s? # One optional whitespace character
+ \( # literal paren
+ [ \n]*
+ (?:
+ <(\S*)> # src url = $3
+ |
+ ('.$this->nested_url_parenthesis_re.') # src url = $4
+ )
+ [ \n]*
+ ( # $5
+ ([\'"]) # quote char = $6
+ (.*?) # title = $7
+ \6 # matching quote
+ [ \n]*
+ )? # title is optional
+ \)
+ (?:[ ]? '.$this->id_class_attr_catch_re.' )? # $8 = id/class attributes
+ )
+ }xs',
+ array(&$this, '_doImages_inline_callback'), $text);
+
+ return $text;
+ }
+ function _doImages_reference_callback($matches) {
+ $whole_match = $matches[1];
+ $alt_text = $matches[2];
+ $link_id = strtolower($matches[3]);
+
+ if ($link_id == "") {
+ $link_id = strtolower($alt_text); # for shortcut links like ![this][].
+ }
+
+ $alt_text = $this->encodeAttribute($alt_text);
+ if (isset($this->urls[$link_id])) {
+ $url = $this->encodeAttribute($this->urls[$link_id]);
+ $result = "<img src=\"$url\" alt=\"$alt_text\"";
+ if (isset($this->titles[$link_id])) {
+ $title = $this->titles[$link_id];
+ $title = $this->encodeAttribute($title);
+ $result .= " title=\"$title\"";
+ }
+ if (isset($this->ref_attr[$link_id]))
+ $result .= $this->ref_attr[$link_id];
+ $result .= $this->empty_element_suffix;
+ $result = $this->hashPart($result);
+ }
+ else {
+ # If there's no such link ID, leave intact:
+ $result = $whole_match;
+ }
+
+ return $result;
+ }
+ function _doImages_inline_callback($matches) {
+ $whole_match = $matches[1];
+ $alt_text = $matches[2];
+ $url = $matches[3] == '' ? $matches[4] : $matches[3];
+ $title =& $matches[7];
+ $attr = $this->doExtraAttributes("img", $dummy =& $matches[8]);
+
+ $alt_text = $this->encodeAttribute($alt_text);
+ $url = $this->encodeAttribute($url);
+ $result = "<img src=\"$url\" alt=\"$alt_text\"";
+ if (isset($title)) {
+ $title = $this->encodeAttribute($title);
+ $result .= " title=\"$title\""; # $title already quoted
+ }
+ $result .= $attr;
+ $result .= $this->empty_element_suffix;
+
+ return $this->hashPart($result);
+ }
+
+
function doHeaders($text) {
#
# Redefined to add id and class attribute support.
@@ -2460,6 +2743,7 @@ class MarkdownExtra_Parser extends Markdown_Parser {
$head = $this->parseSpan($head);
$headers = preg_split('/ *[|] */', $head);
$col_count = count($headers);
+ $attr = array_pad($attr, $col_count, '');
# Write column headers.
$text = "<table>\n";
@@ -2564,7 +2848,7 @@ class MarkdownExtra_Parser extends Markdown_Parser {
(?>\A\n?|\n\n+) # leading line
( # definition terms = $1
[ ]{0,'.$less_than_tab.'} # leading whitespace
- (?![:][ ]|[ ]) # negative lookahead for a definition
+ (?!\:[ ]|[ ]) # negative lookahead for a definition
# mark (colon) or more whitespace.
(?> \S.* \n)+? # actual term (not whitespace).
)
@@ -2578,12 +2862,12 @@ class MarkdownExtra_Parser extends Markdown_Parser {
\n(\n+)? # leading line = $1
( # marker space = $2
[ ]{0,'.$less_than_tab.'} # whitespace before colon
- [:][ ]+ # definition mark (colon)
+ \:[ ]+ # definition mark (colon)
)
((?s:.+?)) # definition text = $3
(?= \n+ # stop at next definition mark,
(?: # next term or end of text
- [ ]{0,'.$less_than_tab.'} [:][ ] |
+ [ ]{0,'.$less_than_tab.'} \:[ ] |
<dt> | \z
)
)
@@ -2639,7 +2923,7 @@ class MarkdownExtra_Parser extends Markdown_Parser {
)
[ ]*
(?:
- [.]?([-_:a-zA-Z0-9]+) # 2: standalone class name
+ \.?([-_:a-zA-Z0-9]+) # 2: standalone class name
|
'.$this->id_class_attr_catch_re.' # 3: Extra attributes
)?